|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 d- I- v6 @$ D/ Q% A) Z( @
#include <linux/init.h># ^4 l. r6 y, K) O
#include <linux/module.h>
$ H1 B! K) \1 `- `- E6 F# m#include <linux/kernel.h>
" X) @$ I; V+ `* y4 u' r9 l#include <linux/types.h>5 u2 [; q& I& u
#include <linux/gpio.h>7 }) e6 l9 J9 k0 v6 F& c" y5 d6 ^+ W
#include <linux/leds.h>. @, X6 j* u( h* v# Y/ w1 b9 d- E
#include <linux/platform_device.h>
) y4 `8 V! I l" f% c& ~6 V- ^$ {, }3 W4 Z9 X0 w$ F! d
#include <asm/mach-types.h>; _0 a/ o3 |6 f0 m
#include <asm/mach/arch.h>4 r0 [, V& ] i
#include <mach/da8xx.h>
# L, u% U. p( T#include <mach/mux.h>5 T" A! r, |6 n& h! \! p, h
1 j+ J3 A2 z' m* C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); S' \6 z7 i( B
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ r4 }0 p. `! W8 U) @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 ~1 s4 y7 t B! i0 F! _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 P* ^$ U4 r/ `# c4 J
7 |; I! i3 ]9 R6 \* a) Y
/* assign the tl som board LED-GPIOs*/
* g' r! a2 e Q4 g. m3 astatic const short da850_evm_tl_user_led_pins[] = {
+ j- c7 J/ Z( i' E /* These pins are definition at <mach/mux.h> file */
0 I& V/ E& M* | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 g' _( G7 r$ D9 W3 U
-1/ f! E9 ]4 w4 l% d- C% n
};
( M; }6 h/ s; `5 _7 E* G f- x5 C8 y: ~$ N
static struct gpio_led da850_evm_tl_leds[] = {; g0 G2 f7 H* I1 I3 X/ m
{6 O8 }& w6 I3 s" o/ i
.active_low = 0,+ s1 l/ {' ]" n. D$ |
.gpio = DA850_USER_LED0,6 ] K w. C* F$ _! Y' [4 e
.name = "user_led0",
. l$ d" p9 D1 N+ j! ?, | .default_trigger = "default-on",9 T# w) e. A, R/ M) E' b) ?
},
3 w) y7 B3 _1 g7 ~ {+ |: F/ \! K1 R
.active_low = 0,
4 ~# T; t' H& o: @ .gpio = DA850_USER_LED1,! d5 e# @" r3 z3 @2 [
.name = "user_led1",
7 L1 a* T0 n5 ~- u) w3 H .default_trigger = "default-on",/ Y. g2 D1 {% j' T; P6 Y
},# t7 I \* A5 ?: |) {
{ T2 A) M: O1 \
.active_low = 0,( O& a+ {: X7 y. \: J
.gpio = DA850_USER_LED2,9 _2 J+ `/ h$ m; ?& M
.name = "user_led2",
9 V @! R, s* v. k! E- H .default_trigger = "default-on",9 j! [: u0 f2 S) t% e6 V
},
8 s& t5 y* X& w2 f8 w0 h {- ~" j! V4 x% n; F& t# n' Q
.active_low = 0,
( v, `5 ?' _! ~! |" t .gpio = DA850_USER_LED3,
6 @2 O, ?% {3 b9 e+ m .name = "user_led3",# [( g6 [& ~' H% Z- z( ]1 z
.default_trigger = "default-on",, m) }4 [& A( t" w6 i9 F
},: J( e( }( D$ a, ]0 s8 s" P
};
. Q9 A: U/ h5 i. h0 d( a4 B# s# ^: o0 d: C% @+ O, B& O' E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- _4 ?% s% ?/ Q' Z .leds = da850_evm_tl_leds,
7 F" l* L/ W* Z- Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ X% d' K, D1 c; |& r! Z2 S
};
; W( G( P- v- s
% G. r$ c5 f9 i+ ]) h4 ~3 T& qstatic void led_dev_release(struct device *dev)7 E7 F7 G, S: {
{( s3 G" D2 M3 |4 x9 ?, U+ p
};
4 E8 v" T& n& y+ K8 T1 V: K, r: d
% O+ O" ]: p7 @& h$ Zstatic struct platform_device da850_evm_tl_leds_device = {
6 o( C1 |2 U4 c" R9 F .name = "leds-gpio",8 p/ W+ O; ?& Y+ A+ U: K4 K
.id = 1,
- S: z3 d! x1 F8 R$ l$ J! ?+ e .dev = {* p/ Z" f) \$ U: f% y8 P
.platform_data = &da850_evm_tl_leds_pdata,
& u: u5 u/ U9 w3 p/ p .release = led_dev_release,
5 l9 \: A9 O% k) Y/ F: j }
# |9 _% J+ L4 `$ b9 u8 @8 u};; J% t2 @ @" u) K* ? }' X$ [
- r! Q: h! q) I# n! Xstatic int __init led_platform_init(void)
2 W( d. O2 \3 M. f5 {{
% {5 d" n7 u* I( b" _ int ret;1 A8 y" s/ M; z2 i5 }/ \
#if 0) q" x5 l/ @8 J! B) a
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 I5 j# e/ u2 p# _$ f {! e4 x2 ]& A& @
if (ret) ?" m4 Z4 @6 E1 L1 [
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. D+ @1 \$ O% E9 n+ P "%d\n", ret);) K0 J& T% ]. H( R& q, U4 o9 q
#endif, a7 u. M! M" t, A9 `' x7 e# |
ret = platform_device_register(&da850_evm_tl_leds_device);
" [# d+ L# K' V0 g" \' D0 N+ F if (ret)
3 A8 ~ E# g" t! Y! a1 Q z1 t3 z pr_warning("Could not register som GPIO expander LEDS");
: o7 p5 O6 f( [$ O/ ]+ @ else7 @# Q4 f) X" Z6 d R7 U$ x- e
printk(KERN_INFO "LED register sucessful!\n");
$ ]% H, q1 \# g/ p2 q% B+ a8 X/ J9 U- H# o& A! I) o- j' g6 |
return ret;
: a! u5 ^6 Y5 Y. Z- i}
. m U1 d+ c% A
. }, \! ~. g6 W7 Ostatic void __exit led_platform_exit(void)
- h2 u8 M1 _$ v! f1 m, q8 c{4 f; _8 X, H- h
platform_device_unregister(&da850_evm_tl_leds_device);
( ~3 r4 L5 N% q+ U* y" y
+ T) s/ x6 r3 ~/ L, ?! E2 d printk(KERN_INFO "LED unregister!\n");' d4 [, w8 p* c) N5 g8 x. j
}
) S9 {3 T7 V* i
0 g! N! m- ?9 hmodule_init(led_platform_init);
1 r0 w" B/ ?2 ~& N" y1 Imodule_exit(led_platform_exit);* R1 \* p( q1 k3 M* c9 A, v; |
. R6 G; E' S8 v% G/ JMODULE_DESCRIPTION("Led platform driver");
! w9 A- f4 U8 W3 C( I3 PMODULE_AUTHOR("Tronlong");
6 X6 y: E* ^& o4 O. e9 NMODULE_LICENSE("GPL");
4 h. U* r2 V% |2 e9 Y. ? E8 K6 w5 N/ J9 k" s: D( i
|
|