|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 M/ @/ u! T6 ]6 L3 c
#include <linux/init.h>! A8 X/ b& R9 L, \1 j
#include <linux/module.h>9 a! S+ B5 O: H% T+ Q9 H
#include <linux/kernel.h>
% m5 K/ c; t% t& r/ I* |; p) ]#include <linux/types.h>$ z/ j# C* w( H( o
#include <linux/gpio.h>( V! k' }2 O5 l8 d$ S
#include <linux/leds.h>
; M6 {; H2 h6 \3 g#include <linux/platform_device.h>3 s3 ~( S# G7 [: Z. y6 v' b
t8 `( J5 g- E/ I# O4 S( u
#include <asm/mach-types.h> ?$ t n' L3 c* y/ t, U
#include <asm/mach/arch.h>% r* s' e9 m( w7 r% b
#include <mach/da8xx.h>; ]- v b% F( a& X9 |
#include <mach/mux.h>
: M% f l2 v* e& P4 h4 _5 n5 m! \# v. E1 ?8 \
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ ~& Z9 R6 T4 [# Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* |2 B) T) A; A+ ^& e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 X5 d3 r( `6 m6 }- |#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. Y! l w" c& J" W( v+ }
" V& T) S3 q7 I8 X; _$ [6 H \6 r/* assign the tl som board LED-GPIOs*/ O- [$ ?7 U! l8 P1 \1 [: p$ Z
static const short da850_evm_tl_user_led_pins[] = {' \, n: h9 A. S: p
/* These pins are definition at <mach/mux.h> file */
( e8 e l# _5 ?, @+ o. u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. \* f! A* K2 | ?1 i& h -1
1 L% j$ g; r0 ?. a};( c a% m6 t" G7 x% S
2 w! l+ h! ~4 V8 e$ v7 _: u* J% Qstatic struct gpio_led da850_evm_tl_leds[] = {- f; j) m: {/ _# e3 E$ O
{2 Z# w9 r3 R% w2 _& l& @; O
.active_low = 0,( c1 `1 S5 `4 L9 B- D! ^
.gpio = DA850_USER_LED0,
: N1 Z' a, P$ h4 \ .name = "user_led0",* D' C" v0 v( H* C; Y
.default_trigger = "default-on",
5 Z3 e8 o x+ p },
/ H0 T/ k/ x9 D( C3 T; c {
, a0 q2 G2 T, R8 } .active_low = 0,
2 @# y7 [& l4 w5 [- E$ E5 S& d$ B .gpio = DA850_USER_LED1,* I9 ], r- F0 F1 l& K* R
.name = "user_led1",+ N+ ^# H: Y- t1 ?! a
.default_trigger = "default-on",, L6 f0 p/ ^$ E5 g5 N$ N
},
- @7 ]+ l( I, J2 Z. } {# ^/ l/ r0 [( W R, [) P. }+ ]9 ~ J
.active_low = 0,8 y) W5 y7 \# i' e1 ^; f; ]
.gpio = DA850_USER_LED2,
; ]/ ?' i. w' v$ O: F6 T# o% i .name = "user_led2",9 o" ?8 e# E$ @. P0 ~
.default_trigger = "default-on",# _7 C, o& W6 i) ^
},
( t2 I# _" A$ C/ E( W/ \5 A {
& o5 b# P. F9 V7 L$ B0 t* c; p .active_low = 0,0 _8 v2 w! y" I6 f
.gpio = DA850_USER_LED3,
8 e/ a' k2 y j, P a+ P& p* ]' W .name = "user_led3",
$ ?' ~2 V: A6 Z' w- U1 R .default_trigger = "default-on",6 O6 Z3 z' ^( k" x9 x2 j
},
1 _! h8 P# j/ U# X2 F' a7 s$ O};
$ U- v, U1 I$ W& r4 `6 |# O
9 ^' {( X+ t7 vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 }* Z) T1 M3 n6 n4 c! r/ J$ R- t
.leds = da850_evm_tl_leds,
" B' ]- r! K p .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( o' Q4 K8 H2 u! x};+ {, i( R+ a/ m
9 Z6 w6 e# ]9 w( ]1 C
static void led_dev_release(struct device *dev)* C9 y3 e4 O5 B1 W9 q
{+ W; `, g7 ^- Q) F R' @
};
- y9 C! Q5 k5 Z) U% J3 e0 s, z1 o& q
static struct platform_device da850_evm_tl_leds_device = {
; ~2 T4 b5 N: {* ^4 m& I" o! R .name = "leds-gpio",
1 h: z; V0 `2 B, p .id = 1,% ?# X( D5 u1 f% k' D+ e9 I& l7 ~
.dev = {, P; z& Y; V- {; R' H
.platform_data = &da850_evm_tl_leds_pdata,
# J) H; r6 H( T, | .release = led_dev_release,& J' t9 ?$ X+ r7 i
}
( W6 Y7 D7 [4 l% K};" w9 K n _( K6 @- B
# }1 E1 ?+ A! M+ g
static int __init led_platform_init(void)% B: k- J- F5 @( B+ W- k
{
2 e* J) M2 j; \: Z int ret;
" w- }5 S% G. P+ p" n0 ^4 T6 S- S5 e#if 0
; O: J2 ?9 C% h5 e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ @1 r) A- V/ W1 N
if (ret)/ i* g6 I! O1 C6 {1 h# u; m2 R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( a7 s8 P+ Y+ y/ R2 u1 @
"%d\n", ret);, u# ~+ [% |" U9 L* d; k6 e" k
#endif t) I2 p+ x4 l3 q: h# h# F
ret = platform_device_register(&da850_evm_tl_leds_device);
/ e$ l. Y4 D0 h1 Y8 [* j+ f5 D if (ret)& |1 n6 @; `: l* L6 r
pr_warning("Could not register som GPIO expander LEDS");6 A! z8 A- ~, {) ]( y
else8 ^/ u+ Y% ?) A2 U2 R; X
printk(KERN_INFO "LED register sucessful!\n");. B+ j7 u ]6 l; g
4 Z7 q ]& f& t( o6 U6 g
return ret;. w& g+ k( E; f! e9 a+ Y( N+ @
}- N2 R9 |. i. y2 @
4 ~ h+ W' N$ y3 a( ?
static void __exit led_platform_exit(void)4 s% I( A+ u" S( {' E
{
3 ^# K# `, r1 N platform_device_unregister(&da850_evm_tl_leds_device);
$ A% X( y; z4 Y" [5 F6 s3 Y9 s3 U" h- e) K3 c, Z4 R9 |
printk(KERN_INFO "LED unregister!\n");
: }- J! x4 q; u! a6 N' J}
" g3 v) p& f# i5 R( Q
- v7 w. I6 s/ O1 p% n3 tmodule_init(led_platform_init);7 x w% I9 {% d3 [. [+ V% l( {, ^
module_exit(led_platform_exit);4 B3 g- G C# Y
6 P: V+ u( U4 T; XMODULE_DESCRIPTION("Led platform driver");
7 J! u8 ~5 X4 r% [0 o7 \9 l7 fMODULE_AUTHOR("Tronlong");
& s5 n# U0 x6 ~, hMODULE_LICENSE("GPL");
5 v8 M. m# N* K9 V' i9 O
3 E! n. e$ k' Q4 |1 g0 } |
|