|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! v+ j* N, W3 L3 q, U( [0 k0 X
#include <linux/init.h>
: K9 [) n3 R" p8 P ~% K#include <linux/module.h>
' w( e. v9 A. o/ w#include <linux/kernel.h>& i7 T6 z# |0 w0 Z( a0 u: [
#include <linux/types.h>7 d. T m1 ^1 A8 [
#include <linux/gpio.h>
" |% | Q. P# K: k: _" f#include <linux/leds.h>
$ R& c, b8 F1 s F#include <linux/platform_device.h>* ~ e! ~( M+ G4 A0 S( a* x3 a0 B M
1 T$ a; _; a( ^, v& w% y2 w
#include <asm/mach-types.h>5 j. _3 k$ |3 h' h* o
#include <asm/mach/arch.h>- i: O8 c, H s' q0 p
#include <mach/da8xx.h>
1 W/ \2 A7 P3 Y#include <mach/mux.h>
' m ^2 X* ]. U3 z; Y4 G. E" T/ T$ ?& P: K1 o" d
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ }- {$ }* ?! w9 b8 ^#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, B5 t9 N5 U# S! K#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 W, a+ `: ]7 h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) d% z; ~9 U- m% H0 @- ], s3 A2 I9 F( v
/* assign the tl som board LED-GPIOs*/
. `$ l `4 V3 P% g3 n# v# e4 d% Mstatic const short da850_evm_tl_user_led_pins[] = {5 @% J4 n1 a7 R% c0 v2 n
/* These pins are definition at <mach/mux.h> file */
. q8 N3 m% N9 d7 s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- j- J4 c2 d4 a7 H" C% {2 r3 x -1! e. K% G( _4 a) U2 |8 z# _+ f& @) U
};
6 \, l' V! a4 ^) ^
3 i: o' T9 y, B+ {4 P0 {static struct gpio_led da850_evm_tl_leds[] = {
& } C' G: A0 C {( I! z, K# u' M% h( k
.active_low = 0,
- K+ T$ ^; b i/ C& y0 V .gpio = DA850_USER_LED0,
1 H! i6 b$ r- g, }! e# T0 D .name = "user_led0",9 z1 s' w% |/ U5 o# K7 f7 K
.default_trigger = "default-on",
9 B2 n5 Z$ B$ ]# L0 T# L( f },( P' R- B# |: h* g
{
2 u9 M& Y* y p: f: g$ r .active_low = 0, _" M% V9 U; e4 d+ e; \& r* G
.gpio = DA850_USER_LED1,& N# H) b1 ]7 u. N2 S3 x7 {
.name = "user_led1",
; D/ y0 U8 m- [' @ .default_trigger = "default-on",8 Q; q, h6 U2 E) m: p: A+ j
},
# z! A; k+ Y. `% h! L {( e. [( y0 R$ C; l7 M( P' }
.active_low = 0,
; k5 [7 v6 ^+ `; C: A .gpio = DA850_USER_LED2,
6 f" e4 `8 w6 e+ u9 y .name = "user_led2",
1 i4 ] f& p6 J. A( H( k4 I0 b .default_trigger = "default-on",
% r& l( ]) Q: T, z0 T+ O/ ? },
. I+ z8 v8 Y2 {$ s* Z6 K$ H8 W! ~2 L {& g9 A3 G9 l& r8 D2 n; I
.active_low = 0,/ d5 T2 Q4 T3 c% k! R. t7 z; Z
.gpio = DA850_USER_LED3,
8 Q; N( H$ Q" R8 j0 @ B .name = "user_led3",) _, n6 w4 Y9 a6 u7 a4 v
.default_trigger = "default-on",3 B2 ^ i5 _1 e, ^! r
},
2 i& N! y5 d0 A* K& m8 }) q) q};
: ]1 h( b3 t) @1 f* m% [
+ _) L. ?8 g7 g. Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 }6 X* @/ K+ l* y8 o .leds = da850_evm_tl_leds,
8 {0 m! v; F1 b3 h* v0 V .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 ]5 L- h9 S, Q3 a+ [};
8 u# k. o! q O+ h9 W. w/ l
5 k. T9 S! | {. C+ L, P- xstatic void led_dev_release(struct device *dev)
) n- A- ^ S% P{" g/ w$ F; V; G/ z2 q Z& g# c: _5 }
};6 ?" ^6 s9 x; D2 A; v
& x8 Y: F4 o/ u. {7 Cstatic struct platform_device da850_evm_tl_leds_device = {5 ~5 x: x' o7 s0 P2 p% j" Z) [
.name = "leds-gpio",/ S+ X! v m. \
.id = 1,% ~0 {0 ], e) w: V
.dev = {
5 i2 `0 N3 o- V2 z! u* ]6 C0 g .platform_data = &da850_evm_tl_leds_pdata,2 p% A1 f4 F; B% s, H
.release = led_dev_release,7 H0 k" q! o6 }! ?1 ^
}
1 O$ t3 e# P8 Y1 C};- T1 ^( J% }/ E$ J3 _5 z
0 \1 d: ~- w+ n( C$ u7 xstatic int __init led_platform_init(void)3 f: Y2 l3 }# V: e% c( ]: p
{
2 v5 m' n. o3 t1 h7 v int ret;
2 ]: d6 a5 F H" F3 @( Q' `' o#if 0
) R6 L' u2 K9 O8 _7 R/ S( n' x! D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 @& j# b; `) J8 h7 P if (ret)/ o6 D" L. F |- n" F% R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( I) o; l9 N5 m" A
"%d\n", ret);
2 U/ ]" d; \- [0 K#endif6 e! k5 W6 s, d) ]" v& K& M3 c; t
ret = platform_device_register(&da850_evm_tl_leds_device);
( ~$ c% b0 Y. Y if (ret): o* R1 e1 ]% J# R
pr_warning("Could not register som GPIO expander LEDS");
4 I/ w2 x0 z1 ^ else0 i K @# E# u0 c$ ?: ~3 }7 F
printk(KERN_INFO "LED register sucessful!\n");' j' c; L8 E8 ~4 A$ I: e
8 o: T+ S8 `: F. Q. P% A
return ret;2 \4 B; j. l9 F! K6 T; v3 N
}2 I: u& [, x. C. [6 k9 h0 k8 A9 u
, {. S- L2 r, X$ j Q' D3 K1 a
static void __exit led_platform_exit(void)) d& p% a8 t9 f
{
) e! Y' ^3 ]. U3 N( [4 V, B platform_device_unregister(&da850_evm_tl_leds_device);* [+ |( _; _2 T
) B, L$ A: N6 r0 I" w printk(KERN_INFO "LED unregister!\n");
3 h/ C! [& c+ i# _$ V1 B+ R w}
8 k- m. r% M2 ?( Y8 S
+ E- G% P( R$ imodule_init(led_platform_init);
, |. F3 m _0 ^6 J& k4 o% q! t: amodule_exit(led_platform_exit);
3 v _8 B* `" q3 r3 Q$ s; b
0 C/ q5 C! b9 Z7 i3 Y0 D* q8 r% zMODULE_DESCRIPTION("Led platform driver");
m0 t0 V1 W' K1 U' ~0 x8 P! sMODULE_AUTHOR("Tronlong");' C8 _0 g/ ?4 [; G0 w5 U6 Q4 x
MODULE_LICENSE("GPL");
3 W2 [* b: X1 k5 l0 f/ X0 q5 O
. [; C" j1 [" s; c |
|