|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' S% @0 o/ Q4 q! R8 o
#include <linux/init.h>
& n" [& X% T" X8 h1 K; v0 \) ~#include <linux/module.h>
, u6 m0 L! J: d6 L#include <linux/kernel.h> K. V1 S& P/ M$ n) O
#include <linux/types.h>
0 |; I/ e" H8 w* F+ |#include <linux/gpio.h>& q; U/ Z5 E3 g( n4 }" N+ d
#include <linux/leds.h>1 V& }. a$ c9 d9 l* Q( E
#include <linux/platform_device.h>
9 v: I! l' R/ n K, A. N3 T- W% P( \! w, C6 E% S; B
#include <asm/mach-types.h>
5 Z+ r. h" s. a) n2 M1 y#include <asm/mach/arch.h>; z: q8 b, y) @
#include <mach/da8xx.h>
0 U1 Y, O, W0 m- w. v#include <mach/mux.h>; S: r4 `. ^9 R, e- y
V2 P$ {% S7 x
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 c. Q1 ?% P5 y* n+ D' c4 K#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* g3 M5 ]5 h/ T+ i' d
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 _: e/ }8 d0 l8 n* Q, ^+ V, q5 H) V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# E; E8 q! g# h3 U) P4 ?
/ {$ X! l, e6 u2 x/* assign the tl som board LED-GPIOs*/
. Z9 v7 g+ o. h, K$ M+ D; ostatic const short da850_evm_tl_user_led_pins[] = {
( v' P# p7 S$ O+ [: x /* These pins are definition at <mach/mux.h> file */
5 k. d) R, C. S* r. | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ U1 r6 f2 S: k* H, K7 w/ u -1# N4 U$ m: O9 z! X7 ]4 m5 T
};
5 ?% r& I; a+ U# K7 v: v/ n0 K
, \: I" C& [- i. a4 P" Vstatic struct gpio_led da850_evm_tl_leds[] = {
1 d$ a7 a7 c# Y+ [+ y3 V {
( j: l$ u& _, M .active_low = 0,
5 ^ D; w Y! N5 d; I2 d .gpio = DA850_USER_LED0,
' G& a% h8 {+ l' P: P .name = "user_led0",1 q: b, A M$ ?# }
.default_trigger = "default-on",
6 P g" n; y" h },
! |! c* r- K- ?% @ K; U {
1 L% ?- M% K' p% L. a- u/ g. Z .active_low = 0,
9 M: M5 Q' K0 ^- D% J: ]3 C& s .gpio = DA850_USER_LED1,
0 E% c5 n, p9 o* ` .name = "user_led1",1 T) C2 b0 C- w0 W% w, {- \
.default_trigger = "default-on",
% T8 T" \/ E5 m( { },( C. v# j& ~ l" C% w' O- x
{( L: n4 U& y' a% x
.active_low = 0,% V, D9 f6 D& o* V
.gpio = DA850_USER_LED2,: B8 U' i. v2 c' {
.name = "user_led2",
+ ]# x& O) Z/ Y0 ?4 p0 m3 b .default_trigger = "default-on",8 `: s7 v' z4 W8 _1 M2 W# y+ t/ E+ X
},
$ w3 U2 k6 S M1 K {
4 w, D4 L- V& N9 q/ S* c$ r5 Y .active_low = 0,
, E# o8 |# S Z, h! A2 Q .gpio = DA850_USER_LED3,
+ t1 {, Y+ Q! J" p! k, u .name = "user_led3",+ L; @% m+ P9 D/ z( P6 _
.default_trigger = "default-on",
# f; l% g7 G* q& [# P },
, P) e3 F1 r* {1 U/ @+ {5 r& E; ~};1 f. Q( u. C) \; B2 J, z* _. M
+ ~ t( y6 m& e$ D s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' k; z' N" l, Z8 I
.leds = da850_evm_tl_leds,) x" A1 ~2 ^7 r6 d
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),) C. i+ G2 a: X& U* u9 g
};4 x: C) Q; y9 p& J
5 I3 i/ q7 C \9 \, D
static void led_dev_release(struct device *dev)! w" i* f* @2 B+ P
{8 J: z V- `8 g$ V/ a) X9 f
};9 e8 H4 Y; C, A+ {) O# c; j8 @( y
2 E6 E& K( ~, ?( Q1 N( F3 J7 \6 H2 ostatic struct platform_device da850_evm_tl_leds_device = {
! z3 o# i! ?6 }/ t: d .name = "leds-gpio",
# L1 H9 w+ T" n1 J" D2 ?. { .id = 1,+ H; A+ N( |" f% q" U
.dev = {- q1 X; v3 H0 x- _9 l( ]
.platform_data = &da850_evm_tl_leds_pdata,
, s5 ]' G! Z* ~/ |$ h/ q+ p/ x% b .release = led_dev_release,1 d+ G% G1 @; D# N& S ?) L
}6 c. ~% @1 _2 V
};
5 |' O9 S. D9 Z4 ~4 } r) x& Q h
: }' j8 w* q. ?' e* K4 {static int __init led_platform_init(void)
2 r4 ]1 Y, A2 c/ r) }( j; {{
! r1 K$ G/ U" j8 r" I int ret;
7 `3 S! r# X; `6 \- f#if 0
5 m1 O: A) i: _) ?6 a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 w. g: N+ V2 t! M1 H3 b if (ret)
4 |2 f0 m4 m0 L7 X6 S O' l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- C! i1 _1 K8 g
"%d\n", ret);
% A; i& H5 R1 K& ^! `% `#endif# H% T8 _' Y: x5 p& F" W! i
ret = platform_device_register(&da850_evm_tl_leds_device);8 N: {2 I6 G' M9 n$ v B' I) a
if (ret)+ k/ x* s5 l( `, K
pr_warning("Could not register som GPIO expander LEDS");+ o$ _& G4 R8 [: |9 P' r
else \/ E6 A9 Z2 D9 b- z
printk(KERN_INFO "LED register sucessful!\n");0 D" I2 @' r/ k4 E3 Z
& M/ T- i* Q0 ~ M4 G1 }
return ret;' w. Y0 V! J5 c0 j$ Y5 k
}
" b6 r; c' Z. v1 q" }, c
9 w# V" j+ Y- e7 o8 mstatic void __exit led_platform_exit(void), E' t" }* h0 E; C0 _/ A: M
{0 K% V) C0 ~% d8 \# n' ~
platform_device_unregister(&da850_evm_tl_leds_device);1 l! Z/ p* c6 C6 ]# B
% K7 V' F% B3 t9 i9 V K8 @
printk(KERN_INFO "LED unregister!\n");
- E a+ m1 n/ g; ^- Z}) Q# @4 Z0 `8 r
( `0 H/ p9 r0 e$ o5 O
module_init(led_platform_init);7 x% v* t& P5 a2 Y: Z; ?
module_exit(led_platform_exit);
0 o# K: c; g3 Y7 t/ n
) @" _) V9 v1 n tMODULE_DESCRIPTION("Led platform driver");
/ h3 r: S( q+ K0 z* t+ cMODULE_AUTHOR("Tronlong");
: C; q2 c/ F' z5 P8 E( ^MODULE_LICENSE("GPL");# T) E- S4 y. ~' `% Q* e
5 C! o' l; ~9 A+ B, t9 n
|
|