|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 e$ V# {+ q4 u6 A; s
#include <linux/init.h>7 c' `$ R0 v' \6 ~
#include <linux/module.h>! f, ^* h& D# j% x. a6 {
#include <linux/kernel.h>8 U% A3 H; E2 [* D9 `1 h
#include <linux/types.h>9 G( A2 w" m" |1 E1 C, z
#include <linux/gpio.h>
: b$ {" Z' f3 h% e- s#include <linux/leds.h>* A1 I# [7 |8 l$ U, o
#include <linux/platform_device.h>
9 V* A7 n( C- r' L4 K2 U
! x+ V" C$ M( s- M: u#include <asm/mach-types.h>
8 s0 [. u4 `% Z% i( |- v4 }#include <asm/mach/arch.h>
" L1 L5 h( E. m#include <mach/da8xx.h>
& r* |% q/ r. }8 F, o#include <mach/mux.h>
0 a( o% ]0 ]" g, h: J2 t5 W7 `
) ~+ G# z* v% |; n#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 [' M/ H2 B$ Y' H3 B! \5 V#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 B% P7 B6 g. ]#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 c2 }( _& A- p" W0 C8 T1 h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 |' ?0 \( E. ]8 P5 I
9 S) B3 R, X% U" H/* assign the tl som board LED-GPIOs*/1 p: h, e/ K( A# m3 H
static const short da850_evm_tl_user_led_pins[] = {8 I7 E- o; b% v6 x+ f. S
/* These pins are definition at <mach/mux.h> file */
! f' R) q# N; r9 |' p+ ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( [. Z3 p7 u; v! Q) `" g v -1" U: r2 c1 _1 d0 t5 {& Z; W1 ]
};2 m7 d( c2 X% {: v, b% [
& k3 D( Z, Q, p7 a6 f' cstatic struct gpio_led da850_evm_tl_leds[] = {
, b& F: b- }) i! A) y1 u {; p7 O: v/ E" m. E6 l
.active_low = 0,% Y7 L( A6 U! ?( i0 ^, n/ B) X5 L
.gpio = DA850_USER_LED0,
% }* p ]. |3 c: a# c1 o) ~ .name = "user_led0",1 L) N0 w/ S7 |) y1 v
.default_trigger = "default-on", L# a, c$ A1 j* S6 P/ R; f- r
},
' w- p: e2 a( h! ] {$ F! G9 |, c, q7 E! t- C
.active_low = 0,
3 B$ O9 J, [- C .gpio = DA850_USER_LED1,
* ~- g5 k2 | c) A* N% B3 k: t2 i .name = "user_led1",/ N) _. d: \2 u# F
.default_trigger = "default-on",
3 T8 X! |9 y- Q2 h4 s! W9 `; u% ? },( J7 h# g8 ^; a7 b3 n# k, ^8 V
{
& Z' I* r4 s6 Z/ H- m R) ^* E .active_low = 0,
$ A# i+ }$ y5 a+ d' Q4 ^ .gpio = DA850_USER_LED2,
3 j' ^ T$ ?, ?8 P .name = "user_led2",
) s2 C0 q: [3 l/ Z+ v. i0 U) j) i .default_trigger = "default-on",5 K! x5 Z# k- ]1 r2 ? D; I
},
# d( n2 ~) Q" h& D/ e {
! M8 W9 L; L* v' o, G* j .active_low = 0,
4 q4 H4 l, z) U/ S9 y( T .gpio = DA850_USER_LED3,% {& t* d" Q) J* |1 t% V
.name = "user_led3",* E$ z7 I7 w- H5 P6 b* I
.default_trigger = "default-on",' e8 H; P8 D2 O8 F; Z. A; z
},! W% }: \ t0 c& w; s7 T
};. {2 ?- F& C% ]) J1 C' i
; Z0 X/ f# U" q9 O' `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { U7 ?4 e+ y) e
.leds = da850_evm_tl_leds,1 d/ m$ _& C" ^+ t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 Z8 i/ W, L( t, I) C5 x9 P};; F, B; ~1 r1 \' Z
3 ?! R1 @) W! k$ n. }1 Jstatic void led_dev_release(struct device *dev), v9 g1 i% Q- u' F1 h) {3 A3 Y# a- J- I
{& f2 m- S; C3 m/ y- B6 G; Z
};
8 I/ q3 g, y/ g" G- U% i/ x; o+ O3 Q3 ~3 P/ [! \# \
static struct platform_device da850_evm_tl_leds_device = {1 S: a' z/ |7 Q: L" b" H
.name = "leds-gpio",& M' `3 B y7 I* _2 M: x
.id = 1,
! j" o5 @% n$ r, [, E .dev = {
+ h3 ^9 j; a/ m .platform_data = &da850_evm_tl_leds_pdata," Y8 d/ B% {* R N
.release = led_dev_release,
, N7 b+ o: Q7 k |0 j- {5 \ }
4 K; j( {4 d1 `4 N* y; @4 G};& S1 O1 P% W& P5 Q# s9 }2 R: K% g
+ ?+ J0 ]6 e5 Y; `# X" T* bstatic int __init led_platform_init(void)
1 n# h X; I$ u9 \& n" ~{9 v4 Z( G- V2 { _5 T! m3 r4 [* A. j. F
int ret;9 }# `, ~4 E4 [9 T
#if 06 [0 H/ W& `! h
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) M* g J. Z. V; E) R
if (ret): _4 _9 L3 @5 ~4 x+ K! ^- W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# K& [1 _3 \8 ?3 L. `% l "%d\n", ret);1 r0 F( D& e$ M% W
#endif' e0 {: Y, e5 M# n, ]+ j* X; X& m
ret = platform_device_register(&da850_evm_tl_leds_device);
. U0 O' \, t! {9 D% W" ~' T$ K1 S- b& s0 p if (ret)
; R) J* I" o i C9 T8 E pr_warning("Could not register som GPIO expander LEDS");
: ^1 y; h! v. p1 o else& D. }; d. x, J9 Z, a
printk(KERN_INFO "LED register sucessful!\n");6 z4 |5 k: Z+ I/ Z, `! v3 y
( _) C0 m+ {4 Y/ { return ret;
/ H& g) g8 D- F) a' \9 j}* `. N9 b: X- G% o3 p
0 ?' c1 }) {# w6 H. A6 W
static void __exit led_platform_exit(void)
9 _4 ^! E: {% ^2 L, c) Z5 \{) u8 j' U: h( R, ~& B; e
platform_device_unregister(&da850_evm_tl_leds_device);
# o9 a% |* G& ^2 d K, j9 e) O
. k( i9 S! H8 @9 U printk(KERN_INFO "LED unregister!\n");6 @/ U1 Z) }* T
}# J- z0 `" x- q% ^3 p" u
( s# N; ?0 B5 e7 O W4 [. r: N
module_init(led_platform_init);
# J4 J! j+ _* d) }3 J( n& b$ ?( }module_exit(led_platform_exit);
( y' z3 v+ g; e/ }6 x, C
+ \" h% _& i7 l% Y- o) UMODULE_DESCRIPTION("Led platform driver");
* ?3 d! F; _! ]- Q. o. e, yMODULE_AUTHOR("Tronlong");) U6 l+ M9 C# }* r: P) N! z" ]; E
MODULE_LICENSE("GPL");
: M' N% ?/ t; {0 ^5 O6 q9 k
4 [) D ~, z3 E9 O |
|