|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 n" c3 w5 N8 |4 e5 j. j, S) w9 v#include <linux/init.h>
% f- u2 o8 o5 a/ u e) F0 t#include <linux/module.h>! d0 S& m: c% U* t# R2 ^' |
#include <linux/kernel.h>, l4 o' E9 f) V. q( s
#include <linux/types.h>
6 j3 G" I2 ]* a. S% y#include <linux/gpio.h>7 l+ x1 u" }4 c( H0 _5 p
#include <linux/leds.h>6 Z" y' x2 [( F/ E# l
#include <linux/platform_device.h>
8 v; i* {0 Q+ \. U, ~: _
! A% l% n( h# [! D#include <asm/mach-types.h>9 d+ w" V* p5 Q
#include <asm/mach/arch.h>* T, R/ r1 ?6 `* v1 L5 V9 {0 R
#include <mach/da8xx.h>
' k3 _' v" D! N% i#include <mach/mux.h>& A8 j; k8 e: u6 H3 }
; _2 r) e( U6 E7 x9 A T7 s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 S, Z _9 M; h: R" Y, B* X! k: ^
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): q4 P/ P1 i( T
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* m( M0 E4 T" \# H% P# z, R1 H#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- ]) j+ R0 [4 ?& J. n' m3 ^8 X
! I2 n5 |( `- T6 h2 G/* assign the tl som board LED-GPIOs*/2 D5 n/ x- W6 X! l9 H
static const short da850_evm_tl_user_led_pins[] = {7 Z8 `/ \, b& V2 d- q' X3 s; W
/* These pins are definition at <mach/mux.h> file */
, Z; q) [% A1 A8 p0 k7 f/ ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% E: Z! r: R# t" x# t( {
-14 k% y7 }9 J7 s, ^% m K9 o8 r. ?
};, C$ v8 E" @% b7 o) ^9 _; K
9 E- G' m0 g& k1 [( dstatic struct gpio_led da850_evm_tl_leds[] = {! y7 G7 f; K+ m, {$ N+ N( |6 \
{
1 ~+ _) ~" w8 \9 j5 G3 Q6 Y- Q .active_low = 0,
/ R1 V3 R3 j" Q5 s .gpio = DA850_USER_LED0, B5 i2 } k* I# o
.name = "user_led0",9 R) i O8 }6 r: u! }
.default_trigger = "default-on",: ]; b4 a0 d5 r9 ], Y% b
},
- y: ^/ @+ P0 w3 j8 {; }3 t {
* Q/ k [$ u& Y4 x+ x& a/ w; ` .active_low = 0,( O* t: x$ c6 ^3 Y! @4 o; Z5 n
.gpio = DA850_USER_LED1,
& V, }' f, E+ Y# V: u1 Z# f7 h .name = "user_led1",
$ q; \7 ^) i* E! V' L .default_trigger = "default-on",. R4 S" `! }& @
},9 }3 x0 g4 F- C2 U+ O
{& R) u7 X* _( a- r* X- V
.active_low = 0,
" G9 l% o4 b" u2 j8 Y `% e, E- N .gpio = DA850_USER_LED2,
+ S t- r1 Y4 ~' |* T .name = "user_led2",! R% d( O- U: n2 N
.default_trigger = "default-on",
( O, ?) t" ]' X8 T7 [8 W$ V+ f },; J4 I! V) Z! Z1 I: O+ ]
{$ v/ e _8 f8 W+ s
.active_low = 0,% ], ]' L: u8 ]6 ^ _; t" W
.gpio = DA850_USER_LED3,
& f2 Z5 p& |) H5 ~) h5 x5 l .name = "user_led3",/ U( H4 t! Z0 M1 Q
.default_trigger = "default-on",
% c4 t* z+ _! P, d7 o! I' q },* Y8 I1 I7 g3 n1 E
};
U, A4 l( q. Y- t. m+ h, Z+ \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. A5 @# C0 n0 R7 O% s# ]" M .leds = da850_evm_tl_leds,
" U4 v8 H+ R; j6 d0 Z' ]1 b1 I. X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 G8 V* N, S7 ]0 |3 Z! \1 H
};; J2 u+ i- J l* X
0 d/ Z; r0 H* o9 Z, h7 |( e/ Y
static void led_dev_release(struct device *dev)
) m" J0 {0 q' q9 R6 h{
8 e3 v9 u ^8 y6 S- @0 y};1 h1 i% L( F, n$ }
: {, `# F* Y/ ^ D# \
static struct platform_device da850_evm_tl_leds_device = {$ l+ @% ]- N- \
.name = "leds-gpio",: R6 v: j8 r. X5 d+ ]8 z
.id = 1,
( O3 W$ g1 n2 v# u .dev = {) |+ g# f7 U% U; M6 W* S( S
.platform_data = &da850_evm_tl_leds_pdata,- L& {, u5 T8 q% [3 P6 t
.release = led_dev_release,$ P, c2 t2 f! B* e# u
}
4 `+ H# H+ \( J E2 h N};
; {/ _, R6 J+ b& C Y, I- i7 P6 m# r& I
static int __init led_platform_init(void)# K$ k0 P/ `* T2 a [% _7 N5 l
{' B1 i3 w( k! N
int ret; h! W3 o& o0 f% O" f
#if 0
9 A# m J4 ^. I( ? ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 h9 r/ [* Y# c% y3 _ v if (ret)( a, h; f3 n1 [5 V9 t) V( k
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 y. |! S' J6 r8 R
"%d\n", ret);
) w' v5 d4 [" m4 {# ~+ r#endif
8 w' f' h0 @6 H# F/ J( l7 k, p ret = platform_device_register(&da850_evm_tl_leds_device);
. t% q) H1 A" [; C, L4 G if (ret)
/ z# ? o# U1 e) v pr_warning("Could not register som GPIO expander LEDS");' K9 \% p' w! y6 b* Z! w
else* N) _1 D! \8 T8 q- m) g
printk(KERN_INFO "LED register sucessful!\n");
( V) e- y# p: n# H! \) A3 i+ n$ i
4 ~6 @2 n3 O' q4 ? return ret;) ~* v9 r6 `1 C! ]4 x3 A
}- A) @2 C- O \" |
! i4 {- f8 t5 ?; W( qstatic void __exit led_platform_exit(void) M- T" P2 b+ _
{" ^+ f9 t8 S8 C1 A
platform_device_unregister(&da850_evm_tl_leds_device);/ p9 p7 ?6 `, `5 t+ L
, d) m' U+ X* R$ L printk(KERN_INFO "LED unregister!\n");' k% r4 c3 O0 F5 A
}
, `8 ?# ?5 ^; E, e _3 V: z, v2 X/ k: D' m
module_init(led_platform_init);
5 l1 e6 n9 t c9 O( n5 u3 p q) [8 ^module_exit(led_platform_exit);' f+ C- Y b$ C* G. }
# r2 }4 \! [0 ?( v
MODULE_DESCRIPTION("Led platform driver");: \% x' R% V, I+ t; _
MODULE_AUTHOR("Tronlong");, y ^3 x/ r: M& d$ _' z! A
MODULE_LICENSE("GPL");
: x6 m z3 J1 ]! D, A& r/ h4 F! s3 Z7 {% @, ^+ o5 Q
|
|