|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( H1 T' E' e# }+ l8 d0 d
#include <linux/init.h>4 `. W$ S! S7 h, s$ S8 x
#include <linux/module.h>
% T$ q. m9 Y/ f. g, r- R% }#include <linux/kernel.h>
9 X) r5 N, K2 { n) A#include <linux/types.h>8 X6 _! P8 @3 v* k2 ]* e* `. O7 g1 {; r
#include <linux/gpio.h># o U( q( r$ V H& [+ o: K% |: u3 }4 F
#include <linux/leds.h>
# r- Q- g8 E' G- R' l8 t6 o#include <linux/platform_device.h>, g2 s, t s4 M* F. n! s9 u7 `
/ y+ B2 u) |& Q# [, `
#include <asm/mach-types.h>* _ A3 A, j4 K5 |- I4 p
#include <asm/mach/arch.h>7 ^* z, e" D! P* A Z0 `- S) o
#include <mach/da8xx.h>
1 j5 R. ~& a$ W3 y& K6 c. J#include <mach/mux.h>
5 p8 b' f: m' h- v; ]5 ]
$ ^5 {9 o* l4 D1 Q7 t& J2 l#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" I! \& a1 X. I5 w) c' e#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 z. U: U/ c& |/ Z4 j+ L#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). p1 w; b9 [: L1 x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) }( y+ b- b! P3 C: w
: i/ V3 z2 v* N7 M/* assign the tl som board LED-GPIOs*/
4 U1 [. p/ O9 o& K# X5 F# Astatic const short da850_evm_tl_user_led_pins[] = { ?- `6 i3 s5 C& b5 p0 \6 v' Y
/* These pins are definition at <mach/mux.h> file */
! P a( i1 X, d* p1 \* v. M! P DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 M, g5 o3 m5 q. g! H
-1
2 S+ t/ A B- u# |7 B$ g3 y};
+ ^" u' j# n) p" c- t! P [% d& W1 c! h* D G0 ^* U F7 t
static struct gpio_led da850_evm_tl_leds[] = {
/ g$ S( k- g3 M: K1 o6 F+ h {
/ Z" {6 U1 U; k# O9 k9 o7 ] .active_low = 0,4 Y! E3 v1 _% c( n# P
.gpio = DA850_USER_LED0,$ b9 Q M7 F+ u* p I
.name = "user_led0",
3 p/ ]0 x- O ] .default_trigger = "default-on",7 t4 V8 m1 n& v1 u0 Q! s
},0 {9 }- B _" z" j% B# T
{$ }- ^( j% w r' v! i: ~
.active_low = 0,# N" y9 {6 e7 H' l
.gpio = DA850_USER_LED1,
0 b) s, ]1 d! e% z9 Y E .name = "user_led1",4 ?; Z i( i" r4 ]& E1 [9 y
.default_trigger = "default-on",
7 I9 A1 w1 S' W& }6 a! ? },
3 s7 T' B$ `& v9 z {
( s( y# Z: Z$ C) U .active_low = 0, Z0 ?0 Y0 J# O: t4 E9 b
.gpio = DA850_USER_LED2,
2 b+ {* U6 q- r9 s4 A, Z .name = "user_led2",' v/ L: \/ z) a8 @' ^; R: \" x% D% S
.default_trigger = "default-on",
% @4 r4 v6 g- M+ x, F },
( X& G' x4 N4 s2 a8 b! G# h l& X {4 Y: `0 C! ]( `3 h9 F3 o. c2 ^, \4 j
.active_low = 0,7 p) S0 \8 |2 }& R% b" h% x E% C
.gpio = DA850_USER_LED3,3 S8 y% Q3 P9 t8 K# e: K
.name = "user_led3",' c1 s3 g) N- x; e" K
.default_trigger = "default-on",5 l$ l' H$ g$ e: ~: q
},: }+ |5 i' M; }4 s9 y& U
};
$ w: |% ]$ d- |; z$ I$ W, w
! |" y( Q2 t$ D% B) ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
f) F2 `! `/ V- f4 H .leds = da850_evm_tl_leds,
3 w* k: i2 `1 A- V+ s. z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: Z! ^5 }* B- [; ^};
7 E0 D& n7 g( l" G
' C1 v5 t( r& Q- c1 `, C) ~3 |# bstatic void led_dev_release(struct device *dev)$ W: @, v1 s) l( ~$ x
{6 w% k1 w, u8 T2 x. }
};
m( J7 x5 }! l( d9 E% u+ |+ T* X O+ Y2 i
static struct platform_device da850_evm_tl_leds_device = {- ]$ [. Z* K& a) H, K9 n! g
.name = "leds-gpio",4 L8 k1 Y% i) N
.id = 1,
9 @- _8 w0 {6 e: q5 D1 O6 { .dev = {: {+ i4 F0 \( o, E; m
.platform_data = &da850_evm_tl_leds_pdata,
$ h: b0 d2 f+ B/ s7 e {( I .release = led_dev_release,% d& [4 U x% Y9 N) z% p1 z% p2 k
}" r# F! C% U, `2 Z+ g
};0 b; W. Z: D- C- N9 r Y& j
; _8 v2 [+ l5 k3 bstatic int __init led_platform_init(void)
; q& M1 w$ J# m k% G{7 Z# B- H C3 r" A9 }- b- O
int ret;6 |% a2 J% M1 H
#if 0 r: R. \2 s" @6 ` ? v2 E
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ j- t* V( h6 }( k- _& E if (ret). W' Q0 W& {# i3 h2 _0 Z; R: I ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% t/ J/ Q, ?1 M1 X ~! Y+ C
"%d\n", ret);; k1 S1 z1 K! m7 P' n
#endif# a' W7 d. p+ O1 b! X
ret = platform_device_register(&da850_evm_tl_leds_device);, S$ I' M8 P; l. s7 [) A* Z- ?% l
if (ret)- {4 q9 T' F# b; K
pr_warning("Could not register som GPIO expander LEDS");: `+ C+ F* ~! f! t, J% n8 c( H
else
( M! w5 R8 }. o) O) \ printk(KERN_INFO "LED register sucessful!\n");4 f# _: t$ r( x8 P0 G) O
, N" ?( x. R$ v+ v+ `
return ret;- s: x; A8 ]/ H% S/ z
}
% r- A+ ^; J4 k- b( R/ b, ^ S0 \( g7 R4 \- X
static void __exit led_platform_exit(void)6 ?3 Q; {: h" f H. \
{7 Y: u5 n8 K6 O" t, u; ^0 b
platform_device_unregister(&da850_evm_tl_leds_device);( G- n% H8 Z" ]" u/ I; K( P1 n; F
4 A0 z4 D q- `5 a
printk(KERN_INFO "LED unregister!\n");3 J* N, d) n( g u% h
}
) O* \1 e" X6 Z! q+ H( Z {7 R
5 }( |) l( L) r# M8 W( V7 b* o7 z& Rmodule_init(led_platform_init);
2 [1 t8 u, o4 [ B1 m. Y5 @: Pmodule_exit(led_platform_exit);
, E0 r6 I/ m8 L6 q# b
/ s8 G6 ]6 ^/ U8 w0 h ]0 l0 ?MODULE_DESCRIPTION("Led platform driver");
0 k% D7 R) A2 y8 @% sMODULE_AUTHOR("Tronlong");
) R# C: V' j5 @MODULE_LICENSE("GPL");- i( R2 V1 L. a c: q
& f& @2 ~( W" O) I$ U
|
|