|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 O" v* o5 P# b9 r6 m( p- x#include <linux/init.h>& Y$ S# R! @7 [5 ^. p# \9 O
#include <linux/module.h>+ @ @& o# R# Y! K
#include <linux/kernel.h>
& y% P/ t2 j+ {7 z: |9 C#include <linux/types.h>
3 p! P+ Q" D g7 {( Y" i#include <linux/gpio.h>+ S6 z) j7 X7 f: K+ p+ v9 g
#include <linux/leds.h> o3 w7 H; w- @
#include <linux/platform_device.h>8 `( k. L1 o, `& u4 \7 v
+ s4 v; [3 O9 a6 A ~8 Y#include <asm/mach-types.h>
- m; L9 n! c9 t' q7 Q6 Y#include <asm/mach/arch.h>
4 w' w Y) Q& w5 V#include <mach/da8xx.h>; ]/ u+ `1 x5 F) U/ V7 l* Q
#include <mach/mux.h>' D$ S& f+ x/ V: i
1 O% U0 \' G+ m
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& U' z0 |6 a: [: T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- M4 ~" l3 G+ D- S+ B' T6 Q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) J9 G5 d7 M' m: z! @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 N( a+ }- |/ M' O$ x `$ }9 b1 ?3 ^% X# s
/* assign the tl som board LED-GPIOs*/
8 T1 J/ Z* c9 @" z e: Rstatic const short da850_evm_tl_user_led_pins[] = {; d) n# b7 o. Q& A$ r( }3 _
/* These pins are definition at <mach/mux.h> file */$ e8 y7 x$ R! w/ y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ w4 m" o0 d4 s
-1
& L5 |# v; J2 U+ c5 K! R$ k};- ~% m) I. [, L
$ x3 m- E* `+ g# y/ y4 S. ?" ~, ~
static struct gpio_led da850_evm_tl_leds[] = {, U: D$ Y5 s |: d4 r. s& \
{
6 X: m& b! n3 C7 K* y .active_low = 0,$ j) M! x/ l, w2 k* U
.gpio = DA850_USER_LED0,
# l$ n& |" e5 k3 @4 ^& x c6 M/ G3 Q .name = "user_led0",
+ F8 n% m6 |. x$ b1 B- w .default_trigger = "default-on",; q$ A8 n) }2 r6 _' M7 D4 m8 ?) x
},
; |0 l2 f; v0 @5 A {
. d! i+ h6 U4 q j .active_low = 0,
7 U. H0 c" m5 J0 \' } .gpio = DA850_USER_LED1,9 o" ]; @( g, _9 u2 j
.name = "user_led1",3 t9 P: g2 y, X
.default_trigger = "default-on",+ ~; n7 k# Z! w) v- I% a! d
},. W5 M; Q- X# B. d5 S
{
0 [; y8 p: @' N) ]+ ]. x' e+ c .active_low = 0,) G) V* h6 O- `
.gpio = DA850_USER_LED2,
+ O% M2 D: C0 L/ |- u5 n' s .name = "user_led2",
# O9 I" {- E: L) z$ T) j9 [; d% w; H .default_trigger = "default-on",( D W6 J. ^( B7 x; d) I
},
5 i4 ~; M: K: a7 N2 I% @- `% a {) c. Q+ ]# ?. o1 u1 O0 z$ M
.active_low = 0,4 o0 u% V( Y. v6 f7 H, a) K
.gpio = DA850_USER_LED3,
+ d+ @4 v" a8 A+ {& T .name = "user_led3",. s4 ]% z8 q9 X
.default_trigger = "default-on",# n1 ?' o' S0 p' R2 w* a3 _. x
},7 I- ^& x" \$ G' r
};
5 [5 D2 O& r0 s# z6 W/ Y2 p. K* O) Z4 n+ d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 B1 o" a6 V9 b* x) O4 u .leds = da850_evm_tl_leds,% W& L/ y, C5 y3 o! R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& z1 |2 Y/ J) Q4 B6 S
};' t0 @) ?% A+ T4 W t4 N/ B
2 s! m; ?" p( y ~! C9 Hstatic void led_dev_release(struct device *dev)+ N" ^. Y. v! A% Z$ m, R
{
2 x- e1 `' }& C1 ^};
7 w* w q" L5 C7 q- `0 A$ m% s% a+ Y7 q
static struct platform_device da850_evm_tl_leds_device = {
- J( Z1 K. ^1 R0 p .name = "leds-gpio",2 [/ G9 y% x& T4 k. T" v
.id = 1,
v3 c! F% S% o, _( T8 V4 m .dev = {" W7 l" a/ h7 F; ~- V0 X; K
.platform_data = &da850_evm_tl_leds_pdata,. F- A# [. k3 J
.release = led_dev_release, \% h, @, e! M5 A; b
}
' c# o8 f; e6 k1 h- |1 B( z};* O8 m/ K3 i1 r
4 [6 L( l% e3 t N, ^" h
static int __init led_platform_init(void)
3 C& c$ Y! _( v C$ J1 Y) M{% C9 i( G0 V- m/ B) {. P; Z
int ret;1 j% b: E) E6 S5 p5 P
#if 0
" r! @ T9 U" z- M- M, A3 T ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ V1 {4 a) u3 @
if (ret)
' S" R! s+ @( E @4 t6 r pr_warning("da850_evm_tl_leds_init : User LED mux failed :". @3 q( a; o7 Q. c& y/ v" l* `# u
"%d\n", ret);
4 w5 ^ H+ W4 J/ ^4 a! ]! [#endif- W; E( B+ H2 k, h0 x" G
ret = platform_device_register(&da850_evm_tl_leds_device);. o/ t+ A, B6 e1 T; n
if (ret)* q! {7 ` w' P, z/ d
pr_warning("Could not register som GPIO expander LEDS");) N8 r: |2 ]5 s& h) a
else
4 }( D, y& h1 W6 [ printk(KERN_INFO "LED register sucessful!\n");
8 k& T& a+ ^% b/ H3 h" |
! ^. G# X5 H0 `/ F return ret;
% V8 H7 W, v) Q* d' V2 X5 O}$ [* v$ ^- O/ O
4 h. F6 i4 J! O4 E
static void __exit led_platform_exit(void)
1 C% j- _( V8 l2 r* X' f$ g{
- y! H6 Q8 C! p, M0 H platform_device_unregister(&da850_evm_tl_leds_device);
) p5 _8 t# I1 o- g0 G; \7 b' i# R2 x; d. r0 g: K
printk(KERN_INFO "LED unregister!\n");
/ _. c- d' m# o}6 l1 c% G, B/ ^. l! ^7 g& x
/ S& `9 f+ \2 s3 x) A) Smodule_init(led_platform_init);
( |& O6 n7 f% a ?* `: Pmodule_exit(led_platform_exit);5 ?$ ]- d( f6 {4 s+ B: Z! }
/ D$ v0 _" R4 H* Y* G6 W2 f/ B
MODULE_DESCRIPTION("Led platform driver");' A1 v) q4 j; s Z( v5 U. N
MODULE_AUTHOR("Tronlong");/ |+ D6 g: K. B- p0 I3 d
MODULE_LICENSE("GPL");
) L9 K# G% I' Z0 l7 |4 X+ S- j# J8 l8 ?$ K' H3 t! }6 F6 }6 \: h
|
|