|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! C7 z- ~. |: W+ h' ~( b' J1 o#include <linux/init.h>
$ `4 @0 T# m8 B$ Y( t#include <linux/module.h>
! o! S2 c3 J$ N! `9 b7 c7 ]#include <linux/kernel.h>* S; U* z; d$ r7 W( t! F
#include <linux/types.h>
1 ~# R0 M, y: {" M" y: o+ x M j5 c#include <linux/gpio.h>
+ a. M+ B9 h- A, d4 X#include <linux/leds.h>
* m' f4 y ]! I3 A#include <linux/platform_device.h>
; `# q6 m! M1 [+ ?' r
; z! `/ d, D/ v& J0 {) w#include <asm/mach-types.h>
! e" K4 \1 q' u5 X+ q- t/ n#include <asm/mach/arch.h>
' ?4 B, h" [8 S9 A* [#include <mach/da8xx.h>" U' j1 }7 t y0 i5 m
#include <mach/mux.h>
' [5 T' @8 C& ^' P* h$ f/ ^' e9 c& K6 ~; X) u+ C0 s; u1 B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% _( a4 }2 K: i6 G8 B4 P! F#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" S( [, y# g- X$ y5 r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 l& @0 V/ j2 { h( z5 i
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), H+ H6 S9 S( x
' u9 k6 v4 l, s/* assign the tl som board LED-GPIOs*/
n' k3 k, r' K8 H; P! Kstatic const short da850_evm_tl_user_led_pins[] = {9 C% E/ C! x- q: C9 s
/* These pins are definition at <mach/mux.h> file */
6 w4 h' H. Z" ^' P DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 e3 ^7 L; \! G# R2 V. A5 ^! i g -1
+ j. k# f; r5 ^" _};9 ]3 { F, V5 n: B
, `7 V' T# f1 l, `0 Q
static struct gpio_led da850_evm_tl_leds[] = {8 s6 ~5 S* V/ Z- ^: j n! G
{
* I" R$ [+ X7 B+ j$ |3 b- B) e) Q" i9 F- F .active_low = 0,
+ c7 E4 C! x) e! E% P( F" I .gpio = DA850_USER_LED0,# t. M& J ~9 i. V' X0 ~7 f# s
.name = "user_led0",# ^) L, l; h/ V1 W
.default_trigger = "default-on",% e8 N' L' S( q8 O" z' N
},
# D( o2 v; K! z6 O {
, ?+ ^+ X: u( W7 W& r% t .active_low = 0,
# a1 S; k+ T$ X- e9 n9 X; a .gpio = DA850_USER_LED1,
% F* t0 e5 w* K, P- b% F .name = "user_led1",
) X# ]: A6 @# J; s$ ~! j .default_trigger = "default-on",$ _! x7 b7 Q$ Q9 I C- D
},$ Y+ K) B$ x, t g$ @: l8 p
{) G$ L9 {% X& H7 S
.active_low = 0,
- I; i7 X* B7 }1 V! X- Q .gpio = DA850_USER_LED2,
. ]$ Z. h! L9 m1 O" G1 N3 m. z .name = "user_led2",) t, b) @( p- P) u0 g
.default_trigger = "default-on",5 o8 g$ p% H' q2 R, X7 T' S3 Q
},
+ L# M$ u E. W: A$ J3 Q+ d, m {; e0 ?$ T6 u$ l) C" A( i8 B1 F
.active_low = 0,
5 I+ Y! o3 {. Z: ~, f- I) H .gpio = DA850_USER_LED3,
8 a8 Z1 D" ^3 S% c( t! B# _ .name = "user_led3", D1 A6 u+ g% I
.default_trigger = "default-on",, x9 @1 A+ w, `! d' {6 T1 X
},9 f9 X* c+ C- i7 z8 d
};1 b1 p9 Z" s( O8 }# C
2 U- F/ M/ J- o* G- mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" a& N* g" D+ M c
.leds = da850_evm_tl_leds,. ]4 W( \/ S2 X/ \ S
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),! E2 L/ ]! T$ ^8 T, Y- t
};
0 B, f1 ?0 L0 i0 r6 Y4 @
7 C- d, [$ l4 R+ W% Ystatic void led_dev_release(struct device *dev)6 U9 ^; z8 i e" ^% T
{8 i1 O- M ]( _) x3 @
};
, `2 x3 s+ ?2 B3 P
( n+ [/ c' B6 S) k' d" e( gstatic struct platform_device da850_evm_tl_leds_device = {! H# V6 D) Y( M( o* l8 B; @: P
.name = "leds-gpio",
/ o/ s% W% B l; w5 d .id = 1,
- w, y6 ?9 e; O' k M0 x .dev = {; l X. C) o8 ^3 N) R6 Y
.platform_data = &da850_evm_tl_leds_pdata,3 M% f) ^( d G! }$ ?( K% @6 F" _
.release = led_dev_release,: U7 H- N% B+ u: Y' z; K+ t
}
2 C2 }; Y5 z5 S4 Y c, v};
! w/ ^ P8 L( h5 A5 D# v9 k/ y* k; P/ `5 _* n% ?
static int __init led_platform_init(void)4 [* u" `% Q$ p K
{
% o4 m3 J- ^% T" P$ W int ret;
9 X) W7 W P: p#if 0+ N' B/ |* D; j6 ^4 B) [3 |' @
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 ~. t0 D- R( E$ p# K2 s/ Y# R if (ret)* X+ `$ R4 N; y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, d2 z; Z4 J- J0 p "%d\n", ret);0 G: `. Q* _) R
#endif
1 d5 X2 I7 V$ x+ k ret = platform_device_register(&da850_evm_tl_leds_device);
- G5 h% F* c L5 M if (ret)
" T8 Q( f' S4 L8 J( j" d! W pr_warning("Could not register som GPIO expander LEDS");
; m* N# C& X4 H$ W0 ] else# h- [" E' I3 U( o
printk(KERN_INFO "LED register sucessful!\n");
4 Y7 z5 L8 e8 c% T" Y6 v( t6 I- D) i
( M8 _: a9 o% l: a return ret;
8 w T. s* n: V}9 k5 B) G& N5 A4 D) T/ ?
( b |; @3 m6 Y+ Ostatic void __exit led_platform_exit(void)
% b1 o9 ?; x. ?8 m{/ Q% n9 l n7 e y/ g: ]9 I
platform_device_unregister(&da850_evm_tl_leds_device);) {9 A) E! x5 ^& ]- L
) |: e$ Z: A2 P l4 G3 Y. ^ printk(KERN_INFO "LED unregister!\n");3 N$ z% j5 g' x
}& j" @& [/ t( s" i. }
) l" U- B5 W" F6 w4 x3 @6 v7 \8 u, v9 Bmodule_init(led_platform_init);; r0 V, I1 x+ Z
module_exit(led_platform_exit);
+ |7 u2 a+ L6 U3 d+ K. N- s% [3 b0 Z0 ~6 w- ^: w2 `6 k
MODULE_DESCRIPTION("Led platform driver");! H7 D+ E9 B0 f2 v
MODULE_AUTHOR("Tronlong");
# G6 W( l; s; c* yMODULE_LICENSE("GPL");
7 H4 r8 N2 R* r+ Q Q* @! w* K( V0 H
# D* z8 c9 A- b1 D |
|