|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# V/ h; c% b/ |$ @" N, v! A
#include <linux/init.h>' r: `7 |! ]2 |# D% l! R5 U
#include <linux/module.h>) B# M+ A9 i3 S# D
#include <linux/kernel.h>) ~# ^2 N8 S3 R' F
#include <linux/types.h>
1 u& r5 D3 b4 _! u9 R#include <linux/gpio.h>
- p' ]/ C0 [* ^! @7 ^1 C#include <linux/leds.h># r- a/ S6 |8 r, k
#include <linux/platform_device.h>
3 e1 S1 S Z4 G% i( E6 r' _/ r- c8 {. H" I1 s- s
#include <asm/mach-types.h>
& c; W8 c! P F8 g#include <asm/mach/arch.h>
. i7 V4 `9 h& b4 c#include <mach/da8xx.h>
* i# ?4 {# E3 k1 ~#include <mach/mux.h>
0 O3 V% G4 s' A( Q/ \( P' T: R8 F+ u% \/ ^9 i+ U. a' T8 e6 z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% w9 t- G+ S( K
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
f) Y1 ?. m( j4 @; _#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 \9 x: a6 O. k
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' B; {3 J8 g0 {4 y; L6 N: `8 E0 Y1 }( ~- t- n+ l+ y7 y W8 I7 T
/* assign the tl som board LED-GPIOs*/ ~: l0 }+ ~+ ]& n2 P. Q& P9 R- S
static const short da850_evm_tl_user_led_pins[] = {
- X# h$ K( P) A9 d% D! u* X' G! l /* These pins are definition at <mach/mux.h> file */& {3 }; K( }9 a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& _: p, z. C8 D+ l
-1
( g, c0 o2 S V: `/ f}; L" v( O+ p% ^' U
& i3 p% S! a* w+ ^+ I* m- b
static struct gpio_led da850_evm_tl_leds[] = {
) [. w3 k3 @- z0 [' { s/ z4 e {5 f M2 Z( Z! Y5 e3 }
.active_low = 0,, D: Z5 W/ K/ v; Y
.gpio = DA850_USER_LED0,
5 I/ z- B5 n# `. H# t .name = "user_led0",
! l" n5 n8 x2 o. X+ c) V .default_trigger = "default-on",
' y7 ^: G2 P( \9 b% d6 c },
" i* X/ R; I6 U* z/ n4 ~/ ?8 _8 X3 U {7 t6 }) y1 @" A/ _! u* ]* ~
.active_low = 0,+ d3 F( [! r& b3 X
.gpio = DA850_USER_LED1,8 j" g0 \0 ?- \7 @
.name = "user_led1",' d/ \5 S1 T( [ c' b- X/ T
.default_trigger = "default-on",
/ I: u. I: v: p7 E" c6 ^9 i },; {, m8 z; O# c2 f" V8 M
{
. x, k7 e* U/ d" a; ^- |2 Y% e .active_low = 0,) i% `; z/ e: `, l- k, f7 x
.gpio = DA850_USER_LED2,
5 A5 u3 _8 y8 V2 G+ r5 W# o .name = "user_led2",
! [1 b S4 N+ d+ ]# W1 G6 u0 e2 S$ ^ .default_trigger = "default-on",
2 N% P0 s6 E# l# t+ }2 f! H3 i- E },6 E- I! T$ r+ E9 h; u
{7 H. W$ ~, ~9 D$ z; S0 R4 H( _
.active_low = 0,
3 P% v6 C- f% f$ j/ [4 s .gpio = DA850_USER_LED3,
) i- v1 H- R5 i( ~- ~1 ` .name = "user_led3",8 e# z* O( |. ?9 A
.default_trigger = "default-on",
4 t) f+ o% M, S },. j( R; h6 @; t/ j$ j
};
7 K1 N. H, u5 s! @. V5 P
; L) E I# n. ?! cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- M1 R" q9 g' n
.leds = da850_evm_tl_leds,) K2 f. m' D p% H& j/ O* u1 _
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 A+ i5 j! I: E
};
2 Z# k4 l( z5 l, @, _4 R" c. \
. s2 _; q; r/ s7 S0 M/ hstatic void led_dev_release(struct device *dev)1 O' r6 N+ o! e- l1 n& c
{
0 G0 q- q( T5 f};6 i6 X& M3 z4 d
7 G9 [0 c5 }( t4 y" R
static struct platform_device da850_evm_tl_leds_device = {2 f0 x0 X1 ^9 W7 j) u
.name = "leds-gpio",3 |) r% b. ]) ]% J0 ]0 l
.id = 1,: s8 C6 W/ q2 ^& d& M
.dev = {
- U+ Y0 r6 W/ M9 `; p$ | .platform_data = &da850_evm_tl_leds_pdata," ?9 t# e+ \/ C& [7 j/ `
.release = led_dev_release,: R5 j; R; y" ~. A: P
}
' R$ q% v5 [7 Z% g* I# N7 O};" R9 E/ j) P: W# K: r$ p' A
: H$ m8 e# {/ b% e9 \
static int __init led_platform_init(void)
4 M# ~3 S) p% t3 S% a' O{
' J7 L7 w1 M, a( u int ret;
. S+ Q! [0 w) s$ _2 k4 H6 l' t#if 0
5 C0 v. i4 w( A9 U' l: P ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) [6 q9 S9 Z9 V/ ]* W6 l* L7 A, {. j; E! O if (ret)
. Y5 X* y! h! h. f6 _ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 e, [; J* L: h: `+ l
"%d\n", ret);9 M0 |; f' ^) x
#endif
. u. A& T$ u% J* d6 r- C ret = platform_device_register(&da850_evm_tl_leds_device);4 Q8 _$ F# J9 O
if (ret)( r( t, i' ^- b
pr_warning("Could not register som GPIO expander LEDS");% Y: @ r5 B& l
else
0 S* |6 w- j* m0 {5 b. P printk(KERN_INFO "LED register sucessful!\n");6 U& @- y% N, E2 q: F w3 T
/ D9 X! G: h- ^) c' y/ I
return ret;& l6 p/ ]" p. i- a' B+ ^; h
}
2 n2 p, w. Y; o$ v8 g" D1 r0 T+ s1 x- s# F! N
static void __exit led_platform_exit(void)6 F8 b6 \, d8 J/ J# L
{& M( z$ ^6 X8 z5 a1 z8 V4 e
platform_device_unregister(&da850_evm_tl_leds_device);- V& S, i5 \9 [: T
7 H- P L5 X4 v; |# m) ^
printk(KERN_INFO "LED unregister!\n");
n/ C5 K# u8 m& Q- A}% [6 t9 e! n1 i; F5 U
1 p2 s- L, S) E
module_init(led_platform_init);+ t0 b+ C' h) Q: P1 D5 y/ D+ A7 `
module_exit(led_platform_exit);
7 \! d5 E/ J1 }
) y+ E( V7 m' Y% y" l5 m# a2 q4 BMODULE_DESCRIPTION("Led platform driver");. ?! w/ f8 o& u5 |. b
MODULE_AUTHOR("Tronlong");
+ ~) A# ^8 X% AMODULE_LICENSE("GPL");" C- E! D ]/ h) k
D" O/ [& p: Z( ^
|
|