|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( I6 p v. H' I4 k% k9 Z
#include <linux/init.h>
/ j2 i1 k4 y! m& L9 e#include <linux/module.h>
; Z; E( @5 X1 c. x0 [* }#include <linux/kernel.h>
+ j5 b. f# t* d% s3 a0 i#include <linux/types.h>
C/ h" s4 _" Q* r7 @' q5 {#include <linux/gpio.h>& t; a( K, Y, d0 u( e2 h
#include <linux/leds.h>
" ^( L7 b, s$ Q#include <linux/platform_device.h>
" h% a: m' Q/ ~! a* W' O: T& {
9 h# ]) D+ A; ^#include <asm/mach-types.h>
8 U( ], U" k0 C! h r#include <asm/mach/arch.h>0 w$ J9 O, F% [5 Y2 J
#include <mach/da8xx.h>% t) z& \* _/ g( I% J/ w
#include <mach/mux.h>
) g/ W5 L* W( H! l3 D
" r% q# R3 h5 ^9 h7 _' p3 T4 k; ]#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ \# e5 q% @/ ^: V J3 a( c7 c#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 R7 ]0 z- u* E& g) b5 C
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ r: Y D' c2 o5 I6 B+ ^3 K
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% }* k, n9 W8 V
+ q9 x9 P0 p$ t. m7 V
/* assign the tl som board LED-GPIOs*/
: G/ j5 R! P8 p( jstatic const short da850_evm_tl_user_led_pins[] = {
$ i, H* J- v' M; o /* These pins are definition at <mach/mux.h> file */) o8 M: \; y4 I# H! V0 F
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ f) \% ?1 U- k8 \7 t7 b& L -1
3 `% y. l( V- Z- P% Y/ O9 m; G};8 U; x& R, u9 V3 |4 U8 Z' W
3 @3 t" X( `0 _: Q0 V2 X: I: sstatic struct gpio_led da850_evm_tl_leds[] = {
( [; r5 z/ H7 O$ N& Q {* m+ I5 ]. \. S( K) T/ N
.active_low = 0,5 Z& `% k5 Z8 r
.gpio = DA850_USER_LED0,
! e" K C' l. p1 [2 `+ G .name = "user_led0",
; y% } ?# M0 H$ a2 y .default_trigger = "default-on",
! `% s1 ?4 T' M2 K# ] },- H+ s! g- `" v8 L, c) a
{ c' l, k, Q7 [ _0 A
.active_low = 0,2 X! [5 b$ H" Y! a R, l+ S
.gpio = DA850_USER_LED1,
, H) I+ F. u1 r7 v. u( N .name = "user_led1",
# L. ~* n+ h$ L! ^ .default_trigger = "default-on",
( a, F- C! h7 I& ~/ Q" B `3 J+ h },
/ `; @: V' r3 h {0 C; O4 o/ v9 b/ @# t
.active_low = 0,, c( [8 x5 Y% V' a: `6 x
.gpio = DA850_USER_LED2,7 Y4 O* q7 n. u% ?! F1 f
.name = "user_led2",5 O+ E, h9 F5 G8 Z5 f& Q
.default_trigger = "default-on",
; L3 D1 t5 @9 u0 U },
# Q4 [( z4 P e8 F* b/ o2 Z) c8 k {) d& }0 {: ~& D E
.active_low = 0,
8 D4 X% n" t$ D9 S; p8 u$ P! d .gpio = DA850_USER_LED3,
# T+ [8 \6 M& S, k+ ~+ ?2 b* w9 h .name = "user_led3",
5 h! {) y3 t+ p" y9 r( }0 n .default_trigger = "default-on",+ o3 @" l: m8 X" X4 B [
},
+ O4 \1 l+ T( x; c};4 [5 z9 J6 ^! W& ]+ C
% E8 K& ^- x3 u, P" d* `) v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" d; @& O+ D- V .leds = da850_evm_tl_leds,
+ t) f- X; ^. A1 Q' W( { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' i6 J0 P4 K# m3 o};
+ y# X( M- q) T$ o! n
, s7 u5 o9 f# L) C0 Lstatic void led_dev_release(struct device *dev)* H, g: z6 s5 d. w2 |4 u
{
9 H3 [0 {- X6 q# b `; p3 p7 Y};/ Y/ I6 |2 H" K K- b* M
, g+ W8 r0 L1 Z7 f. u6 A9 C6 v( a
static struct platform_device da850_evm_tl_leds_device = {9 W/ n m% |1 Z+ y# Q
.name = "leds-gpio",
8 Y0 F5 X1 ` y0 X/ s/ F .id = 1,
& ~3 P7 R* [& d" G! L) m& Y" ? .dev = {
* S! {" j3 k; A% b+ ] .platform_data = &da850_evm_tl_leds_pdata,: R, G& R2 q, f3 R4 ^
.release = led_dev_release,# N7 Y9 f4 G: c' w& q. ?
}
* m2 Y0 T( A; F, B3 Q2 J};
) [( p; e' ^4 _- P+ R/ _ o) J
7 J& \0 u8 d% D0 o% w( b# s d9 H& Ostatic int __init led_platform_init(void)4 f1 W1 V0 F) A' M' e
{2 K/ f4 V a8 s/ k/ w/ R6 n
int ret;
2 F, _3 a9 f/ d( x5 k; W+ O#if 0, X; X" E: r% l$ {* F6 o' |& `( l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ j& U* ~* G$ K$ a: [2 c' n7 t if (ret)
0 n+ n) C3 K! j6 G3 h pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, M) }+ O4 \/ B$ T& p. [( B) u& D "%d\n", ret);
! Y( a2 X2 T+ U; k#endif: [+ s6 U9 b+ m
ret = platform_device_register(&da850_evm_tl_leds_device);# c1 z7 p) K9 k( i% e) f% n" X
if (ret)6 b9 D" ?$ E2 e/ o+ f
pr_warning("Could not register som GPIO expander LEDS");+ a$ K% k% ~ u9 c$ w5 J+ n( N3 v
else% r3 X* V& _* W$ D6 k1 z: ^6 ^
printk(KERN_INFO "LED register sucessful!\n");4 f2 [* E& T$ `" K; F$ y
6 O/ Q/ T3 b G. k% S& Q z
return ret;- R* i& W# x/ ~; s+ t
}
1 d2 c* D: R$ g9 m( v4 |
6 z( K) I$ _4 @" {# tstatic void __exit led_platform_exit(void)$ p. }% z7 q" [- f8 N) ~1 r
{
& S+ v" `# f0 G; z platform_device_unregister(&da850_evm_tl_leds_device);: A5 y5 n3 B3 h3 F( _
8 }; b# i, k9 l% Y$ { K* x6 \& e printk(KERN_INFO "LED unregister!\n");; r2 h2 r/ z$ [: s/ m4 ]2 q# x
}
3 a, G2 C \5 ]8 w/ E
9 q9 t" Z( h* c q$ |# Nmodule_init(led_platform_init);5 G3 k# [9 k) e, n' B- k$ H6 h
module_exit(led_platform_exit);
2 V0 C2 M+ U8 Z5 I: h
$ J4 C2 p g' s* n: \1 EMODULE_DESCRIPTION("Led platform driver");
2 {: t0 [: a: F1 ]. eMODULE_AUTHOR("Tronlong");
! R) Q2 d- m' ^% \MODULE_LICENSE("GPL");% R4 J) q( x) q' d- M
, O; R8 B! _, Q8 c& F8 J
|
|