|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" L5 b9 H5 j/ P0 v- A+ L
#include <linux/init.h>
1 t, P6 N3 T- O#include <linux/module.h>% j' `' i) X# H o* ]
#include <linux/kernel.h>- @* u8 O& _6 }) k
#include <linux/types.h> y. S! l0 j- E7 `5 v
#include <linux/gpio.h>0 ]/ H& Z0 K) l0 `4 L! y0 m
#include <linux/leds.h>
3 v9 g, y2 [% b Q#include <linux/platform_device.h>4 g* f+ a; Z) O8 g3 Y
2 z( s" P9 m' y. k# b
#include <asm/mach-types.h>
0 Z: J7 {3 @3 q7 s- [- P#include <asm/mach/arch.h>
% O$ t8 ?8 y: ^. b+ z2 u* h#include <mach/da8xx.h>
, j" l3 E6 g1 z( q7 n' G/ A5 j5 O7 ^! K#include <mach/mux.h>
3 D' N- Y$ `2 i/ M
( g* G) A6 n. {4 G) o. G#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" v% A3 i; T* v3 `) D- F2 ]& W; @; o- }
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- \2 O3 ~2 v- h$ L C# s( M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& t2 H4 w1 e( r! L9 k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 V8 Z) y; Q: w k% ^
- V; p) {- O6 ]# j
/* assign the tl som board LED-GPIOs*/
1 e& w9 D" W& j' Cstatic const short da850_evm_tl_user_led_pins[] = {
0 b3 S+ H* U0 Q5 e. Z /* These pins are definition at <mach/mux.h> file */
7 @ ?- I* p* w3 g: j3 t/ D: D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! c9 l: Q# @# b/ W3 I# [6 \ -15 w B W% ?4 n0 E
};+ N7 Y% {* ?8 Q! u+ Y
1 ^/ q; _: f& N0 T. p4 }
static struct gpio_led da850_evm_tl_leds[] = {
+ N- A/ Y$ u, X0 [- }2 g* ? {3 z& x1 h2 q; a) B5 a. T' Q! s' @
.active_low = 0,
" ?- ~4 ]# } c8 J .gpio = DA850_USER_LED0,
2 ^2 ~% v* F9 [) j) k1 q: V .name = "user_led0",
; `5 L, d4 S4 v; y. D8 a .default_trigger = "default-on",7 `- _& [+ C4 l9 F
},2 {2 S1 j3 n: y- E( t$ [# \
{
& @6 z" o# h; {( y .active_low = 0,
! r! W4 A5 n. m7 b4 M .gpio = DA850_USER_LED1,1 r# i1 e7 I! V2 c8 c
.name = "user_led1",
: y+ t5 s, j9 M, P .default_trigger = "default-on",
, s* i' P6 q6 Y8 V },
0 e0 {% H! M' A+ | {! |6 m# }0 s, u4 S" \
.active_low = 0,
. Z7 }/ l( T" Z% O o. Q .gpio = DA850_USER_LED2,
! w( |2 ~5 S) c2 c9 f, B' [ .name = "user_led2",
8 ^' K( x; i/ |7 U+ y4 F1 J0 U .default_trigger = "default-on",
- r# Z$ b" O. c& d$ r$ H },6 z5 @: S6 k3 Z2 A$ n/ W" P. |2 H5 w! p
{) ]5 x- M7 P5 w
.active_low = 0,
% V: j- }: R) h0 O" T .gpio = DA850_USER_LED3,2 i! J: r9 |) X6 ] W
.name = "user_led3",' V T' h- T; C5 n$ M& @
.default_trigger = "default-on",9 q4 h, A5 p. G8 H z7 ]
},- V9 V! ?3 Q" h0 D6 D% w, b( Z
};; e# Z$ _9 }% g" P* _
7 u* ~7 Q' ^! W6 e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' r' Z6 B8 m. H. a( b2 L .leds = da850_evm_tl_leds,& s$ w {- M" _, m% p
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. y' h6 D D5 d a7 [1 d2 y9 p+ ?};1 l' T+ d% U3 D/ W/ @
" U7 ]4 N! j- z% P. r7 rstatic void led_dev_release(struct device *dev)
, N9 e& [& g4 Z) i( c. w1 \1 _{" {! W: S8 ?7 C
};8 L/ T. Q3 c. u' ~) `: i( p. u
! i1 w* l8 k& z% f8 I/ a
static struct platform_device da850_evm_tl_leds_device = {
o% k; w8 i2 W/ @3 O+ k/ u/ ? .name = "leds-gpio",
) F# D0 q( m/ K+ ^/ O* N' ? .id = 1,
& l7 i2 w! G* F2 ] .dev = {
! v6 n1 D# \# E6 h% E8 F0 S .platform_data = &da850_evm_tl_leds_pdata,# E1 G; `* h, X; H. {) }
.release = led_dev_release,9 u7 N* D) J' G- k, Q" u- W \/ G6 O
}
6 G4 g( E# k1 q};
2 f! R+ c* N O+ g( t% O
! l; b6 }! a+ p2 C) ~. Ustatic int __init led_platform_init(void)
3 y! w; z% s0 ^7 Q" t. x3 E% ?{
. r# c% s A8 |$ V" Q: } int ret;% g* `+ x# ]$ C: S1 g7 P1 H
#if 0
2 V4 E0 C; I- ~( K ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 P* e$ e9 L0 P. O% } }4 Q
if (ret)
4 K7 Z3 b9 i. U1 o6 y5 m; f3 B pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 F( `$ D+ Z# H7 A* Q/ @8 f "%d\n", ret);
$ X; R P' M9 j0 j1 m/ |! Y#endif
. N" P2 M" r% ]. \* y1 E' T ret = platform_device_register(&da850_evm_tl_leds_device);
; r2 _) R0 p: d/ c- \+ m8 K- G if (ret)
( B0 K/ z9 B6 y( j8 v pr_warning("Could not register som GPIO expander LEDS");5 O5 k% h- F3 U' D: ~* w2 _ T. f
else+ e( J3 V( h" w; Z
printk(KERN_INFO "LED register sucessful!\n");
* @! k; z: d$ p4 W( D5 K' B1 D/ D4 t5 ]0 o* e% S7 g+ @
return ret;+ p+ S/ U% Z1 I; u
}
' o( L/ K5 D' f' N$ [* ?- }
6 J+ v4 z9 U9 U5 u4 rstatic void __exit led_platform_exit(void)
1 L3 f% K- q8 m" u, Q{6 s0 |: ~! @/ V+ ?
platform_device_unregister(&da850_evm_tl_leds_device);
: q; ^! b. l4 [$ A0 s% ?" {6 e; M4 f, X
printk(KERN_INFO "LED unregister!\n");/ I( k9 L" x; J0 m" ~ q
}) ~0 v2 [+ q! e0 K& t0 f
H1 q* |9 `7 ~* w0 U
module_init(led_platform_init);
0 B. U" h5 Y9 p& S! S5 \module_exit(led_platform_exit);
+ C8 [- D9 h5 w D" ^6 m8 _. c* f& v4 {5 k
MODULE_DESCRIPTION("Led platform driver");
' |" a1 P' l8 f1 D% ]5 K# q* [MODULE_AUTHOR("Tronlong");) d. x# J- k: i v. ^+ n( K
MODULE_LICENSE("GPL");
1 P; T" S: C3 Q# @3 y# A$ R% D. c& @% K9 E. U; Q" v7 `+ T
|
|