|
求大神给下面的程序做注解,请稍详细些,谢谢。) s4 f. N+ j% ^ f! S
#include <linux/init.h>
! e/ {3 T: O/ `1 _( Y#include <linux/module.h>
- s3 D; n, I/ W) y( O' r! {#include <linux/kernel.h>
S+ N% X# Y$ w#include <linux/types.h>
- ~6 F- a3 F" a1 `#include <linux/gpio.h> e) y5 z+ W. {# Q
#include <linux/leds.h>, m4 \* ~/ ?) j/ M! x/ T6 c
#include <linux/platform_device.h>7 m" P+ K6 D8 j8 _& t& ~4 e
. ~( g! h- c2 \& [5 Q
#include <asm/mach-types.h>
6 ]$ u' c* S: u8 h#include <asm/mach/arch.h>
" \# z: I# h6 z7 z8 j2 z#include <mach/da8xx.h>- f- H4 D0 N' f; P6 G3 E
#include <mach/mux.h>6 f% J# q2 z3 C
0 P& ^, e/ K3 w- G0 A0 M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ G$ h b4 }+ f @5 G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 r( W; r' t# j6 s7 b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" f9 Q* t: F+ G" o1 {& c#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 E3 X- ]) c; Z* M G! Y. m' }
3 J1 [- m0 o r h4 n; x3 M# I- [/* assign the tl som board LED-GPIOs*/
, M% q; `. R" q+ Ystatic const short da850_evm_tl_user_led_pins[] = {7 R t+ x4 N8 @
/* These pins are definition at <mach/mux.h> file */# E2 r; N0 g- W! z7 {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. k- M% M. s9 l -1
; ?" r; k2 y! l. D5 l};% {3 D8 r2 a# v5 E4 q$ J% [* M
1 ^1 Q# c Y6 C& u* N9 z& }" l1 Q* o
static struct gpio_led da850_evm_tl_leds[] = {# c7 U9 t3 }! F. C5 c
{0 T& K9 ]3 b3 e" R
.active_low = 0,8 k7 b( a2 s/ t
.gpio = DA850_USER_LED0,8 ~5 {( Y. e' v+ ?& {8 F4 M1 }2 E" \7 l: H
.name = "user_led0",
, h. v7 \& c Y$ W x2 D .default_trigger = "default-on",
6 @6 C- `* a p; y; }$ S3 k+ C* g },. K$ w1 u0 O3 U, C
{8 k0 W% D# v Y) J" T& `' C4 C$ i! n
.active_low = 0,& Y! {$ F2 R6 K; [$ k# L
.gpio = DA850_USER_LED1,7 P R- f+ m, }( W) d
.name = "user_led1",* r6 R3 w0 p8 p6 V# A* K9 E1 G" H
.default_trigger = "default-on",
) P% P' p) g0 d' \% _( y$ @ },
6 n7 \2 P- P+ ~ {
8 c; P {7 \! Y) K. \ .active_low = 0,# h' k( J9 |0 v3 s2 \# F5 t
.gpio = DA850_USER_LED2,
& B% ~, r3 Z/ A; k; | W3 o1 N; Q0 w4 G; F .name = "user_led2",
5 q, p) H; s( _* A9 r" _ .default_trigger = "default-on",( n# f3 v5 x/ Q/ w6 e! ^
},* `/ C" T) [! g1 t# b% {: s
{
- c4 h5 f2 b8 k, D .active_low = 0,/ j! O4 i5 y' T/ S. @
.gpio = DA850_USER_LED3,) d+ t+ K' A9 ~3 t) s+ F7 ~
.name = "user_led3", C0 w* e# q! ^9 M2 T
.default_trigger = "default-on",- V* n2 C% s }6 r
},
: }+ |0 Y: Z. P+ K7 C1 ]};3 \' W6 t+ j5 \& T' Q
. h: t0 Z3 ], L5 ` K6 {4 |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: J8 ^; p$ ]" {: M$ {; P5 g/ h .leds = da850_evm_tl_leds,% d: v/ ^/ y/ `0 Q' S7 m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' D0 s. n0 P1 X9 Y, q0 Y
}; H0 `+ T6 G8 j
4 S8 C/ a; q/ l+ ~4 l, T. M4 y6 T1 `1 n
static void led_dev_release(struct device *dev)
: c" i: k/ R: `3 b: m) q H{
5 ]3 C, P' ]: w* ?};! {, |. Y ~: t) f- u: @/ l! z/ q
6 r1 m$ v6 j" a: Z7 x6 X' D& W& ]( |static struct platform_device da850_evm_tl_leds_device = {6 }) X1 D$ K7 V; z/ ?% ?9 ~5 W
.name = "leds-gpio",( l: P: q8 i: a, g- l Q
.id = 1,1 g. n0 O, N0 \+ }' ~1 P6 }
.dev = {2 z( s( h3 d$ S0 ~2 |4 F$ Y
.platform_data = &da850_evm_tl_leds_pdata,
, E6 y6 t* V! ^+ _: P8 V .release = led_dev_release,
4 m% T7 H8 y9 q/ E/ M }& c% c7 I) W- \
};
9 O+ z" A8 x# ~8 F* {8 |
. T7 W* |, ]3 C5 W2 Gstatic int __init led_platform_init(void)7 M6 S' p4 E* ~5 }( q' R9 {
{
! w* O$ ~. B& U8 A6 G# D+ v int ret;
/ O+ K. I4 Z/ E7 J9 ]: S#if 0
7 o( c5 ~9 H, |, S4 _ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* b" c7 c( j8 N# d, [+ P8 X if (ret)/ `( Q7 E/ P }
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ K; D4 M T6 G& b
"%d\n", ret);
) }/ h& n; E1 Q' d1 G8 I* m* O#endif
, s2 x9 a. ~$ x ret = platform_device_register(&da850_evm_tl_leds_device);
/ e, c% h! a0 ^* \1 ~5 j3 _ if (ret)
p% B3 L3 a- D3 }& M3 X. q pr_warning("Could not register som GPIO expander LEDS");
/ Z7 D8 T7 c& f7 J3 y1 q. P" q9 S else, ?6 b; b1 J' E* o U9 T
printk(KERN_INFO "LED register sucessful!\n");
6 [2 [2 j5 v; ]+ @1 r7 [: n( S
J6 i& D5 W( H, N8 l return ret;7 T1 J% k: O% x& [5 ]6 j8 P+ D
}/ J) w J; N# w a8 Z. b% c/ V
! _& _9 J! r9 r7 [2 G; y) `+ Y+ istatic void __exit led_platform_exit(void)) Y# v7 W& N* U" a1 x/ N/ g& e
{, Q c9 P% ?6 l$ _8 e z( O
platform_device_unregister(&da850_evm_tl_leds_device);
j, S+ S W$ o
6 S2 c3 k$ n/ ?/ c/ x7 H6 H5 U1 ]! i printk(KERN_INFO "LED unregister!\n");
8 f* G" ]0 [( I) M- [0 A2 g}
/ A1 ]( H* M5 Z. N' C- Y5 R6 d8 |6 c9 |* h8 l% E2 ?0 i! ~
module_init(led_platform_init); _) p2 ^& v* O& [. @/ j5 m @
module_exit(led_platform_exit);
+ i# z- [& _! r8 ?- u3 ~0 h
B* q3 I* S5 q) TMODULE_DESCRIPTION("Led platform driver");* @! G4 F/ S. F' h; Z* \4 O
MODULE_AUTHOR("Tronlong");
$ m: R3 A& _& q. K B. WMODULE_LICENSE("GPL");
% D4 r$ m: C4 A6 t% [& `; ^; F' o( t: x& C4 k, c
|
|