|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ ^+ v; A% T5 [% S& ]2 p' D
#include <linux/init.h>
1 A2 \" }! l# k#include <linux/module.h>
2 Q# [ V4 X2 N j6 S#include <linux/kernel.h>. T8 l" Z4 s" J, t& ]
#include <linux/types.h>
( [9 e0 r$ l- T$ L#include <linux/gpio.h>+ L7 |$ t8 r& f# z$ k
#include <linux/leds.h>
# [0 n) Q& h7 @" J#include <linux/platform_device.h>" Y. w ?# _6 [
+ V, t5 Z/ r# K7 o" Z#include <asm/mach-types.h>
1 n+ O8 G! r; S; T! m3 e#include <asm/mach/arch.h>8 c: e5 ? K: c
#include <mach/da8xx.h>
& J8 a3 V2 Z8 m+ \#include <mach/mux.h>8 |5 Z! V0 q3 V
/ Q) e! ?/ f& M! d. f% |+ a- T4 @& r3 v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 E- o6 Y+ k* c5 h2 Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 v+ Z8 {# D! p) H: |' A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 l5 U0 \6 E, p6 E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 j/ ]( i2 N# y8 x+ S
6 f2 d/ {# e3 e! C1 m6 t3 q
/* assign the tl som board LED-GPIOs*/
* N4 q$ `+ Y% T+ jstatic const short da850_evm_tl_user_led_pins[] = {; q; P) C, J+ }7 W# D
/* These pins are definition at <mach/mux.h> file *// K8 o$ I2 ?' n( P( M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! K# }1 k3 `- s3 ~4 v1 C+ `8 H% n
-1! i, [7 P4 l% d% }+ R6 {. A
};
4 h9 z; d" z S( j; L, j+ z6 m# V( h1 T0 ^+ M8 Z. Z$ B5 Y$ I: f, l
static struct gpio_led da850_evm_tl_leds[] = {
! {. |: b* _7 l; m5 h2 i {# ~; d& w6 N8 u* C, q
.active_low = 0,
2 T7 A& s1 {" Z6 _ .gpio = DA850_USER_LED0,
5 a" L. B+ o, Q0 C/ J5 l2 \ .name = "user_led0",
% A7 b! ]% o" ?8 P/ z. b) y .default_trigger = "default-on",' Z4 b# t# n- y% `7 _1 _& `
},
0 R: Z" J# ?, P- F* \, ^! W {5 t2 g* A& x5 ]8 R! V8 m# ^2 l% k9 k
.active_low = 0,
7 g" e; k' a2 Y) n, A5 ]( |! y .gpio = DA850_USER_LED1,, E4 R5 x$ R+ n' w
.name = "user_led1",' m+ ]( G- @. g% z# ]! U
.default_trigger = "default-on",# {& L4 x0 @) R1 R
},' o0 q$ ^1 c. Q
{. S n; f8 k$ P) c a4 ^7 {7 ~
.active_low = 0,
$ p% K. c% G2 s- ^/ i/ R .gpio = DA850_USER_LED2,8 i' ^- L" S/ P
.name = "user_led2",6 r* x, K9 J; I! H, K
.default_trigger = "default-on",
* @) a3 E& R: V4 a$ ~6 }# r2 ~$ r# ] },
1 s3 Q' q) P+ i9 Y {! N3 ^: J- O6 ]. c
.active_low = 0,
3 G- P8 L3 A* F' F .gpio = DA850_USER_LED3,
, t, U8 ]5 r( I3 I9 z. ^$ b .name = "user_led3",8 t) K+ y9 ]' w$ ^3 ]2 F- |
.default_trigger = "default-on",
7 _$ R* t0 s4 \: P8 S) E# S },
- O9 z. T X4 @. k3 B4 G4 P};
$ s8 g7 ?- t7 W0 u
: r( h: z2 {- ~9 mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 E4 }2 n/ g: h/ C# A
.leds = da850_evm_tl_leds,+ j" a3 X' z7 v9 D3 i2 G# T
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% s' Z: w0 l/ b/ Z# p};; m6 j) a$ ]; J- P6 e
. M: v9 a* z$ G- P. @+ G/ C9 V) Gstatic void led_dev_release(struct device *dev). ~- j6 O) Z) Q/ f. O
{
' P- ^/ q s4 k6 v. D) s};+ r4 x# U% \- l. ^: T1 o' t* R
* q Y# X2 z- ~. {$ Ystatic struct platform_device da850_evm_tl_leds_device = {
2 \2 q$ T+ @ _" z .name = "leds-gpio",
7 L; ^8 b) M* B K) ?( [# j$ u .id = 1,
# T0 b/ V( @; K .dev = {
; W: j$ A1 |4 K5 _" \: P& h .platform_data = &da850_evm_tl_leds_pdata,, Q. S6 V$ U; m8 x% A1 y
.release = led_dev_release,
9 z8 u, r5 [% \2 \& e/ {; U) ` }
2 S9 U& [/ |: ]9 y};% l3 O) F0 ^ s& I: w1 |. n3 ~- r
- B1 d+ t% M8 q; cstatic int __init led_platform_init(void)
2 h; u0 Z( e. [5 N{: J- K7 n) a0 c
int ret;
, H4 ~" \' ~4 w0 B, f#if 0
1 w, u$ p2 H& ~6 i* N6 i( a1 i ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 n& ]2 h$ E& _0 U
if (ret)
: q$ e9 D7 ?* u) N pr_warning("da850_evm_tl_leds_init : User LED mux failed :". ~: u, F+ j2 A, v2 r5 s1 k
"%d\n", ret);, C Q, r( B/ P: q! `+ b
#endif! c! w1 ?; e! Q
ret = platform_device_register(&da850_evm_tl_leds_device);
) ?$ p1 X( U- o7 R" R! W; d& O6 y if (ret)
Q8 E* H/ o n, t0 | pr_warning("Could not register som GPIO expander LEDS");
' l- \& f+ N q; t, A$ N+ g! V C else
5 o% `: U+ q. a8 d8 g0 h printk(KERN_INFO "LED register sucessful!\n");" k' k, Z0 w) ]5 c9 j0 g3 z
* T5 q& n* Y* C3 y' O) p" ` return ret;4 E7 R: P7 x1 k3 l. S* G
}3 \% h+ d/ _/ B; w, B) L- d4 c
3 z, V' v* K* |: c, k6 ostatic void __exit led_platform_exit(void). u/ x; z' |+ w! B0 R" O& X
{0 v# Y7 I2 p9 ]5 h' e" ?& E
platform_device_unregister(&da850_evm_tl_leds_device);' a( F) y# L9 q7 l. M- @* a' o9 M
5 Y. H3 n* P, ^
printk(KERN_INFO "LED unregister!\n");
0 ~/ q9 d N" m1 h7 ^7 {}
" ?& l8 s6 E$ h) u$ \" ]+ x4 K4 Q+ ?1 g. _
module_init(led_platform_init);
$ Q5 C' R3 }% d; |0 c+ g$ S) D. }module_exit(led_platform_exit);
. h. ^, [4 x; L7 F3 A7 h0 N) {4 E7 F. a2 i( ?" a
MODULE_DESCRIPTION("Led platform driver");2 {; X! N4 \( F
MODULE_AUTHOR("Tronlong");
, B; N6 | R+ w: zMODULE_LICENSE("GPL");
' F- n% Y0 @- z* Q- ?; a/ U# E, I6 p: s* w, V
|
|