|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) o3 V5 E8 x" s8 P) o
#include <linux/init.h>
& Q+ g9 e" Z" h& m! i0 I2 c#include <linux/module.h>
3 d! H! T1 q X0 c Y) V+ G#include <linux/kernel.h>% M8 |) d/ J# }8 L# h9 r- s
#include <linux/types.h>* W: I1 m/ s8 A; v' y0 q' g0 k
#include <linux/gpio.h>9 j) z# c& f1 P% T' \
#include <linux/leds.h>
" j; \0 ~/ p: k5 A* Y, r& S#include <linux/platform_device.h>
; M e: [2 i- b: }. j1 F \6 W
7 _. ?' _9 k" o2 m9 r* j& |#include <asm/mach-types.h> L2 Z/ m, D9 M
#include <asm/mach/arch.h>- S4 y! F4 g3 O8 l1 r2 Q8 t! ?
#include <mach/da8xx.h>" B( }. I! b' R2 T+ d
#include <mach/mux.h>
& a' C' d. w1 B: a; n/ }' ~4 j$ O3 W x& x
0 S# \/ t, Y! e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ F( A# h1 v$ H2 d) v1 e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ @8 \' F/ W: ]9 v
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 ~* A6 T: P2 b% K% J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 I/ |% O4 j. a9 x( q. i
- N, H, T- C0 s9 C/ Y/* assign the tl som board LED-GPIOs*/
& Q' j- O) P# Y9 n( J/ Dstatic const short da850_evm_tl_user_led_pins[] = {; i+ y& O( ~% Q5 M. K; b5 l6 V
/* These pins are definition at <mach/mux.h> file */
8 ^, W- _+ I6 Q4 J4 y& z. {' q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," |0 c6 P3 d& m$ k
-10 d y: s2 j; r' A8 e: P" c
};) k2 [1 g# A8 j$ \. N
+ y. W4 g W' y& u0 ^static struct gpio_led da850_evm_tl_leds[] = {- A8 Y+ K) ?4 W1 s" J
{
% L- r! ?' j$ J/ K( D .active_low = 0,2 b7 u9 A- N3 [- _- l3 _% _- V% S! H' U
.gpio = DA850_USER_LED0,1 O2 ?* [: r2 T, r
.name = "user_led0",3 e9 K4 i7 Z% D) j# ^" Q
.default_trigger = "default-on",2 Q4 G0 j0 B0 _$ |1 o) t4 c+ Z
},$ A) W* {+ P: P" n X* j. o2 v
{" l' n4 W2 R1 l; w z& ^
.active_low = 0,
1 T* L2 c5 ~( M) m9 Y, y/ q .gpio = DA850_USER_LED1,& e9 q# I3 k, E1 v* z9 r
.name = "user_led1",' C8 o% F* L; Z6 {9 J( `7 ^! |
.default_trigger = "default-on",
! a3 l4 \1 G0 l },
1 o3 }( x `; p9 L7 U {
2 q# H6 ], b8 o# \/ W3 g .active_low = 0,
& e; A' R" ~) w+ h5 r .gpio = DA850_USER_LED2,
6 ~0 Z: v1 g! C .name = "user_led2",
) C+ d2 V# r1 f. L X! E4 ^ .default_trigger = "default-on",
+ Y4 m( \7 n) w0 N },
( \' p k5 ]8 s0 m* z# L {9 P4 D3 G/ m/ B7 k3 O2 J/ Q0 X
.active_low = 0,$ u% v& b( w) ^6 m, T
.gpio = DA850_USER_LED3,# ~) N: x% B- x9 O
.name = "user_led3",- P( ~' _* F8 a' b
.default_trigger = "default-on",1 M; G0 h5 m8 `) M% a" l& \
},
& @6 B& ^6 i7 |6 ]2 y* B};
6 l. t7 b8 T" q- X$ n3 O
) Y1 s( R! p8 Y, zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" c; S. j( ?( D+ P5 `: ? .leds = da850_evm_tl_leds,
) m. w6 b4 f* J .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 F& o0 z) h" i. f }8 R8 @
};6 I2 P, s4 s: T9 _, z' x
: A9 H! b) T2 k; L9 [9 f
static void led_dev_release(struct device *dev)
4 X% _, { V( z9 ?. z2 D# N{
) G6 F) |' z* p" o; w};: l5 C& s/ }8 s. G: E. n ]+ s
3 j/ C+ r! x2 g" N0 E
static struct platform_device da850_evm_tl_leds_device = {
3 `! s0 e: r E6 I k .name = "leds-gpio",7 Y' y; ?! R+ @, Y- B1 ]2 i
.id = 1,/ y4 z, e. D" |# w
.dev = {( I% ~# o6 Q: K. d4 v1 U: m; M
.platform_data = &da850_evm_tl_leds_pdata,
2 E' |' y( L( F C, D/ ~' R$ K: y .release = led_dev_release,
, Y+ P1 M' @1 F }
7 l3 {) i# A* V};* P- W, S4 \: n: F# ^/ Z
1 I$ @% X" Y2 e [+ F$ k/ b8 y
static int __init led_platform_init(void)
6 {& M; J* }4 i{ @6 D0 ]" z1 S8 l. C+ @
int ret;
, Q7 U' y- v9 f _4 h* D8 S0 E#if 0! A7 u; O2 ^ I- w! w9 T; x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 B' L# c: n! L- d+ O3 T
if (ret)
$ H- k4 i; { Y% |7 x' _ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; j7 p3 _: y/ E- n5 _7 ]& Y "%d\n", ret);+ n$ M# U. Y0 |5 J: u
#endif
7 x D3 H8 [8 j$ u ret = platform_device_register(&da850_evm_tl_leds_device);. P; e( ^- G% _6 L" p
if (ret)
6 m, W2 ?9 v1 u" i: ]# }# w7 V pr_warning("Could not register som GPIO expander LEDS");
& S* J; A/ j2 A+ E else
! L0 b1 K0 }# r& b& `, t printk(KERN_INFO "LED register sucessful!\n");
U, a6 m. p/ |) X4 d2 b2 l1 Y1 [5 n% p* S4 L4 H" c! z" `
return ret;
D. o) G5 Z4 P! _}
' B% a6 w+ d; h+ j( e
( O' P3 P) h: r4 E5 P) M" Fstatic void __exit led_platform_exit(void)7 q3 A/ G, h5 `. ^4 g3 m3 a
{
9 u3 E* [+ b1 t, }& J5 G2 w platform_device_unregister(&da850_evm_tl_leds_device);
1 N6 N9 N* [/ v: m; b
$ J4 L4 Y; x0 ]: b- K/ A& j printk(KERN_INFO "LED unregister!\n");
6 `" g3 F _! ^. ~% k3 B}: A: i% R. W. @! R0 `2 T- ~0 J
5 l$ {- \. y( Y0 b& Amodule_init(led_platform_init);9 u' @$ v4 U0 Z2 B$ o
module_exit(led_platform_exit);
7 {+ Q1 d6 \' A( d g+ [4 T1 a- p
MODULE_DESCRIPTION("Led platform driver");1 w" v+ w+ z+ {
MODULE_AUTHOR("Tronlong");5 u6 x# N' I f
MODULE_LICENSE("GPL");6 e- f- U( r' w5 ^) i. b0 x
+ Z2 ~/ [5 Y, U/ A+ G |
|