|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 d. ]( | [, u+ a* Z
#include <linux/init.h>5 i' v( V; R( k2 z& a( x2 e
#include <linux/module.h>0 m3 [( M$ D* j8 u9 T
#include <linux/kernel.h>
; ]8 K, c" {/ q' U6 x8 q#include <linux/types.h>
3 }! E5 v5 M: A7 w#include <linux/gpio.h>5 O$ o- o' o7 b# D! j' L9 d; t& I
#include <linux/leds.h>
9 _* H" C' G. G! ]9 |$ F" Z#include <linux/platform_device.h>
) H; K) z0 \4 T+ F- o# \& ?& W
; d X2 F4 b. Q! [# N#include <asm/mach-types.h>, c9 ^& f% O/ [0 P
#include <asm/mach/arch.h>
, @4 J0 \/ Y, ~- I3 L* w#include <mach/da8xx.h>8 z1 Z- O4 U0 g* Z5 _1 p) p
#include <mach/mux.h>) m9 Q9 M5 B& m7 C1 q) ]9 e
- q8 T Y0 e4 h" R- s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) h! X$ t1 ?2 h+ S# V6 B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 E8 Q; K- @( v( v
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 Z0 a7 U, }2 {& H2 I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( \- f, g/ e) e6 w- ~' H7 ?% |$ [9 Y& @% g$ ^
/* assign the tl som board LED-GPIOs*/
' W! U" p5 Z0 f/ Q4 vstatic const short da850_evm_tl_user_led_pins[] = {+ m" V7 h) f9 ~9 F
/* These pins are definition at <mach/mux.h> file */3 z7 j! M+ w( J0 _# u
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 P, l( X4 |7 v ] -1 ?* L/ L% T* v. ~/ C3 \% e N
};
9 l' M8 N; X& q* L' D
* z+ e e8 {# ^static struct gpio_led da850_evm_tl_leds[] = {' t% r3 q4 p& @6 ?* p* P
{4 s- z @' I9 j( K& O; k* n2 V
.active_low = 0,
, b- k* z7 L2 X: y* U2 U% } .gpio = DA850_USER_LED0,
( s( H0 P. w' R' t .name = "user_led0",$ K2 Q0 I# t" R1 W# k
.default_trigger = "default-on",7 h9 x/ c7 ?% p2 O. m, }1 @
},
* H6 n; }& D) |8 e8 p {, h9 N) Y" m1 M1 V
.active_low = 0,) M0 }) Y+ L# y! l8 O; K
.gpio = DA850_USER_LED1,
, ^. ]8 @9 }- q; A/ s% n1 g .name = "user_led1",9 N% W% g4 a% ?) i- D7 Q6 z; }2 `& J
.default_trigger = "default-on",/ R3 t) Z3 d, F
},
. f% u4 E1 p) q {1 \, [- D4 m/ D
.active_low = 0,
3 @; ]3 w* m% p, K2 V6 `8 q .gpio = DA850_USER_LED2,
( s) |2 ]" X" f% W* Q2 H7 M .name = "user_led2",
# e6 p/ e( k6 D2 T .default_trigger = "default-on",4 K0 d; S& C4 V" o2 i
},
2 L6 Z1 O7 p+ J" ?6 Q& ?8 d% ~; ` {
7 Z$ G5 G9 ?: K# E0 r0 u+ Z/ ? .active_low = 0,; u5 o5 E& I5 k' a
.gpio = DA850_USER_LED3,8 Y2 Y% l" V* |- l! {' U; Z) o
.name = "user_led3",1 T7 ^% N- R7 O
.default_trigger = "default-on",& A9 x! n) \ C5 w7 S
},: w* o( ~' r- h/ V" [
};# P4 ~5 ? B3 B# N: `+ K9 V4 ~: h
# J, h! o' W9 l8 [8 v8 r3 D7 estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- Y8 o4 r" Q# o+ p. j
.leds = da850_evm_tl_leds,2 h0 j" e6 `" j+ d. R+ @& ^, G7 L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* [" T3 S) N4 p7 W. \
};
5 O+ T/ S! }' h5 b! n$ Z" k& c+ D% u: E7 R" v
static void led_dev_release(struct device *dev): _: L |) i& X4 ], L7 k
{0 d1 B' k0 T5 P( z+ \, @
};
2 A, D+ }" S, {1 ?. ~5 a" L% x
; ?5 k5 @, l, o/ z; d( o6 M/ O: d, Rstatic struct platform_device da850_evm_tl_leds_device = {5 \' g5 u) x4 g3 X
.name = "leds-gpio",3 e! O5 R# R0 f8 h; `+ O
.id = 1,5 o) I2 x) g1 t" ?- E# U) K
.dev = {. {4 k- p; @% { m8 y
.platform_data = &da850_evm_tl_leds_pdata,4 N% r0 w2 c0 m' J0 {# L( R' }
.release = led_dev_release,3 \/ p3 P' U v% n; V
}
6 N* h3 T$ V+ u' Y5 D. m};- \" X0 W- T7 B) e0 g$ P7 b! N: _
! u8 h9 K4 c4 u6 Qstatic int __init led_platform_init(void)& K6 `/ `! ~3 z, A
{
, W# [% W. d& h; @7 X6 W int ret;& l) z' ]* r) u/ b1 s) ]& P
#if 00 p2 x8 U. K, ?# u$ n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ w) m2 K# c9 E* r9 k+ ~
if (ret)* m) }% x5 X9 P7 G( }! J0 b
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ s1 r n1 E) z. g
"%d\n", ret);
- ^6 i1 }0 j/ l#endif$ \8 E% Y( V0 X \6 }1 e
ret = platform_device_register(&da850_evm_tl_leds_device);
8 U ?; V5 |4 \3 d- Q( P if (ret)
- ]7 W/ w1 ^9 c) d2 {, Q pr_warning("Could not register som GPIO expander LEDS");
+ G' V5 n; B* B, x/ {" P5 `7 j else& _) U( B) q( O; I8 M: @8 F
printk(KERN_INFO "LED register sucessful!\n");7 l/ g# F3 L% x
6 O" q6 F a8 v/ E0 V
return ret;# W0 G, O" y; k0 e6 a+ P5 |
}' @* i$ ]. n% x' Q7 z
7 H0 J. k1 l5 P9 H+ x3 i( G$ h
static void __exit led_platform_exit(void)
: p2 t; u5 r M I A! l{) b d0 o: ~$ r) P. a4 a
platform_device_unregister(&da850_evm_tl_leds_device);, F$ n; _, {% f T z& `
$ T; H9 l0 w0 r2 z0 w: t
printk(KERN_INFO "LED unregister!\n");- d" s8 E5 R5 r- `, `$ e$ \' c& W/ A
}
3 U7 y( Z4 a, L2 i& R) P& i* S$ Z1 D' ?+ V' w
module_init(led_platform_init);
$ J0 n+ D4 S# O3 _9 ?$ O* ^module_exit(led_platform_exit);' h6 K( o( s* [6 G
/ t6 \7 A7 z2 r+ h# p, y% R, T
MODULE_DESCRIPTION("Led platform driver");8 Z0 }# m% J: `; ~8 C
MODULE_AUTHOR("Tronlong");: A% g8 ~; w; c6 i0 U8 H3 K
MODULE_LICENSE("GPL");
# _3 L t0 Q0 b
1 s8 Z& x9 X8 [2 {# v5 h" F; x |
|