|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 ]( c4 u- z3 D+ v; y#include <linux/init.h>) V/ T D5 w" Q, O
#include <linux/module.h>
- q* }8 ~: Q0 c" f8 s) y#include <linux/kernel.h>2 y: t' T+ m* |* r7 G. ]! @
#include <linux/types.h># T& D2 v* Q. `; {3 w& j
#include <linux/gpio.h>
/ H) C& v/ x& E#include <linux/leds.h>
; L8 ]/ Y- U2 |#include <linux/platform_device.h>9 _6 l0 R. A [) P( m( q, _
# p: p, a& t- B0 o) J#include <asm/mach-types.h>
4 ]' G: X5 \& E* J) D0 }#include <asm/mach/arch.h>
$ I( S h+ _$ d9 {* f#include <mach/da8xx.h>
3 F& t! c) K" p/ Z) S8 n$ H#include <mach/mux.h>
7 G$ Q5 T$ D' ^* l2 x E, P! N$ `$ e b0 M' v; T! d
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ Q+ z0 J0 S7 O% b; x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% Z. ~7 Z8 H( l: J( ]) m; ^ j% q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 p6 W; c' h. E9 |# A: o5 D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 w5 z' d k$ c1 A, m
0 T9 L2 @$ b3 b3 {' N# J, h
/* assign the tl som board LED-GPIOs*/
$ T6 L4 O/ _0 N( w% q3 ]) Lstatic const short da850_evm_tl_user_led_pins[] = {& Q2 ]9 n8 Q, C1 b; t! j7 o# i+ o
/* These pins are definition at <mach/mux.h> file */
! V ^5 ]+ w( ~7 b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( L6 ]. Q# D) u7 ]# A" T1 c: A -1# Z& J9 G: Y0 P! `' a
};6 N; Q5 U; ~$ ^- c, v3 I" W' o/ b. i
; y3 P: X! X' B! Q8 {# |4 ]static struct gpio_led da850_evm_tl_leds[] = {0 Y8 w' y1 W' w
{: d* G1 S7 T9 L9 a2 m. l" ]
.active_low = 0,
( I4 {9 |2 |6 I5 M) | P .gpio = DA850_USER_LED0,
' N- f: Z4 `" O7 g l; b- t/ H .name = "user_led0",
4 b4 Y. Q9 }9 A4 C { .default_trigger = "default-on",' x- B+ Q& E1 @
},
0 _+ i; X& J. k _/ K {
2 O$ H5 q/ k5 [, u0 {" u& N4 k .active_low = 0,
/ T+ l* W+ o3 o d) y& ?4 P% X .gpio = DA850_USER_LED1,
P; N: @- m: A3 j7 w .name = "user_led1",
6 m" {6 a) R I( l .default_trigger = "default-on",+ g. @; \3 c- G9 Q+ ]' p! p$ w
},
- p3 F5 R4 D, a9 X {
3 K! x6 j' }4 c' u. i .active_low = 0,: G& n2 N+ {9 f" }* ]
.gpio = DA850_USER_LED2,; Z& G3 e. G- K$ t; w' ^
.name = "user_led2",
' E8 u/ y, o6 ~/ V" [. I2 x .default_trigger = "default-on",7 N2 W" X; j" c' t
},
1 R/ x8 p& a' H1 v3 g& L5 X {
, a( d# a& ^4 ~! a8 [/ \8 p. I5 x .active_low = 0,: N- `9 G6 O) X$ b
.gpio = DA850_USER_LED3,
' q/ r) _ `# C: E# f .name = "user_led3",
7 c5 z3 I( k$ z. Z1 d3 i4 H .default_trigger = "default-on",0 x0 x6 ^# `$ F6 f& x* K: G
},4 p- H2 ^) Q3 s4 r
};5 i; V% C% x7 K: l# k& n9 ]9 x
0 b! W0 Z+ K7 @& L; R) r1 O$ L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- X! d5 q* {' |6 O* } .leds = da850_evm_tl_leds,
! q2 j9 e8 B5 A7 a' s .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ x+ [1 `% q/ E) e! K% T8 e) V" W* ~};
! t7 E6 f" ^, H6 c. r; m1 t, B! E1 ~8 M
static void led_dev_release(struct device *dev)$ J) `4 x: P* E8 o0 c* j% K5 e$ h2 X
{4 z& ] n4 g* i1 h+ h5 L& v
};
0 o9 `% Z: ~- v7 z L# y
3 Z/ ?! K! _0 c! E- y0 }1 o$ Sstatic struct platform_device da850_evm_tl_leds_device = {* _# @1 u5 a7 z$ w
.name = "leds-gpio",( ?1 N! M1 p0 m# z. Z+ C! L
.id = 1,
6 A$ I) P+ H8 I .dev = {
) ~6 Q5 A% U4 h* w9 ?: t# _# H1 N .platform_data = &da850_evm_tl_leds_pdata,3 l" a6 p- N0 ?" m( t' G
.release = led_dev_release,
" F5 {% b, P" t! r: y0 u }
0 o7 Y+ E6 z1 R0 J' j};
) v R0 V" m+ P' S3 ~' ~( o8 r, _! ^1 r7 { X3 |9 S4 }
static int __init led_platform_init(void)" @3 ^7 L1 S7 O' c) d
{0 X/ _7 q- q+ N3 G" }# P
int ret;
+ s# U% h z4 U* n/ D# h+ F#if 05 b- ]: s; k" m3 L* P* D5 \
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: N4 }- h+ x- s( f5 A) {# Z
if (ret)
1 q; s: |, z# a2 S K$ p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- U! M5 _& c- d$ { "%d\n", ret); C9 E; L1 `! d2 C' \" I
#endif
$ c7 l+ ~! X7 e& u% A. P ret = platform_device_register(&da850_evm_tl_leds_device);
! T' X- K% C3 A) v8 M# V# q6 ? if (ret)* h+ D2 s, w7 A
pr_warning("Could not register som GPIO expander LEDS");
# ^7 z$ I/ K2 Z7 c; u else
7 O4 T2 Y* v2 Q5 v# x printk(KERN_INFO "LED register sucessful!\n");
2 y4 X( p3 i6 }. ]6 p4 l7 f- ]- V& o* t
return ret;
# G* x1 ~% Q9 l* a1 F}0 R6 h& ~! H! e0 q7 H; s# ?; W
) p% P& k7 T; I3 u+ l8 lstatic void __exit led_platform_exit(void)$ Y3 K) V) ~( g Y( W2 F
{/ C7 ~) s: g2 _) s
platform_device_unregister(&da850_evm_tl_leds_device);
1 f$ y& d* X8 l e; Q3 F4 [% V
3 j2 S7 c# L( b' d6 u S" K printk(KERN_INFO "LED unregister!\n");7 h7 w: w3 n/ q/ b, S% a
}
6 E. {: F6 M. {
; H' d4 A3 R1 X7 \7 T8 M5 ~; j3 Kmodule_init(led_platform_init);
' O; q" p. D0 r8 omodule_exit(led_platform_exit);
! {) Q5 x8 O! D; u
+ b- J# z4 D& q2 aMODULE_DESCRIPTION("Led platform driver");; P6 i7 e5 W. o- L0 H+ M
MODULE_AUTHOR("Tronlong");* r: \# y) A* X* h3 G5 x
MODULE_LICENSE("GPL");
7 Z2 x/ a; Q6 R+ F1 B3 N; g8 ?! w- v1 T* k
|
|