|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ G0 Z; w5 V3 o' [5 d#include <linux/init.h>
: Y, j8 n" N; T8 n#include <linux/module.h>! ^0 s; x2 Z- I9 E [0 m
#include <linux/kernel.h>6 m4 G) W4 s X! ~8 B5 s# x
#include <linux/types.h>
! J. a# L; n# r* ?+ V#include <linux/gpio.h>; ?' j: M( ^8 d, r9 ]( p$ H/ ?
#include <linux/leds.h>
. j0 P/ ]' r9 l5 i# z#include <linux/platform_device.h>/ r3 K2 Y" ^4 j
8 c1 v; H/ K+ L- L5 K
#include <asm/mach-types.h># t* b0 H+ E, }0 E: U
#include <asm/mach/arch.h>! |+ ^0 \/ z) `4 B) z3 j0 o0 O
#include <mach/da8xx.h>
( H; D* E) e5 Y# j#include <mach/mux.h>1 {' |( i% |: U/ Z
9 o. T+ C: m2 r+ I) f/ \! a
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! o8 @3 |8 D: o. P$ \4 r s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# }0 K1 ?7 ~2 M1 `% a9 Z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% a$ u e0 u. q. u: `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- I# A2 f+ w( `, G4 o
; S, |9 I$ x; z$ C; M
/* assign the tl som board LED-GPIOs*/: ]4 l* o* |' j
static const short da850_evm_tl_user_led_pins[] = {
6 ]# r1 S) n: y( ]4 h, s) {# E /* These pins are definition at <mach/mux.h> file */; D, }" T" J+ W5 ~
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 Q$ @4 v' U1 C& D* @' H -1
4 n: m X) c2 S, R};
" Y6 W8 }5 U9 H( @( ?
; Z" ]: H7 F* b, i1 \' o" v1 S8 Istatic struct gpio_led da850_evm_tl_leds[] = {: U8 E8 s4 @% Y$ n( O! z
{# k+ o* j; ~4 f1 K4 y
.active_low = 0,
# V. c/ s& D- {0 L: t, g$ { .gpio = DA850_USER_LED0,4 V5 R5 C- f: E. l# ^ M' s* X7 m
.name = "user_led0",8 u1 M- `0 q* O! c( m
.default_trigger = "default-on",' s6 P+ \7 U& M. ^7 c# g. y
},; Q- U4 E r" D* ]/ D8 Z* W) n0 U2 x
{
) ~+ r7 ?; b3 e3 e8 p# u2 o .active_low = 0,
! z7 B- w7 d2 I .gpio = DA850_USER_LED1,5 L1 f" D( v- S
.name = "user_led1",
1 b3 ]8 m2 }- s& y% w& r: J! p+ c1 [# N .default_trigger = "default-on",! x3 W8 Y5 r8 `
},, ?# p: p3 V5 r$ Q
{
! e4 I# k) a+ F0 }: t+ s2 ~ .active_low = 0,
2 v3 T' ?' F Y2 r+ V# j: }& X- N, g .gpio = DA850_USER_LED2," r' V4 [! a* o9 V* V7 b8 D1 V
.name = "user_led2",. I# H8 o2 N; H m
.default_trigger = "default-on",! n X5 X# }) n* e, x
},+ Q2 g$ z2 l5 ^8 v
{8 J0 _ d, U& V
.active_low = 0,
1 h/ S7 c' S$ I* y$ | .gpio = DA850_USER_LED3,
9 O4 ^5 q/ [5 k% y' B, g$ l$ Z .name = "user_led3",
: _3 j+ P& `3 T, x* I! n- b .default_trigger = "default-on",
+ D o# C" U- J },6 Y# Y+ Y" Y, D/ z" w: l
};# \, i% `- Z. b7 n9 [
K9 d6 @5 o9 L. l( b) O. ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# v# U& e1 n+ l" F" D8 z' `! E
.leds = da850_evm_tl_leds,8 k# D6 p- d4 ^$ t8 \5 e0 H
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
~% e9 D5 o- B% s6 r, e};% |/ V+ ]0 e! M* M
$ A/ J+ ^* p8 @. Cstatic void led_dev_release(struct device *dev)& x# H0 p$ u$ ~; c
{- ~; d1 Y( z- N$ E" l' B" t: C6 C& I
};
9 h' O( ]1 Y: q0 E9 B
s% W7 e% ^- q0 A- hstatic struct platform_device da850_evm_tl_leds_device = {
2 @" C$ F* C% J7 b .name = "leds-gpio",
( |) z$ P8 N6 m7 `! W/ W .id = 1,
! U7 D: h; n, S .dev = {
( d; U# W4 j# H' _ .platform_data = &da850_evm_tl_leds_pdata,
, O! t* b9 g& Y! H5 n! r$ Q) x& [ .release = led_dev_release,, s# ~8 O6 B6 m T' v! D
}. R; _ ?! P. p, h5 r9 o
};
0 [0 m" s h7 ~. ^# A* k
4 b @( D+ \' u8 ?) a% astatic int __init led_platform_init(void)
: G7 o8 _6 e$ w! w{* S, g5 [; v) m
int ret;
' S& F* w' u0 c8 n! j#if 0
) b; T( P% k. j" U9 r7 D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ p8 z; d" a6 j6 T' K if (ret)5 }( u$ t+ J V, U) z7 b; P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" A9 s5 Q% A2 s
"%d\n", ret);
" w0 y, L3 K4 c/ o! t#endif
) m" f. |+ m. m# a, } R ret = platform_device_register(&da850_evm_tl_leds_device);
7 F! @- c; v1 K- s" `$ u+ _ if (ret)5 F# ?# r4 B; l* z" v9 g% c1 L) m
pr_warning("Could not register som GPIO expander LEDS");
3 L0 m# e' H" G& ^- B5 q else" \7 _5 R) O; O' N! H/ g
printk(KERN_INFO "LED register sucessful!\n");
+ A r$ V8 _# y) A' I* A2 A$ V; B/ P' V
return ret;
' R( |" h4 F- q2 [5 D+ c}
3 }8 K2 z( t2 N* o l. k5 e) n
0 n5 e7 o: w5 Y/ a9 E1 F4 T* cstatic void __exit led_platform_exit(void)
6 L" C' `8 g$ f" L( M{! B9 g" U; o/ \$ l# e
platform_device_unregister(&da850_evm_tl_leds_device);4 r5 m3 \) j x$ g9 h& V" k
4 n; ~4 g: m+ R b% \1 n- Q$ G printk(KERN_INFO "LED unregister!\n");2 y# h* M/ D) I2 ]5 U
}
/ ]5 ~$ j+ j+ \) o- v
" V2 F3 |% ~ z% Jmodule_init(led_platform_init);+ u4 W6 D5 X1 n8 B: q K) b% E
module_exit(led_platform_exit);
9 _3 E: I9 v6 v: \+ h1 R; O+ Q: _+ {: m, }6 R" G
MODULE_DESCRIPTION("Led platform driver");
- h0 N; @* H% O% [3 lMODULE_AUTHOR("Tronlong");; Z8 D! z4 `9 e- i% R: t5 I
MODULE_LICENSE("GPL");
: M& i3 M3 ?* E$ [4 b+ G& @8 T' j; J/ L" G, Y& P
|
|