|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& R4 ~, z4 P& N% K
#include <linux/init.h>
: g$ L; |/ E" |, z5 p* `" e#include <linux/module.h>( s7 V2 o$ I4 r) J$ f, P
#include <linux/kernel.h>
+ R7 I. G" M |; d#include <linux/types.h>
+ U1 n8 M: _+ U' d \* I$ ^#include <linux/gpio.h>2 S5 g, ]3 n% M5 C Z
#include <linux/leds.h>
* F# y! G3 e* s: N) u( r#include <linux/platform_device.h>
2 ]' [9 N: N) }+ {+ c3 I, B, ]: p1 f, w/ `3 V7 v W
#include <asm/mach-types.h>! }" r% i9 I$ \+ Z7 @" ^( w9 W
#include <asm/mach/arch.h>. D) x4 w+ R2 l
#include <mach/da8xx.h>
6 U2 ^" E/ c: L- w* G#include <mach/mux.h>; |0 ~. F' c- k2 g2 [6 O9 O
6 |$ S& B9 Q& o: `* G f
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 k4 w4 c2 J4 c: P9 ?
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 N, Z/ D7 z6 d# M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& t1 N* d4 U" `( R, z# `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 ~! p. U! r2 e5 d& d6 ?! x5 O" F7 H; P1 ~/ k$ X
/* assign the tl som board LED-GPIOs*/
! n. ?8 y, }3 H! x6 b- ystatic const short da850_evm_tl_user_led_pins[] = {9 d. @- ?! m0 F+ A8 P) \( c
/* These pins are definition at <mach/mux.h> file */
& { a! C" q- P, d DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) N8 `! h0 M7 n7 F, v6 a
-1! b$ c! m4 S1 Z' k4 I$ {
};
0 ^9 T' _0 |( J s
* _* ?* b6 S- K0 fstatic struct gpio_led da850_evm_tl_leds[] = {
- D/ t7 j2 r: b) [/ i* o0 E) p4 P {. R; K7 l! k& }/ D- k p
.active_low = 0,: O: @4 B2 m8 T" z: ?
.gpio = DA850_USER_LED0,
5 m0 J: Y% _# g8 a; e .name = "user_led0",1 V$ U3 E- @. l5 i8 v* I( l' w8 Q
.default_trigger = "default-on",( R* b6 @3 _) t4 G6 p& V
},2 I; r& U0 X3 l0 A7 U3 e
{
: S2 B7 ~; l' \9 Z" d .active_low = 0,1 ~$ Y! [& a/ M
.gpio = DA850_USER_LED1,
* I5 X. y! b# V7 D5 K7 k) p .name = "user_led1",$ U# |8 c4 ^; p: K: z
.default_trigger = "default-on",
. A" _7 S. j' Q0 l" c3 O },3 k4 g% l& F% c: \* x Q
{
; Z/ e/ L" Y5 Z, D/ w2 {3 }# T .active_low = 0,
9 x/ o& C3 W, a7 z. H& R/ M- r" C .gpio = DA850_USER_LED2,
/ ]5 Y* q6 V6 u; {( `. B% D g4 Z .name = "user_led2",
' W* Q% x$ ], W! g .default_trigger = "default-on",
8 \/ z9 O+ p: c5 d$ d },) v* J) M0 E; B8 |, W+ }
{9 z6 P G! ^7 F; F% u- y/ j' v
.active_low = 0,+ }5 d6 R+ M/ h. e( L, w5 Q
.gpio = DA850_USER_LED3, }: r0 D5 e" j; q
.name = "user_led3",: y2 L8 ^- n% u7 ~
.default_trigger = "default-on",
@7 W$ _( w/ W0 a/ U },* z) a7 I+ v1 W' V
};2 `) e/ ^0 T; x0 G
9 X; D- }( d, P; f8 }2 u7 e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 n5 ^, k/ l0 A: T .leds = da850_evm_tl_leds,
7 x/ P% e3 P1 c .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," c* L- p9 L9 M! L0 k
};
, U. e7 P- u6 }
( U, P2 O, J6 B0 t2 Wstatic void led_dev_release(struct device *dev) H0 U# S) T0 u* y2 A" z- x
{
/ x6 ^6 p6 T& d" t- f$ {) ?};
4 ~8 j4 `* R8 C7 W1 m
' G* @( X$ \* c. r% Mstatic struct platform_device da850_evm_tl_leds_device = {
$ Q4 `4 J$ X" y2 E .name = "leds-gpio",1 u- _3 j+ _. h) e4 h N7 @& T) {
.id = 1,2 t p0 e. p, a. z
.dev = {5 g0 j* j. y" c% x% S
.platform_data = &da850_evm_tl_leds_pdata,. E! ^& q+ C. Z9 _
.release = led_dev_release,
) _. _% k9 t# M% i }
# \+ o$ m0 n8 G};' s) V# M! f G, b9 I7 C
! c7 T6 Y# s5 ^: P; }( l* ostatic int __init led_platform_init(void)7 d) j! E3 U: |' J% f8 ]+ ~
{3 w; N; e5 S4 N m- i5 x
int ret;
7 ~2 ?0 M. } A8 Y3 ?; |#if 0
" a$ Y- ?% q- w5 T ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 r) M7 b0 N' v if (ret)
) ^2 Q% e: l ~4 Q3 T6 Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :" d" T; G z5 T" K/ f
"%d\n", ret);/ x9 N8 a" D& q P
#endif4 P7 X, s2 D0 h, h. ^* ?$ {! X( j
ret = platform_device_register(&da850_evm_tl_leds_device);4 J8 h0 |# U* u6 d0 X! q) r$ c7 E/ Q
if (ret)/ i* {" L2 T) y4 k( h5 w4 f. o
pr_warning("Could not register som GPIO expander LEDS");
+ }4 f- a( K9 Z" c/ k0 z- P else! y4 b3 g# m5 m+ [1 F
printk(KERN_INFO "LED register sucessful!\n");+ Z' _% j# X5 x; s
" k2 e& X- ^- x0 l
return ret;
. q1 S+ p6 v4 d}" Z9 }# ^: x1 r) M0 g) }
. y7 k4 U& _8 J; |6 A( Y; Z6 d* Lstatic void __exit led_platform_exit(void)
6 ?/ F; S+ H& B Q0 W9 @: w0 R{7 A: p% a# @5 R( z( M
platform_device_unregister(&da850_evm_tl_leds_device);
% b! d1 B1 D( H" x* }. W* e0 L# R! x
printk(KERN_INFO "LED unregister!\n");0 { C6 `4 N% e% X7 Q
}( h1 P7 p% ~( R% _) _9 @% }. D
v( @% k/ r; _$ \module_init(led_platform_init);+ D K M' ` h* V# ?
module_exit(led_platform_exit);: W: n+ A8 V& `) u3 v9 U) w3 L; v
/ l9 j4 B3 H) ~9 I; X
MODULE_DESCRIPTION("Led platform driver");
2 j& A: C# W) dMODULE_AUTHOR("Tronlong");; P7 ^. j4 B/ I7 B2 m
MODULE_LICENSE("GPL");$ h, V6 }& s( t$ P3 [
: I1 D2 y( Q4 p3 w
|
|