|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: `1 ?7 A m a" I#include <linux/init.h>2 r& v' x/ K" Y- E6 R
#include <linux/module.h>
+ u& J" V+ l2 U#include <linux/kernel.h>
: C' Y0 R+ ]( |3 S+ J#include <linux/types.h>
7 s' ~% O7 E* X0 N: D4 q1 ]1 G#include <linux/gpio.h>) A- [1 `, L5 r" g3 I
#include <linux/leds.h>! g2 o/ G# g8 o
#include <linux/platform_device.h>
' Y: ]6 T2 h0 j- M5 z9 F3 o1 ?
, I5 f% l* m, g& U#include <asm/mach-types.h>
/ n: ]- k! o% W ?# z#include <asm/mach/arch.h>
/ T( J' R/ `& H#include <mach/da8xx.h>
4 S- Y! D* F( P" Y+ T5 b& f. c# ^#include <mach/mux.h>8 R5 l' z& W' R( s
% J6 Q, X( z$ P# |# Q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* x8 F9 u3 m) M1 x6 ]0 {. s6 Q1 T6 c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 s5 }+ v! S9 \, b: w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ d* o: W8 i- _! }' d( ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- l; ~. q0 w6 ]$ o" ~$ v
3 P8 m3 K8 p/ ^/ i' S/* assign the tl som board LED-GPIOs*// b1 M+ R, ^* {; v8 I
static const short da850_evm_tl_user_led_pins[] = {# j3 J/ X, A" z& N
/* These pins are definition at <mach/mux.h> file */! T; a9 b) S4 c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( B# ]4 o0 L" @0 A5 b4 |7 H
-1
! \( ^ N- ?% h- S% f};" Y3 j4 ^& p0 x8 h. A/ X
+ n% T4 L* y9 M R$ _$ O/ C8 B
static struct gpio_led da850_evm_tl_leds[] = {- P. r2 ?! U; j1 g
{7 R8 \0 i( Z6 _
.active_low = 0,
7 M+ [* X4 H7 m2 m$ M0 y .gpio = DA850_USER_LED0,
/ x1 ?( f' o7 `, P3 V; s .name = "user_led0",+ H# F% D% U9 h& I
.default_trigger = "default-on",, [& ]* f5 z0 F1 E" D f6 a
},
& H& c; k2 F/ Q [ {
' g7 ^/ y& `/ n .active_low = 0,
: j$ `9 }/ @* q .gpio = DA850_USER_LED1,0 i' k% N" L+ ]
.name = "user_led1",
* t- |9 x; C( f b- a .default_trigger = "default-on",
$ M) j+ K. D1 c6 d. ~ p# B0 B; Q9 z* } },
0 B% k C7 c# x% H( L3 ]! w+ V, x; n' C' x( ] {
! I. s" a' c1 r% P .active_low = 0,; j' c: S6 I1 I
.gpio = DA850_USER_LED2,
* Q4 P7 _! Y) z9 ~, {: s' J4 [ .name = "user_led2",
7 d, q' X7 X- n% b .default_trigger = "default-on",
9 t, V! \* j: W7 _3 u },
7 g4 @& Y* [2 `3 }3 l9 _* Q7 u+ Y- b {
2 b: T( @6 @% R- t* F4 |6 I .active_low = 0," F7 e) ?) w) I8 w
.gpio = DA850_USER_LED3,* O B/ F1 }" l2 r8 ]$ b X
.name = "user_led3",- @5 b7 G- O6 W- r2 | f
.default_trigger = "default-on",
) F4 l/ Y5 k b# ` }," R; Z5 y2 r$ N6 P. W* Y3 I! ~% j
}; M D- c" x( W1 G5 O8 o, i) J% s
T5 D1 o( j! o
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 I/ h3 \0 ]# V' s+ {
.leds = da850_evm_tl_leds,
: g. M) p; E$ K' X9 z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% W4 n% }8 ]" f' f0 m};# n( \2 z( K' O9 m# D& J+ K! h; K
9 i0 ]2 X; l0 w% V! m, A) H2 jstatic void led_dev_release(struct device *dev)
3 a' h8 d i) ~: o$ K) ~! L1 F{
1 c1 Q& J8 R3 ?) f! [% K};0 b+ L" B4 s) c3 ^
2 m/ T9 b/ _) ~ L* l4 r2 Rstatic struct platform_device da850_evm_tl_leds_device = {2 N O( G: [0 F. i
.name = "leds-gpio",
! C5 k4 ^' X. ?' d .id = 1,! k/ _0 E/ D2 L/ H& M: c
.dev = {* Q' ]6 L( L5 Y* {% _
.platform_data = &da850_evm_tl_leds_pdata,( d1 I# {( |' U5 C; h a ^
.release = led_dev_release,
/ z5 N1 n. F6 M) [ }
3 G/ N# b+ ^6 n) p# ?};5 l9 @, `; P6 u. _
1 A' B H$ k+ `; z( S( e
static int __init led_platform_init(void), d: b- h4 |2 D; u: Q* s
{) A _& n% K( C e- ~1 Y
int ret;
$ M1 [* i6 _7 k& R. x#if 0
% j5 ^# J2 h3 P* e2 C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 G2 J+ A9 ~# A9 C( R- \
if (ret)
5 E. L* r# }" \$ X- G pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- L$ J0 u; w. p "%d\n", ret);
, @5 r7 D+ @" B( z4 I#endif
% M9 X' k$ R" W D' I* j ret = platform_device_register(&da850_evm_tl_leds_device);
1 {% b. X6 K, G# C4 N1 M5 A9 v if (ret)
. Y% ^1 m- N% Q& X) V8 F" C pr_warning("Could not register som GPIO expander LEDS");2 K7 ]# k& h' e, y3 U1 p' l. U
else% A3 a0 i: r D# t3 B0 G! Y
printk(KERN_INFO "LED register sucessful!\n");+ x- Q6 c. R' I
2 t! q9 v- l; w8 ~; f8 p
return ret;" Y7 U) a5 I" W0 q
}$ G5 V6 J" E& H5 x/ ~! Q" g8 L
# e$ e! Y0 A$ s# e" E6 z% mstatic void __exit led_platform_exit(void)
# j- Y' l6 X: n5 l{9 K8 Q8 K/ C1 G2 ^6 C- s% a5 l. g
platform_device_unregister(&da850_evm_tl_leds_device);
, D4 ~4 |% A/ m) }7 @% F6 _ Y, S7 }1 z6 h( y/ {
printk(KERN_INFO "LED unregister!\n");
3 i; w! M' e9 d9 W}
$ P: u! w/ r( d& W. A& M) ?8 j+ w2 h' K8 l, V/ B
module_init(led_platform_init);
) h0 e& }2 ~" W' f6 R9 f2 O( P/ x/ umodule_exit(led_platform_exit);! [3 \5 |, B$ m- F
; ^5 B+ m% p: uMODULE_DESCRIPTION("Led platform driver");1 b) @4 B1 g2 {$ S
MODULE_AUTHOR("Tronlong");5 G/ F( w% [% Z& N/ {! S& {5 N3 n
MODULE_LICENSE("GPL");
, X5 l. c6 l& N. W; P5 \7 w9 g6 ^: L. G5 H8 P1 r; T9 p
|
|