|
求大神给下面的程序做注解,请稍详细些,谢谢。( S$ k( ]0 a) E. S0 ~& [
#include <linux/init.h>
5 ]' G! z" }* m#include <linux/module.h>$ s; C; R4 u; p/ {; ]
#include <linux/kernel.h># d) ?: }( D6 Y" {( ~: k3 N; w
#include <linux/types.h>& x' I' R8 O( n. ^' y0 w. c! ~- V
#include <linux/gpio.h>$ f3 `4 ~: |. R4 N' c6 w
#include <linux/leds.h>8 y% Z8 M) Q' u) ?) k. N9 @
#include <linux/platform_device.h>
5 L n8 c: M# L) y9 e3 g$ U4 f; q( L$ _
#include <asm/mach-types.h>) _; B! s/ Z# w8 J
#include <asm/mach/arch.h>! Y7 y( n1 d& x: O: n4 I# l8 V, R
#include <mach/da8xx.h>
# j! N% ?; t& h9 c#include <mach/mux.h>- C; H/ I1 [4 z% \
1 I [. }+ `' m* K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
`2 k3 d6 C. u; ^6 I \# t5 _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, U7 b" D9 t9 W4 v8 {( H: U3 {' W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). L- _# ~# ]. u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 U, C4 v* P6 T9 t6 }) T5 |! R2 G
$ ?$ w% Q+ B# b) k" L5 O: i3 S' G, h/* assign the tl som board LED-GPIOs*/7 E% `+ r$ U* X0 M V( ^6 Q& O
static const short da850_evm_tl_user_led_pins[] = {) c% ^5 }* S) [- a' ^" l) A
/* These pins are definition at <mach/mux.h> file */* p0 M" Z2 |2 K+ Q1 J% W5 m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 J; f1 U$ `5 `+ t$ F7 ?+ N -1* f9 _; |! a+ f. {6 o, w
};5 P1 @6 o2 g: `3 s# ~7 T; `* h
1 _& {* X- Y/ H4 E' Z
static struct gpio_led da850_evm_tl_leds[] = {
! F( ]( b+ d+ D; C2 e8 Y/ B U {' [% N0 q4 T5 K& H
.active_low = 0, T$ ?6 S! P! h+ g" R9 p$ b# e
.gpio = DA850_USER_LED0,9 w" H+ `7 J1 _
.name = "user_led0",: G B" q1 r4 `! K$ \) G: c, A
.default_trigger = "default-on",; \$ | D! o0 S* O- c+ C
},
" B. l) M' g5 h9 U' z {7 _) K! k2 e+ Y4 K( t
.active_low = 0,3 c% M! D. z3 p9 i4 N7 ^# H
.gpio = DA850_USER_LED1,( h6 @% @- M! C: W+ E$ ?
.name = "user_led1", G* B( k" l# {$ Z; W
.default_trigger = "default-on",
9 Y1 G6 }9 @. {6 c! j& `0 ` },
* q" V' W; u7 |8 T {1 h; a* j" j \/ N$ g1 D9 k* k
.active_low = 0, w. b Z# D9 C
.gpio = DA850_USER_LED2, p, t1 d* _% p2 {3 b
.name = "user_led2",
* ?. W5 G. ?) \- U9 a M2 A .default_trigger = "default-on",
$ ^9 s0 T* I9 b. `' P ~3 ^1 [ },
, n/ ~+ h* ?5 ^! U- ^2 g {9 \+ P2 D+ J5 G4 c' ^: F8 @
.active_low = 0,
' Y! ]) q( j9 s. _& G1 H0 G .gpio = DA850_USER_LED3,( e0 D' _2 K% \( V
.name = "user_led3",
2 _8 |/ t5 D( c0 X) F. R .default_trigger = "default-on",0 m7 S% K3 E; a- V
},
. b) V/ p7 u, d3 ]6 V};
' e" n' j1 |# i* B# N
% T& |) x. F# o+ j: V( Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 G2 Z! e4 e: d2 s8 z$ _3 W .leds = da850_evm_tl_leds," A9 o/ u2 p$ C0 \3 F
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, L# d& S* @( q9 e7 t
};( k: D& A+ T Q0 ^
2 ?6 G# k$ _* t [5 ]7 ?- hstatic void led_dev_release(struct device *dev)
; k7 f' c0 O" J2 T7 G. }7 g% Z{
' G( x" z2 z; D% r& [- ^; X};
" h D5 {' K0 _: v* D: ^
! X0 k, ~( d6 }8 lstatic struct platform_device da850_evm_tl_leds_device = { J' A) y8 ?! {
.name = "leds-gpio",0 T: k2 d* l9 A
.id = 1,
% ?2 G/ N$ T8 ~) z& e .dev = {$ ]4 R7 b _; o: P5 G" t
.platform_data = &da850_evm_tl_leds_pdata,$ C, L) {. L( \
.release = led_dev_release,
" ^8 R8 d6 Q5 ^3 ?% T$ s$ _ }
4 F+ d/ X$ q! |: D6 A};) T/ K9 J$ M& w
" ^) b2 V- V% ]! C2 k5 C- M
static int __init led_platform_init(void)) R/ B2 Q# G- O2 N) G: ^! W% `
{: w$ a) r5 r H' b( \
int ret;
; E) v! V& \! ]9 g#if 0
) y5 I$ n7 q, i; u+ v# ?$ b5 ? ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, {7 C& z7 h9 P: h, q. h6 V
if (ret)
/ [. [" p3 w) i a: q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ H {' ]) X7 [+ ^& T% D/ y "%d\n", ret);( M$ k) N8 j( K8 H9 B# w! w
#endif
' o. X; H8 @: w u: n/ @ ret = platform_device_register(&da850_evm_tl_leds_device);
1 N2 N! Z3 f! P# F/ ?7 u# a if (ret)6 z. W7 Z& o. d: b, M# k9 Y
pr_warning("Could not register som GPIO expander LEDS");' Y3 h$ B- V# a" n/ e& W! w. i: z
else
/ p$ H% ~% z8 E# } printk(KERN_INFO "LED register sucessful!\n");
+ d A1 I- F3 v% F9 U1 q0 q; W$ s* G( s0 Z7 ^5 @- g" h1 F" a; G
return ret;
3 u: z) m6 u$ @; u6 A}
5 l9 B! ]5 V" v- X p/ Y5 N! x u
! V( K5 i/ |! M" X5 l- r" f$ pstatic void __exit led_platform_exit(void)
u3 r$ H0 _2 }{
4 E5 ^1 T, Y0 G platform_device_unregister(&da850_evm_tl_leds_device);
( l9 @0 J1 F( \5 L5 m! S
; G. E2 q+ J% G7 T$ Y5 p) U) d printk(KERN_INFO "LED unregister!\n");
8 E2 j$ a! i% A* @0 Z1 a8 x}, Q: j) l* R: I% |$ k$ E- r6 q
0 Z7 m$ Z* L+ z8 b+ T! hmodule_init(led_platform_init);
6 `7 y: W: U3 X" T4 W, D' U& t6 D* jmodule_exit(led_platform_exit);
1 x, ]8 C3 |. V+ r" f7 ]5 M# A) }* l+ Z1 R$ _
MODULE_DESCRIPTION("Led platform driver");
. g) i/ V! X; s: V) JMODULE_AUTHOR("Tronlong");0 Z7 T+ ?( }% e3 Y1 f4 ?& n5 G( u
MODULE_LICENSE("GPL");8 Q- y1 W. Q% Q. P
$ w* L7 H! U4 S: t& X, V; X% I: t# u
|
|