|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' a( C: L) L) Y- |7 b' J
#include <linux/init.h>
" W* x% c0 o% B+ y0 M#include <linux/module.h>
$ G' g3 K3 \' C Z0 G. J. ~, p- I#include <linux/kernel.h>
! Y7 x, z+ Y: U: p9 }% o7 [2 n( Q#include <linux/types.h>
0 A c) ?; z) W3 c; Z l1 c$ t#include <linux/gpio.h>, j( c: n* h' j# O- A4 D
#include <linux/leds.h>- U: n: Z" h5 k/ E4 }# ?& L
#include <linux/platform_device.h>
5 z2 Z( H; j; e
! T" f( ~" l& H2 B#include <asm/mach-types.h>
" f. H% K8 c+ K- X: f3 ?#include <asm/mach/arch.h>" F* R$ k# w0 @' ]2 r
#include <mach/da8xx.h>
, a9 {% L! t" N* T6 U+ Q#include <mach/mux.h>
9 y3 Y; ?8 H0 B- l
- N# q; b, k' i% B' N2 m#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ F. A7 ~: {2 E. b- c#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* [) ` n) I0 \#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! d1 j. N% v$ r- `. n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" y0 D! p4 Z T6 w
* u4 f+ S& P1 t
/* assign the tl som board LED-GPIOs*/+ E' j5 L% g8 C& I% O
static const short da850_evm_tl_user_led_pins[] = {
! H1 Q, p+ v1 @( ~7 D. C /* These pins are definition at <mach/mux.h> file */
* R% Q$ i- U! x4 s2 x DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( c. P3 a9 q; b; {( O -1
# d' ?, ~; w+ Q};
2 W) t/ t6 r+ T- ^" ]2 b
6 W% e$ `8 r# tstatic struct gpio_led da850_evm_tl_leds[] = {
& A6 a0 X2 n' R {
2 ~. ?/ Q* K0 L& l2 @ h" R! ` .active_low = 0,
! k3 h% j% o1 X: u. u .gpio = DA850_USER_LED0,
: E7 ^+ ]. G1 G- b" b* m4 C" W3 { .name = "user_led0",( Y! N, G' I! l) R9 _2 I& E) |
.default_trigger = "default-on",4 a R1 G' o( W B1 ]2 E
},/ {. v, D$ i. K& z
{
6 u; X& Q* h) V' }- I( H& C9 b .active_low = 0,
$ K* k- M! F r .gpio = DA850_USER_LED1,* p8 ~$ k( e& Q' b
.name = "user_led1",
+ E, c: O1 t2 l; h" u; d .default_trigger = "default-on",
% }. ^5 ?. J+ o5 J, Q M8 h },( X4 O& d! \! m) d! h; L0 _6 }& Q
{8 Y' \* R0 E1 _' \1 e& x1 C
.active_low = 0,1 b6 C1 m. m# f/ a' k
.gpio = DA850_USER_LED2,
9 T. L5 j7 t# M# {& A .name = "user_led2",
: d4 c/ p" u* K( B ] .default_trigger = "default-on"," ^+ b. i7 t$ i1 y( J' v* z
},9 [3 z' m! W3 |9 S/ U6 w
{1 T. t; h7 C T! b* j: u6 g+ F) N
.active_low = 0,0 A2 ]& y8 w& f
.gpio = DA850_USER_LED3,9 u4 L2 q' Q- D3 P
.name = "user_led3",, y8 h& {8 ^* J7 j* A9 v
.default_trigger = "default-on",( U4 e# t# c6 h7 M7 o' Y
},4 x b; `7 N7 \, V' n
};
8 y! a5 \& Y' j) v( n
' n0 E6 J2 n* h4 g* `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 { v9 W2 l7 F
.leds = da850_evm_tl_leds,6 \3 k$ o- r: `; ]- [" [6 a
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 w3 G/ u5 `6 K7 m( s+ U};, M3 r9 q& V3 R8 M/ w1 n/ s [& v
5 e0 [4 u4 y0 q }
static void led_dev_release(struct device *dev)2 Z! n1 ~( m# N0 b; Z4 w
{( R9 n' n0 {% r+ l5 {
};
. M# U, _6 a r/ O
7 |5 q" I8 i; {static struct platform_device da850_evm_tl_leds_device = {
5 u( h- Q w0 T. Q2 z( c .name = "leds-gpio",
5 l( c, N! j: q( S7 ^/ R .id = 1,
) k9 p G; P: y* A1 e( e% F .dev = {0 @7 @% D2 E; e* ?! S+ a
.platform_data = &da850_evm_tl_leds_pdata,
, i; } R' G1 L1 ] .release = led_dev_release,
1 ^( B5 `3 e. g% D }
b* l F9 _. I1 o5 y};
, X" E, r; R' R% k: g7 I2 [& }) L- f( H
static int __init led_platform_init(void)" \1 @0 o8 l H& @* h
{1 p' `& m( t# U$ L) _& q* g/ }
int ret;
; k9 e/ |8 z$ H6 Q k#if 0 J4 O/ _9 Y% `
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 [! B3 K, D$ P, |: L: S) [1 T if (ret)
) g$ d$ W& x/ C' r/ f9 y4 l* L4 Q$ f; L pr_warning("da850_evm_tl_leds_init : User LED mux failed :": L6 A6 H; C" D$ `4 r
"%d\n", ret);
; R# `) A; B; N# W#endif
& g# Q7 m4 n \, \' m& [ ret = platform_device_register(&da850_evm_tl_leds_device);
' O2 c9 _/ C5 k9 ?# K( _- H if (ret)
: \3 _# I4 Y0 I- S( R! c pr_warning("Could not register som GPIO expander LEDS");; l8 q+ [9 W3 K1 c& P
else( ^) w' \' o# |6 C
printk(KERN_INFO "LED register sucessful!\n");9 l0 j. n7 H1 m$ s1 S
- p) X6 N. j: L return ret;
, _* v$ Y, A2 [}: c. k2 Q2 Z, C* C' C. d
4 G0 n$ r" [1 D2 [4 Y1 e& ystatic void __exit led_platform_exit(void)" w0 m- r) s) V0 D b
{
7 ^% m L4 f' a z' P. H platform_device_unregister(&da850_evm_tl_leds_device);
! _, j) P# e8 q2 n' w! R/ O- v: R7 C/ [* v4 O
printk(KERN_INFO "LED unregister!\n");' @' ?. \+ j8 v( J
}7 a% L2 e) o1 i
1 y5 q" B( [- ?* j
module_init(led_platform_init);" U! b: r; V& z: W9 p5 F
module_exit(led_platform_exit);8 O# t1 d& w; f3 B, l2 T
7 |2 i7 q6 l+ |MODULE_DESCRIPTION("Led platform driver");
% R0 v& M! {! E% H# V5 j% l, LMODULE_AUTHOR("Tronlong");! w/ T+ ?0 }" H0 S* }- ~! W) `
MODULE_LICENSE("GPL");* U4 a) q% c0 X; `8 q" J
0 o2 L, l! m P: y T |
|