|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 d1 S, {9 n( o) f) I8 n# t, Y#include <linux/init.h>
9 c! i+ M1 e! l#include <linux/module.h>
3 G$ y" A* o- s- r#include <linux/kernel.h># T' p5 d _* g% F1 a K2 _
#include <linux/types.h>) _ z$ _! [% p7 N& C0 Z+ R; ]' t N
#include <linux/gpio.h>- V6 S, C# x3 v) f# y J+ j4 o
#include <linux/leds.h>
1 a* `, b5 b8 f3 r0 {. w#include <linux/platform_device.h>+ B8 D2 }: `9 ^
$ |2 r. _9 T, t" x! V
#include <asm/mach-types.h># E* @. n8 F6 q6 z
#include <asm/mach/arch.h>' r" I; \5 T% ~! O! E% P |
#include <mach/da8xx.h>7 h, D3 S |6 V
#include <mach/mux.h> B1 j9 g1 }$ B7 ^4 h1 D/ {
3 `6 Y2 |. w2 w# L. Q& V/ \9 L
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ K' j$ ^& ^9 Y0 a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* k9 J n$ B! q& x: C
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 x+ b O% [6 I' N) h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 g2 O r9 b: m/ J$ P8 g" v
6 l7 f+ g( R: h( U8 R8 f0 k/* assign the tl som board LED-GPIOs*/9 `- c U% x! g5 K: ~. v9 c% @
static const short da850_evm_tl_user_led_pins[] = {' ~' O. y' J' `0 `/ f' q
/* These pins are definition at <mach/mux.h> file */: I. d" @, D- Z2 o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," g$ K1 h; W% d+ p5 N& J$ x5 \# D# z
-1
$ ^1 s4 U1 @5 t};
! v. S5 m- l+ s2 y- l# ]' [# Q; J4 B1 a: ^: M* Q4 z4 k+ N- y
static struct gpio_led da850_evm_tl_leds[] = {# J3 C- t' h% M/ s+ `5 O" |1 S/ A
{3 X9 p$ h. D$ k
.active_low = 0,% H8 ?- i, j' V8 a4 I( K
.gpio = DA850_USER_LED0,# F' N& u6 H4 X2 I" D. m
.name = "user_led0",
, x( N, t; }0 I H# [0 `5 u& g .default_trigger = "default-on",- h* T5 W1 [3 U9 F# t/ t) v
},9 W& H: y! i+ }
{5 E% s4 `3 y0 y+ ~7 {. f8 W; r
.active_low = 0,! x& z' a/ B( f j
.gpio = DA850_USER_LED1,
4 }' H; F: X4 w, H1 Y( m. l& w6 o .name = "user_led1",
, k( y# P$ q. ^* c8 r: Q; G .default_trigger = "default-on",; | B( C! h, w0 U
},
4 c5 d- a& e$ o9 X {7 Z1 Z' j: i0 h: j8 x
.active_low = 0,
! B# i: B* _& e .gpio = DA850_USER_LED2,
( d2 r6 r3 R5 l4 |. Y- ^$ k1 _" s .name = "user_led2",9 I1 E9 c; y5 s0 e3 Z
.default_trigger = "default-on",
& ?: [$ Z4 g9 Z, ^6 t },
2 m; J9 x+ t# \8 a$ U {
4 l: g7 o- e, I7 b" W, D& j .active_low = 0,
% W9 t+ ~! R* R; l+ C .gpio = DA850_USER_LED3,* I9 c' R9 M7 o+ h" z
.name = "user_led3",5 z9 g D0 q( S9 F* J s4 \* A8 R
.default_trigger = "default-on",
& N$ o' Y4 b y }," z' P3 D7 G) h0 A
};; A5 _& @3 A0 U: u) C8 u
5 x: @/ g8 O. X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 C0 l2 N7 @* ? .leds = da850_evm_tl_leds,8 J( w1 `0 Y: N
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),. S+ `; ^/ ~2 e" ?) x9 e' P
};
3 \3 Z. s0 J, Y7 X+ z
5 u f q2 v$ Hstatic void led_dev_release(struct device *dev)2 G8 @7 g, W6 U
{
, d5 K: R" @5 k5 h};
0 ^ | `- ?( V% z
+ j- T8 ^; @, h& ?+ y; U! \static struct platform_device da850_evm_tl_leds_device = {4 V+ J |/ {' E+ t' o- ]
.name = "leds-gpio",/ d5 E) R: I2 N2 b d
.id = 1,
" p& E; ^8 u4 r3 s .dev = {
+ g2 I+ f5 d- ~) u% d .platform_data = &da850_evm_tl_leds_pdata,
" v/ L; T$ _4 X7 w" W$ e. s .release = led_dev_release,
6 q- d$ @7 I: N- f5 ?2 U/ r }
, M% ?6 f ^9 ^};
9 Q+ ^, A$ t: q* ]" Y2 [* I+ O% z( x: G
static int __init led_platform_init(void)
( R% b" k- B/ c& w, a- _{4 N1 N: r) C6 S' p
int ret;0 c7 U" }6 ^* r+ d+ _9 W
#if 05 D& X+ v( m8 D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, b; t' Z* N' f' U; E
if (ret)
: {; b9 J4 U2 K( f# q# m3 ]9 b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 Y: N& R+ U m
"%d\n", ret);
% l6 R, y$ Z9 O, D8 R7 p#endif
& R+ z/ _* W" P; O: q5 F+ Z ret = platform_device_register(&da850_evm_tl_leds_device);! D) Z0 K' k2 ~% p6 X: T% [/ K
if (ret)
8 r/ ~ M- k7 O( w, G% k' S pr_warning("Could not register som GPIO expander LEDS");
, a' X9 {$ K' _8 b else$ j( ]6 a7 x, Y! ]+ `& s
printk(KERN_INFO "LED register sucessful!\n");
! Y- ^% B5 A% ~
" Z- v( K9 L3 R, x return ret;- O9 D* v- G; Q; w, D3 y
}; Z- l, Y8 w. ~" p0 f
2 k' S& d4 u4 G
static void __exit led_platform_exit(void)
, m$ @0 v1 f2 B$ D& E1 \/ l{, R/ x; J) U. S( K( Y' ^# m
platform_device_unregister(&da850_evm_tl_leds_device);: M a( L9 T: a; h, p2 Z
) H* S& m4 |- D, r9 v printk(KERN_INFO "LED unregister!\n");. y& i- l8 L) l9 Q( E" g" y3 i
}
9 E2 _8 ~4 B, Y5 \: Z. k
: f; m7 t& T! M. W3 d. smodule_init(led_platform_init);
9 s; B5 C _, r, hmodule_exit(led_platform_exit);
0 o0 a& i$ K; ^+ ?1 _# v# J( e$ S5 g2 I+ i0 V% a/ O
MODULE_DESCRIPTION("Led platform driver");9 i Z4 f0 B/ v& ?! c7 x
MODULE_AUTHOR("Tronlong"); S. S* H0 v5 e* r
MODULE_LICENSE("GPL");
- j; ~9 h ^% ]+ @% P% [) V; _6 {" i
|
|