|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, b T; z c7 ^/ M- t8 {! i# @
#include <linux/init.h>
X4 w0 v2 n4 f#include <linux/module.h>" E4 s* @6 N9 G6 Y% _) z3 f9 V
#include <linux/kernel.h>' Y l5 Q; O" i
#include <linux/types.h>. c% f; z3 o8 ~( ]
#include <linux/gpio.h>3 b: p* R( j3 z/ ]8 d0 I
#include <linux/leds.h>
( n! d" v G: Y! k+ F#include <linux/platform_device.h>
: ~0 L. {1 [; z: s. _4 W3 {: }
/ T4 F, E2 _ h* Q- {8 V#include <asm/mach-types.h>: J/ s$ [6 q1 Y& Q9 \% U+ g
#include <asm/mach/arch.h>
* \: E- W$ V1 C7 d- k+ d! F; X#include <mach/da8xx.h>4 I9 u. i! }) ` Y: X; O, w2 q
#include <mach/mux.h>
6 v I+ }5 ~; {/ Y
- _0 u3 E2 I& W% ^0 {( H' \% x8 X6 G) U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; Q( {0 L* y. k8 v: _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 C, I, J+ ~3 {+ F- \; I" e; t#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) f* ^- P4 x8 R4 ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ @# n8 o/ [3 g
v# U& d i6 l2 @# ~/* assign the tl som board LED-GPIOs*/% o8 s; i8 h) D8 @2 Q& o
static const short da850_evm_tl_user_led_pins[] = {/ `9 O- {5 M, r* Z( H' w9 K9 k
/* These pins are definition at <mach/mux.h> file */+ E7 \9 t6 ]* D2 T. w; Q/ }1 \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: D2 @( }' t7 T: t4 X8 w* R
-1( M7 g% p7 L! H. Z% T4 ]
};2 \5 X7 k2 I }9 R4 W% S" ^
* n0 d- ~3 G3 H8 @static struct gpio_led da850_evm_tl_leds[] = {
' m% {" ~1 ], T& }: c) i9 I9 B {& z3 o0 p" X6 m$ V% \- s" G" R8 d# \
.active_low = 0,
( l# j# Q6 v/ f .gpio = DA850_USER_LED0,5 ^3 ?, \7 y, K- p% W
.name = "user_led0",
3 b8 z% n7 G0 ~- N( y .default_trigger = "default-on",
/ A ` t8 y: h5 i' k },
1 c+ E* d+ i1 B( d$ N5 k$ W {$ \2 W* B( `" W( v
.active_low = 0,
7 r5 C# c" u) B: @3 N; {1 q .gpio = DA850_USER_LED1,3 U; R2 ]; ]- u# h5 R, y7 E& u
.name = "user_led1",0 q8 ?! y4 b+ @' n
.default_trigger = "default-on",, R6 ~2 L) Z$ q2 J# v9 H# B
},7 w4 m- S8 ^; k5 t4 A% b8 A# @1 `1 z
{7 n4 e0 g/ l: {* S
.active_low = 0,
1 n3 e' u/ }$ f2 b& L# } .gpio = DA850_USER_LED2,
$ m0 Q% o% ^' l7 u3 ~8 R1 ?- H' f; U) Z .name = "user_led2",0 d, z6 C7 X1 x! m( ?
.default_trigger = "default-on",2 Z9 l; b7 [6 R
},
4 z4 G% o" t- B9 M5 t {# G+ T' p6 ?5 f" O4 l
.active_low = 0,! f! X; F7 K. g j# j6 z0 `
.gpio = DA850_USER_LED3,/ b+ M9 c M2 `
.name = "user_led3", B$ e" C0 p8 ~( S5 x- C
.default_trigger = "default-on",& T, k. @! C4 Q% D A) w
},
4 u3 u9 ] a( T& g8 r0 E: W9 Q+ o" K( b};: C+ F7 h$ a- A" I# J
) E P& N5 g( g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, h/ x9 L- Y1 ^4 N% `* I4 ~# s( g .leds = da850_evm_tl_leds,
% \4 C [: i& k; n" g- S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 M/ {7 D+ f3 F6 e% E1 [
};# K5 d3 E4 W6 O0 K w
* h$ f+ @2 {) F( }' Nstatic void led_dev_release(struct device *dev)
: k+ h2 c0 R( J{6 d6 n) H- e. l" G: |
};1 M) y# @2 j8 {4 z( O! y
" }7 _0 L3 m8 r1 e- D* A* W' istatic struct platform_device da850_evm_tl_leds_device = {
" | S4 M- P. B .name = "leds-gpio",
+ x0 b+ A! L1 y0 C! N0 A .id = 1,
: H1 R+ L$ ~$ L4 Q) n .dev = {
- Z) R. C/ g1 M- i% A, V) q$ t .platform_data = &da850_evm_tl_leds_pdata,
1 }5 L. _( m! q3 X .release = led_dev_release,
: B( M6 I* B. Q; b: U# L2 L# N/ G) N. v }
$ P# Z6 ?" M0 `1 W5 Y1 E x};/ d6 H! k* z0 |+ \+ o
) _6 B& V! q1 \ Cstatic int __init led_platform_init(void)4 h8 Z0 k' {. N3 S* B
{
$ Y3 n( k8 N5 J5 n: S( g L4 F int ret;. s9 p2 W# U, e
#if 00 l- P4 M, z/ ~* s" n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: k$ w9 B% I. f) j if (ret)
: U6 ^' x9 j! @& m {3 L4 b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 a6 t' M, t. v "%d\n", ret); J0 c+ s" l8 L8 k( V) F/ g4 S$ q
#endif0 Z6 J U% n1 I8 J+ `; r
ret = platform_device_register(&da850_evm_tl_leds_device);, r; P3 r$ ^% i
if (ret)/ F5 \3 a, S) k& j( w/ t: T3 i! U
pr_warning("Could not register som GPIO expander LEDS");
5 }/ P0 ~9 x9 Q& l, {9 y! Y else3 ?! ?" D4 L+ r2 k! P2 H
printk(KERN_INFO "LED register sucessful!\n");! Y5 I+ p, g0 A2 p0 H. v
, ]5 O3 \3 r& B0 b6 ]5 @' h
return ret;) m2 b$ T% d1 }+ r- ~$ G( W( X
}
1 c' t9 _" i& Q C: ], z8 T
; g0 N6 Z& Q' I. y, Ostatic void __exit led_platform_exit(void)
/ A; [: Y/ X/ z8 b2 I3 Z. x{
" }" B+ G% R# J1 J7 h0 s# D platform_device_unregister(&da850_evm_tl_leds_device);+ Z. P. n; S* V% w3 n
0 G' ~" D" @$ t. P, Y, q- k printk(KERN_INFO "LED unregister!\n");0 I9 h$ q1 D$ H( K: N" @
}. O+ ?' d8 o' D+ L. m) w }
% Q, f! X6 B+ F# omodule_init(led_platform_init);
/ T5 m& I0 i' H3 ?, Nmodule_exit(led_platform_exit);4 W% M5 Y, S4 W ?) c) ]# J
2 D7 Y7 e& ?0 hMODULE_DESCRIPTION("Led platform driver");
5 k6 w" n/ S4 c4 P2 {2 q3 tMODULE_AUTHOR("Tronlong");
! v: G; V6 s3 O$ P7 U9 }MODULE_LICENSE("GPL");, u+ u- @( ]' W8 h" p* N/ I
% o% U0 q4 p6 ]" _( ]% e/ y
|
|