|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% c/ \" a8 Z/ A: H3 f9 {! j
#include <linux/init.h>
& ^. A5 B' ~6 R0 Y#include <linux/module.h>& A$ u S' f$ V" I# i
#include <linux/kernel.h>6 N) Q9 I' f- M3 L o7 d& S( \9 x
#include <linux/types.h>3 l! k* Y7 w- S! G Q5 C
#include <linux/gpio.h>7 K- R6 m* b( C( m) O1 J+ O# ?, w, i: v
#include <linux/leds.h>* b8 n( p6 [3 `
#include <linux/platform_device.h>) R$ A9 K" l' x
6 B1 \ k) {6 w& x$ q# h: \: J1 O& Q( i
#include <asm/mach-types.h>" b5 w4 _: y0 r8 ]
#include <asm/mach/arch.h>
5 S) X9 g. U/ ]8 F. p#include <mach/da8xx.h>! y6 \; m7 ~' ^5 b
#include <mach/mux.h>0 B6 k! I6 s. m' m
G+ E$ Y' i7 S9 R! r, S) N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 d8 p C- E& b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ `( F4 `# `1 s" \#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) i4 W' ?! M ]4 w& E0 b& U% [#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& c9 D& a! H+ s
2 l) {+ O) I- ~& i3 F7 r4 C3 j/* assign the tl som board LED-GPIOs*/
$ t: p5 @1 y! L& G4 {% B- Ostatic const short da850_evm_tl_user_led_pins[] = {2 k% m+ R6 r) l [9 I: U* V) ]
/* These pins are definition at <mach/mux.h> file */
( U. f% z \0 @- {. z' ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* I4 N) f! v, R$ p/ a -1
. I( J! Y z9 p};9 e6 X" k' w% K( T
8 N2 e5 _/ e: g l6 Dstatic struct gpio_led da850_evm_tl_leds[] = {
1 p& O( T4 [7 K& J0 V" ^" l/ p {4 T6 u. v, [1 n/ m! Z/ a3 d& S/ x
.active_low = 0,4 a! F4 E& W- ^
.gpio = DA850_USER_LED0,
9 p9 d% j7 }1 t* b, H6 O Q2 R .name = "user_led0",2 l. E7 y( k- [5 t* W
.default_trigger = "default-on",& u0 g$ ]: r, v/ f" _- b
},
6 J1 i' o/ r- n& _) ^! ~. e3 A {6 b8 R3 i5 S5 @6 r
.active_low = 0,4 B D0 j+ s: I- a. L1 l
.gpio = DA850_USER_LED1,
' h! q2 g6 W; S .name = "user_led1",# K' Y' f% A. b- e% T: P
.default_trigger = "default-on",
; ]1 ]! I! F) a; `) o+ h },
B& l5 u1 h0 c {1 H3 N7 M* k2 H* F% i- g& ^
.active_low = 0,: N$ ^: i# T. V* \: r% L
.gpio = DA850_USER_LED2,# N [( t& @( S/ G' V0 U, w
.name = "user_led2",/ U7 Y; x, i; u7 d3 o& A; w- Z) Y8 X% J
.default_trigger = "default-on",
5 A9 m+ E* x8 u4 U },5 P0 C; _3 {- N
{+ x+ Y: A5 `% \& v8 M
.active_low = 0,, E, Y8 q. f1 I$ _
.gpio = DA850_USER_LED3,* @, N4 \1 ?: }- T0 p8 H
.name = "user_led3",6 V% p& w1 ?4 Z- _
.default_trigger = "default-on",; ?2 z a* H9 p' L( y9 n( v
},$ M4 h; y( J3 T: Z9 k- {
};
& q( J5 l) o7 M! Z: C
0 ]2 V0 j e4 ~: x+ k Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 t+ o: P3 g! Y% U/ V1 I
.leds = da850_evm_tl_leds,
2 B) H# Y; z6 o% y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# T8 n8 a* C2 ^& M};( x- X+ |. s* t4 E# h
3 R5 f+ J, [7 |* W) Q+ |static void led_dev_release(struct device *dev)- u% m$ ?/ m- t9 O: S
{
+ \( c- y# h, H8 a6 @" R};
# \% F w4 F4 `/ l/ f$ v. j. q- Z0 P" j* O J/ k
static struct platform_device da850_evm_tl_leds_device = {$ t5 j* h: r; }8 A
.name = "leds-gpio",
) g+ Y8 f( C+ i3 B3 N .id = 1,: v/ K5 S7 g/ v. C
.dev = {- a0 R# W+ w3 D9 u
.platform_data = &da850_evm_tl_leds_pdata,
& h1 F1 P, L( p2 i2 W .release = led_dev_release,
& o5 Q/ B+ h8 D. _ }/ K) l0 q4 k4 g
};+ H3 c9 y9 t: Q
; N/ t( W; O* Estatic int __init led_platform_init(void)
G( a) p0 k# K: ?8 e" ?{
. E1 W/ m# ]3 p# i int ret; S( `/ t( I" {/ c1 }1 J7 s
#if 0
; b6 o1 p1 }2 l7 U" x0 F( u2 a" u3 h ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 O( Y) @3 |$ ~5 q if (ret)
6 Q3 s2 N6 k& K1 q' T pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 s" g) O5 D L* R* \) r9 g "%d\n", ret);
/ a2 h. z0 t2 `% O: p: y#endif
F7 l" E5 {" j/ H+ h ret = platform_device_register(&da850_evm_tl_leds_device);
) H4 N4 W! e" a6 D3 P) t& t if (ret)
6 E5 k$ \1 h0 e& C2 ~4 r pr_warning("Could not register som GPIO expander LEDS");7 d0 K& W& ~. D5 E; W! u" L
else
# q8 w$ F0 S- W9 d `7 X" N printk(KERN_INFO "LED register sucessful!\n");
$ ?- m" U* L, x7 g- l" m1 i0 E7 ~; Y S" ^" m1 v1 W5 r
return ret;
4 L$ j3 ^; a) s) B8 L- Q" b6 g$ A}9 a, F0 k8 l. y+ \% e' u. T7 P2 r
0 Q. C( v1 w, ?1 r# o; Z7 ?% T
static void __exit led_platform_exit(void)
( U+ n+ \2 Y! k2 ~0 Z/ J{
3 e% N3 D3 e6 h! E$ \# U platform_device_unregister(&da850_evm_tl_leds_device);1 A$ b- F+ y) {' F8 G/ x8 p: K4 t
6 I+ k( j. }! u6 r
printk(KERN_INFO "LED unregister!\n");
5 F8 w6 M4 I" K7 f}; W3 ~) j7 o% g# ~' w
2 j8 ~6 v% s6 ]& Z6 ~: D
module_init(led_platform_init);$ J# J4 M& ~9 w' f, ~- R
module_exit(led_platform_exit);/ i9 [5 `$ p: b: i) l+ F8 T9 l( {- M. Y
8 ~* ^; E) e9 R6 ^* |MODULE_DESCRIPTION("Led platform driver");
" r$ o1 M& c, `& OMODULE_AUTHOR("Tronlong");
+ [; R/ S5 j* [0 i4 kMODULE_LICENSE("GPL");
0 {2 J: h7 s" ~+ A# T4 _# a
- w: W' l! K }+ c# y: a! [ |
|