|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* h/ w) [. T3 B6 V; j% m
#include <linux/init.h>
$ }4 W5 n: x* l. {% s) Y& R#include <linux/module.h>$ E7 [1 H R% U `
#include <linux/kernel.h>
0 K3 X- ]; {/ X+ D1 b4 d#include <linux/types.h>
' \# P) { R. w#include <linux/gpio.h>* ?+ {" ]2 ]: F
#include <linux/leds.h>8 t. @- A: ~# C2 T3 T3 l9 I
#include <linux/platform_device.h>; D* M% K3 n% S9 C& M
) s& I2 r% L* W; K" E# L3 H
#include <asm/mach-types.h>
0 T3 q6 I% s* ^#include <asm/mach/arch.h># W' w/ q: `6 U R: \3 |
#include <mach/da8xx.h>
( T1 f" t; h3 Y3 d1 V6 }; h8 p) `#include <mach/mux.h>; e7 g6 h. F- C, h# Y+ A3 T
8 P" D4 j9 B9 l0 D c, K; b
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): {' y, E- P `& b) i, ]! \( v9 K4 O) t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 j' O. q# H7 e) Q5 b4 }0 i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' l$ n2 K0 y0 {4 E+ C
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% J5 D, J6 {5 r& G! I. a. v- G
1 e" @ S2 B# S# Z q, t6 d/* assign the tl som board LED-GPIOs*/
; ~) L3 p/ g1 g0 Astatic const short da850_evm_tl_user_led_pins[] = {
* _) q' i2 Z! A L) x /* These pins are definition at <mach/mux.h> file */3 ^5 }1 v0 |- j$ u6 G5 |5 n; I
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 D" P% z; @8 h" n -1" Q( F4 h0 I6 e/ s$ k$ C" [2 O
};
% }1 Z2 ^* q) m/ Z* V2 G7 @* X; b4 K/ l& r) f0 w( n
static struct gpio_led da850_evm_tl_leds[] = {, W* Z2 G6 {$ z4 @
{7 u S9 A% R5 _$ \
.active_low = 0, \0 @+ X. }: h$ F" h# r* Z4 x; |
.gpio = DA850_USER_LED0,. M9 a6 N, W; z6 j$ Y
.name = "user_led0",
" \0 G( g7 u5 A! Z .default_trigger = "default-on",- f l, v" S; {0 f! p5 a1 u5 j l
},2 c" G& W3 d! o( g( \3 y
{ q# _: ~4 |# H
.active_low = 0,7 e) d! M4 B) ~' `
.gpio = DA850_USER_LED1,2 I4 w/ g: d8 E, a, t i% N
.name = "user_led1", \$ ^+ P7 A, p6 @: F
.default_trigger = "default-on",
+ Q% W* p: _; ]7 H/ d },8 ]3 k: b7 x1 K) A. j0 v
{$ M" g" e- k7 J, n q* ?9 K8 T
.active_low = 0,; q- y! c$ W0 ^) W
.gpio = DA850_USER_LED2,
1 g' I+ j6 E/ X9 `# } .name = "user_led2",
$ T- s7 ?+ s9 \. y6 ^+ ?, c; d- _ .default_trigger = "default-on",
: ]: r. R U% F# r& V },6 o! t4 @9 H0 j, c
{
2 \9 {4 }9 Z/ }7 m& d3 j/ e7 {: z .active_low = 0,
! {$ S$ \) Y+ G- D& }, { .gpio = DA850_USER_LED3,' J- m: A) F: D/ [" e7 L/ V
.name = "user_led3",
/ H( c6 Q0 Z4 q' _( [: V" m5 X- K .default_trigger = "default-on",, V" D+ D% D E u1 U
},) a' G% c* m4 A0 v
};
. g8 U7 ^% Y( u( A5 x
" W1 T5 p! F! ?" x: P0 C% mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 e: U# R; h6 S/ n! B .leds = da850_evm_tl_leds,
3 H7 f" z# G$ O+ r1 Q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" I* c" I3 I! ]5 a; q};$ s! W. d2 z; L, y& f
5 r- G& f! l: W& l
static void led_dev_release(struct device *dev)" H+ C J0 A. b O( ~: k
{- N6 G" s& `8 Z" X
};3 X( I1 u5 [# ~$ ]- s0 z) ^+ y
/ C) j9 h; X4 f2 O
static struct platform_device da850_evm_tl_leds_device = {
+ H) W3 g, j, [8 R; _ .name = "leds-gpio",
! z7 U# B4 F% X& ^; ~. j0 L .id = 1," v2 O" s. ^! r, T" a4 `
.dev = {
; x$ c- l. c1 t- U .platform_data = &da850_evm_tl_leds_pdata,8 _/ v& _# Y: U9 F" g; G: u% d/ s
.release = led_dev_release,6 Y& r! @, b5 T4 w2 v& r' Z% @
}
, F1 O& C+ [. I. K6 U' w' m};
' ~, e: `# o( ?0 h4 K0 b* S
- v5 n: C0 ?: `. G3 Q7 [( j) M, A! E# ustatic int __init led_platform_init(void)3 f" |! C: Z3 Z. @! I
{
$ J' ~+ I0 Q+ [- p F int ret;2 l# w# C7 ?( E! s- h. n
#if 0
) d3 T- Z, B% t& Q+ W7 ] ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 l2 Z0 ^# G4 i1 m) @ if (ret)1 M( M2 ]7 E8 t# J! `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" S$ M& ]& J5 w8 w' s6 _+ D "%d\n", ret);1 L1 @5 o, P2 _6 k: [& N+ x6 `
#endif$ W+ A; m* F6 ]/ i/ y9 i
ret = platform_device_register(&da850_evm_tl_leds_device);( X0 s# z) y" l( P' V$ n
if (ret)
, R0 A( s, K) R1 ^ pr_warning("Could not register som GPIO expander LEDS");* n2 I0 t, ]3 B
else: z- v$ B6 C4 S$ i, f1 X
printk(KERN_INFO "LED register sucessful!\n");
1 N, T7 h# [, a$ g7 G& }2 m- k. m' w
return ret;
& b' J& P& ], C8 @$ W, C- U( Z: ^) ^}
% q, x. @# M# J/ I, c) @: L A! ?) h/ ~2 w( p
static void __exit led_platform_exit(void)
- D2 Y `0 ]( w2 H2 Y( F{
5 w& q2 N3 h/ J6 A) n9 k) H$ W platform_device_unregister(&da850_evm_tl_leds_device);7 N: N9 J- ~6 I6 F0 U
# r+ N& X. ] t6 O printk(KERN_INFO "LED unregister!\n");3 F8 s5 t8 B; T: f
}
; N# i. b g, j$ H# h; o. w
: d# e0 ^$ {$ a2 S' emodule_init(led_platform_init);/ g3 _7 I0 \ C. r
module_exit(led_platform_exit);
9 ^7 l3 I# [2 \. r$ z1 a+ B3 d& {9 K7 t9 c
MODULE_DESCRIPTION("Led platform driver");
4 s6 t3 s$ g7 W+ ]0 ~+ @MODULE_AUTHOR("Tronlong");
+ X, s, J' E. U; a8 A, NMODULE_LICENSE("GPL");
+ ?/ L# e. m. q: I
- m3 [/ ^. t1 B. K |
|