|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 f9 [9 A( }7 A I#include <linux/init.h>' z6 A1 ]* I. N6 R
#include <linux/module.h>
W* q, P5 A4 \) y8 s) J7 v#include <linux/kernel.h>3 a+ O: j: f: O6 u
#include <linux/types.h>- ~4 t L4 |9 N; G6 r
#include <linux/gpio.h>
* @$ G$ c8 U* l' t& l. ]0 |0 E4 n#include <linux/leds.h>
! x5 a. o4 r: E$ v2 N. H( v7 Z/ m#include <linux/platform_device.h>8 ?, @# z9 u; o! e
( R2 z6 ?7 X7 M# X# s
#include <asm/mach-types.h>
# h' j. J9 K- o1 e1 P- T1 m1 i#include <asm/mach/arch.h>- ], [) P; j7 d3 _
#include <mach/da8xx.h>
( R' L r8 B* d$ E* \#include <mach/mux.h>
( M! y8 h% z- a& m, {1 x2 M! |2 y6 }7 @8 F
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 y* M$ x7 t# l0 l9 ?& n$ i
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 [4 B( z5 e6 A+ ^8 v3 E3 W
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' b- X; |+ ^% K$ g3 c; r* D+ C6 K% d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# i w8 J/ ^- S4 e6 `3 V
' N7 w4 Q, k. }3 L, r# h/* assign the tl som board LED-GPIOs*/
8 |4 L2 d! k4 T4 ostatic const short da850_evm_tl_user_led_pins[] = {
2 a& {& d7 x2 M0 |, Q K /* These pins are definition at <mach/mux.h> file */
( |/ `; N) b9 O$ V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, ]) o# C0 S- L8 W* V$ j# R4 k Q
-1) u1 i0 `4 x2 m$ V8 _5 n* `4 m
};
. B" I6 k2 z8 a
% U0 `$ N( }' D( Rstatic struct gpio_led da850_evm_tl_leds[] = {1 R/ J& p6 R7 H+ _. `
{' a' U O. v& ]0 y! D. q
.active_low = 0,
; T" D6 z. z! _% c: M% i .gpio = DA850_USER_LED0,5 t* Q3 m" c& K' `# U2 x- D4 `. A
.name = "user_led0",
% U+ ^& `* V: D .default_trigger = "default-on",
* J& u: Z, F- u* V" s+ W: Z },! e$ T! l$ q5 W' D' G& r5 `! _
{
3 A( D$ x1 @8 W9 ~: O7 P* G& C0 i .active_low = 0,' z: A, m* _1 f$ o+ s
.gpio = DA850_USER_LED1,
, U4 T: i- i5 I0 X( b! j! L# X .name = "user_led1",
8 C' a) ~8 [1 D4 n .default_trigger = "default-on", N2 q& e( |. g8 T! g$ P! J
},( X+ Q6 H; S2 |' Z2 Q
{
! z! H) x0 {; v0 Z* p .active_low = 0,( q$ \# l+ q4 ~+ {4 u* w
.gpio = DA850_USER_LED2,
( e; J: s: P. c( X7 }! @* x .name = "user_led2",
* u6 w% s+ U1 B5 P5 r/ k0 M6 I .default_trigger = "default-on",
8 x) B: `! ^8 A7 \( T" p/ M },
# \3 U1 y& N: o* e {
' z. p: `! i5 y- G .active_low = 0,3 Q7 @0 w% D2 D/ y
.gpio = DA850_USER_LED3,( C/ T* ]- O/ K4 y2 U5 }
.name = "user_led3",6 C3 }0 @; x0 D8 m( [! d( i
.default_trigger = "default-on",
+ r" A6 y7 f0 ^8 c2 t! D# ~8 C },
/ D' o' u8 {! F/ A7 |};
5 g/ u' i' X$ X+ v9 V
( P. C6 n) @5 i1 Pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { E4 {. k0 }/ W5 z& _# g# J
.leds = da850_evm_tl_leds,' s$ ]7 D5 N& H8 m% @1 M- y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: A6 c8 l( l+ G+ H};9 V( `: [1 \' { T
) v% n: \0 @9 o& ^6 fstatic void led_dev_release(struct device *dev)* a# b8 Z" V* y
{' l$ R' ?3 \, B; M" s0 y" \
};/ m! i+ ^& b# ?/ y9 a6 }3 H/ v: ?- m
8 M% W/ j' m# v" Y4 A8 rstatic struct platform_device da850_evm_tl_leds_device = {
6 h# ?* c3 X2 ]! {+ E .name = "leds-gpio",: S( z% H: E1 B9 X( v8 J
.id = 1,
+ ^# t9 ?! z9 }4 f .dev = {2 x, m" Q7 f- K( T% y; F) [
.platform_data = &da850_evm_tl_leds_pdata,! S0 U% l1 x3 b; o; X' F& f
.release = led_dev_release,
1 v* ^+ ?5 x( Q6 z! w( H3 n }
' F* D& [. _ @2 J) M& q/ R};- `' [5 J0 @$ R% | e$ v7 k, g9 i
5 u* L( }' G" Mstatic int __init led_platform_init(void)9 I5 r4 n1 i9 [. U
{
" |% R% h) T% Q- Y; {. w int ret;
3 l7 `. Y0 H [( c- n7 _#if 0# r4 \9 c, i1 N- _( v( z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
t7 P& w6 a* X. L1 H if (ret)
* g3 f; u$ `/ F- Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 H. ^* }1 Y( q" m. H; k
"%d\n", ret);
G- x' ?' Y6 J2 [# \$ s#endif' [+ Z4 Q; _$ F& Z+ {2 {9 ~7 |% p
ret = platform_device_register(&da850_evm_tl_leds_device);
1 X% V* m& s# V- B8 u9 @- d if (ret)
6 E9 A) d# C) b% F pr_warning("Could not register som GPIO expander LEDS");
2 R4 r( {5 a* ~! \- e else
$ z, `; e9 n! j* V! d' D printk(KERN_INFO "LED register sucessful!\n");# b+ c% Q! K2 U s# p
" }& i. c, C+ N4 P; @4 O return ret;
) N# g! l' l7 h! T5 E3 Z}
- J5 \ } H' Q8 j2 C$ k/ h/ \9 R- D; ]7 d' t7 V
static void __exit led_platform_exit(void)
) t( I9 T1 e5 s+ _6 |$ w/ R{+ ]0 E2 S& j& {" d6 w n9 Y
platform_device_unregister(&da850_evm_tl_leds_device);4 x/ ?' a! Z+ r1 o Q4 _
( G7 y+ S# v m v* r printk(KERN_INFO "LED unregister!\n");
& q/ F& w4 s' D8 R}
6 J2 `% r" H, J( [2 m" x0 W" B* j. J) }' c5 d( O
module_init(led_platform_init);, h- P3 R& s5 z- w0 Q
module_exit(led_platform_exit);
7 n% R; Q4 W; E8 r
7 W: h+ \) H# Y% i3 t @MODULE_DESCRIPTION("Led platform driver");
1 |- d/ N0 ]: a9 h7 U2 v5 e5 ^MODULE_AUTHOR("Tronlong");" E: c$ b3 z6 T# o# g* `
MODULE_LICENSE("GPL");
: A' N; Q3 Z) ~. A1 i: g3 [ p6 \+ _
|
|