|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 d6 K2 a0 h+ w; c& E) K
#include <linux/init.h>& D! Q8 R6 G& M9 l6 I" E9 X
#include <linux/module.h>
5 T# O+ x9 b7 n) f#include <linux/kernel.h>, X9 s; ~- A( P$ s& A
#include <linux/types.h>, _5 C; z y" M' a! t
#include <linux/gpio.h>
' q0 F; x( n) @8 @3 _#include <linux/leds.h>: P% Z7 v! j! E/ d W' K& s
#include <linux/platform_device.h>9 | ?6 [" J- M
. Y8 ^( w5 V5 X7 [4 |+ N3 `#include <asm/mach-types.h>
6 \9 X1 [, V7 h& P g& w$ y#include <asm/mach/arch.h>4 i( ]) O1 y# i! B6 ]+ a' W
#include <mach/da8xx.h>
5 e. b1 _9 ?$ |#include <mach/mux.h>' ]# D& R4 ?8 ~* t" s: @
2 b; X$ i- C- V- @9 y2 b; v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 A6 I8 W8 h6 ]* [# f0 o
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) {3 x7 x* _% s9 M; u, t+ b
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! U! S+ D. Y9 G5 t- M& f2 O3 v" h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# h, @1 b3 T1 @+ k4 e+ S* n$ ~; U
I, C3 X2 S2 |) s( y/* assign the tl som board LED-GPIOs*/
. H7 U( g5 n$ Estatic const short da850_evm_tl_user_led_pins[] = { F4 s4 o5 i) J' e) O& ^; l# T
/* These pins are definition at <mach/mux.h> file */) t# B* \7 j( } e/ g8 T
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 O; V% o5 J3 Y0 O% A: e -1
1 Z, R- }$ l. H0 l9 N};
; E( I) y* {+ H2 w1 k2 h8 d( F( E1 b O
static struct gpio_led da850_evm_tl_leds[] = {5 f1 U' H+ O p- R
{
! ^* N( d+ G$ J/ }2 F8 n' i. Q( a .active_low = 0,; |* U6 S) b, V {1 P( F1 |
.gpio = DA850_USER_LED0,& v d5 E/ h# R- C/ }8 C4 I$ j% O
.name = "user_led0",
7 _. N% L1 ?. o' \% U .default_trigger = "default-on",
6 @& s8 C4 D; M },
1 t" S1 I/ H; D6 y- h9 p- E {2 [1 I+ h% S$ U9 I
.active_low = 0,
6 a. c: z- U- L0 v .gpio = DA850_USER_LED1, z, g) K6 c4 l) W1 @; P: L
.name = "user_led1",( V& Q, T5 M+ _$ W# \% i1 r$ n! }. F
.default_trigger = "default-on",
, _& M# ?/ P9 I( `9 L6 a6 a* h% E },6 O6 J4 S! @. r. y8 F, G3 b
{
$ E% }' _: w: Y" V5 ]* X .active_low = 0,/ X' M9 q2 W1 U4 w
.gpio = DA850_USER_LED2,
- k& u; f& g; m- j .name = "user_led2",
B* ^6 V6 D* t( p4 w# P .default_trigger = "default-on",
0 J" B9 h! |6 C) {3 u) Y },4 L, L7 r N# z2 f" G
{7 }: z: |$ O. a+ U. V Q
.active_low = 0,
+ x) @! B/ n- f$ M3 v% @ .gpio = DA850_USER_LED3,( F- i8 @4 _; j+ K
.name = "user_led3",: A. m$ s# k$ m0 p
.default_trigger = "default-on",: ~; o( Y% K1 t2 \
},
! ?0 G" e. k) D4 P7 {" e8 l! n};. R/ `# O% W: i( U5 U* y
" k; W* u2 u/ J \/ C; i( l3 m: ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 m( D, z1 Q5 F& \& z/ l
.leds = da850_evm_tl_leds,3 I9 G$ J; I2 W; E2 n& K
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 F# {5 e$ ?+ c0 `7 d};
) S& I' ? C5 ~" E
/ @; f4 _5 p( Lstatic void led_dev_release(struct device *dev)* P& e! q d7 x- E; n3 w+ D+ d. t
{( [: t# H+ S! ^6 {: H" U; B
};7 |; x2 _0 C1 }8 e
8 A$ c% j6 _3 }static struct platform_device da850_evm_tl_leds_device = {+ Q' h) Y6 \# ]# u
.name = "leds-gpio",
8 K7 O# B. x: D .id = 1,: [3 u& W- m+ s2 R( k8 a
.dev = {
* @/ d3 e& v- T9 Q2 H9 m+ L! ? .platform_data = &da850_evm_tl_leds_pdata,% M6 C; E7 k; `0 z3 L2 D
.release = led_dev_release,/ ~- s5 Z2 a' o8 p
}6 N; M# p3 x( P1 \" s
};6 {2 C. ?! L0 ] n0 X
1 `1 F5 c$ Y: S2 ], o4 f* F1 Hstatic int __init led_platform_init(void)0 x* s1 |, ]( h8 j& V4 E
{
+ Z9 v# ?3 X9 _ int ret;0 u2 @6 i* p, F- \$ V
#if 0
) w r2 b6 P$ v* X9 A( i ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, Q/ N2 {0 s/ ~9 i" [1 f if (ret)3 K q( b! U5 W% f
pr_warning("da850_evm_tl_leds_init : User LED mux failed :": ^- A4 x4 b/ v; \7 r
"%d\n", ret);
, z, G7 s/ h6 B#endif
6 k# Q! r5 `+ [3 I; M3 k. { ret = platform_device_register(&da850_evm_tl_leds_device);
& ]3 |$ }- G5 l1 l& N if (ret)1 G+ v) o7 P( e8 L' \
pr_warning("Could not register som GPIO expander LEDS");
# P( F3 G" O3 E else
/ |1 I: S/ Y; x& y, U' u8 l' H printk(KERN_INFO "LED register sucessful!\n");
# O3 P# o0 o. i7 `+ ~
% s6 H" p$ @# N* S return ret;
+ B8 n2 ?6 q0 h4 G$ Z7 f M}$ V& L. h3 Y" R! M! ~3 B
. x: n5 t7 e' _static void __exit led_platform_exit(void)1 v" g/ N8 c! s' L/ @
{9 a6 q+ X& s! l2 ^* P1 V/ Y
platform_device_unregister(&da850_evm_tl_leds_device);6 }* w6 Q: z5 w7 p5 E' q
# u& B5 o9 `* _! l printk(KERN_INFO "LED unregister!\n");
, U: O' j' i( Z. }. W' C}0 _ i6 p0 v. V. @) w8 r5 V. V- m
- S5 {, ]/ L* C- } C8 t) q
module_init(led_platform_init);9 P* _8 C% T+ u4 o" M+ D& m* h
module_exit(led_platform_exit);% S) y A7 ?' @+ P7 Q: |, C7 n
: @1 s6 o6 i. p% j
MODULE_DESCRIPTION("Led platform driver");
$ o1 j. w G' Y: j fMODULE_AUTHOR("Tronlong");
) p! n2 k! }* a1 `) cMODULE_LICENSE("GPL");* o% m7 } N9 O0 @- z) V) T
2 x/ l+ h ]$ I3 j L6 z* o+ s |
|