|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 f8 D0 R5 u/ D% C( v
#include <linux/init.h>% s8 M k5 {6 a- g
#include <linux/module.h>, w; ~6 _5 A! n) A1 B
#include <linux/kernel.h>( a8 p9 ]/ Q: X; w+ R( K
#include <linux/types.h>3 q% y$ j$ L1 k8 q$ z+ ` I
#include <linux/gpio.h>3 V/ W& v# ` f0 y" U4 U
#include <linux/leds.h>
! d/ E/ q4 j% @4 m5 j# e" ]. z#include <linux/platform_device.h>0 M2 m/ D9 H. e+ A l) u8 p1 a
6 V* c0 L( v- T9 J- @2 `) G$ U" r8 \#include <asm/mach-types.h>4 Q) Y* w7 m$ \' h/ z9 t8 Y/ s
#include <asm/mach/arch.h>
. x Y& F: _& Y- y#include <mach/da8xx.h>
9 t. X' S$ B0 C7 @' k% i9 o/ s#include <mach/mux.h>
3 |$ v3 b5 F) M+ S* u/ d, R9 n8 r% V1 `- {) N
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 Z/ f9 C3 }' `( d$ R#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; D" W9 k5 l/ H& F#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# i6 i3 U7 b; E# p#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 l' ?1 S1 g9 [" U
( ~ j% @8 O- I1 }+ N
/* assign the tl som board LED-GPIOs*/. w$ H7 b" |+ S6 W: I: h ]
static const short da850_evm_tl_user_led_pins[] = {
7 h2 v t1 @6 P' P; { /* These pins are definition at <mach/mux.h> file */
" v- a( I9 m! O q# E DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: P$ k* \, A- z e -17 G. ^( ^" V$ H0 ]+ s: n
};
2 F. J: z0 p! y2 l6 U1 h7 [
B/ p1 p7 k5 Z. ~3 p; M3 Z7 M/ Sstatic struct gpio_led da850_evm_tl_leds[] = {7 N0 U3 d5 D( {, J( M6 v
{( n8 N1 X' x; Q& a1 ?; @* F4 g
.active_low = 0,) i4 f5 M+ ]5 C2 \: L
.gpio = DA850_USER_LED0,
, J# k+ P- b: B5 x, x. L% w .name = "user_led0",9 F' _( {! Y! ?0 [; k. \0 J
.default_trigger = "default-on",
0 l4 L/ E' v8 ]" w },
# t4 q; R3 y1 ]* U5 ]& f {; L& A0 P+ e1 `: }* E6 G
.active_low = 0,( y4 M* Y: q& \& S6 S5 }( t
.gpio = DA850_USER_LED1,2 ?6 t3 p) I' N. i9 `6 u7 {. t7 e
.name = "user_led1",
. u7 J% G; A D9 R8 G+ J .default_trigger = "default-on",$ i, O" f0 Y8 Q* C- J* w
},' x' ^% O; Y+ k
{
/ H' d: m# y1 c/ h+ R- p& o .active_low = 0,
0 w& y {4 w. F s+ e- \3 B3 s5 {1 [ .gpio = DA850_USER_LED2,
& v z6 C" E; ]+ a- G .name = "user_led2",/ q9 [$ N9 I X0 S: j! |
.default_trigger = "default-on", z3 r# M2 x$ f" u9 ?% O+ i
},
9 y* X8 q, F1 D1 q: m% f, C {
2 M' G5 L1 {3 w* S+ [ .active_low = 0,
& w. ]7 ?! Y' r4 y8 I .gpio = DA850_USER_LED3,6 z% y5 ?3 c3 Q) _" j# G" q
.name = "user_led3",- ?/ S+ u' h; c
.default_trigger = "default-on",
8 T& R% h, b2 p# V },! t% U% h6 o4 T% o, ~. p1 X
};) b# B' S0 c0 A- m+ o' c. k$ `
1 Y+ m% @3 x5 P! g; lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- A# v- v% p2 \$ h* G .leds = da850_evm_tl_leds,/ L8 @6 h8 G& s0 V
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' n) b5 S P9 {: v: l7 k' l! W
};
% q- A! n: Z7 K4 s2 L- M7 d j& q$ v
static void led_dev_release(struct device *dev) U6 s/ y' y2 A
{" @( X4 h; R* o+ B( x6 V+ }
};3 k- L- C& r. {
; t1 h7 c" v# x. E# i2 _2 C
static struct platform_device da850_evm_tl_leds_device = {) q, o0 r# z. e8 x
.name = "leds-gpio",
2 I: \& H+ `- m R, p* `+ H9 B .id = 1,: W8 F2 D4 i# D t
.dev = {+ ?& ]" i0 w! P- ^, a. u; Z
.platform_data = &da850_evm_tl_leds_pdata,1 S! w3 Y( x" G6 L2 N7 @: J
.release = led_dev_release,
7 D; M) \. {& Y4 d- D9 U5 S }. U% j! b8 M. F# {4 B' g( T
};3 l( Y1 m7 G4 T. O' O% \1 A
/ x6 L) c7 }. s0 E
static int __init led_platform_init(void)
# v5 o6 |5 Q$ o' C6 t{
/ A5 j1 T6 m0 W: O! O, { X9 v1 Q int ret;
8 w2 z. ` V$ G0 e#if 0
0 d/ f. a4 o4 T2 Z w/ g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& F) ~4 Z: f( r6 }& h if (ret)
5 L' f6 k% s, V: G Z$ X# `( h4 ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ K- d4 |0 p! k& R; C
"%d\n", ret);
. w" r. Q: n! ]4 }#endif' i. h* e9 s# c2 b, b5 E
ret = platform_device_register(&da850_evm_tl_leds_device);
8 {8 y& _ m6 P: ]; b/ x4 K if (ret)
' a" c( I# F" \) I8 F+ o9 {/ b pr_warning("Could not register som GPIO expander LEDS");) _/ P) |7 m. o' L" h- F) q6 b
else
$ `3 s: B) \; M3 I" w& b printk(KERN_INFO "LED register sucessful!\n");/ q4 b7 I. N. V
6 M z* W Z t
return ret;
W/ K( g2 ] H}- u3 T# {$ G! n
M, |/ e& N; _- u/ g- d
static void __exit led_platform_exit(void)
: B1 A7 s4 @& Z; D7 u& F9 ~{& z8 v- I+ Z1 w: W& A# t1 L" r
platform_device_unregister(&da850_evm_tl_leds_device);
# Q& Z* y1 b: o* f, v+ k T
# c; {4 ?: E, Y p$ Z printk(KERN_INFO "LED unregister!\n");! ^* D1 o/ r' c6 L r8 r$ G
}
6 |8 }; V: _3 n; i. B; i. w5 L! Z- E% [- e! G
module_init(led_platform_init); E2 x0 Z& H: e3 h6 d! L2 Y
module_exit(led_platform_exit);
3 ?" t" T5 v' `' O7 H& e7 j
( X5 f+ r* n: A3 i/ H% W- ~; WMODULE_DESCRIPTION("Led platform driver");+ z, `. Y7 }6 I H* [% x; b
MODULE_AUTHOR("Tronlong");- l- r* ~6 W" H; p1 g$ d
MODULE_LICENSE("GPL");8 C0 X0 w$ {" h8 Z0 l
0 D( O9 J) B4 D
|
|