|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! G) G3 W/ b$ m" e! V#include <linux/init.h>2 M! K: L0 R8 z& o2 v' m; q
#include <linux/module.h>+ H1 x8 G& \8 i9 b
#include <linux/kernel.h>
" n3 H0 _2 ]' F+ E; x9 \: a#include <linux/types.h>6 ]7 J+ c9 A; C
#include <linux/gpio.h>
4 W2 r8 C& Z5 w' ^* ]% [, F5 y#include <linux/leds.h>
6 Y* q4 I5 v; Y! j: Q/ M4 f) S* S#include <linux/platform_device.h>
8 D3 `( K( c! h! a5 W/ H- s# i. N1 {5 [" y4 b8 {; P5 v6 w2 T
#include <asm/mach-types.h>. L) O; w8 L0 Q: U
#include <asm/mach/arch.h>% v) i" R W- b3 K) J! L
#include <mach/da8xx.h>2 J9 K7 M+ J+ Q+ M
#include <mach/mux.h>8 G1 l$ P1 Q+ B: A8 t: y; R
" |1 d8 {4 O, O, n& y: ^& w; r, D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 c% l( n9 r4 e3 U2 s0 K9 e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( Z+ d5 y3 m+ k3 e0 b: [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 z6 f6 @0 ~1 o3 @- G#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) C* O5 ], F6 R7 o4 O6 @
& v; }1 a. n' Q/* assign the tl som board LED-GPIOs*/ _. D7 z# u( E2 Q
static const short da850_evm_tl_user_led_pins[] = {3 Q+ Y4 J. {# h6 X$ Q6 r" U! f
/* These pins are definition at <mach/mux.h> file */
2 W) z: {/ Z5 A8 M DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* L, A* d# S9 `# ^% X
-1
6 R. w, I! H; h& O t, s8 V( c' k6 {+ G};$ E. w% t1 b# ~! L
+ Z2 d) |& Z3 j. _. Q+ j& ~
static struct gpio_led da850_evm_tl_leds[] = {
9 w$ S3 H/ z$ G Z6 Z( T. T2 }' G" B {
! a3 a: ^& ~; k3 v* e .active_low = 0,
# d4 Q3 F) Q7 x0 n6 m E7 T .gpio = DA850_USER_LED0,
& p5 }1 O" \! G8 |2 E* f* W+ D# D .name = "user_led0",8 l) G* ^4 K0 }4 P! M
.default_trigger = "default-on",$ T' q& d4 @0 x- ]7 x9 {
}," C0 t( n# |9 W
{8 W: p! Z% X( ~9 J. \
.active_low = 0,
, `; V! w+ E- C' r7 s- b9 s4 q .gpio = DA850_USER_LED1,: h1 C& j, @ K& X2 o9 X: b
.name = "user_led1",
# L' T- Q6 ]3 Q2 o( a .default_trigger = "default-on", h3 D$ I* W7 ~8 t
},& j1 c. T& L4 D- n8 f
{1 n: d: m2 y6 K" c: R C2 o
.active_low = 0,
6 o( H) ~' c0 Q6 j+ a+ p .gpio = DA850_USER_LED2,% I2 ]4 [! l& e% i7 F0 V7 I% y
.name = "user_led2",
' s0 R* \$ \, ?" \5 l .default_trigger = "default-on",
! n5 _. Z+ B' Y# s, G4 s },
/ H$ ^( B3 N4 U4 ]7 l0 m {& _3 k8 ~ [( O1 y9 g( x- }
.active_low = 0,
/ x) L: j4 T7 x! u' s# H$ c9 } .gpio = DA850_USER_LED3,
y9 R4 ~1 n+ V4 _' A0 t# ~0 T .name = "user_led3",8 E% N2 ` g' j. G! U5 u( t
.default_trigger = "default-on",
- w' i2 b* h& c0 y1 G6 ~ },0 q ]1 }* e8 z h
}; X5 F% P, p2 p$ `
4 p2 }1 b l( P9 {. ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 o, Y1 O4 Q% { j+ a$ @
.leds = da850_evm_tl_leds,
& l! S2 J9 t4 O: h! c: b1 B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ O3 R; @; y2 w8 K% z" n7 g};
( l. H2 z5 @+ o' [) y3 y
g. U) c6 V: d, \/ g4 Z# f9 [static void led_dev_release(struct device *dev) r. M/ ]3 m! m# ]- _7 \
{
: E3 D- n' X% F6 g& B, u1 z+ Y};
+ E( v. {/ w0 V7 [, F5 j6 b1 N D' l. F* v( ^9 S) G! a% m. a& \! A
static struct platform_device da850_evm_tl_leds_device = {
5 s; _3 b/ C) x/ V2 ]) j .name = "leds-gpio",
6 M# M' l% S2 I3 ~ .id = 1,
% \) m5 }" |: h ?$ X! I .dev = {
; F- z, J8 ]! @3 Y; `; z .platform_data = &da850_evm_tl_leds_pdata,
. r A7 x+ k' w/ k- N5 h .release = led_dev_release,0 X; w: }1 v' ]7 L/ h- N
}
6 r% P3 o6 J @& o3 {1 b4 h% E- P% G- d};7 w: s% p% m4 r. d4 u
+ G8 I2 h$ w+ E2 g cstatic int __init led_platform_init(void)) q4 L4 N9 Z0 M4 p( u
{( J+ W' y3 H( Q; h
int ret;
! j8 G+ K$ d+ x#if 06 Q7 [6 T. P: r4 f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! i) a; [' `6 s. b* `, Z
if (ret)4 z3 z: t& C/ C0 F& Y; J8 L# w; D
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& O8 O" i1 t1 R1 M
"%d\n", ret);* o4 s6 K& q# {# T8 E+ h
#endif
& G/ e; `, p* J4 j* c, p8 {3 p ret = platform_device_register(&da850_evm_tl_leds_device);
9 @+ M$ Z0 M! [# M if (ret)
7 k4 R3 L+ A& ~* }2 l pr_warning("Could not register som GPIO expander LEDS");
% l# G w. R0 F0 c/ D6 G else
! ~7 Z) k$ l/ Q; s printk(KERN_INFO "LED register sucessful!\n");
! I' h' P0 C! h5 E) H& M
7 [1 T, U- V0 D& x* u- v6 @( e return ret;; ~+ b; R" L& Z8 k
}+ B7 G8 L# ]0 U
5 j7 N& a/ D" C9 q4 b9 H$ Rstatic void __exit led_platform_exit(void)
5 D9 Q' T* f& U" ~! [2 ?' ?% N{1 J% P, Y0 o% J0 g( c; ~
platform_device_unregister(&da850_evm_tl_leds_device);/ c- Z" a3 E1 F% w
' ^5 X# @1 J7 ]. ^6 Y5 j printk(KERN_INFO "LED unregister!\n");+ D) X6 V S6 r9 P% `4 S% Q
}4 _; s$ W5 p5 O4 d0 |
0 R; `0 K7 L3 m: v
module_init(led_platform_init);
( h: ?( w6 s+ ^; hmodule_exit(led_platform_exit);
# ]3 V/ v: a: q$ y' y! S2 }3 O( f' k* I6 O+ G3 A* b! E
MODULE_DESCRIPTION("Led platform driver");
( U+ b2 A2 I' f3 u. Q* S1 q* pMODULE_AUTHOR("Tronlong");1 _0 D5 M2 J: y6 U; u2 \
MODULE_LICENSE("GPL");$ F- W- I9 T4 z' A# P% X
: L, G/ J) l. g" B9 m2 |
|
|