|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: v; R: c# e2 v. w# t0 p#include <linux/init.h>3 c2 v1 N- ?8 t7 C, \- K
#include <linux/module.h>
6 \7 n' C+ a8 X2 O' r3 n d" x#include <linux/kernel.h>$ _5 f& [0 f; Y! Y
#include <linux/types.h>1 O( D- s/ u* x
#include <linux/gpio.h># X7 N1 Z" h& T0 \! W( `& C
#include <linux/leds.h>
) v s# G' i5 d( Z9 c4 J+ d#include <linux/platform_device.h>
/ R1 \( I; ]- r* K0 n U& Z& c0 G" k9 D. s! J
#include <asm/mach-types.h>0 ] m! l$ Y7 l: P/ y
#include <asm/mach/arch.h>
* s& W j8 \. o' [: t, v& n#include <mach/da8xx.h>' L3 b- P2 n' A3 O1 b
#include <mach/mux.h>
2 f5 H8 ]. i# f. K" ^: n! f: V$ Q ?5 U% A% k
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% e! W6 I3 Z7 S7 Q+ b# b5 y7 {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 q8 Y9 {+ H# }6 ^5 \" F
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* P* e9 r( \0 F& O5 n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! D m2 e5 {" u; S; n6 ?3 o2 L% ~
( @2 c2 m, n& M3 }# M. M+ Y/ {
/* assign the tl som board LED-GPIOs*/
: l) I; H O+ n4 \5 v+ e8 h" kstatic const short da850_evm_tl_user_led_pins[] = { d" V& h- x5 }1 q
/* These pins are definition at <mach/mux.h> file */: J0 L6 C$ H0 v; [, U; ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ n+ r. O% a. V- p7 P -1$ \( [4 P5 J! u5 U. g3 @' j
};
; F; J1 o4 P5 {6 R1 d) p0 F' o
0 e6 l* f* t8 H+ A; c8 Tstatic struct gpio_led da850_evm_tl_leds[] = {6 y3 W7 N) g+ j# ]2 p
{. d o+ {2 {+ a$ U/ y& l6 A& Q
.active_low = 0,& O1 f9 b3 B( p8 `+ d! p
.gpio = DA850_USER_LED0,
- D; x C1 U( t9 N4 { .name = "user_led0",
$ {0 l: m* o t) S0 V .default_trigger = "default-on"," N2 d+ h6 G1 q9 p9 B
},
+ o$ Y4 I* O, p6 r4 X) p {
0 \* V# I0 G4 k% f* p- e) U .active_low = 0,9 _# e( T G" [
.gpio = DA850_USER_LED1,
; {7 N+ } O2 s8 P .name = "user_led1",) @5 n# e* _% W5 |! z
.default_trigger = "default-on",' k0 I2 Q& |0 H
},
& H: r; @3 B% H6 | T# [ {3 {- n$ J! ?. c, u
.active_low = 0,. P- V4 ]5 s' F1 f* |3 e& B
.gpio = DA850_USER_LED2,
: m$ h4 E; N5 h$ p" m .name = "user_led2",+ o) d" k* h7 s- X K, G" X% A
.default_trigger = "default-on",2 k1 `3 z- ?4 Z$ ?
},% n0 h1 z1 }. u
{
, x' s4 U/ x; v) U( I6 {2 O .active_low = 0,; @3 z. w8 G4 [/ O
.gpio = DA850_USER_LED3,
/ G: M" n; W/ m9 Z( G .name = "user_led3",
6 G) q& G; n% w( T& @$ X. ~ .default_trigger = "default-on",
! x& G/ g" d, _; Q+ ^ },
& r- w" c4 v- n2 v) c8 ?4 ~};$ v$ X0 W6 O' \% z
; w3 ]& Z/ y7 h. R- I, L% g8 \' {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 }( R, x, _* ?* B o& z5 H. h .leds = da850_evm_tl_leds," }1 m# X8 R: _5 G' U
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* m* n E& N% n5 P' D3 w};
( l* ?% z4 P$ s; E
& S+ @: M& }: u9 P* i U( M; Dstatic void led_dev_release(struct device *dev)2 W5 ?6 R4 z1 q8 V0 I
{
. t# F1 U7 T& o# X};- c3 Q* B8 H& I. Q& A) E% _
9 W4 n! Q6 q' `: F& c7 M4 C
static struct platform_device da850_evm_tl_leds_device = {
7 Q/ I2 O7 h3 x$ K% \1 D! ~ .name = "leds-gpio",8 n/ N' u k0 ?* ]4 I; B% O2 I- P4 T
.id = 1,% w, Y$ e* y5 y- R9 ^
.dev = {2 {$ q" @; B3 l1 ?5 @' ?
.platform_data = &da850_evm_tl_leds_pdata,0 K' g W$ I5 B/ [$ l: W
.release = led_dev_release,
+ |2 R$ S y' c! x, C9 r }
* f. i7 g* n b" ^, Y};9 k5 A# v/ S9 s9 s
2 Q( @" M$ d+ |8 k
static int __init led_platform_init(void)
+ |2 E9 M8 ]1 P: d" j( b{
; {2 s# n, m0 q- c; L% b int ret;
9 ^* ]/ Q2 g/ \6 Y#if 0( n( t$ |; q% L9 h2 y/ ?, ?
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 p. l/ t9 B0 [( Y) e& w5 {
if (ret)4 g. c7 k0 E' u$ Y3 ~* q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 Q/ q; D6 D& {( f) E1 Z, q "%d\n", ret);
" W; C& `% Y) V# z#endif9 v3 E' W! E1 I3 m8 y% ~6 C
ret = platform_device_register(&da850_evm_tl_leds_device);
/ ]/ [$ S5 Q0 i" M5 K4 u if (ret)1 w/ P2 j! ` x+ l! h
pr_warning("Could not register som GPIO expander LEDS");3 W7 I! D% L' |4 S# b* \
else" C0 W e9 y$ a0 H9 g+ {- a
printk(KERN_INFO "LED register sucessful!\n");- ]" R9 f6 r$ d: Y! z5 r
4 E* r) d+ |, Y. n4 v! c, l return ret;4 g0 E' ?) q, W% F
}
, i. M+ P+ m) v8 q. y$ r3 h3 c2 X. s6 K& y# I
static void __exit led_platform_exit(void)6 D+ O5 g1 l F+ V; U4 \3 I( S1 H
{3 f& ^. s1 G! V
platform_device_unregister(&da850_evm_tl_leds_device);; L0 C; h1 K2 b/ T$ y
$ g4 ^ s) S$ ] printk(KERN_INFO "LED unregister!\n");4 v7 O/ z* P& o w/ w3 f
}# W; [8 [9 j: S6 Q' Q" H* N# t+ y
2 ~, y4 c6 w/ u" Z o1 ?: g1 C# \: ?module_init(led_platform_init);
& U" K2 u; K; p( O7 V# ]5 j& N' Fmodule_exit(led_platform_exit);
; s a2 k* k9 y) Y; _3 }7 m+ L& l& y9 l6 F* ~3 A3 V. s, j
MODULE_DESCRIPTION("Led platform driver");$ n& B7 B7 f2 n
MODULE_AUTHOR("Tronlong");' ]; o. ]1 U0 {( s& m+ F* l" N
MODULE_LICENSE("GPL");
! B2 |$ Q+ V5 u0 h0 S# B+ k" |$ d' I
2 B/ s& E7 U& y/ k+ C; | |
|