|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) D+ t- N# ]1 G/ V$ ^/ v#include <linux/init.h>
9 Y4 h& b: L0 V5 g) c. ?3 `/ ^#include <linux/module.h>
% m0 I2 t! r( e& B) z( p#include <linux/kernel.h>
1 l1 L1 y" e2 I5 P4 a* n! ]: }0 y#include <linux/types.h>
- Y( d- E, Q7 @ u1 X+ n#include <linux/gpio.h>
: w! I1 v8 Y* }! J. n- r#include <linux/leds.h># Q" l" r; d+ U, u
#include <linux/platform_device.h>
& N/ ~! f0 j0 z; I- u' w* ?+ n' z5 H4 Y% `2 @/ f
#include <asm/mach-types.h>3 U+ w3 O' J/ r( V
#include <asm/mach/arch.h>& x8 Q; i" i* @, p4 O
#include <mach/da8xx.h>- R. Q2 J3 m3 B" L1 p( {( k
#include <mach/mux.h>
% F* K/ G3 S' u1 U8 r
8 b$ a" k: n; M; g$ }#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) `$ n+ Y" r# Q. p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 L9 I! d- u5 i; @8 l
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' i* h" Y" E' H# A2 x# r! J+ o0 u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 l- ]$ S' Y8 u4 B: b
/ a8 r1 V& n3 x. m/* assign the tl som board LED-GPIOs*/
- @! e9 n9 y; x9 G, o# ?static const short da850_evm_tl_user_led_pins[] = {
8 [% s6 m% f7 _& B+ K% H7 w /* These pins are definition at <mach/mux.h> file */# V( I6 o: \) j/ l! q. e$ Z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- [6 ]. c; t$ u
-1
2 Q+ V* Q0 W- K2 T* v};# I% O% {- c& X$ Q- A2 T$ J
( _* O8 `3 x" B$ | J
static struct gpio_led da850_evm_tl_leds[] = {
! x) D. V$ z9 f: v$ D6 X {
% B T9 N. W6 o4 ~. a: n7 \/ O( y5 q .active_low = 0,
, U$ S0 }& V# U .gpio = DA850_USER_LED0,
* F3 t- A) f$ y1 E .name = "user_led0",
% a. y9 n5 Q$ Y0 T3 ^ .default_trigger = "default-on",
/ a5 y4 u& B( }3 A5 Q! B },
- J% L* F! p" h& c- \' s e {
: v) ~& Q: c$ B* J2 Y, ` .active_low = 0,
4 Z# R4 o, T( M; M0 E .gpio = DA850_USER_LED1,
1 l% r6 g% Q3 O6 w4 @ .name = "user_led1",
# f( p5 a: W& ^9 k .default_trigger = "default-on",
5 Y- l1 j0 u9 A- p( |. ?2 ]) f, i },
0 M* v+ Z: D$ M; f" }' m0 Q; D$ K {
3 Y1 u) m0 w% D: A1 u- v: Y0 } .active_low = 0,
; S: U& V* U; \' g .gpio = DA850_USER_LED2,
! z* H U6 z9 l! f8 Z; ? .name = "user_led2",
' J: c# [5 h9 d- r- N .default_trigger = "default-on",
. Q/ Y5 E+ f8 L7 L" R9 ? }, Q( p' X W0 A# z4 |& D
{; K) p' t" Y, b" L1 e* a4 {
.active_low = 0,# t" Q2 @7 f( e; P9 x# F% a7 m
.gpio = DA850_USER_LED3,0 d7 t" M; w, {9 {- t
.name = "user_led3", A+ c; n5 ~, e* D
.default_trigger = "default-on",! c: x7 D- A" i5 p
},2 @6 [0 ~) A3 s G/ P: i# B
};
8 T- E9 U) ^/ w9 A6 }! K0 p5 X' |+ z: K; c f& H3 f. ^6 c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 S. B4 n% e! m- ~( ^- H .leds = da850_evm_tl_leds,
0 C6 p+ `0 P6 F4 } .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," ]8 {) N& u- J6 C! q8 D- w
};# l4 W& {- |/ w4 I& ?- \8 v; ]9 F
! e5 [! G4 M8 U/ X
static void led_dev_release(struct device *dev)
/ D& w( i" B- `4 X{$ \6 w; f5 g( Q4 b8 V8 j4 v
};$ C3 {! Y5 H3 J9 }
, r( Y4 C/ M6 z' A7 o$ E$ \static struct platform_device da850_evm_tl_leds_device = {
% J0 ~0 y& ~( J3 X2 j* L( D .name = "leds-gpio",8 w$ I9 O/ X1 c
.id = 1,. y+ g" Q3 c# ]2 p2 n, `7 X& V
.dev = { D, y$ u, l2 j' H. |; L
.platform_data = &da850_evm_tl_leds_pdata," f* v: l5 {( l1 c5 K$ F
.release = led_dev_release, v3 h0 Z/ x" t/ N
}' \: I9 o" C) q% H P+ u
};
3 o' c- f% ^5 X: `6 a. \ t6 R7 |* A
static int __init led_platform_init(void)
& F" ^9 x5 ~% E3 f$ m{
: C. q5 ? G$ V# R, q/ ?; U int ret;
3 O1 H* M' Y5 h#if 0% T3 m8 z+ [* x, g. L$ K" |# [* f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( y# O6 w1 M" n' R if (ret)% T3 R7 J/ d. M, v
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 v V; g. J: _9 x* k "%d\n", ret);
% V9 O8 C) x6 `#endif
6 H! ]' x+ L. J ret = platform_device_register(&da850_evm_tl_leds_device);
}4 {6 K& _4 R, s R3 g/ c if (ret)* E9 ]) ], E6 Z- X
pr_warning("Could not register som GPIO expander LEDS");0 N7 h. _$ s: c: C3 w8 \
else
& Q+ C% c1 B) f. h* Q3 v) H) i printk(KERN_INFO "LED register sucessful!\n");; P4 d- T# a& F8 a& }5 B6 X
- R, |7 ?* Y" h. [
return ret;5 C7 P% U+ S, V* i# |
}
7 f5 V; g/ z+ i. i* v$ ~; Z' J* B3 k! ?! B# A4 D
static void __exit led_platform_exit(void)
7 ?1 _$ ~$ f6 O+ O/ b f{: X" W6 ^* p- p- I) Z
platform_device_unregister(&da850_evm_tl_leds_device);6 W) w% v$ i8 p. `) d9 Q h
$ g/ C! q) ]3 J0 s% ^1 v4 d) x1 V! T printk(KERN_INFO "LED unregister!\n");
4 E5 Z( ?4 i, h; ]+ W4 o}6 d4 k- p( ^% H8 W
7 F/ j8 ?, {* y
module_init(led_platform_init);
8 u% N9 W4 D# x- r% {, Hmodule_exit(led_platform_exit); Z- B9 w, b( M# {$ N2 S
6 _! H3 d" i9 @3 U7 G: E2 qMODULE_DESCRIPTION("Led platform driver");
6 z( K9 A! ~! Z4 aMODULE_AUTHOR("Tronlong");3 X8 O8 ~( e' K3 N: j) e
MODULE_LICENSE("GPL");& b* z2 E( L- F4 e% N
/ f% \6 F! ]7 n8 c: a: q |
|