|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' X/ [; v1 F2 B#include <linux/init.h>3 p- O& M3 N. T" r4 u* O
#include <linux/module.h>
' o$ W; d4 q7 h! w: i+ _0 _5 T#include <linux/kernel.h>
! D' `" i( |$ }" n9 g#include <linux/types.h> q8 O9 W+ o1 x, y
#include <linux/gpio.h>
; B6 ~! s' Z) K8 g$ L#include <linux/leds.h># u1 s5 I+ I' e# ]( g
#include <linux/platform_device.h>; d2 h6 H1 W4 z
# i2 |5 X: ? F5 Y, z; w
#include <asm/mach-types.h>; M0 s7 b) T- K8 M4 C- C3 A. y6 l
#include <asm/mach/arch.h>. M. h' d& d& K
#include <mach/da8xx.h>8 r9 t0 @$ A" [2 B
#include <mach/mux.h>
4 S9 W: H/ v/ v/ ]8 \/ K/ v
- @9 |) \) i! z9 j- o. K0 Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" C: U* i3 `0 n" J3 h
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ D* `1 x& j. w7 Q$ [3 t# _#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% B( j. b' |! d9 H i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# g$ A7 [2 A. O- K% n
( h' h2 |7 s6 e9 o0 F+ d* m/* assign the tl som board LED-GPIOs*/
3 n& J# N3 ?/ a/ u1 A5 }7 v6 ^2 X1 Mstatic const short da850_evm_tl_user_led_pins[] = {/ d: C. o- z' N
/* These pins are definition at <mach/mux.h> file */
5 t ?" z- g5 \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" S0 o! l2 ~% `9 d+ l, l9 K -1
- M" n B6 W+ z3 X};
( L$ {$ z5 e, ?# Z9 G; w
! }, W* F8 K; R' H! i6 i( Q3 x, ystatic struct gpio_led da850_evm_tl_leds[] = {
! Z1 ~$ }) W, @" K2 Q0 M {5 q! R1 O! @. ^5 F9 O4 ^
.active_low = 0,
. M; I0 k* ?& F& a4 J .gpio = DA850_USER_LED0,
! s" F$ ?# N. y! Q- Z5 e. n; t .name = "user_led0",; n0 K8 e/ o" r; y3 r
.default_trigger = "default-on",# E9 D3 p+ v0 K+ s5 X9 h) W, X
},
: E. Z; U; J1 T/ E+ y$ H {/ D4 E( g2 m6 d) T9 T2 I' O# g f
.active_low = 0,
- q$ ?# I( }' c* \' B" q9 I6 Q .gpio = DA850_USER_LED1,4 L" r* m) H. }: F( N. n- y
.name = "user_led1",
* W, M4 T0 d, K' [9 w: X+ o .default_trigger = "default-on",
. X7 I9 m" S! a& H },
( B' x* t2 s2 R8 \2 U6 z0 ^/ F {0 B* W3 q; b* @: [+ |
.active_low = 0, b% Y3 C; E. Q( m
.gpio = DA850_USER_LED2,. S% W$ ]; w" H5 s
.name = "user_led2",+ t$ {( t, z/ Z' r6 @/ p4 J5 ?
.default_trigger = "default-on",9 a$ k. o# t: n* G* @2 v" o$ N2 O
},* M* s( L; L' B
{
6 B8 H; H3 \: c0 c! V4 g; I/ x .active_low = 0,
! q8 o! g5 o8 @ .gpio = DA850_USER_LED3,% a. N) ?2 d3 t( [/ }
.name = "user_led3",
- x% E" {' x8 P) G8 V4 K2 U$ \ .default_trigger = "default-on",
( e$ z( n$ {$ f1 n) k& }) N },
]: V3 S& a" f Y) K9 a- {};3 i* k. B( U' K; G6 N4 e2 _
$ ^! G ~. {2 |2 |* U& Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 a$ a: H) F8 F$ u: E+ {! n
.leds = da850_evm_tl_leds,4 N2 D( K- @9 s5 ^8 y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# @& X$ T1 C% N- P7 k' [" V0 J};1 y6 i9 F+ v& s: A% m7 w: h
( V' v2 Z& ?# d* t9 q. }static void led_dev_release(struct device *dev)/ l# F D, g# J4 h7 v( Y
{
. k) j9 s8 \# L7 |};% E) D" e9 d6 g5 g1 u6 ?# @
2 [. Z& r2 l5 T6 d" F l
static struct platform_device da850_evm_tl_leds_device = {
' w0 G% v9 _- ? .name = "leds-gpio",
3 @& D0 x! l, ^! ^ .id = 1,5 ^3 W, F, J- R. ~6 ]$ a
.dev = {
( n/ H X7 y( \' ] .platform_data = &da850_evm_tl_leds_pdata,- M* y& ^' |% C$ I2 l
.release = led_dev_release,+ N& c. u' B G) f
}3 K; N4 ~7 B" ?- ~, y
}; f" X) _- n- q) \
+ T7 g' w8 N# A* [ J/ D
static int __init led_platform_init(void), t+ ^! q" g4 J2 y, `9 k" o
{
$ G$ G3 h( o0 a5 O9 b. M9 u int ret;
) I4 [ ?- ?2 S#if 0( f; R( u0 |4 r# `+ j6 H, C
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% J- X/ o7 k7 C# z) [3 R2 A5 m1 a if (ret). A, v3 W6 n/ e1 R. a2 V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 {3 P$ c [; n" F+ ^4 Q "%d\n", ret);
* r3 d( S. y# D/ ]#endif
1 O X @7 f w( h9 o. H p ret = platform_device_register(&da850_evm_tl_leds_device);
4 p% S+ p% |2 |0 q, Z2 `/ o Z- J7 B X if (ret)
- @8 @% ~, w/ T' g& [* l" C0 G pr_warning("Could not register som GPIO expander LEDS");1 z2 J, v- P6 e, W
else Q( k0 V0 W! l: B; @: u5 D) {/ Q! u; ~
printk(KERN_INFO "LED register sucessful!\n");
0 d; j& y" c6 d
" l8 ]9 ^2 W& M8 Q return ret;
4 D' d9 C" m* |- A3 X/ F; w. k1 O}
- z9 |7 e+ C: T. B% y- @/ D; v
static void __exit led_platform_exit(void)! X; i8 B8 X) z8 ?; _; p6 I% k, y) u5 {" h
{
9 X2 W! u" }7 l platform_device_unregister(&da850_evm_tl_leds_device);
& z: A8 a+ Y6 f4 l2 x$ k( }+ w) N, u+ K
printk(KERN_INFO "LED unregister!\n");
' V3 s# ^) ?$ H}# d6 l2 C- g; }6 F
( X4 q$ G3 h4 }1 Dmodule_init(led_platform_init);
3 |2 g: i6 r4 s* v# tmodule_exit(led_platform_exit);
8 e @+ o: P u* F2 R' ]) t
$ A3 f3 F/ b2 X* P. \MODULE_DESCRIPTION("Led platform driver");
2 S' Z- c+ U$ Y0 ? y& i9 e* l! [* xMODULE_AUTHOR("Tronlong");& ~* z- ?. _/ Q) V g! ?' `
MODULE_LICENSE("GPL");9 [+ _6 K" H9 z, N
/ T. L; P5 \+ l) P1 K7 m. R! P
|
|