|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. w. @8 y; f* O+ S5 e
#include <linux/init.h>: b- K* F+ |. w4 M+ C0 z
#include <linux/module.h>5 E9 }( M- V) p' o" k7 E
#include <linux/kernel.h>
3 }" Z7 j7 l. L3 d/ E& P0 y" Z#include <linux/types.h>( B" ^+ E1 D' e+ p9 i. {3 G1 Q S
#include <linux/gpio.h>
# R) L B0 s$ ~2 L# x) g#include <linux/leds.h>
, P6 F' ^( I: o+ k% X) c#include <linux/platform_device.h>* w- t& @- ~2 H( n
( z7 N7 a2 q; } {#include <asm/mach-types.h>
/ [6 |* h9 }; C#include <asm/mach/arch.h>
9 A, \& N) B4 M+ Y; m) A#include <mach/da8xx.h>
. ^- D1 Q; D. w; o! v2 n% W! ]#include <mach/mux.h>
5 G% t4 j6 N. D3 I0 Z- q5 Q; j* H& T8 d+ g8 c0 G2 b" ~* U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ U L& m, B) a# k' i6 U#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 M; K! h. U* P8 {#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" O: u/ x9 N( Z" I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ I1 H1 y2 H/ l4 X& q: y! W- o3 t/ ^% h+ g
/* assign the tl som board LED-GPIOs*/
5 z: @7 u; E5 m$ T. g7 ustatic const short da850_evm_tl_user_led_pins[] = {
0 @" m z. m8 t# q% V" m9 M /* These pins are definition at <mach/mux.h> file */
& c+ @4 k/ o8 p" E7 i- \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& d5 |6 Q2 H; w7 B j
-1
9 }2 y6 |7 m8 E/ ?, i};
' M1 z& J1 N. n( T
2 E, a4 G2 _3 R8 wstatic struct gpio_led da850_evm_tl_leds[] = {
3 L0 D+ \& a& b {9 R7 ~- m. {4 p4 C% p9 A( ~: n
.active_low = 0,4 h8 z: j# s7 |
.gpio = DA850_USER_LED0,; ^8 D0 H* ?; k' w
.name = "user_led0",
& O* ^& i* n1 g- U1 A* M3 ^" Q .default_trigger = "default-on",! { t- a" c0 g
},
- |) Q! y# d! Z8 C4 W$ M2 y" A {
4 R/ U/ _% E6 q5 K. P8 X .active_low = 0,5 m% y- G* \( Z# D5 d
.gpio = DA850_USER_LED1,6 K& s7 U# W2 `2 R+ ^6 o# D
.name = "user_led1",- [- z9 c* g+ H d( D$ h: S
.default_trigger = "default-on"," R% J) ]( _9 _4 [1 r! U E7 ^
},( _# E- T+ m2 g1 W+ f+ C
{
, r5 _. _1 k4 ]. J+ U .active_low = 0,; E$ _2 j$ S0 ~) I9 {
.gpio = DA850_USER_LED2,! r I7 G$ W5 s# y
.name = "user_led2",
! k2 F1 o8 p, d% z/ P .default_trigger = "default-on",& \* ?2 S/ \1 K6 U" u
},
6 c2 N$ R! S0 L8 y$ _ {3 a7 ?9 C4 P* w- B, v
.active_low = 0,, q8 w/ t6 F2 o
.gpio = DA850_USER_LED3,
0 W8 `& m( Q$ Z! u; L .name = "user_led3",
- q( n/ b& @9 i& H2 N: L+ A4 | [7 x6 \ .default_trigger = "default-on",; S, G& Z/ I8 \ N# Y
},9 u: u) p [+ s
};: |8 t o" w" Y0 @3 _
8 R( h# f& a I% i* c" }, Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) ~4 N9 k& ]* Q6 b& Z, y
.leds = da850_evm_tl_leds," _, _; v& o6 T8 J4 K" q# B
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ M/ g ~. A. C& k* p
};
0 n% p; q* b# }
0 K N4 \% `2 P! s) P1 v( ostatic void led_dev_release(struct device *dev)
3 c" a. q7 c5 n" e; _{2 `7 s* @! k k a* K4 F
};5 \6 E; Y* z9 H
* q) K9 E: [6 w( Q- D1 Q! R# Lstatic struct platform_device da850_evm_tl_leds_device = {2 j0 |6 F2 f; H8 |
.name = "leds-gpio",
w# s# }' {2 `7 ` .id = 1,) H- Y% [& f2 Q
.dev = {! |) s) q9 i7 i6 Y- }" s, b
.platform_data = &da850_evm_tl_leds_pdata," }# M z8 L4 b @
.release = led_dev_release, n0 C. u2 }5 ?: _) q( w* }
}
+ T( x2 H8 x4 `3 e, M* r% ]5 t};# r: V) A8 _' R
" k2 a2 y; S. ^1 [7 Sstatic int __init led_platform_init(void)
" k: Z9 |6 Q8 m6 J+ Y{
8 z' S0 |9 d: }. k, r: b+ z) S int ret;! R8 G4 ^4 x: K( M: w! Z
#if 0) P4 S' \- f0 \9 ?! c8 V) a$ A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# Y& i' w; y( ?( }: {8 S7 r
if (ret)8 r+ W6 k$ Z# M/ A
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% \( r- G+ x% z& n
"%d\n", ret);
/ J0 `$ F% j$ E6 s( ^" D9 N1 c#endif; R# U$ e+ o- S8 O5 |' V! j7 X2 \
ret = platform_device_register(&da850_evm_tl_leds_device);
7 @/ [0 E' s- @" \3 }8 M" C/ C) ] if (ret)
; a: t8 ?% O. {& s4 k$ F0 l, X, p pr_warning("Could not register som GPIO expander LEDS");: U5 Z( J3 D `2 I
else2 P6 n" [7 @; [* R: e) U
printk(KERN_INFO "LED register sucessful!\n");6 o4 c# T# U/ l0 i: D) Y
( L+ Y* _$ Z" ]7 }8 d# w
return ret;4 m2 ]6 u* a# M9 G
}
$ c4 M9 W* C. T1 |3 I' R/ T) R& v7 @
8 C4 y1 J' w% w+ O, |! p( \1 Ostatic void __exit led_platform_exit(void)+ N3 K2 g& H% |9 r( J
{; T4 t" [- e/ S& x3 t. j3 I
platform_device_unregister(&da850_evm_tl_leds_device);8 v1 Q& t. I5 |5 c5 i
# t6 ]/ Z% X# L( w
printk(KERN_INFO "LED unregister!\n");* D1 _0 {/ N9 X* n
}
. @* {: I1 S( E7 R( @+ i+ T+ q8 n6 z" M& ~, w/ K8 v
module_init(led_platform_init);( A ^; R# O$ |' B
module_exit(led_platform_exit);
. E; p7 P- J4 ~ b. a3 E
9 J+ z! d+ b* ^% _- X+ RMODULE_DESCRIPTION("Led platform driver");- N$ A& H; d, M& l5 g5 W4 a
MODULE_AUTHOR("Tronlong");
+ m& Y% m2 g/ A: Y0 B1 L2 w# }MODULE_LICENSE("GPL");
- B6 ?% p( C& I& Y r8 ?
+ H# ~7 l* H3 ~8 a( B7 E7 \ u |
|