|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) I* A1 y/ h, `0 F; M, ]1 m2 ?
#include <linux/init.h>
& d- H$ U, H7 E. |#include <linux/module.h>7 z7 M, n* [; M, f" u6 F$ m- ^
#include <linux/kernel.h>( D$ e& B+ ?: n; g! l( i9 Y/ u
#include <linux/types.h>( n$ m8 h' f4 ~3 V
#include <linux/gpio.h>* S/ U3 p' r6 A& h$ W2 K# R: ?
#include <linux/leds.h>
" l; M/ T3 J2 ~# o/ Z% x#include <linux/platform_device.h>8 Y. O( t' p3 q0 V
$ k4 G2 U8 E5 b* Z2 u; R8 o#include <asm/mach-types.h>
M! H |, h. `4 R2 P6 |& [4 V* \( T#include <asm/mach/arch.h>
+ l& O& b! q* g& N$ ]- m H#include <mach/da8xx.h>3 R! w; p& S$ m6 D/ [3 ^
#include <mach/mux.h>% l& C0 l1 f$ h# G9 Y( m" n- \
' F& {0 m7 _. _7 y0 Z4 [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( K" `6 ^* [3 d/ f* X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 R7 M3 n/ K! l4 O( C: v* E#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; `4 I& E) T6 S0 K( h- F1 v; x0 ~#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" B2 g1 U; b, }" {
* L! A0 T) w7 T8 n$ X; q; ]4 ^- J; G
/* assign the tl som board LED-GPIOs*/
# `3 E" S$ c; K0 S/ v" x' W) h5 q$ Vstatic const short da850_evm_tl_user_led_pins[] = {% @. `9 O( k6 J& I- |) t
/* These pins are definition at <mach/mux.h> file */ j- S9 q! a& S6 M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 J7 H& n S2 q2 q -1
( }) p+ V; r$ p& @9 _" j' K};
2 f: x+ o; R, X
# S! c6 W$ ~2 o! O0 estatic struct gpio_led da850_evm_tl_leds[] = {1 d5 q4 P) G- C( M" `
{7 y0 v; ]/ A5 X" P7 w$ \
.active_low = 0,
/ A4 F. X" x5 F- |3 n( }/ E+ H .gpio = DA850_USER_LED0,* b( _" } N0 n* I. ~2 \+ ^; `
.name = "user_led0",2 E! W- Q8 Q8 ~4 y# M$ d: }! E
.default_trigger = "default-on",
0 }$ P2 K/ i0 c! G3 o- l },
* f7 }6 U, Q/ G& l% r' I {
6 ]- W. \8 b$ m4 C, `; h .active_low = 0,3 y# P" q& w! M* m9 O/ S
.gpio = DA850_USER_LED1,
' m" j; p; e* O .name = "user_led1",% H6 W) H; L3 L4 i6 V8 r" K
.default_trigger = "default-on",4 u" W2 p( \! I3 R2 j9 _2 o
},
! a# q: q/ G! Z* x! w# W# g {! p/ a3 e8 O# y. p% X4 {1 Y. G
.active_low = 0,
* @, T, O0 N( g3 n" Q% |, _7 s. A .gpio = DA850_USER_LED2,
) Y8 y; V3 s! \ S .name = "user_led2",7 I0 J5 f. }, S! i0 g
.default_trigger = "default-on",
3 {% ]9 n& {, F: S7 I' w },. o: [( b% _% ? f. |- e
{6 X1 g3 x( F# {% |
.active_low = 0,, m% c& o1 g! S( z) |
.gpio = DA850_USER_LED3,
3 ]! K0 {# N) M J+ d; P) U .name = "user_led3",
& _5 M W! C- X# E% g& P7 E- k .default_trigger = "default-on",8 k9 R+ ^ [% p# k# X2 E
},
7 q5 G- t( [; G6 s5 l* t' u0 y& l1 P};
. J' k+ s H# N
( x# F8 Z- e% w* N6 vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 j8 [! a+ z; z, Q3 n- N, [
.leds = da850_evm_tl_leds,/ f+ l& @, f& y4 ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& U/ z% r! g5 c8 }# w3 F; o" p};
% ]( y0 [; a- _' G# y, f
8 M- Q( N4 q6 u7 N& Z* Sstatic void led_dev_release(struct device *dev)/ O0 u3 o! j9 l
{+ {: z. U# @8 g; x: ~1 ]
};) T- ?! _! G& M) a2 N+ Q5 b
* M8 M9 p# X( y H t; u1 nstatic struct platform_device da850_evm_tl_leds_device = {
* [# f- ]( ~* D, a; {7 r .name = "leds-gpio",2 N7 A' f" c# ~8 X/ [) F
.id = 1,
$ e m7 M# ]( D0 s/ A .dev = {- A% Y/ x: u# r0 R9 E4 f- W
.platform_data = &da850_evm_tl_leds_pdata,
$ l' L4 d' K$ K/ i .release = led_dev_release, d$ q7 c6 m5 E+ [
}
/ u! P8 S0 @% ?. {3 _. {};* g* }/ C0 v' H1 |: ?; a9 V
) s* L1 F! N P$ S3 D
static int __init led_platform_init(void): V0 S- W6 ?: [" Y; G1 [/ D
{! c q/ v) R: \9 E7 R% M
int ret;* X( j$ h9 Z' H' t) e2 i0 n
#if 01 I" y0 O: v1 {3 U+ L; A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 @* N4 q0 ~5 `5 s1 o+ J
if (ret)' e- \ R, c% p* d. f8 R: `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 y2 f6 ~1 ^2 @ "%d\n", ret);
$ F" S- e7 S. F r8 R* ?6 S1 M( R#endif/ H0 F. ^8 \ v' }" \
ret = platform_device_register(&da850_evm_tl_leds_device); t2 ~4 M; z7 [
if (ret)+ @) l- Q8 G' D
pr_warning("Could not register som GPIO expander LEDS");1 ~0 d, ]$ P# P4 B/ ] l- h( o. j b
else
, ~# c7 V( L- i7 ]3 x printk(KERN_INFO "LED register sucessful!\n");
0 U1 G& m W1 G: z! g. A1 @8 O$ X7 [# Q& }5 Z
return ret;/ H G/ f" e/ q7 @5 ]. h5 ?
}
: e5 V: g3 g" o& E
' l1 ]. A3 f6 vstatic void __exit led_platform_exit(void)
! ^+ c# |# Y+ E4 S' u+ C7 O0 v{, {: Z; {" h7 o2 E$ s5 M
platform_device_unregister(&da850_evm_tl_leds_device);
4 y& A! n( e$ d9 M& k b5 a; q: B/ H1 C
printk(KERN_INFO "LED unregister!\n");- B" d m* f- R9 U( [( F
}
- }0 k: k6 h0 ]* r7 Z6 C# y# e5 t0 x4 ]6 S# n8 P2 c4 O' |3 ^; w1 n
module_init(led_platform_init);
! J" P, Q1 I+ V$ y" g5 Dmodule_exit(led_platform_exit);! n& G% u( a+ m
$ J( H0 @( F! g! B6 Q6 I8 K/ K: N( E
MODULE_DESCRIPTION("Led platform driver");* W7 e6 P+ {8 ^5 \ G) ]
MODULE_AUTHOR("Tronlong");* N& Q9 L4 C1 M' ]3 W' [5 G* m& J. ~
MODULE_LICENSE("GPL");0 B$ ?1 s6 u8 e) a: d' X4 ?
' Y0 R2 i+ q* z3 g
|
|