|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 C4 [1 n# G2 W: g: o
#include <linux/init.h>, b: {2 Q. Z( O! p. i2 K
#include <linux/module.h>
/ J& U$ C) P+ _" h/ o& Q#include <linux/kernel.h>9 x2 j; ~% a5 V
#include <linux/types.h>1 M) m' t+ h( @% s- r$ _" g! p
#include <linux/gpio.h>; I6 d6 a: I" G, g
#include <linux/leds.h>
; t% C- C4 ^; `1 M" d#include <linux/platform_device.h>8 m& I6 k- o1 n5 i# }- P. q
* S: U/ N! E! i& a#include <asm/mach-types.h>
^/ W+ V' o) d- p+ K#include <asm/mach/arch.h>; X- A8 A8 E- O
#include <mach/da8xx.h>* B2 W& } D0 q3 A- A
#include <mach/mux.h>
v7 b O* P& O/ ^" Y6 P/ }7 \- `& `. ?& T; h
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' R; }) p& G4 f* C! `; E#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 f; B, e2 u$ m5 a# N
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 w5 ?, V( M+ d3 R2 ?#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 q3 {7 b& U) v: E6 S0 o/ E$ G
$ U0 ^1 z0 n3 Y5 a- X% J
/* assign the tl som board LED-GPIOs*/$ ^- n5 p: K; z: m2 c0 ?. l* M
static const short da850_evm_tl_user_led_pins[] = {1 s; D3 t- A$ Q
/* These pins are definition at <mach/mux.h> file */
k5 _$ U* r% P7 ^# Y6 G DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 ~( {4 y# R5 X8 F+ d' F! |7 W
-1
1 K5 d. p6 Y. L3 }! J" P& h7 m};4 g" c7 q5 a4 t5 o# t3 Y% u' k* x
5 j4 q% _8 U, g" H) z+ z
static struct gpio_led da850_evm_tl_leds[] = {
1 l2 G0 ^" e& C. X1 X {
& u8 _" i& T7 W .active_low = 0,# J+ v( Q p, F: g4 e( q2 ^" s
.gpio = DA850_USER_LED0,
6 s9 p( Y* k' p! w- ~& [& A8 w+ L .name = "user_led0",) c2 _7 e, `# ~: C2 S0 V! U7 X
.default_trigger = "default-on",
+ u, E: f: c! V: ?- r: ~- h: A },: o1 a0 v) H6 b( p
{
) _- @' N! X( b5 j5 b1 ]* }" i1 { .active_low = 0,
9 E6 k* I" g0 @5 o .gpio = DA850_USER_LED1,+ P+ n8 P8 N; d1 g, t# f2 `
.name = "user_led1",
9 O1 b1 J# K2 v( B' B/ C9 i .default_trigger = "default-on",1 `9 ~6 J( T2 ?) G
},8 R' R+ h, N* a( v' r$ q
{
, v3 I2 t: r1 x9 h. ]) P .active_low = 0,1 v- a) E$ u' L% }4 h O4 ]
.gpio = DA850_USER_LED2,3 \5 v: Y* z9 z+ V- c
.name = "user_led2",5 `- G1 n7 e* f' N/ ^# n! ^
.default_trigger = "default-on",
5 \& }/ N- Q8 }9 s },$ s; T: t% P7 [3 I) {
{7 O5 _( T- J. s: Q9 i
.active_low = 0,2 \5 V4 Q. B, F: R& _2 @- S8 Z
.gpio = DA850_USER_LED3,
4 G8 l% D' _5 y% T( n$ ~ .name = "user_led3",
, f1 M' f4 v( ?/ }7 U" p1 _ .default_trigger = "default-on",
" @6 |8 V9 z, x Z k; F },
- K9 {9 `4 _ H" {};2 a. j8 \) v. w
. G v8 ]* o; \& A$ v+ g1 ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ p' O; L; L# D$ c0 T .leds = da850_evm_tl_leds,
6 H* R0 }8 V% {0 w, } N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ w/ w% m* ?* D' L- E};
; H( S6 L9 `. {/ K
0 e8 [' d1 J+ U$ C5 _. Cstatic void led_dev_release(struct device *dev)) ?2 C: L; w+ o5 A F4 i. y
{
) k9 A$ A6 j/ |5 r};' C- q. b, e0 I
4 @' |% F, c) g O5 d# |8 g* hstatic struct platform_device da850_evm_tl_leds_device = {; ?# t* \4 m/ K) E$ S+ N
.name = "leds-gpio",9 U7 E7 {$ K1 t+ D
.id = 1,/ a2 _( \" Y+ a
.dev = {; b2 [: z- c% g! c
.platform_data = &da850_evm_tl_leds_pdata,1 Q3 F1 p z$ Z) Z" U w9 K, A6 n R
.release = led_dev_release,) n3 O( u3 _/ O" h
}* p9 I9 K# A4 k: l
};
7 g7 h$ _/ j6 T) x* t; z# E
0 [6 F! Y7 X" t4 v E9 D7 Qstatic int __init led_platform_init(void)8 E G: ~0 l+ q% O3 b% h
{% e* f" z$ y u
int ret;
" e4 j) @) k( p& B! \#if 0# A: n k. [ T! S0 [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; H# w' i6 n" I6 p3 S4 x
if (ret)1 b, x- a5 b* S8 H" A; L! D$ Y* V9 p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; v6 t1 y5 N( r, I' R
"%d\n", ret);
; b' ]. h/ K# J& u#endif3 z5 z+ Z" O% F- X( T
ret = platform_device_register(&da850_evm_tl_leds_device);
2 i: l7 Y9 Z% h2 H/ Y; _/ M if (ret)) F e; v' t6 z9 |, Z/ _2 a8 i7 x
pr_warning("Could not register som GPIO expander LEDS");
$ V* C5 O0 j r: s else6 t# F7 b0 a3 r' U5 l, B4 w
printk(KERN_INFO "LED register sucessful!\n");
: ]1 k u5 M4 x7 w" @* C. T$ g( ?! g6 U& d9 Q' V9 [+ `+ `2 }4 H
return ret;
3 ^4 I% D y3 s+ u1 q}
; h5 G# e( A, q# j8 h
& I3 f4 l6 o( Z) c" V; J* H0 ]static void __exit led_platform_exit(void)
: Q0 l# ]9 j* a' ~( g$ u8 M+ M{
. z- [7 t& \( F8 N, i1 z' L platform_device_unregister(&da850_evm_tl_leds_device);4 l6 y( F7 n" p4 j* C, J. U. ?% c* d8 C
- E8 I8 n. n' ~& v, l
printk(KERN_INFO "LED unregister!\n");
/ H# J! u0 z! k5 D}# {6 h3 G( H, W! k- _
1 Q/ d f$ P7 T3 ]& X$ Pmodule_init(led_platform_init);: z/ m9 m' Y$ a
module_exit(led_platform_exit);. C. N9 r. }- K/ R
# q2 i5 p3 q/ r( o( \8 @MODULE_DESCRIPTION("Led platform driver");
' a6 A1 @' W6 T: tMODULE_AUTHOR("Tronlong");6 u- f, I* n0 A+ k" ]2 E5 A' N# }
MODULE_LICENSE("GPL");
: K4 a1 `4 {( U3 s7 O! Z* ^. \
|
|