|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 }0 h% D+ ]) |- g8 C#include <linux/init.h>
6 M* V+ c6 U; A/ g# B* _# z#include <linux/module.h>
, J! I" W+ j: P0 ]#include <linux/kernel.h> [* y9 P3 g; L8 p" k* J6 i5 j
#include <linux/types.h>
* F' R1 l1 Q/ E# S#include <linux/gpio.h>
$ q" x+ \! ?) d) r2 X8 u- A#include <linux/leds.h>
( @: U0 D' z5 g& K& Q1 N* n#include <linux/platform_device.h># d& W$ j& y4 y8 Z/ h' L
; q7 k; c" e5 U. l6 }: @- @#include <asm/mach-types.h>: m s: U/ n% U
#include <asm/mach/arch.h>
@" D" h' V: ^, N" [# a& d, P( ^#include <mach/da8xx.h>
$ n6 w9 R/ u/ |2 d% k# a/ F#include <mach/mux.h>
6 F0 U! D2 y5 [) j l8 r% }. J
+ e- p) K2 n7 F; ~. b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 {2 M) O; ]3 z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 O6 y6 Q7 S; v
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 u, @( C1 a `% U% r5 f
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) ^, A% y1 P, Y; m
/ L4 i0 N/ s$ m2 u8 p/* assign the tl som board LED-GPIOs*/, n1 D( z# Q' N8 k
static const short da850_evm_tl_user_led_pins[] = {
3 @8 r- ^2 W9 ?3 N, p /* These pins are definition at <mach/mux.h> file */
% Y) [! y- \) A& \5 J0 Z/ w9 d9 ^* T DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 ` K$ o9 E! J/ Y t
-19 b0 c" u% Y& t% m, s4 Q- m R/ c( }
};" a: N( L0 t- F0 `" S
9 r, P- Y# g0 U+ D8 K9 Z. s$ u
static struct gpio_led da850_evm_tl_leds[] = {1 [9 K. M) Q4 O& s6 F
{
( f+ r, K5 D* w. `% {6 J# o1 e8 i .active_low = 0,' P! y! d5 w# I: ?- g2 X/ V
.gpio = DA850_USER_LED0,
7 V/ }! K; P B3 s1 ^# W .name = "user_led0", I, B& e: ?, E* f. m. L# n: h
.default_trigger = "default-on",
5 D7 C. A! t$ d6 r4 {8 F+ x" ~% @ },; a Q0 Z6 M/ j. K7 X
{0 B& L2 z5 s, u4 u
.active_low = 0,( z. [0 H! W% b
.gpio = DA850_USER_LED1,
6 f8 Z1 q2 t ?8 P6 b3 l .name = "user_led1",
: i# z w( H/ q .default_trigger = "default-on",- R0 e; I2 ~1 S! l6 ]
},; a# f. e: Z1 p
{
0 P$ i5 T' ^( H4 B+ ?- }4 L2 B .active_low = 0,
7 L5 W1 @. E& G- l* c .gpio = DA850_USER_LED2,
. p5 @+ E" @. B2 I6 [$ L .name = "user_led2",' E# w, U0 p* b
.default_trigger = "default-on",
% [ T" {: u! E, G, c5 h( v },3 u% c3 L! i6 I6 y8 X# }! d2 L
{
9 L% u- k" n$ M) g .active_low = 0,0 K# T2 |1 [2 V; O; h* w( n5 n
.gpio = DA850_USER_LED3,
1 R" n' D! A1 g* f( C% d2 V! |9 e0 M6 J .name = "user_led3",8 Z. s8 `! O) I6 v* h
.default_trigger = "default-on",( d$ v5 _$ U- @! F7 B* }
}, s) j! Q7 o& k- t3 S
};
/ j' Q5 n* k: H$ G2 [& i
# `* I8 l+ s1 N5 n, D; K! C) R' b6 c; Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- U- p# `! X9 _ .leds = da850_evm_tl_leds,
/ c! C* R7 F% u( h2 D {# ]# Z3 a5 k5 D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 M+ T2 _2 O1 Q; h! s2 s( H1 Q};
& B" t' P; C' v- F9 n) p% @. }& w% ]" d6 n! i
static void led_dev_release(struct device *dev)
0 L. Q+ O( U' A! s/ a# ?{1 s* Z9 i- _- x- U( \0 e, g
};3 d3 i+ o5 x, q' r, a) v
L0 w' L* j( S
static struct platform_device da850_evm_tl_leds_device = {
1 g }+ d7 t8 m5 r: x1 c .name = "leds-gpio",
" D% G! i E! ]1 Y! _$ [" o" C( o .id = 1,
- I- [2 y8 s1 d0 D! S/ I$ H .dev = {
" o: ~& H6 G- l! l+ ~ .platform_data = &da850_evm_tl_leds_pdata,9 i6 R8 v$ P6 R. p1 q) a4 A$ t
.release = led_dev_release,8 t# _2 p9 z9 J9 L+ K' v
}
' m1 }! d% F T};! g) ^3 y6 H% T: ^
5 l" t5 b" u1 S. T/ q' _9 i0 }0 Hstatic int __init led_platform_init(void)
7 N, d i: l/ j- f+ Z% Z$ D{) u' G! K% c" _& X3 S
int ret;+ y S- H' q! [; g4 b, z
#if 0, ~& F" K3 I D( `7 X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ V' j: n" g3 T; D. @
if (ret): i5 J2 m# m' ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! M1 G4 m! Z. c$ g "%d\n", ret);5 G& I# x" T7 C' Y) f
#endif
5 I% ~7 w6 M; E7 j- L! [6 k ret = platform_device_register(&da850_evm_tl_leds_device);
7 F3 W9 z' Q6 k" _+ i6 w M+ B if (ret)8 C6 b/ V) m1 x2 Q" o' E
pr_warning("Could not register som GPIO expander LEDS");( Y4 w" J$ B+ A2 B1 `" t
else
N6 b4 z' z. x8 \8 p. X& Y# ]7 W printk(KERN_INFO "LED register sucessful!\n");
' v: H, N3 f0 t# l- y
! Z7 K7 h; }9 Q. j return ret;
4 O3 l: i0 E7 Y( L}
6 I( Y) M# E. M) a) c3 F
3 J( U. D% L- j, p. h- M3 a; ?static void __exit led_platform_exit(void)" \; H8 [# w0 J. X6 J# _$ d4 Y
{
- w1 u: v1 r9 a) ]/ n& T9 n platform_device_unregister(&da850_evm_tl_leds_device);. z) m; n- }) l+ e! g3 e0 R( U% j j
3 V9 P- s2 `; b% E9 v printk(KERN_INFO "LED unregister!\n");0 `5 j* Q' [ t: N# _/ D
}
+ Z3 j9 K# C R5 s) j% G, x' j" a
module_init(led_platform_init);
6 @- w$ G& q3 }module_exit(led_platform_exit);
' ]# L/ b; k7 |4 L8 `4 b V; R
8 v4 E) ~( `4 E4 O4 v5 W/ h) J* fMODULE_DESCRIPTION("Led platform driver");
1 W: ?9 X6 I' }7 v7 N" nMODULE_AUTHOR("Tronlong");5 F( W* Z' x/ J# |9 F$ s/ f
MODULE_LICENSE("GPL");* P; C. ?7 W" ]& C$ e0 |$ g. N; O
" A( @5 m+ l2 N7 R1 i q |
|