|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) @" ]+ ]0 e9 @
#include <linux/init.h>; a8 ~( ?5 U/ x% p( b
#include <linux/module.h>
' G4 Q* D# F e" B8 g#include <linux/kernel.h>1 V0 ^3 h- H! y3 D4 o
#include <linux/types.h>
8 P. E4 L6 \3 E- S) O& P#include <linux/gpio.h>
4 \- \% Q' [. [#include <linux/leds.h>& f0 h9 V6 a V+ q6 `
#include <linux/platform_device.h>
) }$ t, Y' u U; f" r5 a
- f% S+ }0 B r1 b: L- C#include <asm/mach-types.h>
4 d1 {3 r2 D8 B! b3 n6 Q, q7 I) d#include <asm/mach/arch.h>2 R, Z5 x, `2 ~+ f1 H8 V
#include <mach/da8xx.h>
5 {6 @5 e [' s) j& H8 M#include <mach/mux.h>* u6 i) F4 N% g7 f q1 E& g! }
3 ~0 E& j& I! J+ {4 c! a8 W4 A$ K+ v
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 l5 y$ A3 ?/ Y6 I9 C* U$ m' ?7 M# G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ a% y1 J0 E/ o8 F( E
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 Z, A3 `! i8 P$ [3 r
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' q" H& G* x Y3 `7 F5 F- O; @" V5 f: X4 ]9 N5 }* Z& h0 G; t5 }
/* assign the tl som board LED-GPIOs*/
( x& ] O- {: Q" rstatic const short da850_evm_tl_user_led_pins[] = {
# R7 X- e! D+ M7 B+ X /* These pins are definition at <mach/mux.h> file */
$ V, j8 O: n1 q9 u9 t1 ~3 u" z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! d+ k9 j' d7 d" j- N7 u( F
-1
. ~- j: l9 B* m+ S3 A};
- `3 I, s* S) Z' F% C6 U, h A1 F( C S `/ _0 P- o& G2 I3 b# [
static struct gpio_led da850_evm_tl_leds[] = {9 h0 J7 V6 P% x9 W+ ^
{+ i& }/ B" D* p4 u' I1 n7 F
.active_low = 0,
0 J4 q6 N! x0 O& H _. I, ]) I3 l4 J .gpio = DA850_USER_LED0,7 v2 o6 s( Z+ D5 X H8 A5 M
.name = "user_led0", w: p( P7 }$ x
.default_trigger = "default-on",
+ t* h4 `' C2 h! V/ ^; { },3 E( ?$ d4 H7 ?) ^: t2 ]& Z# d8 s
{ h. p( d' y; F
.active_low = 0,2 G5 ]. g2 S# J L
.gpio = DA850_USER_LED1,8 n7 T" i' x- L/ @5 e* G
.name = "user_led1",
0 h: [+ _( p! q1 h. p* A .default_trigger = "default-on",
" _% i; |% [# m9 W ?# D },
, ^4 V m+ B6 Q% S% J {# n2 N- y# q7 x
.active_low = 0,$ [+ M: D' o; p
.gpio = DA850_USER_LED2,; Z# H9 Y3 q$ n
.name = "user_led2",6 M) Q- A( P) z
.default_trigger = "default-on",
* L( ?2 y1 H, p) F; C6 J" G! {6 V; V },
. A+ F* S, {: k! b {7 ?. ~* V+ q. R$ S
.active_low = 0,
( I# e, h, j; L" t; V .gpio = DA850_USER_LED3,5 ^& u4 r1 M3 |0 Y5 _
.name = "user_led3",
3 g! {- ?+ t( u .default_trigger = "default-on",
' P0 I' t! \8 s0 ]* J! T },
2 f5 u+ Z% I! D p8 [};4 B1 z- Y" ]$ w& f+ | P# v
) a% ?! `, f3 M V! {2 c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ ^- t5 n5 Q+ g, A .leds = da850_evm_tl_leds,* z! i, W+ }( b4 p3 N: I# Y4 ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; p J7 N7 D! C& [+ t) z
};% r0 q! ~4 M; d0 \6 q* f3 m6 @
( j8 U/ C0 k: l* S0 Y8 hstatic void led_dev_release(struct device *dev)$ j8 S6 h+ D4 n* B% l
{
- @9 n' w+ s7 U5 ]! g: j}; O/ H' Q8 g5 B4 T7 E' b; R
7 t4 D' B8 N5 @
static struct platform_device da850_evm_tl_leds_device = {6 {: T+ W) B& X, B/ R5 l) D
.name = "leds-gpio",/ q9 K' N: _, ]# `6 Y: o6 k9 D- A
.id = 1,. r# E; ~- m0 x
.dev = {' c ?) ~ `4 c* R7 h) n
.platform_data = &da850_evm_tl_leds_pdata, g8 s- z! ~, z$ Z- D
.release = led_dev_release,) \ L' V2 [# l. z1 E4 k
}
/ X& O% D1 ~. ^( V. r};6 s ]3 c1 X3 a7 C* S, ~
7 T# H+ F# N4 s' e( `9 O: o- Y6 Qstatic int __init led_platform_init(void)
7 d Y$ K& E4 z# m{3 i o7 C# l- F( l7 Z. z
int ret;# V9 I$ V5 N$ ~& ]2 Y
#if 0
/ ]5 z6 }" x3 d ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 q- V* R) l% J if (ret)6 e6 G5 Z3 A( T. ]# y5 X6 [
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 d6 H6 o$ _5 d* ?5 ~$ d, d6 L
"%d\n", ret);7 a1 v5 e7 f% _6 z0 G$ F" ]* v) V
#endif
( k# J0 s( `; N1 @9 e$ D ret = platform_device_register(&da850_evm_tl_leds_device);- G, d* a* d w8 W
if (ret)
2 @3 X7 j: e; T" x1 |! v) W6 O pr_warning("Could not register som GPIO expander LEDS");; m" L* K, e/ m" c9 F) M
else
7 P, c& _3 _( d, C printk(KERN_INFO "LED register sucessful!\n");
. [5 @. }/ N5 ~; N8 b; B6 s# Y# G5 x
return ret;3 J" k H( O# |- Q9 {) p4 L& S* V
}$ l0 F' e5 Z( C# S0 {$ D/ r
; ]$ t1 G" ]6 W9 p ostatic void __exit led_platform_exit(void)
8 Z/ `" X$ R7 M- }; x{
) N/ J7 P$ X+ [; Z( \9 y platform_device_unregister(&da850_evm_tl_leds_device);
; s: D1 Y$ }0 b0 S; D1 C3 g5 ^, u. I! b9 `
printk(KERN_INFO "LED unregister!\n");
3 e4 d( D: Q( x- h$ N/ a$ X}
1 _/ B; V# y) z( c8 {0 T0 o0 U- i Y5 Q! j7 q0 }6 r5 v. g( o
module_init(led_platform_init);7 T" T. ~. O p9 i) t" T
module_exit(led_platform_exit);0 b) W7 @9 |" e1 ^4 R' K
7 m+ |* U# h4 F0 d; [0 ?, TMODULE_DESCRIPTION("Led platform driver");
6 ~% ~, M! F4 a/ d9 `: FMODULE_AUTHOR("Tronlong");$ x8 o7 N0 B% H6 k7 E- s7 M: I4 L
MODULE_LICENSE("GPL");
" |3 L. E E8 y; @; D0 f5 k7 b$ p' j b: J! b& E0 X/ T0 {, o
|
|