|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ p5 U$ V' W" d1 ]* Q, s5 T, g#include <linux/init.h>0 }9 t, f0 d+ k2 v! _* A0 [
#include <linux/module.h>* j3 }. [7 T- R* X$ a7 c: @( ~5 E% G
#include <linux/kernel.h>2 r! U; B. N8 h/ F. a
#include <linux/types.h>
0 ^2 t3 r! R2 o#include <linux/gpio.h>
; Y9 ~. f( W) I$ T#include <linux/leds.h>, O. S C% R" j0 z$ H% ?! `9 h
#include <linux/platform_device.h>: G8 i' F$ | P9 z: @/ x
7 z1 s" D/ ]+ q6 P1 [! K! Z0 b#include <asm/mach-types.h>
, G9 n" Z* D! l" D7 i: a. m( N#include <asm/mach/arch.h>$ U6 M. q5 j( Y
#include <mach/da8xx.h>( A" v# E" ~% ]5 j9 u3 L* o
#include <mach/mux.h>+ K Q( K8 m" F# {& V/ C7 y9 f( y
& z4 f: S% ~8 k* F: L6 L9 s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% K- S7 T' [ X, Y& C#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 u$ p6 w4 }8 S4 f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
D- Q! _" H5 B9 m/ E#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( q5 l7 _% Y4 M& V
) j; I1 G. {6 f2 N" W. r/* assign the tl som board LED-GPIOs*/: `# J* e! Y" Q$ }. S! [3 c) \
static const short da850_evm_tl_user_led_pins[] = {
. w, u2 Q! ?. S3 v3 l k$ `& p /* These pins are definition at <mach/mux.h> file */: F$ E/ ?9 ^: t ^/ |5 ?! t! W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 R% e0 W) M( N3 T. p$ ~1 L6 v) b
-1' I. Z: P; U3 b1 T5 r, m/ G* U+ N- J
};
- Z6 g4 z' a- U: f5 i8 J2 V( l
$ |5 H, X% h. y8 ustatic struct gpio_led da850_evm_tl_leds[] = {
. I, C; q- B; F" n: t) M0 P {7 ~# L7 i: v' o0 ?% N/ g
.active_low = 0,
& _0 l1 {) G c+ s3 R+ [ .gpio = DA850_USER_LED0,
% ?+ k# z6 k! {% Q8 N .name = "user_led0",
" B$ _: q& k7 n3 I: r .default_trigger = "default-on",7 `7 s e! K* c+ G5 n! G
},
& R: |1 q' K! `( E/ V6 M3 K {
% Q5 q/ X. c/ E Y) f .active_low = 0,# ]/ y6 h+ B+ q. V7 D6 P! ]1 N& y
.gpio = DA850_USER_LED1," M7 F7 w( q. j( k' [4 T
.name = "user_led1",
0 E# x } X+ U .default_trigger = "default-on",* a' D2 Q# G! o3 ]
},
. q+ C7 ^- E6 I1 Z+ p {
% Y. o" Z" ^ g4 _* D6 [ .active_low = 0,, o7 F* N) t4 Q
.gpio = DA850_USER_LED2,3 e! v3 D' h! P% q, o% x6 \) I
.name = "user_led2",
; @4 C) ~: t: ] .default_trigger = "default-on",+ i- _/ W: s9 F# Z- U! e. n
},2 v& c6 ?5 J ]4 V- J3 V- {
{4 [* `1 y0 x4 i
.active_low = 0,7 H8 X. t$ t/ L1 t
.gpio = DA850_USER_LED3,
* T. @2 Z2 F, B6 f; v1 f7 J/ b) o .name = "user_led3",0 j1 }9 E, z3 N+ S4 a# e
.default_trigger = "default-on",) h$ d6 D0 n+ p: j; e% H& g
},
I! a3 F8 e$ G# H0 a};3 A, @1 `' D# e
2 t9 F$ }8 `7 \2 R' _8 }. d& V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 T! ?# p7 e2 W1 b" r A3 q6 w
.leds = da850_evm_tl_leds,
: _3 E0 j" h7 t4 n: D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ D( D- G7 E, W3 R4 X: S8 C8 a};* j; d$ G3 D3 x3 d
, s. T7 E% V! `3 Pstatic void led_dev_release(struct device *dev); b/ n( e/ h; r& s
{
3 Z/ P- C T; ]" Y& o};
% a) a# g3 r3 R" H9 l
7 A: G. w3 u! P. Estatic struct platform_device da850_evm_tl_leds_device = {
. u- R% o8 e* o .name = "leds-gpio",
& m& ]' x4 u; K! e$ j8 T) q t .id = 1,
2 T1 C+ ^! k8 q) ?/ q .dev = {1 S- t7 ^, G9 S0 D" N
.platform_data = &da850_evm_tl_leds_pdata,3 w7 f4 X2 G: d, a0 B) K, A
.release = led_dev_release,
7 m; ^. W8 u) z. [ }% o3 G8 d4 y2 v
};
- ] A& ~5 p, c/ d& Q/ J+ b# x w
7 b# P5 ^+ S3 ^2 n3 @- d" vstatic int __init led_platform_init(void)
$ o8 K) ^9 i' ]{" e- T5 G$ H. {4 n9 g6 O
int ret;/ o- h% v# Y2 h" V! h5 R
#if 0
3 p6 F% u( K4 p ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, j. Q. H( Z" c7 b' u if (ret)) c: j K ^* }2 ^ A# D: I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 h3 g% x- N$ g* r: M* _ "%d\n", ret);
5 p8 [# @" m* x& k5 o5 O7 r$ J% ~#endif
' Y" i6 v# v( F6 t5 c+ }3 K( ^' | ret = platform_device_register(&da850_evm_tl_leds_device);
/ e& h# H; n" @3 t5 r+ a0 j1 D: a- b if (ret)( o: g2 Y9 u# b& Z
pr_warning("Could not register som GPIO expander LEDS");
7 g5 [) w s! ] else0 E* J" i s# V3 n, j$ |
printk(KERN_INFO "LED register sucessful!\n");
" f; N1 P) S# K
4 Z1 |$ f& p2 ^: V, i& [ return ret;
5 v g% O/ v0 s- V* c; w}/ m( Q$ u1 V0 R* P* V" n
; K* s2 ^: [8 Ustatic void __exit led_platform_exit(void)3 `. r t! x8 {7 f) k
{* j7 K2 D" A/ Q* _/ Y
platform_device_unregister(&da850_evm_tl_leds_device);
% h+ v; T; g7 T' D6 C
/ B" p+ i: _: B0 d" L printk(KERN_INFO "LED unregister!\n");
! {: E7 q* y. O8 s}
" f# p# p/ T1 |! }* V
' c9 k# y2 { W+ omodule_init(led_platform_init);
6 d6 k \- I& B! B/ A* Z. dmodule_exit(led_platform_exit); ?' } s, T$ K6 F3 K M3 M! ^
* V7 ]: @5 `9 y1 c7 ]" w4 OMODULE_DESCRIPTION("Led platform driver");7 y6 R1 i$ p7 K
MODULE_AUTHOR("Tronlong");
) ^- j5 G% w; M- q4 _MODULE_LICENSE("GPL");4 D6 p" z1 m! B. l
3 j! O$ f! X: N; a9 k
|
|