|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* D! {. b( q' K8 A& q2 E( M#include <linux/init.h>
& G# V! g7 O1 @& Z#include <linux/module.h>
: u% c- E4 p' B3 Z9 H#include <linux/kernel.h>0 P& S' l* P' h4 T1 h
#include <linux/types.h>. Q }, I) t5 ^5 s r' j
#include <linux/gpio.h>
+ s+ B3 e" m/ K$ P" J#include <linux/leds.h>1 o% [$ F! z5 `# G! A0 y
#include <linux/platform_device.h> w, _+ Q* ^5 Z3 H
% h1 t& w F8 h. ~) A7 j8 y
#include <asm/mach-types.h>
9 I8 ] M* |5 K. @1 d#include <asm/mach/arch.h>7 F" A% c X, r) L' i6 |7 Z
#include <mach/da8xx.h>
2 ?1 x9 x$ K) m" X% n' r: F1 a! c#include <mach/mux.h>- u4 p; ~/ L3 O3 p$ u
5 e0 q. a7 Z* D4 n4 n5 ?# v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ n: y- q& J& w#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% O: E, x4 n4 t: a0 Q! R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
i% O* b& U2 V#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); `& a: S# o4 m7 x$ }
: ]0 H! ~* U% p8 u/* assign the tl som board LED-GPIOs*/0 [' }) I4 ~* z
static const short da850_evm_tl_user_led_pins[] = {9 H# ~# c' V* |) K
/* These pins are definition at <mach/mux.h> file */- N5 w' u" \% r) ]
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, }+ w) e* T7 z7 V& z' v) _
-1
, ?6 i* G9 F& X) J7 l M; S};
/ A' C/ m4 s b& B/ T% d6 x( X$ r. ]# }% b9 s( y( n# k/ b$ ~
static struct gpio_led da850_evm_tl_leds[] = {
) C- Z1 u0 u D; Y& } {
' v& b6 G8 }) l, a; a .active_low = 0,
s" L; m8 I1 ~5 B0 k* N .gpio = DA850_USER_LED0,) I: m0 i0 ~& X
.name = "user_led0",3 _( O) h$ a: U& Y
.default_trigger = "default-on",
' t) a' E/ A6 R( c },
) D t' o- ]" {/ r& X {1 r# t" ~5 I+ h7 f
.active_low = 0,2 T3 J0 @4 o* c' N9 f6 y4 ]. q z
.gpio = DA850_USER_LED1,* n5 \9 q' m3 {2 C0 o
.name = "user_led1",+ I! r( y1 }/ D1 X2 Z4 z/ D1 O
.default_trigger = "default-on",+ m( n7 M$ e( [. ]8 t
},
# h! f( N+ K( n' M5 t: C {% E! r& p3 o/ _ f0 B
.active_low = 0,1 w# I6 Q7 \6 }- p; Q1 D% F
.gpio = DA850_USER_LED2,! z4 c' C: k _% {0 d
.name = "user_led2",
6 L& x+ r5 B2 f .default_trigger = "default-on",8 Y c) g' P& i# M0 y5 s l
},
0 L/ F% M2 p1 f. R+ X {' H" L2 D! a3 k6 i( G# o
.active_low = 0,
, B5 X# Q' u% w .gpio = DA850_USER_LED3,. L4 T4 O- g6 L6 _2 @: l. g1 b, Z
.name = "user_led3",4 A- f: b6 Z2 E. S
.default_trigger = "default-on",
; N3 X+ v2 |& v5 ?1 ^7 H0 C1 m },( X { w8 k% J7 i0 t- h
};, D D7 D5 _# n: v' ?
/ L4 Z5 |9 K" P/ u9 B
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( s+ C1 ?$ \/ t( q .leds = da850_evm_tl_leds,
$ T$ I i) d* g& d" r8 w; ]1 { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ m) ^- y) {* \$ v1 B: b) F! K5 {7 p7 ]};* ^2 `# q- U/ P
3 W a! _9 u& e: w1 U
static void led_dev_release(struct device *dev)
; z; H L, s3 G( J6 }: X{ m' ^' w- n/ x D9 o
};# _( v7 I6 E: Q$ p+ h4 e$ n
! P2 T2 ?% J8 Y4 O2 M; r9 `8 H+ F* R# Ostatic struct platform_device da850_evm_tl_leds_device = {: J. y* B4 K. A' U9 e6 @8 q) N' [
.name = "leds-gpio",
! w! d8 u: T r; t1 p( L .id = 1, a6 i; d: ^( w' r x
.dev = {
7 `( I5 e( G/ d! o4 n .platform_data = &da850_evm_tl_leds_pdata,# {( c( h2 O7 C: `! j$ I
.release = led_dev_release,
& k) X S' G9 S; m( ~; b" \ }& I" Q* t( d& Y b: K) J
};5 e9 U' e- t: T% z
/ y. Z6 x( g. u% y1 j5 D
static int __init led_platform_init(void)
/ A6 i! a5 D! H1 f{0 f) M; S( p: M7 Z/ l1 L
int ret;
7 K: I$ K# A4 A0 g# [! y8 t#if 0; Q- x4 h2 U% N- Z9 _
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% l( M: z( C; b4 R( [ T if (ret)
( {; }5 W% G$ t6 c$ I1 i3 t$ n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" |4 `3 @/ E: h# |. q) i
"%d\n", ret);; y% K) v$ A- k. q( @
#endif& o! x9 W* H& f! T) c4 b
ret = platform_device_register(&da850_evm_tl_leds_device);- z6 W; b* X; T7 f; L
if (ret)2 c9 A7 d3 ~! w# A3 `, F; @8 N
pr_warning("Could not register som GPIO expander LEDS");3 C, p9 C% ]* }3 K1 ^
else
) }$ k$ I" z4 d& B* r5 T4 `' l: B4 n) k5 B printk(KERN_INFO "LED register sucessful!\n");
, T" X% r! u- H5 g2 D& `( s# r8 S0 f+ K, P0 R M: T1 ` g
return ret;/ Z# h F$ M1 A
}- r7 ^5 d' {0 K( } l% i
1 T; I7 T4 M) |- s
static void __exit led_platform_exit(void)
' d- \0 A1 }5 I# Q1 i8 u& E0 O{( M0 I7 d$ M; o# G9 L
platform_device_unregister(&da850_evm_tl_leds_device);
- v6 _% U; b2 L% t9 W8 t3 U! M6 A8 \" @+ I! O
printk(KERN_INFO "LED unregister!\n");
5 o- j1 [ l5 i}
3 c, D, n; a' P ]
( o1 g# E) e, ~6 Amodule_init(led_platform_init);6 v& h6 E+ v; e7 p. v. M
module_exit(led_platform_exit);; d! A* x' u8 G' r% L% E
( f2 J, z$ r) A# d6 e. n0 \, ?
MODULE_DESCRIPTION("Led platform driver");
' E7 n! J( x- w4 o' _+ yMODULE_AUTHOR("Tronlong");
; m: r) ^( ~3 _& V, q" w3 c- CMODULE_LICENSE("GPL");
2 t6 I* l$ T7 g" r* J, Q% R1 t! r! q- z `& m( g( D$ R+ t4 T- H$ y
|
|