|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- e; z1 `/ ]+ g( y: c# p
#include <linux/init.h>
3 h7 h3 s1 A/ {" a$ x9 X' W#include <linux/module.h>0 U6 i- g4 u. G1 o
#include <linux/kernel.h>
. ~6 n* N0 ?9 k" p7 e#include <linux/types.h>/ Y& x3 }: }* W! D" v1 Z/ [/ j
#include <linux/gpio.h>
8 f! L F7 K' }#include <linux/leds.h>
% I. a/ f& d/ [8 e#include <linux/platform_device.h>- U6 ?: Q& J4 A' b/ v! ?2 U* N
# j( m1 [2 a: d7 o' x#include <asm/mach-types.h>
+ s7 e4 D! i& J' D, a. u/ M#include <asm/mach/arch.h>
- i/ h8 [2 a% y#include <mach/da8xx.h>2 d& p8 u; q4 X+ E/ s
#include <mach/mux.h>
& G- o; a/ A5 }
) W8 X9 p0 ? M1 B& p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 m! F- D# h0 k2 }; H' R' `1 |#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 `. {6 C5 |. L/ {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! s& Q4 I$ q- W1 N1 q- v9 r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ |1 L- o8 F6 E4 W* p) U; p" @* j1 N7 h# ^
/* assign the tl som board LED-GPIOs*/
o+ `3 e! T% X% O, X+ P8 L* vstatic const short da850_evm_tl_user_led_pins[] = {
: O( Y: X* X5 q /* These pins are definition at <mach/mux.h> file */
# E, S* J2 u x8 X$ h. C DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! b9 k: k9 ?. ~8 o -1
7 U! x4 B" _9 }) @( I7 ^};
- \3 i0 A' f4 a. X0 D! B( M4 }" k0 X/ y. A( j
static struct gpio_led da850_evm_tl_leds[] = {- L+ O7 X4 w$ ~% n
{, r8 E6 O8 {7 X T" j
.active_low = 0,& X, J! n$ U+ W
.gpio = DA850_USER_LED0,' M) A% _4 d+ f' `' v" R" |; ~
.name = "user_led0",
. h* Q9 x7 L4 b9 y f. e( \6 p7 k$ P .default_trigger = "default-on",! u! a+ a& L0 K! d
},
: J* X/ ?- q# j {' K* |$ E. n* J' H8 K- q( |% ^
.active_low = 0,0 O* ]* w. J3 D' i. {. R5 {
.gpio = DA850_USER_LED1,
$ x( x% F/ L/ x2 B" d" `) Q( Y8 I .name = "user_led1",
4 T4 v8 d: x; I2 k9 s: Z .default_trigger = "default-on",! l1 d' b3 f g& W. @" h6 }' u3 x
},
; c: ]( _6 L h0 Y+ C. s j1 q& R! D' _ {
' R" | G+ M, Q! Q7 i .active_low = 0,; q' v: a% H4 H" f
.gpio = DA850_USER_LED2,$ T/ E$ {4 U: x/ ~6 U2 h) K
.name = "user_led2",
* q) g0 {5 x7 A% M- h& N1 X! `1 T% b .default_trigger = "default-on",
1 @9 \" w" ^! a* ^ },
% v0 O" J! Y$ }' q0 G3 t {
* K2 O0 K7 P" g. J, D, c; E! S# i .active_low = 0," l) k8 J0 X) j, K3 e8 L' y
.gpio = DA850_USER_LED3,
; D$ d" y- M) L% r. Q .name = "user_led3",9 X f0 n% K. C3 V/ Z: f
.default_trigger = "default-on",+ i5 [- N- q& F
},
3 J/ b" A4 W1 w0 [};) V3 s! p5 l2 Q: v) x
0 b9 s( V; ~/ u. E. {! Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- b* }. E Y( n% y* ]0 p7 i .leds = da850_evm_tl_leds,9 G3 r+ _2 g" X$ [0 a
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( e1 T" k2 e2 V' g! p; W}; l. N) J3 E5 M, v/ n
9 h& I0 Z0 ^2 Z5 ]) F, Y, tstatic void led_dev_release(struct device *dev)
7 D& a: |6 g" u# X{
5 m) E* G7 U% C4 a$ w0 M};
) R9 j& K& E0 A5 `+ \3 o$ b. I
static struct platform_device da850_evm_tl_leds_device = {
9 k/ v. H! D. I8 |$ y. [1 I .name = "leds-gpio",
" T2 r# n. g( k# U# c: q .id = 1,! C8 D7 v: N; n" A
.dev = {
1 ^: y; r/ @/ c/ J& R! [ .platform_data = &da850_evm_tl_leds_pdata,
5 B" @/ q5 y! y6 j) ?7 P. @ .release = led_dev_release,/ ^. `' y$ g. i1 T# R8 q
}
' b6 H) t Y0 N6 @# V};
' G4 x+ _6 T7 h
# W9 p& F$ x- `; g8 sstatic int __init led_platform_init(void)& T, J- h2 o7 s* r; `
{
$ N5 g, g3 ]7 X3 x* a5 V) [; r int ret;
& t3 ~( W# s* }; v/ o4 x: S) ?#if 0% C* ^6 Z( j/ _7 F1 m; T; Y0 ^' l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ n/ i# i% m5 C; Q( d8 L
if (ret)
5 s) R7 R& p; s7 E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ j# q) P& j3 O" A5 q' l
"%d\n", ret);4 _+ N, i2 F8 Q/ J1 A
#endif8 w$ ^$ X( l/ S
ret = platform_device_register(&da850_evm_tl_leds_device);6 c1 e1 A" z6 e& s( x! u
if (ret). ]1 d& v3 C: ]2 A2 F
pr_warning("Could not register som GPIO expander LEDS");; |0 @8 Y9 l9 ?
else
& J; L* w7 H- o# j6 d printk(KERN_INFO "LED register sucessful!\n");" S2 f4 x+ d- ?
$ |7 }' s& z$ w6 c d: A
return ret;7 a) ~2 E$ s' o, @7 N) A
}
' h P& R$ Q# q7 ]3 I8 Q# P3 I# a& V6 G& ]5 D
static void __exit led_platform_exit(void)* j/ o8 h( C4 ~3 C# b4 P# C
{* q5 e0 K7 N6 q& J0 s) K V' O
platform_device_unregister(&da850_evm_tl_leds_device);: k8 o- g2 K) d- A0 {/ o) d6 T
, \$ U7 H* P5 R0 r
printk(KERN_INFO "LED unregister!\n");+ |# J J: O! U6 S5 D7 ~8 `5 @& |
}* Y! I$ `, E& D6 @! H8 R2 R- [
8 q4 ^* f3 W2 S8 o/ Gmodule_init(led_platform_init);6 w! R( g( E6 E; w. i+ U- }' w1 W
module_exit(led_platform_exit);
' |* ]! a+ _' ~, F4 y5 N
! y& |5 g/ r( d6 @$ G2 x5 ]6 `MODULE_DESCRIPTION("Led platform driver");5 B& R6 z# G1 ~5 n* R
MODULE_AUTHOR("Tronlong");3 c3 @; T. r* u" h1 ]! c* N9 |% K
MODULE_LICENSE("GPL");
! a. X b) |/ C
. w) E# g4 b2 H- f: U# N |
|