|
求大神给下面的程序做注解,请稍详细些,谢谢。
( F* X0 [ E+ } w( c$ ~$ X: b#include <linux/init.h>
" M* u0 E* S; B8 u#include <linux/module.h>
n6 n4 ]) j/ |$ u0 s2 j6 m#include <linux/kernel.h>6 b; d. }# b W
#include <linux/types.h>
5 _6 `5 O" d# Z8 d# S7 f#include <linux/gpio.h>
& _+ d1 k7 l9 t6 _#include <linux/leds.h>) ^4 j( [0 D' N/ E; _
#include <linux/platform_device.h>" G% g$ {- R/ y- C# A* @3 p
; f5 \8 ?' G& z4 w( s+ A
#include <asm/mach-types.h>
& ~, B" m4 L+ q) h- ?, d9 L) X#include <asm/mach/arch.h>
1 K! z$ ^1 ~9 w#include <mach/da8xx.h>
% y, l2 @+ j+ s7 S3 M#include <mach/mux.h>
5 R/ X) ~/ m* q6 z2 z: m$ S: p3 A
$ Z( F8 A5 i* c9 \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 s' o* G7 a: X8 l9 P; k1 z5 O( v
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( L3 O9 e N. ~/ v4 x; B) v* Y; S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ H& ^& t: C2 q; S( m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" r4 m; d" U/ f% s/ B; k, L% z. e
/* assign the tl som board LED-GPIOs*/% v6 `8 G2 L) }
static const short da850_evm_tl_user_led_pins[] = {' a/ Z& z5 s, I+ T. ~/ O4 y; c7 u. {$ J* O
/* These pins are definition at <mach/mux.h> file */
7 h1 K6 q( Z& @% F2 t1 K z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ @0 @; v" F# n( t O& {
-1
3 \ Q- g& U9 g( Q* |/ ^};5 |" P) T. U; K1 Y
1 L* E& ~/ w4 i0 q4 N$ {' gstatic struct gpio_led da850_evm_tl_leds[] = {2 p. R' _8 t Q2 \2 f
{
^9 l F+ `" C) Q .active_low = 0,
$ Z7 q. `4 Y2 q .gpio = DA850_USER_LED0,0 q7 |% X! Y2 T+ F
.name = "user_led0",
$ @# [& I( E4 R ^ .default_trigger = "default-on",
4 X2 t3 q3 d% T },. Q' M* ^* V& e' l2 \
{) X- {* V* {1 b d) A, S* q* P
.active_low = 0,7 o3 L! g6 f( `
.gpio = DA850_USER_LED1," A' X! l q3 v/ S" |' D. r
.name = "user_led1",
, E% i1 ]0 [! X0 x# J+ @. u .default_trigger = "default-on",/ D( a3 l6 \8 \
},, c, ]: |, E) b1 W9 j
{+ R# M* g* d: l+ a* T% g y, r, Q
.active_low = 0,+ q5 w6 {; r7 X* B& [1 E& s
.gpio = DA850_USER_LED2,
( x e* O! {% N# D .name = "user_led2",
; A& N/ n S {6 W( N .default_trigger = "default-on",
6 g" K0 D. ^7 t' `; f) m: t5 n },
i" z, y4 u9 Y" p7 k0 S {0 O* z2 X" h: }; g1 Y
.active_low = 0,
9 p J( ]- f4 P* | .gpio = DA850_USER_LED3,* S. B% M# |# K% ^
.name = "user_led3",
$ p5 K( H: _2 G4 Z' } .default_trigger = "default-on",
3 Z! j" ?8 I! E' B% ]. i2 v/ x: r7 i },
/ d0 _$ H: o8 d- e% A};
- l. i2 Z+ S' U9 g7 a$ I' G$ {. T: D4 E1 P, }% G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- j8 ]1 Y) ^. b2 p6 H .leds = da850_evm_tl_leds,
5 A, F9 q0 b3 z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! @; G H% A3 w* F5 h3 _6 Y
};0 I8 G6 {6 G: p9 q( J! o) X
/ G) w) a1 y/ M- |" h( vstatic void led_dev_release(struct device *dev)
* K1 [0 q& `2 c8 H+ y{; ?6 r7 f$ w0 r6 k1 ~
};
' h' o( h+ ^3 b$ `4 K0 s7 y/ q9 E- x/ l
static struct platform_device da850_evm_tl_leds_device = {
3 M. ]/ ]) U' F2 ^9 J$ Q .name = "leds-gpio",; G7 U+ U( x; w! l8 F- d1 i- Y* _, L4 O4 w
.id = 1,
3 _" m& y: o4 r# J% L9 ? .dev = {
$ }! S7 ?: b9 o2 F" K4 ^6 J .platform_data = &da850_evm_tl_leds_pdata,
0 g, ?/ U" S3 E .release = led_dev_release,
3 i; b* D0 \5 @/ ]3 m3 C }
! K! d! }! s. b. K' o};: o, I! C6 b3 }* {4 J
8 M7 J/ @2 V0 G N3 D
static int __init led_platform_init(void)" e: `, u, b" m
{
/ M) @5 _- n7 v3 @3 R. R, G3 y! l8 T int ret;
$ o7 D+ b1 s: [% R3 `+ }. _5 e% C- `#if 0
& ?1 Z1 y9 |8 S% i5 C' ?$ v% B; W& M/ M( b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 H8 d6 N; }9 }+ ^' q if (ret)2 \1 ^% W! R7 `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* b, [ c( T* s
"%d\n", ret);
1 T- _- G$ E5 a1 j b#endif2 m% ]1 X6 H: c i
ret = platform_device_register(&da850_evm_tl_leds_device);
x1 J1 D& u: C4 N6 _ if (ret)/ ~& e4 K% A1 p
pr_warning("Could not register som GPIO expander LEDS");/ k! N/ t8 w3 _3 I
else
7 s8 j6 Y$ e+ F [! u: J' t H) Q printk(KERN_INFO "LED register sucessful!\n");* e$ \6 s6 G- y) ^
( p$ X1 l7 A3 T3 o8 J6 C. s
return ret;( [# b' |0 |7 ]
}
+ r0 S [" ^8 W/ B- [. a. s; n
; c$ q, n# T( E A( w; \0 q' V5 ]static void __exit led_platform_exit(void)- C3 \0 Z& ]6 j- p. G6 R+ Q
{
' C1 m, \) h- ] y: S% l9 |5 ^ platform_device_unregister(&da850_evm_tl_leds_device);
# c& v/ ]1 S# S: e' d# L% ]
' o! F% \4 _1 `( R9 O6 a printk(KERN_INFO "LED unregister!\n");
) C, i- n; r2 B' b4 {6 m) s+ h}
( z! z, z+ P* H( W) M% j" q8 a1 K1 [% ^) r- }
module_init(led_platform_init);' e0 U1 n9 K1 i. E
module_exit(led_platform_exit);# ~: Z2 `0 J1 l! g
7 ?# i9 K# J+ r: f BMODULE_DESCRIPTION("Led platform driver");
* `( k5 Y" [5 O- a3 s3 Z) j1 }MODULE_AUTHOR("Tronlong");9 C2 ]$ R' i& Z
MODULE_LICENSE("GPL");+ \4 T9 U2 D9 s
; s+ d& P# F" X* o7 g3 s3 a
|
|