|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 p+ w- [8 c9 q4 n6 v4 k- r- v2 `#include <linux/init.h># E2 j1 ~ A& i2 e3 S" t' s
#include <linux/module.h>) x/ Q- x% @* z1 K1 D* b3 x0 c
#include <linux/kernel.h>
/ i) w, [4 h, N#include <linux/types.h>" w2 T# h2 f8 z% D
#include <linux/gpio.h>
( i+ T( a2 _; y#include <linux/leds.h>
+ F+ j! M5 i8 m$ T#include <linux/platform_device.h>4 g, ?9 ^+ q* p& y
9 \9 A3 d% p; C1 V
#include <asm/mach-types.h>
8 l; C& C; |3 l9 W/ B/ G7 y! [#include <asm/mach/arch.h>
5 r$ ?9 p- x) M" n9 a5 [#include <mach/da8xx.h>
$ g( @1 y$ l! D#include <mach/mux.h>
8 M+ M* S2 g8 \' A, J$ I6 x
( M, y) ?/ N: N3 x. `1 @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) |% S! ^4 j. V3 R8 B6 S! A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ P3 v" X$ N; r; a#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ w/ e% K' W% F7 [* [) A2 v7 v8 @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ L0 P- h7 O2 \7 F* r( e. g
/ _( ]2 ^/ r! K/* assign the tl som board LED-GPIOs*/
4 E* R* V j. z- Lstatic const short da850_evm_tl_user_led_pins[] = {
O1 c c3 [2 P% |! { /* These pins are definition at <mach/mux.h> file */9 }; j1 C5 |5 V& h4 }7 t6 J# @
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) o% I' B- V4 y0 o
-14 C4 K6 T, M5 g* g' s f6 n
};; h* `) t( k" A" `* W
1 c* r4 o0 d8 A/ \9 R: h8 z1 @# k0 f
static struct gpio_led da850_evm_tl_leds[] = {' h( ~% E! m4 L% J5 T% f! v
{1 k9 Z! I! B# o _8 W. f4 @/ _. X
.active_low = 0,
0 _+ b W& `. q# w1 t. h8 r .gpio = DA850_USER_LED0,5 p0 j1 S' x" e5 p7 E1 F
.name = "user_led0",
. ~: W) j) @. B' Z! U9 d4 ^ .default_trigger = "default-on",6 Q6 ]9 m. M6 b \2 s, I1 o
},$ {$ W' P! y5 N# {6 Q! ^% g
{
, @* ^3 c+ I9 b+ d, Q3 N2 a' a .active_low = 0,
; [2 ?! H/ M, g& y/ p6 [2 f .gpio = DA850_USER_LED1,
* h$ }8 C2 Y+ g. H0 ^0 m* b9 f/ ` .name = "user_led1",
! Y5 b, R* T! _) e1 L) n- | .default_trigger = "default-on",
/ d4 ~! Y& Z6 y0 I },
# S0 x7 _% D$ c: Y1 A {! M; @ |- O6 l5 }; T
.active_low = 0,* m: a7 |% D7 p" D8 |& ]
.gpio = DA850_USER_LED2,
1 w" a1 T0 U* _. P. ^* ]' E2 j. b .name = "user_led2",0 E5 E- ^3 b5 T# m; I' X" o
.default_trigger = "default-on",5 _+ B* N/ ]6 }% y7 O, N; q
},
3 F# ?5 k% H, U% R; e* u2 d {
0 _2 t' H1 x0 u; g- r) Y( W .active_low = 0,! }0 I+ w. t* q) z1 ~- \# ~) Q
.gpio = DA850_USER_LED3,
+ ^$ m! _' h5 ^% v2 T .name = "user_led3",/ ]. g r: Y6 N) e0 E3 Y0 S
.default_trigger = "default-on",8 s( @3 @ Y" Y% t3 r
},! [2 T: B4 \ z3 e2 V- C- g
};
6 c7 ^6 t+ U0 {
; ]9 t! p* q! J# r8 t* sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 L8 Y! D$ K" R# ~ .leds = da850_evm_tl_leds,. Y6 _ j- L. U
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 B9 `2 x& s# u+ g};( G0 _ b( n9 f8 q' D0 q
0 M: q1 I5 Q: G3 f K0 R1 X1 }5 Q
static void led_dev_release(struct device *dev)* C+ r" L! T" C2 i+ m" M) G1 L N* z* M/ P
{0 `; j/ A2 L& r! Q: ^1 p; z
};- N, c& x2 g y9 d6 ^7 Z
9 z* [4 h3 \6 r$ D$ D0 nstatic struct platform_device da850_evm_tl_leds_device = {
/ m/ G" {$ y- }% \( A) R .name = "leds-gpio", R; W/ I! _* N2 i- s1 D# x2 W9 {
.id = 1,
! W$ j8 p; J( `+ e. G .dev = {
' E3 F, E& @7 h. G1 H' H H$ O& P4 s .platform_data = &da850_evm_tl_leds_pdata,
( \7 K) M7 O. g% W9 e3 h8 Z# ]$ h .release = led_dev_release,
8 f# l# P. z1 L. O0 }4 F/ y/ t }5 h7 N; b. Y, u3 w5 R( Q
};0 q* k1 V1 ~: s& x, b
% {1 i/ k) c! r9 J }
static int __init led_platform_init(void)- K6 `5 u7 Y c" H+ t; N
{
4 ^( j1 f: f* p( V int ret;7 f2 j/ J# y6 t1 s
#if 0- T% i" H" b: y5 A7 ]! p7 q2 o# j$ B' X' s
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 ]& s, B0 B. k
if (ret)
- }7 C P( C8 W Q; k, Y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 ]. l# N' F5 |: e) O
"%d\n", ret);
& V+ _: j J7 e* j$ c, G9 t6 p#endif
& G+ H* @: x$ H( h' H! Y4 j ret = platform_device_register(&da850_evm_tl_leds_device);
# t, U1 Z* C7 i; O if (ret). T0 s# p$ A7 X% g
pr_warning("Could not register som GPIO expander LEDS");7 E2 ?) n" ?' ]8 V) n* b
else4 Q& ?9 H% P- t
printk(KERN_INFO "LED register sucessful!\n");
. ]; [7 f/ A0 k$ ~9 |8 t
' ^0 q/ D1 y$ n7 [ return ret;
. I; t0 ^' A5 l: K& D}
* B- F8 J# D" n' x& l, S9 q3 `3 _2 X1 P/ p- g t
static void __exit led_platform_exit(void)- `8 `4 ?6 | T) x8 ^! e+ r
{
1 N3 H6 \& X" f: n" j+ V8 x) i4 P5 Z platform_device_unregister(&da850_evm_tl_leds_device);
1 a2 w( N* P$ s/ m2 Z0 o8 ~) O3 v& ?4 @) V3 L
printk(KERN_INFO "LED unregister!\n");
$ Q: f& r# G3 ?4 |3 L8 r4 |& {) B}. Q$ N W+ {3 O9 B9 o
0 G) g" A& d7 A" G: }% Pmodule_init(led_platform_init);
& D9 h/ R5 C/ wmodule_exit(led_platform_exit);
" Z; ^' L2 I/ a! q$ ]; a. T4 R5 O1 q; s6 v1 P8 D
MODULE_DESCRIPTION("Led platform driver");0 [6 W3 W, ^. r3 L( s
MODULE_AUTHOR("Tronlong");
5 w! O0 v" R1 Q& }3 B% ]0 ZMODULE_LICENSE("GPL"); t9 \: L M: R6 s# M
4 w) d: A6 z9 L8 D( n4 S; n |
|