|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; ]$ F/ f# s/ ^2 U/ x" A#include <linux/init.h>2 O9 ?% b2 `/ V' Y& k0 J0 W
#include <linux/module.h>& W: O8 Q* e# z
#include <linux/kernel.h>
( }, m& c4 b" g+ F# t0 X#include <linux/types.h>
: i( D4 d* `3 F5 ~8 r; @ M#include <linux/gpio.h>2 I: v! V. p4 U9 B- \
#include <linux/leds.h>( p2 \, j8 @3 F
#include <linux/platform_device.h>/ ?" U1 ~ x2 U ~: N; k
$ S! n$ a8 i1 y1 y0 a. t# A#include <asm/mach-types.h>0 g! s# j7 E# O, W
#include <asm/mach/arch.h>
* Q. c( f* D! A; k; e% Y8 a#include <mach/da8xx.h>
5 Y5 ^" [9 E5 t. r$ A7 j#include <mach/mux.h>
4 d9 y6 j0 p. W/ m# v& m
. M# {6 c5 L" s G& @" R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 B R* _' H" @9 v) ^) a% A( H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! Q% ?; L/ s/ l0 y) m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 W: E' p0 T1 i& Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 M+ h- j9 s* t: K; ?5 L$ R
6 n C' H) ^3 x. e; g9 a/* assign the tl som board LED-GPIOs*/$ I1 F! C/ T; F% k/ V# I: _' t
static const short da850_evm_tl_user_led_pins[] = {
. @& m# `" i; B, | /* These pins are definition at <mach/mux.h> file */
) n8 O# W G7 u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( t! a1 K; ^9 Q* Q! y- A) ?' Y$ s9 d -1
+ v9 x% Y$ t+ x) p, @};
( F2 P( u1 e! R1 q( i J
$ }+ U% P1 i: _1 E4 e% h- F, Ustatic struct gpio_led da850_evm_tl_leds[] = {
8 H& c6 R1 A- ^3 m# \" m% j# v {
" X1 l v3 }) m4 } .active_low = 0,
0 G. p- q, {/ ^" b8 T0 X* g! c .gpio = DA850_USER_LED0,
$ |1 X' r- K3 M! g; i- A .name = "user_led0",' W5 u2 J( y/ s4 C4 l6 C2 h
.default_trigger = "default-on",
3 u8 r- k0 k- d$ y3 C0 h) v },
) [# z5 K6 e& I' b8 k {
1 F5 t6 N6 A3 @ .active_low = 0,- n# h1 r% O7 {9 c/ {
.gpio = DA850_USER_LED1,
' D! q( {! h0 w .name = "user_led1",
! _1 S6 ~3 ^4 d1 I; D4 t c) `% R0 Q .default_trigger = "default-on",6 S9 w1 t5 N8 t9 p+ R7 F+ `
},, Y: w/ z( p& J4 b
{, @7 w! X/ l- z# y: i) a! h% G
.active_low = 0," N2 h0 b" ?8 W6 c: U) t
.gpio = DA850_USER_LED2,
8 U5 e; d2 z+ l& j) J) p* t) c .name = "user_led2",
4 z& _9 x9 j! U/ g" h' v .default_trigger = "default-on",
' d6 [8 w4 @) F },& S) n/ \) {" @4 ^9 P
{
; X }' q @7 a5 P* ?9 c! H .active_low = 0,: m3 J4 m) Y. N
.gpio = DA850_USER_LED3,$ x+ `. M& o6 J7 [% Y( ]; q+ g
.name = "user_led3",- S1 s d2 i3 {0 r/ l
.default_trigger = "default-on",
8 n3 s1 P& _7 c7 j- U( y( S! [9 H }, `- X3 b" p" Y. M. k- q0 e! _# C4 @
};7 L9 ~6 I9 n8 `+ k* l: u" i+ o0 K; K2 |
1 Q1 s6 Y- {8 n: P; astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ j1 [. I0 j0 T3 F1 G: w
.leds = da850_evm_tl_leds,/ S' s3 F" R7 E& [! }! _) ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),( B4 I8 x8 l7 j: H
};, q3 R. d7 S D# ~' ]: b6 n
, _- ?1 ^! P* c4 x+ v4 o2 j
static void led_dev_release(struct device *dev)
+ D+ H, @: R0 m7 }{
3 Q/ N6 x! x+ N};) ^ V7 W" w4 P# `5 p- L: f
% @. k: t. X: h2 m
static struct platform_device da850_evm_tl_leds_device = {2 S9 w0 Q% @0 W( o8 z
.name = "leds-gpio",, `' c" y- n2 @. X6 h
.id = 1,& n; M( k( Q7 G' M: n2 k; R
.dev = {0 V* b0 l) p8 o" h* A; K% h
.platform_data = &da850_evm_tl_leds_pdata,( C O) ~, b/ K7 i$ |- f, }
.release = led_dev_release,3 y' q6 `. c1 |3 F4 E; R
}$ ^! S( q3 k; U* h# f( q
};
4 y( a9 ]4 D- b! w& f( Z, Y
# O7 d8 z& I; E ^: \static int __init led_platform_init(void)
x+ \5 Y- V3 q* R6 O) a; j% o{
5 b- C+ L: v2 v1 |0 I& t int ret;
) ]' c, y7 Y# ~- z) L( _% Q( L4 O#if 0! U( x, D2 n( H8 F
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 N# J& n1 W R7 |
if (ret)3 z4 ~8 E' C* ^6 Y2 |- j7 h0 g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 J, \4 x; R( i/ v, u* a8 j0 M) k2 O "%d\n", ret);5 P" G) \3 q; I7 o0 v5 g
#endif
# n* a9 e0 a ~& I$ e ret = platform_device_register(&da850_evm_tl_leds_device);0 [9 Z, m5 ]% N- ^" j$ B
if (ret); {6 J) o( G* F0 n4 y( d5 L9 h
pr_warning("Could not register som GPIO expander LEDS");
+ p5 `; S7 f; r4 F& r, r: @% p M else( m0 Q- S5 {, {8 {, w- `
printk(KERN_INFO "LED register sucessful!\n");1 _3 [: A3 V B$ N2 @ j
4 c( W9 s$ l* U% ]: H# H+ \ return ret;- f1 l# C# g: g2 S% N# J! y
}
$ G/ d$ G0 W0 W) I( f8 E- Z0 d0 A4 q* H, G
static void __exit led_platform_exit(void)
: v' h! S. M8 P+ P/ J{
" A$ z7 r2 D. J platform_device_unregister(&da850_evm_tl_leds_device);
8 W0 ]% A) n6 o3 D; {( z- n# `% C$ _' a5 r" @+ `
printk(KERN_INFO "LED unregister!\n");
. A, d: B4 j3 c m9 _( x& ?}, w1 E6 O7 }( e& I9 P
6 o6 V5 F6 Y' p' V% K7 f M9 g
module_init(led_platform_init);, a4 G9 G! x& A( i" p7 y# P: @- q9 O; |
module_exit(led_platform_exit);
8 }' \5 U. s- h5 D: F( E# `
7 l. y. b/ n G% r8 X) xMODULE_DESCRIPTION("Led platform driver");
/ L1 j5 ]* t5 Z" [) hMODULE_AUTHOR("Tronlong");
. J' z# ?" f7 j# \MODULE_LICENSE("GPL");
1 p# f, R/ o' g# L% u/ F! I. \/ G7 K) f6 J$ W
|
|