|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" m2 ~2 N' Y# v% R2 e' j) q#include <linux/init.h>
& l$ u a' N3 F/ i& f#include <linux/module.h>* K- c1 T* p/ Y% D v
#include <linux/kernel.h>9 ^1 ~$ E1 V8 e5 c6 q
#include <linux/types.h>, @4 w6 ^* R6 P# g7 f+ o" }0 u
#include <linux/gpio.h>
+ U0 H& m3 F1 J#include <linux/leds.h>% ?# H) J" I- |$ P+ J% D
#include <linux/platform_device.h>
1 ^8 o/ ^. {& Z. j2 y$ G# D0 N! H5 m; c/ a1 C1 B
#include <asm/mach-types.h>0 ]/ T* M1 m; A
#include <asm/mach/arch.h>. r) A0 o- B \. n9 q$ E
#include <mach/da8xx.h>2 K; E. \- c+ P" Y6 c5 q, [) v
#include <mach/mux.h>
8 J' v! S, c! ]$ t Q" _( z4 L9 R
( R/ t2 X v8 h9 S U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* V6 y' E* d8 R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# p& k% ^9 s6 y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! S6 F2 M* @5 M1 d5 k5 D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); d$ ~% \( H- C4 o
0 V: }1 \/ b5 r9 k/* assign the tl som board LED-GPIOs*/
% }0 S" V; Y1 u2 k! jstatic const short da850_evm_tl_user_led_pins[] = {+ Z T) [; @4 \" |8 ]" @- [6 E! a0 ?6 b
/* These pins are definition at <mach/mux.h> file */, U6 g! z i' M) J; M" T* G+ w
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 _3 }% m9 n8 S* i' u -14 d9 d8 i1 \! \6 F" y! H
};
3 @/ ~7 l0 \, V, p- c5 S
0 j- r, P9 o, G4 Bstatic struct gpio_led da850_evm_tl_leds[] = {
5 d5 s8 C& F: l0 x1 j ], K {8 P$ O9 Q7 ?4 G- L3 r4 e3 J$ W/ z
.active_low = 0,+ w/ z" x2 e2 \9 s* `6 t
.gpio = DA850_USER_LED0,
" Z- a+ _0 {- y0 I- K0 g/ q .name = "user_led0",
( Z/ ?% C# U8 ? .default_trigger = "default-on",
" h1 _2 Y# G6 U. m4 A },
& ^* _# R g# r9 i2 O+ `1 E/ a {5 M y% d: z6 Q
.active_low = 0,
( |0 J5 Y# P# O1 z0 I- F' \ .gpio = DA850_USER_LED1,, ?0 {6 O5 D* A' |+ C+ j$ A* h4 n' ?
.name = "user_led1",
/ |! _7 i+ i/ b( Z .default_trigger = "default-on",- C) a' G# h2 J0 o# U3 L" i1 G
},
" c1 d0 d+ t$ q$ { {
: C6 P+ X9 K- h! v% x+ ` .active_low = 0,
2 f& x! L5 _! k, q w4 b& z' s .gpio = DA850_USER_LED2,: H6 x; h* E) `. q
.name = "user_led2",
' i; B$ s' |- v( [; v7 y A: y9 _# C .default_trigger = "default-on",/ f$ z: S0 o( \8 R2 l8 B
},
3 v3 d* }% _& D; Q* J* Z# t {
9 \2 K+ d! S0 S* p" ] ^* a .active_low = 0,0 G$ |$ C9 P4 ?2 n D
.gpio = DA850_USER_LED3,( ~# Q$ o, Q7 |1 ]4 S. k
.name = "user_led3",0 [% f2 L y! [2 B
.default_trigger = "default-on",
4 w# y" _5 ?2 ^* \% \7 i- v" m8 I; S },2 }8 j( a* w- |7 v( ]
};6 a9 `0 n2 f) x L5 x% U
& y4 l& t3 ]- `; @% hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' Q, C. {0 A2 W9 c, E$ J: t1 H .leds = da850_evm_tl_leds,& \# S* H" `( L; F, l, l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),) c5 f* u: y/ w/ z, J7 C
};
( |7 U4 B7 a6 w5 D' ?9 {/ z4 d4 p2 E" R. u) `& M) d9 j. S
static void led_dev_release(struct device *dev)$ L D+ |- f: Z* ~$ A
{
1 A+ T5 \* b; _$ H* W4 P% C};% _' b3 S* V; k( [8 ?: U
6 ^" Q/ g ]0 U, Z* ]" {
static struct platform_device da850_evm_tl_leds_device = {7 z1 E2 X& X! K9 b6 k+ i" H
.name = "leds-gpio",
2 |( a( U" n. ]! D5 G. t; i9 o& u' Q .id = 1,) f$ \" M7 v" v' g
.dev = {
) j$ \7 M n" X+ } .platform_data = &da850_evm_tl_leds_pdata,% G1 T$ M% J6 }7 [, s! H
.release = led_dev_release,
' e0 C3 n- l: P. }- V; u }/ R% a, C A- b+ O
};& I6 E3 c' w6 ?# j( K* q
' s& D- B: k$ f1 ~- }
static int __init led_platform_init(void)- v; |# }4 t& ]' O I3 ?2 C9 r
{
) \' x" [+ G# m" ?0 M5 K& J, @ int ret;
6 B# n6 z6 x, U9 s" t5 s#if 0
% e, x1 u0 ~/ z; {" M+ ?. y$ P0 G ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 z& ^" X: t$ Z) F. [ if (ret), \5 s0 H& [, c: K# y# o! f+ l2 s% Z5 Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 _9 ^* c% P' L+ z; L
"%d\n", ret);3 ^, _. ^8 x! j
#endif
, _/ s9 t, A- i- r) P6 K ret = platform_device_register(&da850_evm_tl_leds_device);5 Y0 _# f. U# {$ t F
if (ret), X2 X! w$ G1 N
pr_warning("Could not register som GPIO expander LEDS");* p* D* d0 f* X& Z J! S; I
else- S' ^3 H5 ]; e0 j) k
printk(KERN_INFO "LED register sucessful!\n");) e" `' Q) f7 j) C" H
; S0 n' S; p9 P
return ret;9 f- F+ [# E% L+ A' r& \
}9 |* m+ J' o. b: B2 G, k
( m7 w( P) I; W$ `( K1 U; ?static void __exit led_platform_exit(void)8 w7 n% A% c' c, h8 X* N& L
{- Z! y' z4 m/ \& I8 k
platform_device_unregister(&da850_evm_tl_leds_device);
9 m8 g5 e) g- u/ @- y
H* s0 E# w1 m printk(KERN_INFO "LED unregister!\n");
3 R, x5 @6 W, f/ J}
: Z3 e4 E+ E: @2 b' T, c
1 t! ~" c5 f @6 Dmodule_init(led_platform_init);
( h: v% \* z' l$ ^9 {module_exit(led_platform_exit);) ]. T4 Z9 `% |* Y# y8 H4 x) E- A
( W+ p5 L- ^/ E0 xMODULE_DESCRIPTION("Led platform driver");
3 y4 T' y- S4 |9 m( b A7 u9 Y% _MODULE_AUTHOR("Tronlong");9 S: m4 @' J6 f( p5 G# C
MODULE_LICENSE("GPL");8 A; A% Q, P- |
2 i- K3 |: G) c( N1 c$ `/ t
|
|