|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 X# R; ~3 f0 [0 a7 s4 l" U
#include <linux/init.h>
. q1 S" o p6 l. g C#include <linux/module.h>% e7 j+ j* `) ^( H- A7 w1 _$ q
#include <linux/kernel.h>. D# o) Q5 C7 T# L
#include <linux/types.h>
+ U+ q( E' q8 n9 j5 f: C#include <linux/gpio.h>+ f! Y$ H I" {6 M0 `9 f9 U
#include <linux/leds.h>* a6 y0 [2 b" d0 }/ }
#include <linux/platform_device.h>4 o) `4 _; G o# z9 C
' x" o- X* F" v. ~/ k
#include <asm/mach-types.h>7 |2 z% E i0 X8 f/ G4 B5 x
#include <asm/mach/arch.h>7 F5 }7 V- `+ }% H$ W" [- m
#include <mach/da8xx.h>
3 N9 q! |* `/ w2 Q. S#include <mach/mux.h>9 h( Q' x6 g% U2 ~5 d& s
& P% r8 ?4 N; ?/ Z8 x" W4 b& i#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' }6 ?; G+ i& _2 \% l( l$ b- \
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). m* s8 `0 x" K$ t. k7 }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; N+ V2 h, @7 E$ I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( Q4 {5 ~, @, S! W8 T
6 Q3 q! P, n o' H9 `/* assign the tl som board LED-GPIOs*/8 V& @2 r, {9 \3 E0 d# h* W/ p
static const short da850_evm_tl_user_led_pins[] = {, }& r6 m: L; P+ ]
/* These pins are definition at <mach/mux.h> file */
6 v% Q! y' p& ]& b$ K" ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& S; `' J7 N( p& j$ a7 ?* R3 X -1
2 L( i% j+ f0 r7 i6 N! R};
2 x4 s* O" f6 H8 t
0 u- ]+ t7 k p+ w rstatic struct gpio_led da850_evm_tl_leds[] = {5 _2 R- w$ |7 V% H% C
{" Y6 }6 X& \; T1 ~
.active_low = 0,9 N) f2 T: V" t/ e
.gpio = DA850_USER_LED0,
: I2 |+ [3 `7 d8 v4 S% F .name = "user_led0",
7 w+ Z$ m3 H/ j2 p# q .default_trigger = "default-on",
8 I9 B" ?+ w( k },0 Q; k) d/ T0 A& w m2 _* g
{: ]2 ~- \9 b8 o5 E3 k+ u6 N
.active_low = 0,' R- O, F( `, A( {4 O) M, j' |
.gpio = DA850_USER_LED1,
1 j9 g0 | Q2 s+ z( Y# L8 O .name = "user_led1",
+ V# a+ n) Q! c: ^- {- ? } .default_trigger = "default-on",
: B' c; ?( a& a- m },
3 s' ?/ \+ Z$ @7 U n) r9 h7 ]5 Z {; A& I; c5 w4 m
.active_low = 0,
% r& O! n! I# j2 o .gpio = DA850_USER_LED2,
9 G2 {8 l4 a \/ @" w! M .name = "user_led2",
* U" N1 N( K1 ^ [* L8 P .default_trigger = "default-on",) ?5 r' t9 J _( j0 z/ B
},
0 g5 A0 Q& W5 U! y7 p# F {5 }& |) A2 F/ u, A0 h4 F
.active_low = 0,! L+ A' E2 A# s& I- O( o7 I J" {: Z
.gpio = DA850_USER_LED3,
/ z. T# m* O* |* o. O% `) _ .name = "user_led3",
! Z6 m) p! b- L .default_trigger = "default-on",
9 s* u; n9 U7 y: M5 g },3 l& h5 B. u8 G3 v1 F; a
};2 S7 f: Z, p! \9 }
2 U" h, _7 d7 s5 g& V% Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! i6 q. q( H& T8 Z" A! e: g v
.leds = da850_evm_tl_leds,, _. l6 [5 a" b' y# j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 J8 x' P+ I/ Z2 X) Z2 p
};
# F! Y: T# H' t% Q$ y, b: |# T
" G/ s! F6 f0 F5 G3 vstatic void led_dev_release(struct device *dev)0 A& F/ c+ l% z2 d9 [( k& l; h8 W
{
u, S( S+ _' R$ B};
O( O: V4 c0 e* }. V( p% r: }. W9 t6 E. l( X# b; t: {7 `
static struct platform_device da850_evm_tl_leds_device = {, M$ R. m! a6 v+ G3 z, ~/ F
.name = "leds-gpio",; U) R$ Z/ P- y
.id = 1,
7 _/ @2 F5 H: s1 y4 E .dev = {
# k/ a7 ?% O) [/ D+ M .platform_data = &da850_evm_tl_leds_pdata,0 k: Z5 t `/ U% k- N* h, p ]
.release = led_dev_release,
+ E/ J! e/ d ~; N7 b }8 D- ~/ U- X: o6 L
};
! X: t- o8 @* M' g: z* @2 W% b7 F3 t9 Q: T3 S$ A
static int __init led_platform_init(void)
; T7 b g# r! ^! S$ F( |{
* w4 z- A/ h/ q) ] int ret;
, H& l$ d4 m% E8 N ]& _ D4 ]#if 0* v5 J- x6 o& V" U( a
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& [4 t8 h8 _! ~! C4 T& ^( N4 B if (ret)' ~- o. G! b. j% V( y5 A! g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; ~$ J2 S! ~' X+ \- I3 v
"%d\n", ret);! W8 s( Q& B1 ?6 z) l! n
#endif
) g, B' ~+ g w! b( p ret = platform_device_register(&da850_evm_tl_leds_device);
0 D% S1 I, n5 F Q; d- ^ if (ret)" _: U- C2 {, M" e1 f9 n8 O" K7 u
pr_warning("Could not register som GPIO expander LEDS");+ p* @3 R7 w# U# T# B8 N) b
else
0 G7 i' @ V. @. b. P, O$ V$ K: g2 T printk(KERN_INFO "LED register sucessful!\n");6 h, A, X) g9 ~+ ~# q
: m! S) b- h+ h
return ret;0 d n" i: G& T8 {7 ~: B
}
7 P' ?6 d0 d$ v1 C9 Q0 K
2 [ `" Z5 K- M7 f. Cstatic void __exit led_platform_exit(void)
7 |3 J3 B+ T# L, Y{
P' {2 v% M4 n& G platform_device_unregister(&da850_evm_tl_leds_device);. a. f6 o8 G( G6 C- S0 I
3 W3 L1 C; K0 Y3 o/ S. M' M
printk(KERN_INFO "LED unregister!\n");
# y6 i4 R; A; f1 e' B/ d9 w9 D6 x}1 E2 W e) ?- ~& a) ]+ N" G- S
* r- O% a/ r; u7 V5 D$ R8 Wmodule_init(led_platform_init);
% v1 ?+ v; G8 F' B( Nmodule_exit(led_platform_exit);7 O" f. K. v- @: ]" y9 F
. ^ }) e0 Y, U+ k. p" t8 }MODULE_DESCRIPTION("Led platform driver");( M5 @" y) T, Q2 L/ W% L% a
MODULE_AUTHOR("Tronlong");
) K6 U4 G9 M% y% a% I; OMODULE_LICENSE("GPL");" B ~- X7 b, X) V# J) g
5 E; f: X: v6 A0 L. d/ K; d
|
|