|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ O( A# n$ g0 }2 \+ S3 R) S#include <linux/init.h>8 ~" p6 n& e) {& [2 ]
#include <linux/module.h>! W Z2 A) r+ X- V/ ]4 l% U
#include <linux/kernel.h>
: F' f( w& H( Y! S9 s; |" |#include <linux/types.h>. }5 |0 F, c D* M/ B/ E; M6 X
#include <linux/gpio.h>: O1 k8 |- m; J* W+ ?. R
#include <linux/leds.h>) X+ J8 {( w5 j5 \. ^$ \- S
#include <linux/platform_device.h>
- g% ^, Y; \" }$ r- c# T6 o1 o" ?( {8 q% [4 L$ f
#include <asm/mach-types.h>
* d1 v% M! u. \' j& K#include <asm/mach/arch.h>
! k% F* n: ^' `0 S7 w" t#include <mach/da8xx.h>
3 V% H9 p4 i; D! U) M' Q3 j#include <mach/mux.h>7 c9 r( y% o9 v7 r& b
2 `$ w% P9 H) Y9 A) e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 E) {/ c7 T& X2 J$ ]3 R& V5 X7 C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 h1 ~+ X# d- K; T
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# w& g6 H! w: N+ e$ K/ g" V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( z7 c0 O" L, B1 F8 \
- M$ w/ ~- M$ Z6 _" I, `6 a
/* assign the tl som board LED-GPIOs*/5 }/ ^: Y4 c1 K% W- ~
static const short da850_evm_tl_user_led_pins[] = {, V+ ~0 w- Z$ C5 M6 _" g
/* These pins are definition at <mach/mux.h> file */
' S4 G+ r$ F# o6 s& h. x4 ~" a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& K! b% s& _/ s& C: y* j! f; u7 R l
-1
- O! u! f. e+ s* x2 h) O' Q7 a$ r};' B' {# K U, D
7 v% G; @" s2 V6 R7 R! j
static struct gpio_led da850_evm_tl_leds[] = {
* v; T, n% o( n5 g0 k/ z {7 p/ V4 q- G( z
.active_low = 0,( F" d' t: T( D/ o) l* m$ `
.gpio = DA850_USER_LED0,; y9 i& a; T4 F- z+ y
.name = "user_led0",. |, g$ {8 J9 c- Q% m
.default_trigger = "default-on",
7 G0 z3 i" h z' d" R1 i3 b, n0 ]9 U },% H" r7 J. h3 {3 V: H7 {2 \
{& k! B* B' T0 i0 E
.active_low = 0,
( g* f* n' U, M4 H! r2 s7 M .gpio = DA850_USER_LED1,
1 y, p# O4 d( n; Z% F .name = "user_led1",+ m. |) a8 E7 G S: ]' R* i# ~2 f
.default_trigger = "default-on",
" R3 B; b: W4 J },3 a' N+ b' n# } V1 u1 l
{
& L% B6 S( m! p" `3 V( r .active_low = 0,
0 f* K% f9 S% |' O/ Q .gpio = DA850_USER_LED2,: w6 J, @0 g& W" J3 `
.name = "user_led2",
7 Z8 C1 f8 E5 ^ V" q$ J .default_trigger = "default-on",
' C5 D1 y+ d8 |. ^ },
N' k$ \& Y c6 s {
. A$ I* B8 }; l# c .active_low = 0,
5 L2 e- [) T- x) R U: } .gpio = DA850_USER_LED3,
( I/ @3 o4 H- _% |( F, M .name = "user_led3",* c& f) Q3 ]% O- B b
.default_trigger = "default-on",
1 m6 [1 {) O' ?7 u8 [ e },
. \. | w. X) s0 G4 F* R};9 ]/ k l) S3 p2 o! l E
1 J. _4 \. |% ?5 u& k( X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# [1 e4 T% b% B. A3 k" I .leds = da850_evm_tl_leds,
% R' |( b9 B6 H* I, B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ n3 }2 `$ p2 x- k+ w};
4 y7 e: o3 F3 x# W7 h( v5 J/ h; {& L# X( x7 K: I) _! `" U+ \
static void led_dev_release(struct device *dev)
a; V8 u. f! g& F8 B) j9 z{5 K+ P/ R4 r# u9 k( @$ C- ~. V
};
, A r- @. _6 A$ }% h9 E0 B. b8 w6 u0 J; Y$ \; H- U. ?1 ~9 @3 f
static struct platform_device da850_evm_tl_leds_device = {
; I- ~' `% b) ^2 {! }$ y .name = "leds-gpio",& d5 S! { \' o4 U$ S7 I
.id = 1,
( a _' K* K* ?3 f1 F S" K7 F .dev = {
" H1 k7 R3 r6 c* L! @! O .platform_data = &da850_evm_tl_leds_pdata,9 ~& }3 j5 d7 \( i) R6 x' e
.release = led_dev_release,
6 M9 s/ Q. X6 Y }; A% J( v7 ]. p4 @/ ^, v/ `/ P
};
$ C. e) z2 N6 U+ \9 q+ N
4 Q7 \; m- h G( |$ w' u9 M$ Estatic int __init led_platform_init(void)
- l0 f. r! y6 M2 M. r& s3 w{7 U) q5 M2 j' v& X# J
int ret;- P9 }; S6 d6 u' o4 {
#if 0
( ?; [6 j" p$ C7 r6 H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. u/ S1 h7 o4 {/ @) ~
if (ret)+ T0 ^; _, R; z& \
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 H) K9 Q U3 T# s5 X
"%d\n", ret);8 T4 E* r, M8 @* P2 P. L- R
#endif
( W" z: ^1 T% H9 V; o ret = platform_device_register(&da850_evm_tl_leds_device);
# o2 @6 ?+ c" K0 `# P0 h" c t if (ret)
( E/ J7 w/ p) A$ @ pr_warning("Could not register som GPIO expander LEDS");8 D; T8 f: J) K5 H$ f# z5 f
else) {0 B6 c& `# |& n
printk(KERN_INFO "LED register sucessful!\n");, z( e3 J) z" S
2 X7 P. a, k3 x7 _9 ^4 x- o return ret;
" x' B3 H$ Q6 G+ a8 E. @6 p. l8 r L}
+ k" {0 c2 V% h/ v: C
. _6 S+ y. w" U5 e m& gstatic void __exit led_platform_exit(void)
3 W5 W+ p# c; G ]% y) i8 H{- r& w3 l! T2 y6 x) q
platform_device_unregister(&da850_evm_tl_leds_device);1 N% v8 s/ o! O3 H
& _/ p$ T0 v9 G& c, Z3 S printk(KERN_INFO "LED unregister!\n");
$ M8 C3 C6 J/ ?2 E2 }}- v5 k* s7 p% `# [2 t7 |! Y; U3 D
" e5 G5 l$ q5 f8 \0 ]
module_init(led_platform_init);
) I( d; i( |' x# bmodule_exit(led_platform_exit);
O' ^4 ~1 t/ ^6 n l
6 B2 F! a* x7 k/ j F0 {MODULE_DESCRIPTION("Led platform driver");2 s. F3 R2 S4 Y, m- `
MODULE_AUTHOR("Tronlong");8 r( ^. k9 @) x L/ X8 Y
MODULE_LICENSE("GPL");
* f! F! X: w- g7 n* L7 W% m; A1 g6 @
. L7 H: l2 t! e/ b1 o; A) J ] |
|