|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& T- m9 p# n- Y8 _2 i" T @
#include <linux/init.h>
- U- `/ ~3 S) p. r h#include <linux/module.h>1 L+ c0 P6 l9 F% w
#include <linux/kernel.h>% M J+ R) a# w2 s! q) g
#include <linux/types.h>8 F3 G1 X# f3 F- R; w- d
#include <linux/gpio.h>
# D3 G i. B/ W2 w# y#include <linux/leds.h>
3 R$ f8 C/ n8 [ W x' P! W k#include <linux/platform_device.h>
; ^& Z% ]3 M( E" S* v" [) ^
3 z+ G2 _9 ]# \" t; w#include <asm/mach-types.h>
" H y1 O0 |+ R: @#include <asm/mach/arch.h>4 q' \$ R! n. ]
#include <mach/da8xx.h>
) [$ t% k2 C% l+ J#include <mach/mux.h>8 [+ e, K, o( i
8 e, L" F3 H6 J7 G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 C, j( Z5 t1 B! z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% T/ H' l, `, |7 w1 R# B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! X* y" u$ @0 s9 _
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); m7 |, X1 t7 O6 w- \ }9 \9 h
& ^& C" u. u+ s# c( w1 Q
/* assign the tl som board LED-GPIOs*/" H+ H5 u" ~, n% q9 H8 |5 t
static const short da850_evm_tl_user_led_pins[] = {/ `/ g+ [2 K* q% O$ }4 N( K2 ~0 C
/* These pins are definition at <mach/mux.h> file */8 s1 l# [3 @) t! u' j5 k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 {8 @& n& I; t0 c' k0 h8 z
-1, X1 m3 C9 c( k# D
};
1 B# V! }3 |4 T p* F K
+ H( f0 L8 V: a S# J/ T2 Dstatic struct gpio_led da850_evm_tl_leds[] = { B+ H" B: T' P
{
" O& F: N- u Y3 Q6 | .active_low = 0,
4 M4 g) b0 r0 H0 s& }9 f .gpio = DA850_USER_LED0,5 O$ y% O6 o; y, {: T& G
.name = "user_led0",
* U: j& Z- l3 ^1 ^) m .default_trigger = "default-on",# \: t+ J n0 h$ R
},1 k8 F! R {1 r! k$ m, k1 B
{. s# y2 ~* v4 V% \2 d+ g2 A
.active_low = 0, Q: P3 O$ S1 L- N0 U( \+ e% \
.gpio = DA850_USER_LED1,+ V9 J% R1 o3 l5 c. m" Y
.name = "user_led1",
1 E1 P( w) C. q% R/ { .default_trigger = "default-on",% H' a8 _- x7 v( A1 B
},
1 o: r/ v3 {8 Z5 p+ T {: g) C5 B3 i6 n6 v& l
.active_low = 0,
* B: u+ {6 E O: ^ .gpio = DA850_USER_LED2,
1 y! q" B3 i6 H- D1 D .name = "user_led2",
4 I9 ^- w. x$ l& S, d .default_trigger = "default-on",( L/ `; r' j( X0 p$ C# I
},
& ? N4 P% R) P- o8 n* z/ `: q5 j {' N: i/ l% P: k/ X- o/ U
.active_low = 0,7 ?4 {2 Y! g2 I# Z8 s- y
.gpio = DA850_USER_LED3,
W# b5 V% e. S7 s .name = "user_led3",
+ E6 \& C8 p% f6 Z/ V .default_trigger = "default-on",
2 h. O# N \5 f5 ~ },
( R8 {; @! ?) k) D' f2 W' D7 B. a};4 O1 T( W- H3 z. T2 N2 s
, \1 `; ]7 H! _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# c' m/ I$ g5 T7 j3 H3 T; L8 g6 ^
.leds = da850_evm_tl_leds,
& t3 l* |# a6 {' d" S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 K6 k$ t" B0 w5 v3 o4 K( T, Q8 p6 ]};4 j! ~- s4 x! }' t+ H1 p8 o
3 o1 o4 |- o/ |, z& @' e
static void led_dev_release(struct device *dev)
* K& t( f1 ^5 w* J- I{1 L% U% @3 }$ `4 G; J5 D4 n
};
w0 Z, f4 r+ Q" T
8 c2 y5 l/ n- X: P4 [static struct platform_device da850_evm_tl_leds_device = {
' \8 S9 Z- `) h j+ i4 Q .name = "leds-gpio",
7 D/ q1 y0 G: l+ k/ e# V# h .id = 1,+ |- o. N- X7 r
.dev = {8 t; S/ y# B9 V2 ~) \1 p
.platform_data = &da850_evm_tl_leds_pdata,( q2 m- ^1 o2 ?/ ^
.release = led_dev_release,
7 Y& I8 ^# {3 e5 o5 J" y8 d }
7 I4 x- Y, V; c" K};' H' g- Y% \! L4 Q- g, e
! \+ o) k" A! [" z1 K$ }) R) `
static int __init led_platform_init(void)
, ~, d5 S$ |/ e. f. B1 C. z* k{% d4 p- @0 b7 w8 D: v
int ret;
2 i1 D) z1 K0 c' g* d8 L# H#if 0* r R* x8 ]* x9 ^; h5 |% Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( O5 B" S! r" _% J
if (ret)3 g: P- M. A3 x
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", `( O) a) X9 z' S- R
"%d\n", ret);
( b& `3 L$ B! p) s5 q0 ]#endif7 y! ~ k5 ~9 f! q7 @
ret = platform_device_register(&da850_evm_tl_leds_device);
( b, s$ H& \4 M/ d2 ` if (ret)# x' c. I0 e5 G' d# ?. J
pr_warning("Could not register som GPIO expander LEDS");8 c8 y" h% O5 O# i1 C9 i* _2 m
else0 T6 C4 o- T: B( E7 L8 h) l* e
printk(KERN_INFO "LED register sucessful!\n");8 U5 \& c) C$ n, u( P) \
' X4 f$ O' h4 x; t8 _/ l9 k
return ret;
2 T4 Z+ ^) S1 \7 Y6 Z2 H$ o1 H}! y# K- u3 @7 I$ p. A2 @7 p
3 a& {( l5 u' |8 k4 x
static void __exit led_platform_exit(void)9 t+ I" K# B9 ?, |" d1 C! U
{ T5 M+ K1 F# h3 e E
platform_device_unregister(&da850_evm_tl_leds_device);
* E H8 q2 ~6 F: X r- D2 d$ [" a) h' q: x) c" l8 X F, b# h# E* O
printk(KERN_INFO "LED unregister!\n");$ g3 z$ n' V: a' C7 B
}8 w: m7 r1 h# G9 ~2 S
9 q1 X3 N1 \6 Ymodule_init(led_platform_init);
) _, f1 @+ p3 ~, x) R! X) ^5 Wmodule_exit(led_platform_exit);
; n" Z5 I( I: y, ~! ]
! b1 ]9 H9 M1 X. [( T3 i& XMODULE_DESCRIPTION("Led platform driver");5 _: k5 F, a2 c% o9 H
MODULE_AUTHOR("Tronlong");& M6 K9 z$ H0 [$ y
MODULE_LICENSE("GPL");
) }" ]$ A2 E, t' y2 v3 b9 k' R* `8 L/ t
|
|