|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& [/ k: j1 r2 F E0 U
#include <linux/init.h>
- w6 O! k7 {* Y#include <linux/module.h>0 `% V6 t: ` r4 ^* M4 u% ]
#include <linux/kernel.h>
7 \2 ]$ b. M4 x# E" d6 Q#include <linux/types.h># x( q2 B7 n5 a* H4 P
#include <linux/gpio.h>% c" O3 G+ C: I: C* Z1 ]
#include <linux/leds.h>
' Z W( Q" I: ?( Y) w+ n#include <linux/platform_device.h>
. |) o9 v2 F. O3 M s* N( f$ ?0 Y
#include <asm/mach-types.h>
: q0 K# z9 S+ Y% L) f#include <asm/mach/arch.h>5 [' y& b6 L# E( c4 I' C$ Q
#include <mach/da8xx.h>
. ]! \+ q4 J _! }, x5 d0 M5 y9 N#include <mach/mux.h>$ E Q G# D& b$ b' u
. H+ B' E& w* j! L# g& j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 \- e9 x* y! I1 O. i- R5 {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) L9 ^* j- g+ e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& e4 Q& f8 ]6 O6 I' Y6 x#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 z, ^$ d4 Y3 i3 Y' \* }
) _& f; B3 P2 d8 _) i/* assign the tl som board LED-GPIOs*/
4 q1 e" J1 G. w$ L: k* mstatic const short da850_evm_tl_user_led_pins[] = {6 U: `9 H6 v* r) t
/* These pins are definition at <mach/mux.h> file */! a6 l' @1 g: H$ S- N% _" T3 V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 T9 n2 x( ~: p# ?9 A: D -1% ^1 t3 b$ x7 C. h6 X- k
};7 w; w% k: B4 |/ N
, ?% x- j; B3 rstatic struct gpio_led da850_evm_tl_leds[] = {
$ |; }: E* b" j2 z* a* U {% K4 S/ O1 D$ J1 {" Z) Y5 Y
.active_low = 0,
& `9 ^. r: ~1 f .gpio = DA850_USER_LED0,
1 B$ V x" X4 f y/ J5 v& T0 A .name = "user_led0",
8 Z2 s1 F$ ?' T .default_trigger = "default-on",1 P9 r2 L3 Q4 C, B; R4 ~
},
: U- A( V& |4 o+ {4 H {: h7 G, b& r6 G5 w6 n; s {
.active_low = 0,
" S- s0 O( V0 L. q .gpio = DA850_USER_LED1,; l2 X' {/ E) }$ K5 V9 X3 K7 |
.name = "user_led1",
! @. x; r* Y; S1 J* F .default_trigger = "default-on",- h! m9 o( m" m5 v
},
. Z( J- k$ S* d( E' d9 t6 ? {% d8 M- V5 B7 ~: [; m9 ]& ^$ u$ E
.active_low = 0,
, v8 Q0 v9 g/ j .gpio = DA850_USER_LED2,8 Z$ u6 \5 [! g
.name = "user_led2",6 f* t7 f: h6 K6 A* M+ l+ y
.default_trigger = "default-on",4 s/ T# X: e8 H7 h
}," p- r) Q* N% ]! F
{
" x! T& C; z9 b0 i6 M N- @- b .active_low = 0,
5 @, h( }, G. ~ .gpio = DA850_USER_LED3,- o4 _ S- l; j
.name = "user_led3",5 {% r% a- e% N; M
.default_trigger = "default-on",8 s7 o+ S) J8 b* ^( i
},
' m: [( g/ B. f1 S& o& \};
( E+ h k" H7 e' F0 m
N1 o, Q; R2 Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- H0 ~/ Y# T8 h/ \. s: ~2 J
.leds = da850_evm_tl_leds,: w8 R, r7 I) g! U( z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- Q7 Q) O" K8 O) g};! G0 d/ Z: `& X' P" v
/ f) |: |% T8 W( I/ r
static void led_dev_release(struct device *dev)! I( ^ A8 m+ `2 A3 {" m1 f
{
! W! @2 g; l7 B/ w};
! ]% u+ k" Z! r# G1 ^
* k4 t: r3 F6 d8 s1 e3 X% Xstatic struct platform_device da850_evm_tl_leds_device = {: j6 q, k# O! c- _7 ^& r+ W
.name = "leds-gpio",& K- u* U* p. _0 V3 `6 x
.id = 1,0 `! y( o/ H# G2 z+ r
.dev = {
; ~- C# o! _6 ] .platform_data = &da850_evm_tl_leds_pdata,) ^; e7 F( |9 t2 [/ i
.release = led_dev_release,
" v5 i- y5 r0 Q* s$ ^ }
- s3 ^0 K/ P' `3 @6 p: U, l1 P};
. K5 x G2 Z. o6 T) B
7 y1 T' H* A* b; A+ c, }" y# |% Fstatic int __init led_platform_init(void)) z' z; {2 T; U' [4 H
{
/ x- W5 S: P& q5 }+ d( c6 m int ret;
0 B3 q% j1 C6 K+ ?2 ^#if 07 j. g1 ~& P3 Z& x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 q1 J9 {; a' n8 _( b
if (ret)
7 x$ {% o6 S& H8 x: L$ F pr_warning("da850_evm_tl_leds_init : User LED mux failed :". G# c: J8 e& I% `- b+ Q7 u8 x7 T
"%d\n", ret);1 I( {2 x j3 Y% \0 `+ z& I, `
#endif
/ t( k: k/ d6 E$ F% i* F2 ^) R ret = platform_device_register(&da850_evm_tl_leds_device);
! f2 ^: _) w r8 C! @1 l% t* @% V if (ret)2 C4 A3 N M. S# p: X
pr_warning("Could not register som GPIO expander LEDS");
) `$ e2 f4 Q6 z. A8 m& {9 k0 s else
2 u$ Z5 B1 B* S9 @5 k printk(KERN_INFO "LED register sucessful!\n");
9 b- Y; \: h! i/ l, R+ F& M; d6 p1 s- [( E
return ret;
, x, U; S. [3 t7 F0 `1 Q( O/ v" ?/ e}2 h) P$ H% }0 x4 d/ k
2 R6 @' F/ e) h9 N i. cstatic void __exit led_platform_exit(void)) c: d& }: E& `3 q- @3 c
{
8 Z4 V4 v1 p7 X }* r platform_device_unregister(&da850_evm_tl_leds_device);8 q/ n$ K K% I7 B' K7 ~
6 K1 X- R0 I+ ^$ U8 ~! r printk(KERN_INFO "LED unregister!\n");
( A/ d8 m8 N' K}* D* q) n) V1 n: s0 G# [
. {2 \1 Y# V8 c$ a5 q4 _
module_init(led_platform_init);: B8 m. M4 j7 A( O
module_exit(led_platform_exit);
' n& X. @: }$ V1 r
, X, r* G) L6 D" {. UMODULE_DESCRIPTION("Led platform driver");
% o* q2 h! E# D" A b, Z( G4 t( E& NMODULE_AUTHOR("Tronlong");
+ G' C& @! ~9 T5 ?! ]( }% \0 R* gMODULE_LICENSE("GPL");4 i) Z3 G1 D# k
( B& \' {5 Q% T9 F+ ?; [ |
|