|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' K4 [$ F* A' \& j
#include <linux/init.h>
; [: D1 _/ A) ~7 S#include <linux/module.h>
/ m3 E9 d) @9 E/ q/ B#include <linux/kernel.h>) L( }& x- b$ c8 [4 Z& a, X1 [/ K! t
#include <linux/types.h>
/ n- I3 B1 S/ ]" U' m. H+ A( v. ^#include <linux/gpio.h>6 G9 d8 u/ ]9 [- w
#include <linux/leds.h>4 e1 c3 H- x8 r% t' z* U2 N
#include <linux/platform_device.h>; H# P4 \3 y, t+ s
7 f( O6 Z) k' K#include <asm/mach-types.h>
) F' f; h) e z8 v/ K2 `: v. \" l' d! E#include <asm/mach/arch.h>
( x& r0 c' c# ~% d#include <mach/da8xx.h>
' S* ?* [ ~1 E7 n3 @#include <mach/mux.h>( ]7 b+ D5 i* x& r" L0 ^7 R
! n$ `- W2 s# Q# E M% a6 w
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ W2 ]0 h3 D- {0 L: i#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: ]9 P& |6 L; g: e- O5 c( u#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
U' }9 z$ w6 ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ i/ G3 r0 A# V& {
5 f2 i$ t, Y0 r& j3 @7 |* w& R
/* assign the tl som board LED-GPIOs*/
( N& {" I& _* V% B+ ostatic const short da850_evm_tl_user_led_pins[] = {- V/ r$ w& M' ^4 F
/* These pins are definition at <mach/mux.h> file */% J, B) O1 s# U0 P$ G. X5 V. Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) `, m; f) }" x6 l. f! K0 ~
-12 h! \6 p) E/ h7 f
};! k$ a3 j; o) t" `* D% G G" }+ d
+ b3 m2 U$ E0 \$ Pstatic struct gpio_led da850_evm_tl_leds[] = {
3 Y1 R" U2 q) _- z/ n/ \1 r# ]1 { {# ]' g) _/ ^( f* }6 @% N+ ]
.active_low = 0,
8 V' U+ t7 s( V; Q& m .gpio = DA850_USER_LED0,* s! `+ x8 p' A4 t- _% x
.name = "user_led0",
6 s4 {, |* F6 w. y& ^ .default_trigger = "default-on",; t, l; G2 d2 `3 D: K3 W- g
},' o$ A! S) G7 o' r+ X4 C( Y4 j
{
4 a7 h* p% }* H7 p" A5 c% C* F. K .active_low = 0,
9 f; K% _" r9 q# Y1 X$ G .gpio = DA850_USER_LED1,' N2 J' e8 a. x# ?% M
.name = "user_led1",9 j# F/ t' e2 }$ d3 J, p
.default_trigger = "default-on",
# [* q1 {4 j7 _; R( o/ o) V7 |" z },
. w* @2 k5 N, o2 S {# l& R& Z8 r0 Q2 i; u+ Q
.active_low = 0,
8 K0 @" ?6 N: ~1 ?) h! t- Y .gpio = DA850_USER_LED2,
5 c& h( p- U0 p& j+ Q+ Q# r .name = "user_led2",. r& l9 s" p. V7 A8 R
.default_trigger = "default-on",0 d6 a8 C! } R- z
},: D5 z5 h% s: l S4 x
{
. V9 c0 J+ z7 \ .active_low = 0,+ i6 ^1 j, n1 ]/ S
.gpio = DA850_USER_LED3,
, N% c7 j2 G" Q' e .name = "user_led3",2 P3 W( L2 f0 G( Y
.default_trigger = "default-on",0 S$ t* o6 L' f' v
},, D0 G4 c8 g7 ^
};' p8 F& @" ^4 B+ v+ Q
' |) [5 e: R) P* A, q& b
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ n4 i! l$ Y0 S M
.leds = da850_evm_tl_leds,$ q' L% @" o; f* F
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 K# _0 C9 M4 i) |" K9 \, {8 X};
2 C) }% h3 e1 |% ^& z" P9 G' k
- R, O& T' L5 x8 Qstatic void led_dev_release(struct device *dev)
$ s0 t4 ~9 E8 `* ^' U8 B/ v" m{8 w9 k/ ^9 _' v( C0 t( `
};9 M' T. m8 L4 L& L b9 g8 p$ P6 n0 j
6 {' a3 S! m' F' p9 Istatic struct platform_device da850_evm_tl_leds_device = {# S) V/ S. ]& C# j
.name = "leds-gpio",
`1 C" `0 `# ]( x% N: |3 W .id = 1,
9 j! K/ r g) k1 O4 @ .dev = {
8 `6 \1 `5 J d7 w$ Q- I* H .platform_data = &da850_evm_tl_leds_pdata,4 O6 s, I2 ~# M
.release = led_dev_release,. E( ~9 n. O# |8 q0 i" {. ]. U
}: @- \- N5 v& o- t- J b
};. `0 _0 L3 }+ K& Y
" b5 J. O* a2 A4 ^, mstatic int __init led_platform_init(void)
^0 z9 k5 f, Q/ ?0 F6 z4 F- |{
! m( v4 n& i$ j! b/ P4 \" b int ret;7 W& S0 k! k" e! o
#if 0
- b2 D, p* T* N/ @7 ]- W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" b* ? n$ d# g$ j0 R. t
if (ret)4 e% E1 F4 b! N2 c% M/ r. j
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' I3 B# T8 I3 p& S "%d\n", ret);
5 e! a4 j+ X* L y3 T: @8 A) l. q#endif
9 |% x g: P* g% m ret = platform_device_register(&da850_evm_tl_leds_device);
' M9 o o# j$ X5 U3 T if (ret)
7 k, F# E( b- Q5 u pr_warning("Could not register som GPIO expander LEDS");1 ]8 X3 J7 U n \3 |
else$ v1 Q/ h. B* k2 `8 S9 C/ c
printk(KERN_INFO "LED register sucessful!\n");
2 Q% M, Z/ `' p6 I" p3 Q" H+ c& h9 }
1 v# }% U8 f4 \' d/ f y return ret;
0 R! C2 r6 E, {, L# k' F}( u& x" W" P/ B! Y6 v. N
+ W7 J/ I' ^, ~, \% T
static void __exit led_platform_exit(void)# @+ `" u6 S) e4 `2 k$ c
{
' w! f2 \- M) Y; U: H7 ^ platform_device_unregister(&da850_evm_tl_leds_device);! i6 i- O a! p+ I5 s/ U8 z
! |! q9 ]% Q. B: _( O/ K9 I printk(KERN_INFO "LED unregister!\n");# j4 [: J: Z/ w c
}
! Z! O1 T, i) r: J# w o
0 k: ] W: D! m m1 ^# B tmodule_init(led_platform_init);/ j+ N+ Y% ^9 I6 r- A o0 t
module_exit(led_platform_exit);9 r- U2 d5 z1 x" w# u
2 h* V; E f7 P- j5 B$ w4 { @MODULE_DESCRIPTION("Led platform driver");2 z' N" z- I! j( @: ~
MODULE_AUTHOR("Tronlong");
& r# I2 g6 ]* [& Y. l/ fMODULE_LICENSE("GPL");# I7 [8 \/ o# t2 W) D
7 v5 ?/ {' m6 ]7 _- u' o
|
|