|
求大神给下面的程序做注解,请稍详细些,谢谢。1 e4 k/ H$ l/ O+ x5 u9 o0 T
#include <linux/init.h>- N p# `6 _6 |' {& }! Z
#include <linux/module.h>. a. y8 z5 i; j0 \" v8 \
#include <linux/kernel.h>3 K+ k. k% f5 V$ K& _: e" u4 V* M
#include <linux/types.h>
- p7 y, R r4 c8 \5 q# f#include <linux/gpio.h># H( i- ?( P, `/ Q
#include <linux/leds.h>% C7 ]7 p$ j& p7 Z; l! Q% N
#include <linux/platform_device.h>4 w# D: Y; R5 c) o) U0 ^0 T: F( C
* b5 _9 ?) k0 I, ~0 v#include <asm/mach-types.h>! U1 i0 ]* c7 N
#include <asm/mach/arch.h>0 y% A- w2 }, Y* @
#include <mach/da8xx.h>
, B/ k2 P: U2 N! _#include <mach/mux.h>$ T7 }" X( ^1 b- a: W: W- e
& Y3 N( i J1 W' P8 q+ x5 I; f
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- u9 M9 i6 Q, O9 s% r, x: o
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 a, L2 F" T D4 L5 p# f; C
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
B; S+ {+ k& k) D, ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 X, {& i* h: M: z
" A: p5 [% V) V% a* j' E' Z/* assign the tl som board LED-GPIOs*/
& {" E) J( t& {1 P0 cstatic const short da850_evm_tl_user_led_pins[] = {4 h( v/ m) Z5 n* ?5 R$ G. x
/* These pins are definition at <mach/mux.h> file */
' V) e! o* {/ Y. l: V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 f1 h5 @9 M& k/ e }, X/ c; @
-12 P3 V/ q2 Z7 q- @1 C. \+ I
};
# K/ O. ?% R2 W, ^' J; W* ^# t
2 ~- j; H* X% K& \3 w2 o/ ?static struct gpio_led da850_evm_tl_leds[] = {
" L' W9 K! W3 p8 J {
! m1 K# S3 X9 F! i* f* k .active_low = 0,$ h5 ~! x% M% Z% v& O" q
.gpio = DA850_USER_LED0,. f# g; r- \! V+ y
.name = "user_led0",2 M9 J, q" K7 b# o0 V
.default_trigger = "default-on",; Z4 _0 ?2 n9 F2 F
},
2 G; d2 n1 S! k' E# B {
+ s1 `4 w6 M- L4 h( u .active_low = 0,
& `7 \! m5 U" } .gpio = DA850_USER_LED1,
6 e& r. {0 i' o- A .name = "user_led1",
1 F/ E, C8 P; Y9 F .default_trigger = "default-on",
5 R9 Y e `7 F: d$ n },
, _" m6 |% N/ y/ Y {
; O0 k3 F9 @, I0 ^; Q b6 M( \9 g% V .active_low = 0,6 _& ?5 t. V; ~
.gpio = DA850_USER_LED2,! ]3 T) \$ w( U! m7 ^3 n" q5 c1 M+ {
.name = "user_led2",
0 W5 h- |& W# n3 \' e8 G+ | .default_trigger = "default-on",
7 \5 e& U4 D7 I) l0 w; ] },' @" X7 d& v5 F. i& K3 s
{
3 g6 a- n. |7 W! @. C; B! V- \ .active_low = 0,
! A. ^* ~1 N' t5 U .gpio = DA850_USER_LED3,
, i+ M: c7 `& j9 h- e .name = "user_led3",
( \2 }( e1 n X .default_trigger = "default-on",
& l# o4 x4 `, M# s! _/ T U },
" D4 g( C( [" x+ j+ A};
8 c$ Z# ~! ?9 C* v+ f2 l u2 C
4 u& v6 l. s1 ~. I4 k$ M Pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" Z8 g& L0 T1 }5 W
.leds = da850_evm_tl_leds,9 ?4 s! l; W5 ^ a
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ c: c3 u: v9 r};0 K6 l# n N Z, b y2 G- M
$ m C: e' t0 s) a3 A( R
static void led_dev_release(struct device *dev)
! Y* Z* F# f, z( @0 p4 M5 q5 Q{4 c [/ i) o$ \; a; y: O! E/ K
};
5 P) K( @ W* {. v0 X1 p `" P0 C( K% D1 }. @+ j
static struct platform_device da850_evm_tl_leds_device = {; _0 m% {7 R. k3 F" _0 q' I$ P/ s
.name = "leds-gpio",
b' T8 h! i; a .id = 1,/ B* g, f5 s! s, t B
.dev = {
- A7 Z% f( B" S" w .platform_data = &da850_evm_tl_leds_pdata,
8 z5 K5 j3 E5 e! s$ y$ ` .release = led_dev_release,
1 Q3 t, [% Q& ] d }
f$ @0 p! t6 Y# }0 [};
' y3 E: f- T& B% l- W/ Z/ Y' z( n0 p$ _* U
static int __init led_platform_init(void)- s$ A6 q. R& J* {3 t
{
+ c/ A$ w+ u' S( G. _% S) x6 ^/ [ int ret;
2 L( h0 i0 R8 w( J2 N#if 0' N1 U% ^4 v1 y/ c1 F
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& v/ }" B( K9 g `1 v, \& A if (ret)
# z" c0 _0 r) k1 C0 ], y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 Z" c/ W1 n& B
"%d\n", ret);
3 B- s5 l: h1 e# [#endif
; A& O" x, m% A ret = platform_device_register(&da850_evm_tl_leds_device);
: p1 a F( k$ E+ j" t if (ret)
9 n# Z6 _1 t1 v pr_warning("Could not register som GPIO expander LEDS"); y2 y' s% F$ _1 k( M
else
; u' R8 Z- C8 m( S/ z7 v printk(KERN_INFO "LED register sucessful!\n");
3 K U. d( R+ f) f( M1 o6 j }" s
return ret;- A* v. T# u, b5 i& G3 j6 k& V8 a0 A
}
* {) }" W6 x" h- n' A& Y! L0 S' c) J B+ v/ |- R& G
static void __exit led_platform_exit(void)* A; n) N" j$ J% o& \! @
{* n& u; o' q& R1 Y+ F% \
platform_device_unregister(&da850_evm_tl_leds_device);
7 E3 N$ Y( A9 W* N2 |8 X+ H" [+ W! N1 C: a; k L9 n
printk(KERN_INFO "LED unregister!\n");9 w2 Q5 s2 D& {. x
}
& q. l1 e7 `0 o+ C9 p
: a7 O! C5 s" Fmodule_init(led_platform_init);
4 A4 K1 Z6 T" L! j, Q. H2 b. Mmodule_exit(led_platform_exit);( \% r" D6 s" A
! R) ]' r) E, m
MODULE_DESCRIPTION("Led platform driver");
5 I* t- B! @3 j' N, L7 K# x! HMODULE_AUTHOR("Tronlong");
/ ?8 A; }$ Q0 x& ^0 f+ U; m5 G& |MODULE_LICENSE("GPL");- d* N) O9 y6 S9 l& ~
( ]+ Q3 T- @4 A3 }% ?% Y |
|