|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 {1 @( ?' e% _" K% s
#include <linux/init.h>
* Z2 r* S2 t; K' w- E: d# V" B; y7 u#include <linux/module.h>- Z& z1 |& {5 B1 ^6 k3 |
#include <linux/kernel.h>
3 @ b% m( A2 B, Y; A#include <linux/types.h>! `& P, D. N& I! p9 n4 o* O; z; L
#include <linux/gpio.h>
: P. i/ a. i, F. q% q#include <linux/leds.h>/ H6 b3 K6 e! J( Y/ g% K. }
#include <linux/platform_device.h>4 B! ~! t. s6 a- p
4 y% N8 ~# o) b' o#include <asm/mach-types.h>
( [9 C8 H" X6 @9 }9 |#include <asm/mach/arch.h>8 v3 S$ u0 @" X( }
#include <mach/da8xx.h>
0 c6 c2 s& \; A3 {6 [& O#include <mach/mux.h>! l( J1 V) P& E, [5 k5 ?- m; R2 ]
/ P: \; m7 U; L) L. g$ _; ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; s' n2 D$ h# d- j4 e#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- S5 w. P1 t0 I8 F4 r0 F. j( Z. X
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% P0 z- i6 `6 O+ |% `8 F4 o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% S% I% p; l4 W' u; Y% x
0 \! I) e6 z+ G' ^/* assign the tl som board LED-GPIOs*/, G' r1 L% l9 ?9 W3 F. o: j$ t& S' |
static const short da850_evm_tl_user_led_pins[] = {
2 K5 E% F! F8 I) w. {$ u /* These pins are definition at <mach/mux.h> file */
5 X. T" p1 L7 F9 f+ W: F/ ~. ?) k& ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 \1 c% F |* _& G' A, r" z4 U -1
7 J8 t5 t+ \1 B* |+ H. |: U};8 x. _4 B. l r- U
/ F; ~8 y2 b/ L7 j: Rstatic struct gpio_led da850_evm_tl_leds[] = {
" d0 B. i: m/ r {9 G, \. E8 B/ q# ^" C- P0 X3 H, V- m% K
.active_low = 0,* s; v# J5 x* e& S n
.gpio = DA850_USER_LED0,
5 s8 s% W! P' h .name = "user_led0",6 x7 r5 D: y0 H) {) z. x7 A. x
.default_trigger = "default-on",
8 L: Y y, A* R1 d* M" F },! u k+ a% g Y0 e! ?. Y+ |( o
{
8 J* b6 X2 _* N: M .active_low = 0,
9 ?. X! @8 r% v4 v; L .gpio = DA850_USER_LED1,! U4 y9 {/ l6 X
.name = "user_led1",, a' b7 t% |% y1 z" l- U
.default_trigger = "default-on",3 h( @2 P9 E. I
},8 f& ]5 R, J& Z- H: y
{0 U9 g/ k6 f. H
.active_low = 0,
+ I) b- R9 \5 D" h* ] .gpio = DA850_USER_LED2,
0 Z6 n) R" T$ l, B .name = "user_led2",- J2 \8 F& b! {& s9 p
.default_trigger = "default-on",! X( }+ }- v ]6 L
}, C. E% i8 o- f3 g
{, ^' o y. g- q
.active_low = 0,; c/ v3 h7 c, l+ @4 ?3 f
.gpio = DA850_USER_LED3,8 q6 Y' B0 |. O6 s6 i) }) k* N
.name = "user_led3", ~% w# A% I/ P/ P8 x# p) J
.default_trigger = "default-on",
% N# }+ F# u+ L V( O0 L4 h8 {3 u },5 v& \5 Z5 T2 W9 f- r, X6 |
};
' H+ K# ]; E+ s& C
: t8 X9 U8 K5 ?- `! m9 g/ Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, Y: [/ P7 G* @: L7 N .leds = da850_evm_tl_leds,
B2 x6 P0 _+ Z) }/ k9 z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ W% D( J2 i* r! m% F5 v; m};6 R h6 O/ w; R0 n$ b$ f e1 s
" I2 o! L) N' R$ w x' T% ustatic void led_dev_release(struct device *dev)
* q8 e1 Q) o: X3 }" h; n{
" U3 q) t! J! s% Y};4 u* `: ^4 d6 J/ _
5 W O3 |2 Z7 G3 b1 Y
static struct platform_device da850_evm_tl_leds_device = {8 W# }! K; x! s/ x0 q! W/ g1 {2 z
.name = "leds-gpio",5 K" y. n, A$ t; [1 X
.id = 1,
: ~2 K: H" a% f% C+ y u .dev = {
9 x2 ~: r& [7 Z3 e* p8 C& A .platform_data = &da850_evm_tl_leds_pdata,
& v& W( m, U. d! T4 v e0 y .release = led_dev_release,
8 |: P, x" [8 t/ Y3 N }1 `" U3 n) m, x( A0 l: D3 }2 Q
};4 B5 h9 W3 [! m8 n# W
5 O1 F# o5 ^: M7 ^ g' A# d1 U5 Rstatic int __init led_platform_init(void)
- A3 i7 `+ W, T: }6 ?{5 B# Y8 K: k" r# g- z2 R$ p
int ret;
. h+ B. u' A4 y, ^; L6 J" e#if 0; v2 ]( I" T" c& W6 w) l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; s: ?" x" x+ f( l if (ret)
& B- {' a2 w' Z& R: ~& ]8 ?" n$ j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! Y0 _1 V) s( A& ]1 m1 o: a% @
"%d\n", ret);) [) T! v8 G6 c* v- M
#endif" v+ R' t1 a* R* L2 q" k( K
ret = platform_device_register(&da850_evm_tl_leds_device);: e% F: n m I" ^$ E8 h0 V
if (ret)+ H9 n+ u/ L u8 N* c* Q. y
pr_warning("Could not register som GPIO expander LEDS");& H }+ @' r: h
else
; x: _4 k4 C& K9 C1 K printk(KERN_INFO "LED register sucessful!\n");
2 X2 b$ H& D' C4 a: `
2 ~ N$ ]8 p- Y# L% y- f, s5 Z return ret;. P h! l: q( E! n: b) r! ^( W; o
}
6 P: w, H% x0 N$ R8 k" Z4 t5 ]3 ^ h. i
static void __exit led_platform_exit(void)
/ i7 ` G! p% B{( I, T, V0 v9 R9 `# H+ V2 f
platform_device_unregister(&da850_evm_tl_leds_device);
L& y7 f7 G7 k: k, n! `: I" w) k* j: p3 @$ @2 e h
printk(KERN_INFO "LED unregister!\n");
6 Z5 F. z5 \. W9 M0 P% R: r}
# G7 [2 N0 e D+ [' s7 u! {7 l* ~7 q
module_init(led_platform_init);
: }4 P5 s: ?5 S& j$ }* D Emodule_exit(led_platform_exit);; T# x6 `% z g
7 A9 C7 X r- O( ^MODULE_DESCRIPTION("Led platform driver");3 A) D4 c' y! f" F" {, s" v' A
MODULE_AUTHOR("Tronlong");) E- D4 w0 Y; O8 d! F
MODULE_LICENSE("GPL");5 g3 H4 C, J' E
( @8 |4 }" @8 h. [/ H |
|