|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: V X; W( \+ x- o, C4 f, V#include <linux/init.h>; m' Q* F% a' i; o* h
#include <linux/module.h>
* t; t1 I% T$ {: r#include <linux/kernel.h>1 M* v# h; e [) d
#include <linux/types.h>
$ t! W) l$ g4 a) ^* F* V#include <linux/gpio.h>: F2 d( n, W% _& ^- `: C( o- @
#include <linux/leds.h>
! \8 B# \9 @, R" z. l* X' i#include <linux/platform_device.h>; Y# a5 q8 p% T) G0 F
: N5 C% l: ?, c' [" C V#include <asm/mach-types.h>
- i1 Q& T% W# E& w4 T#include <asm/mach/arch.h>, f& L7 G8 G m) t
#include <mach/da8xx.h>* Y8 ~! ~! `6 j2 E
#include <mach/mux.h>$ w' V8 ?& C( s6 L+ o
, X3 k6 m0 e2 p; s3 Q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- _9 U$ A q. |7 }6 k#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 B0 B% n8 C$ C1 C1 ?% Y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ ]/ i. Z3 R: l* J! H
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 F3 S: k' B0 |2 Z' S9 P8 [2 o0 m3 g2 ?; y) l; X5 `. l
/* assign the tl som board LED-GPIOs*/
+ B0 B1 p# I" Z* x; t+ Fstatic const short da850_evm_tl_user_led_pins[] = {
7 X& d# M3 y' K# u9 v* L! m /* These pins are definition at <mach/mux.h> file */" |, g7 _( l K1 }, V) M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ s: a+ |/ D1 Z# N' o& W h
-19 N9 c. y5 x8 m& L1 V( m
};
6 [# I6 ]) }7 R1 Z/ J3 @/ N7 h" [! ~" ?. ^
static struct gpio_led da850_evm_tl_leds[] = {
h8 f- f* R& m7 h$ M3 q {
/ A6 c/ U" {. N! `' x1 Y .active_low = 0,
& b5 v3 U+ l! N" j .gpio = DA850_USER_LED0,3 ]7 |' r- C( Y' ]$ z
.name = "user_led0",
: [+ X3 C1 o3 K9 s/ Y- D' U .default_trigger = "default-on",
x% i# r6 Z& X },
# L; t c% W B6 G- o5 n# m6 J' { {7 j& ?% @) L4 u4 i8 q
.active_low = 0,. _* u0 _, k U' H9 |. W
.gpio = DA850_USER_LED1,
$ p& W4 @2 d7 Z3 O7 }1 s .name = "user_led1",
2 q3 z( D U: b2 K( E+ z .default_trigger = "default-on",
! I) H6 D0 i7 G6 r0 C! t },
; A- L9 s/ E7 O3 s {
+ I0 ^- X2 f5 Y8 U. x% V .active_low = 0,
1 t. O' H3 o" ^3 k& O* {2 Z .gpio = DA850_USER_LED2,) ]0 `1 m; Z# {9 d7 y8 w1 ]
.name = "user_led2",9 @% h% I/ a- Y' V
.default_trigger = "default-on",, K- y5 c* z/ \% Q
},
) B5 k9 A; l) S {# {% r, e' o. \: m* r6 d
.active_low = 0,
' Y, w1 R: f+ h5 g2 ~8 q- s( z .gpio = DA850_USER_LED3,
6 r' w* `( M+ P" M+ x0 Q .name = "user_led3",
) M0 C' x5 {) O. ~5 j4 [6 Y# F .default_trigger = "default-on",
& K W w4 d0 y& d( W },
0 ?6 C* ]2 \4 ] x2 R5 F9 n};
( c3 |3 k1 r' d; w
9 V% V. ~- G% U' ?$ @4 [static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! J, D5 ^. E* L9 S
.leds = da850_evm_tl_leds,
9 W; c& {5 v, k3 t6 x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' C# d5 B9 s* l7 o% a% K. U
};
9 Y) U5 L' F, V: E2 C+ D# M! m, I, e+ P @' r- k* K' r
static void led_dev_release(struct device *dev)8 h: m4 ~( v6 V% @
{ f/ @) V$ ^* @: m" N8 Y
};: F( L/ j$ Z. w1 G7 [' U9 K3 j; o
7 ]9 d8 F, S4 U: S6 Z9 S9 cstatic struct platform_device da850_evm_tl_leds_device = {% w/ _% |2 ~) T
.name = "leds-gpio",% f4 ]3 F& l- x! h6 H$ h
.id = 1,
* f* w9 b1 b) T1 K .dev = {# ^8 Q2 _' M0 f/ y) ?; k' f
.platform_data = &da850_evm_tl_leds_pdata,
" y( p' H' b5 z+ A .release = led_dev_release,
& \: r% n9 ^: m* U! e, Q0 K2 S1 u }
1 H1 C8 W ~) t# L3 g* ~& {# O};
8 \6 ^9 l8 m- B8 V' E5 E3 s. Q& u' s* g+ q# n: f
static int __init led_platform_init(void)6 S- \8 C" w# S3 _! Q
{* V$ o: R3 W# L: Z. c( G; A! f+ s
int ret;: s, B. Z& ]7 e8 r% H4 ?
#if 0
2 I6 ]7 w8 J7 v/ G* |3 \5 X0 g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% s G) B, }7 q! a) I
if (ret)$ V( S( @! W# {0 d. t0 H# O+ J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 L/ Q2 v* p# U) `3 H3 ? "%d\n", ret);
9 J( v5 o+ f: L! p7 h, J#endif
: W4 z0 H! H; I, U, K M# l8 i ret = platform_device_register(&da850_evm_tl_leds_device);
( ], O v% u$ C if (ret)2 i% a3 \, c. C. z% g0 g$ G' u$ ~9 F
pr_warning("Could not register som GPIO expander LEDS");% M% N- w9 z4 r% ?
else* C2 ?) D3 w9 p5 m$ |2 g
printk(KERN_INFO "LED register sucessful!\n");- J% \5 N( X$ h# Y* H1 Z2 h/ s6 v
9 s9 F3 Z, a/ k1 G) E return ret;
& h% U- G+ h- d& f. q}
# {: T# s, j) ^. o. _$ T) e
) X i, _4 |1 ~. ~0 Kstatic void __exit led_platform_exit(void)
/ T/ s: r! ?0 {* [' c{/ x2 t3 r" _1 }: l' Y
platform_device_unregister(&da850_evm_tl_leds_device);
% U# b) O l! s& {2 {# ]6 Y D3 M4 Y% k: }/ }, }+ a' T1 k. U* ?
printk(KERN_INFO "LED unregister!\n");
$ z$ y4 z; C' e; T7 U}
8 |" d) A$ m: g; R0 a$ {& o. i0 n/ j7 q4 L% D
module_init(led_platform_init);
6 g, J- w. n8 }/ h& Q) {% imodule_exit(led_platform_exit);# ]- x* Q# _, B- m
8 A+ O$ y# L9 Z8 }
MODULE_DESCRIPTION("Led platform driver");
: g% L- I. i* x# q' JMODULE_AUTHOR("Tronlong");$ ], E* i- ?) i! b4 K
MODULE_LICENSE("GPL");1 k5 n) Y0 Z+ U
, d$ |% _$ T8 O1 U( k" K8 H
|
|