|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 f ^; U% G/ P/ y! t- g' P
#include <linux/init.h>
* X) l+ j5 K9 ^, l8 u! R+ O6 H- Q#include <linux/module.h>% V) w4 W6 [& B
#include <linux/kernel.h>- \, w/ s% p/ C2 D' [; m
#include <linux/types.h>( b1 [2 t1 |5 b
#include <linux/gpio.h>
+ \* S2 K; O, O3 T. F3 W7 t5 |#include <linux/leds.h>1 i' ^9 u1 F: q- j1 B$ c9 D$ d
#include <linux/platform_device.h>
8 b/ X6 L$ T% k- w8 v- D
) v3 H t ?: t8 M9 r$ @0 A0 s#include <asm/mach-types.h>
) H3 |, q% a7 S1 W V( x$ t#include <asm/mach/arch.h>% `. Y% z8 w/ {# b* @" k7 S" J: R
#include <mach/da8xx.h>
. O3 W( q7 ?1 N* z( a#include <mach/mux.h>
, _( t# n* o, B) t
u4 L9 ^& T+ ~9 p& a- L#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 b! q: |! M! P$ @' `: t; a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 Q- l$ L; R) \- g7 X/ }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 L2 l' l" H$ R: \#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 }' ?' ?' L% [; s6 i0 ~/ `" R" h8 R" N1 b4 l% G
/* assign the tl som board LED-GPIOs*/
6 D6 |- W+ G' Z2 ]static const short da850_evm_tl_user_led_pins[] = {5 [2 P$ y- t2 l3 [& K3 N5 F
/* These pins are definition at <mach/mux.h> file */
& ]9 p0 K8 H7 q. i DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* n$ A! M1 G# c* o6 D' `1 `; G -18 p; d+ i q2 T' w! E
};2 o; X0 I( T0 V) D* R6 x
- L5 B8 c/ c: o: h8 Z- ~
static struct gpio_led da850_evm_tl_leds[] = {. e+ `# P% [+ P" P, c
{
# L" b/ p1 t$ u# V' V .active_low = 0,
; `3 ^8 C. L: J$ m# t, S) @ .gpio = DA850_USER_LED0,
8 \) L! r; G8 \+ n8 {: u, P .name = "user_led0",1 z8 k7 k/ p/ y2 [. }
.default_trigger = "default-on",
/ e, }* q$ f, O$ s* l6 h },6 I1 M+ g0 t7 A
{
; A/ j7 M4 ~$ H .active_low = 0,4 d) |2 j) P1 |5 D- x3 |, W
.gpio = DA850_USER_LED1,- ^1 q9 c& a: T# P5 c% y
.name = "user_led1",
5 |/ s& ?. w5 P; m- _6 A .default_trigger = "default-on",, M: H# B. P9 o( S
},
$ Y \" M! O% f; ^. H) D5 i5 J, W* j {3 ?0 P; e* t& n' Q8 A- l) t
.active_low = 0,
% z' l& Z; `4 K/ h .gpio = DA850_USER_LED2,2 l' Y6 z2 V' B5 y5 l
.name = "user_led2",/ q. [. N7 U! i! t0 Z8 q, e
.default_trigger = "default-on",1 I( ~ m) c2 h' A4 G' r5 O
},
+ n2 c5 N# [: T6 S7 q {; h8 i. [/ X1 k4 X
.active_low = 0,
4 x" Y- j! S2 M# u6 s( R/ K .gpio = DA850_USER_LED3,5 O4 `3 Q/ d1 ]! I6 L
.name = "user_led3",6 p4 `. N# [, g6 M8 K1 n$ V: E' _ j
.default_trigger = "default-on",9 \, F9 F7 k g
},
8 h2 T& L: f' ?0 @& }4 A};7 M3 T) z$ ]) Z$ }9 I6 E" C
. e0 c+ E/ S) k' \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( G$ Z6 E( r7 r' V }. n8 W
.leds = da850_evm_tl_leds,8 k! H. J. N9 M6 n! V& D- V0 ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),( O* n* _0 z; i! z4 {& N; u
};
5 b2 P7 O) y5 i5 K
C; x1 K' I5 vstatic void led_dev_release(struct device *dev)9 n& {, |6 f5 i# H! C
{
: l# M2 y8 b; C3 L# C8 C6 ]};5 x% l t! m, D
% }% e& h( p' F/ k2 O2 p3 ]4 H5 h7 vstatic struct platform_device da850_evm_tl_leds_device = {' h% A" Y, l# d+ Y9 l; Z' ]7 K
.name = "leds-gpio",' P' A2 T) R5 M! L; b: g
.id = 1," A @1 M7 {% V+ Q- N1 @
.dev = {1 D% }4 U4 g* c' z$ g! l0 x' l6 ?
.platform_data = &da850_evm_tl_leds_pdata,
/ i: H& L7 M+ p .release = led_dev_release,
+ n9 ~* f& T U2 d }
) X9 S* @1 L. P4 F" h};( ]) u: v& _+ e* j4 S
# G& B6 ]8 q+ y7 _: o w; V1 t
static int __init led_platform_init(void)9 i6 a6 P% f6 b) D' r
{
+ l+ d1 A9 J" Y& j, ?; S; B int ret;, J4 l8 Y/ N2 U3 f
#if 0, G& v( b3 b* @
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 h. N: k* i3 C8 }! |9 M if (ret)& c- v+ u3 q8 h4 w* ~1 ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 q; A% U; s7 S6 Y5 L, p+ C
"%d\n", ret);) V* x% _4 Z& x( f+ `" }3 `6 J
#endif* o% ^ {4 R: V4 ?- u$ c
ret = platform_device_register(&da850_evm_tl_leds_device);
. b, _7 ~( p4 n) d# w' J if (ret)* P8 Y% j3 g9 Z& a
pr_warning("Could not register som GPIO expander LEDS");; p' t6 A( ?0 ?9 F: p
else
5 X! L* v$ S7 I5 Z% ~2 @ printk(KERN_INFO "LED register sucessful!\n");9 `! w) b% p5 z$ Y1 e! n4 r
, p3 F; p; ~# i( c. G4 i return ret;& W; Q- t9 x% w& F- o" i; x: X
}
* z- _" \# C* i
& Z3 S" R( W- Istatic void __exit led_platform_exit(void)- h$ n, @" |0 M8 R
{
! A6 N/ Z2 \/ t( t ^ platform_device_unregister(&da850_evm_tl_leds_device);
1 t, o9 J: m0 K* ]! n S/ n
: c; e$ p# [6 O printk(KERN_INFO "LED unregister!\n");8 N8 Q8 p2 A" b7 `4 h; Z- e
}
7 J# ~, H2 w3 t" B# Y5 _( U
1 [ Z: |9 |/ W+ Fmodule_init(led_platform_init);/ K9 N/ D5 D+ o2 m/ b! D
module_exit(led_platform_exit);
4 f/ V5 y$ _# A5 v4 v4 E+ a
$ M" f( t+ {/ D: G4 v/ |; R7 YMODULE_DESCRIPTION("Led platform driver");) G1 w8 F5 H/ x9 h$ L6 H" E( p- y V
MODULE_AUTHOR("Tronlong");( C5 U" M7 k+ y I6 i
MODULE_LICENSE("GPL");
" A) g6 f+ ]& F6 @+ j
% a, Z8 w+ X: L |
|