|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, e2 S& W$ ?+ j7 g$ |7 a#include <linux/init.h>, I0 h* `, z( k, V: P
#include <linux/module.h>4 C& m- F7 Y5 v! i3 M
#include <linux/kernel.h>% l$ E0 H1 _+ k( }, ~
#include <linux/types.h>
/ x3 J& ~7 w2 X4 z; ?#include <linux/gpio.h>
) t& V) J7 F- Y- G8 q#include <linux/leds.h>
) D1 P( U! a5 a#include <linux/platform_device.h>
: R& q i* A* u o
# V# h: a2 ?$ w! b#include <asm/mach-types.h>( n2 |8 {/ k( E/ {9 R5 }
#include <asm/mach/arch.h>) g" s4 i8 c; H. m u# j! W; s
#include <mach/da8xx.h>* K+ M9 O) ~; J& R. R$ B
#include <mach/mux.h>
* U4 \' H9 g k7 d& F) K
1 N( M. j; ?2 X' x- h#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 N+ H# {/ |2 b3 h4 `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- M6 i4 W$ @9 x* {+ O' }$ s
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 \# y5 H/ Z6 ~( D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ U) T) x1 w/ r K+ z
2 B- b& P3 r9 m% L/ v/ }; `- w/* assign the tl som board LED-GPIOs*/4 A% u, u% j$ H. F" U' W8 I
static const short da850_evm_tl_user_led_pins[] = {
+ z! g N7 q; f0 p /* These pins are definition at <mach/mux.h> file */
[' H0 m+ ^8 z/ s! g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, s4 u. C# h- _# B0 G) q4 y9 F9 S -1) x; M4 L! }5 {! t3 @4 M2 q! P
};* ?0 b& ^! d9 ?( ]% p
* j) a, w/ d' M9 I5 v Nstatic struct gpio_led da850_evm_tl_leds[] = {6 l# X( V& _' V" g4 @3 L" I
{
( \( d; A# @2 D .active_low = 0,5 w3 \( p7 Y. W5 f$ x7 Q1 F* y2 ?
.gpio = DA850_USER_LED0,
: ^) R8 q1 _5 m5 Q8 F .name = "user_led0",
4 W; ^" J8 e8 u/ p* p+ C .default_trigger = "default-on",* ^ H# H* u1 m- c
},8 e7 t" E3 S: u' ]: C
{
9 R1 z0 ^5 P& n; {- g4 \. \ .active_low = 0,
+ ^: S3 @6 m6 z8 N* N .gpio = DA850_USER_LED1,
, x, i" @; J) e. {7 l. P/ b5 Z6 T .name = "user_led1",
7 N z& |) V: j .default_trigger = "default-on",+ z% V, c$ g" u) Y9 S: z
},: Q* y) J5 {% I
{
. d% z, I, g* O6 c .active_low = 0, }) Y' a0 g, x! `, b' y
.gpio = DA850_USER_LED2,
6 H, J" u/ {3 i/ y& h5 S .name = "user_led2",
1 m# F/ X, B5 ^' B* l .default_trigger = "default-on",0 f6 C T9 w7 u1 U
},3 A1 v$ ]% X' h6 v% `
{" f) O# F# I; U
.active_low = 0,, M0 D6 s T" y* O/ l& e
.gpio = DA850_USER_LED3,/ i' A7 k$ ^- N+ b6 Q. \
.name = "user_led3",
+ k3 o9 i" K3 T% y .default_trigger = "default-on",
/ n6 M6 m7 |6 k% {: u& b! K },- g7 s9 |+ q: \' p; q
};
, t, {) l: C* _) J
8 l% }6 D: X: f, t; _& F Y" ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 I- @1 W! b0 u: {
.leds = da850_evm_tl_leds,
* F" l0 p/ x/ `- R7 i- E" ?/ Y& a* z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 W- r+ U# j7 e$ `1 D! L6 F& k6 _8 X
};
; T/ B; p' X, f3 ]7 M' Y
) J, }: c' G1 Y3 J5 Rstatic void led_dev_release(struct device *dev), p9 Z6 I( T' B ]
{+ q; w" J6 M7 A- ]$ _9 R
};: I# i% z- N4 o+ x8 }( c# Q+ t
3 {9 s$ z% C1 \0 A2 i+ E1 fstatic struct platform_device da850_evm_tl_leds_device = {
" \9 Z- i- I( E) V. u- h .name = "leds-gpio",
# |* J; \( }- I( {4 }0 J* r6 _9 m ` .id = 1,8 z8 P) L" C9 K. O" a
.dev = {
- f5 c" `+ Y1 _3 [, { .platform_data = &da850_evm_tl_leds_pdata,. D( m7 V# _- C/ F
.release = led_dev_release,& H8 h! Q: b! z6 F l, P, k4 |/ D
}
# `/ [) R7 h6 y( u& V/ q% p};& ]; l- s% V7 T) O
+ ~% b. n" ^& \: m' O: y1 n7 N' Tstatic int __init led_platform_init(void)
$ q- a. C+ P$ m3 v, }{- F- }. m! T& ~$ U$ H: w# ~
int ret;. s) _5 S$ j, E" C1 L/ }# l
#if 01 h' t n% p/ l u' N8 |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 p9 j4 r5 B/ Z" m3 l6 s. c
if (ret)
. |4 y2 p$ y0 T: l; {3 P- e# a pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ p& Y9 J T7 b, \7 f* `
"%d\n", ret);8 d* K2 W% ?& @ J% g
#endif
" g4 q3 I8 [; J% E: x Y ret = platform_device_register(&da850_evm_tl_leds_device);
& w6 ] `# M8 { if (ret)
6 E! {% p5 M) k3 p* a6 Q) r pr_warning("Could not register som GPIO expander LEDS");
2 ^+ O, X4 ^1 s" J4 M5 [4 i else+ X( r# j6 b$ F2 z6 \
printk(KERN_INFO "LED register sucessful!\n");/ I# @' ~) ?- G% e0 E) l- @8 W
6 z* l. y. P7 k' a: y
return ret;
( c! [" R$ H. P3 h9 V* S0 S}
f: p( j5 B2 Z
2 @' V, L8 {' zstatic void __exit led_platform_exit(void)
" W# n* c% d, [" ?# D* ^ _{
; n- v8 L( T; o% P. V& b& U platform_device_unregister(&da850_evm_tl_leds_device);" i. w; g/ W" ~: V `1 r
& Q s2 }. b4 b) b" G
printk(KERN_INFO "LED unregister!\n");% @/ n T1 A; _ l3 y5 d
}7 O: B6 E" ~+ Z7 \
6 Y9 c1 h, P9 F# N( w$ o
module_init(led_platform_init);
2 o2 V1 Z) Y' `3 I% {module_exit(led_platform_exit);
Q9 l+ V1 t8 U l; |" e, `5 `2 }! |% d: O" _7 x
MODULE_DESCRIPTION("Led platform driver");
8 j! O4 U p( t+ ?0 lMODULE_AUTHOR("Tronlong");
* o6 j' B9 |- C) iMODULE_LICENSE("GPL");
8 k, i) d* ] C4 L# N) L" {9 {, p/ @0 \9 v; o
|
|