|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 N# Q1 @" N0 {" d! y0 y, |/ ?6 Y#include <linux/init.h>: j9 K3 n) R" B/ q0 f
#include <linux/module.h>% N! O! h7 E' k# a1 U* W9 {& a3 h/ q$ C
#include <linux/kernel.h>
0 o3 ~. n4 K7 a% i' M1 a) l8 _6 N#include <linux/types.h>
1 \( z% @. ?* q: P; Y7 ]4 f#include <linux/gpio.h>
+ B$ f' e# m* H/ U/ X/ Z" n, c#include <linux/leds.h>. r- l6 }& H1 e& X
#include <linux/platform_device.h>
( F* w" _: \. g/ \, J# S; H
. ^9 o( B3 S8 \0 n#include <asm/mach-types.h>& W \! m3 m2 t2 b, d
#include <asm/mach/arch.h>
! N7 i; ?4 l7 J#include <mach/da8xx.h>
$ R# F5 D( G/ h' \8 h% Z$ L#include <mach/mux.h>" J* z# r ~% o
9 U) r2 ~8 C W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 O+ M2 @' {& R, E8 C2 Q& O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: Z, Z5 y3 l% g" d' N3 }7 f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( ^ s9 L* d( _& }* t5 m# e* K6 h
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' c7 u+ [, i! R& t2 B
/ m3 D+ d4 @$ h/ K, Y, J/* assign the tl som board LED-GPIOs*/
! {+ m7 C( j3 o# estatic const short da850_evm_tl_user_led_pins[] = {; E r b7 H/ z E# {5 W. x: v
/* These pins are definition at <mach/mux.h> file */
, K% U) f* ?' Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
a$ T0 U6 C9 w/ T/ Q- | -1
1 }! X3 N' M% K G2 u, n};: B B4 `# G& \1 O9 u1 f' h. W& j
- v/ D0 T' K9 l# D- ]
static struct gpio_led da850_evm_tl_leds[] = {, A; g. V6 @$ j: `
{
3 `: I1 ^0 W. f5 W1 q0 M6 I .active_low = 0, C# D+ _3 O* K& b
.gpio = DA850_USER_LED0,. Q4 I# T: Q3 ^6 |0 H/ `/ S a( N
.name = "user_led0",
8 L, ]* Y$ l7 i7 k .default_trigger = "default-on",
! V: e. \7 v: ? },9 _! v6 _1 M, ~& [7 s% r/ q4 q
{+ M; w# f+ E2 _5 F" |; q: `" m4 o$ B
.active_low = 0,
* Y5 d. J, Z2 u5 o0 ? .gpio = DA850_USER_LED1,+ S7 D5 B0 A+ S- f1 d
.name = "user_led1",! I9 F, ?. `' [) v3 y6 r) l3 B; z
.default_trigger = "default-on",9 P3 v7 L* b+ i. W
},
! S$ i O; `: g+ Q) ^ {0 w/ m) z/ ^2 D8 W/ e/ `. J
.active_low = 0,
6 X6 w5 H# w' h9 c& M .gpio = DA850_USER_LED2,
& ]2 c. d- Y2 B9 | .name = "user_led2",
7 y' t% Q! o, e4 K1 p: l .default_trigger = "default-on",
Q! m- G# r; {( _+ ~8 C },
4 A" I `1 V" d6 Z1 x. i4 R! c {
4 m. a, _9 ^+ W1 V( Z4 ]" R .active_low = 0,+ h: u# w9 [7 R9 u, [2 k( f
.gpio = DA850_USER_LED3,
9 p' \* q& W' `4 U6 v; w2 q .name = "user_led3",
: q) l. U+ o' @! L+ N .default_trigger = "default-on",& s6 P7 D a! G4 ~3 U% @% g
},
! p4 ~8 c8 W' d7 x# p8 ]# j/ H: B0 k};0 ^# ~0 h7 ]) K; t6 Y/ i
% v% R6 R. k! S0 [9 W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 \) s2 X* |! O; u9 R9 h .leds = da850_evm_tl_leds,
2 p9 L$ [. H) j+ a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 v: K, _% l" ~};! f0 W) {( F7 Y5 _6 B- k# ]
, X+ K% i0 k: n5 q7 ]static void led_dev_release(struct device *dev)' t J' Y7 Y1 J5 U2 k$ |: I
{
0 V, T& a8 I8 X/ `};+ U: p/ p! Z0 ^1 e3 v
+ p2 | X2 L- o9 d& a
static struct platform_device da850_evm_tl_leds_device = {; R7 J! X- H3 A9 ^5 ]; D7 P
.name = "leds-gpio",
5 m0 T. m' B0 H- H .id = 1,
; B; H/ w+ n4 L4 t4 {. u. F- A0 B8 ] .dev = {
3 L& q4 ^3 S# G .platform_data = &da850_evm_tl_leds_pdata,4 d& p7 V8 Q1 Z; n- k y( G
.release = led_dev_release,
$ Z& y9 `' O7 L }
9 F6 v# }/ P8 z4 v};5 ~/ ^6 {5 b8 @( @8 b5 B
& l: e# T6 I9 a1 {$ }' g$ R8 F3 Sstatic int __init led_platform_init(void)
) e0 H4 K5 W3 A# A{
; d) D! d, _' J$ a' ^) n7 |# p int ret;
1 w, V" ^. E) Q+ x) C/ C#if 0
: z- R" K# X/ o: g6 C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. c% J0 q. E' S, {, g, g' k' {
if (ret)/ i4 ~$ z% K& g3 Y* o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 s. f9 u- k o8 l$ @
"%d\n", ret);4 b0 B T- e0 v6 G+ j
#endif" H A6 k7 \1 M/ N6 }9 @0 c* a
ret = platform_device_register(&da850_evm_tl_leds_device);+ @$ X3 W. U$ B$ q; h
if (ret)- ?+ t+ S& Q6 `) \
pr_warning("Could not register som GPIO expander LEDS");- l; { G' J: S6 W2 d8 N
else- |. _0 c3 z! h; ^% s
printk(KERN_INFO "LED register sucessful!\n");
3 @, R1 Z9 r. ?' h# y6 E/ t0 h9 j3 @/ D# \* e/ S
return ret;+ D* C' Q1 _# q& I) N7 x
}
$ t* o! U7 a% p
+ A. `, e }' x; O3 s0 Lstatic void __exit led_platform_exit(void)+ T g2 ?$ ?) j1 I# \* N9 h6 l( T4 F
{5 k, i# G! T( `4 p e Z3 k) i- V
platform_device_unregister(&da850_evm_tl_leds_device);! o" Y2 z' {$ ~8 S1 Q- p) W, _
3 M- |8 I$ r6 N% w' t+ B9 M printk(KERN_INFO "LED unregister!\n");
; \$ G+ R7 k$ ^9 u# Y+ K}$ B1 [- K: B, J' P% L3 P4 i
3 Q4 u" P3 s# s2 Z% s% pmodule_init(led_platform_init);1 P' G; R& x9 A3 m* l
module_exit(led_platform_exit);5 Q7 f. _6 _, c0 p& r
5 ^6 J! C5 ]& X* i/ k; ^: UMODULE_DESCRIPTION("Led platform driver");4 p" h+ D. _ E, c. @3 O
MODULE_AUTHOR("Tronlong");
0 D- g6 @( A B4 c" wMODULE_LICENSE("GPL");) _7 S6 @/ _' r9 `
3 a: f& K1 E1 C( i2 N2 X( r |
|