|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% u2 j8 ?, o6 L9 z( {2 B* g. H6 z" W#include <linux/init.h>. }/ c; N. X% h5 ?
#include <linux/module.h>8 J8 ^# {) i5 a4 t; O3 J3 c2 t
#include <linux/kernel.h>6 R. U3 G! c+ `
#include <linux/types.h>5 R q- A+ U8 ?- X
#include <linux/gpio.h>8 z% w9 y( W5 B% F
#include <linux/leds.h>- x5 D1 n! T$ T. c% p- ]6 E
#include <linux/platform_device.h>4 ]) Y7 }, m u3 M) | Q
* F* X0 J! r, z, ^#include <asm/mach-types.h>4 i5 C/ n; [! v( J/ E0 |6 ?
#include <asm/mach/arch.h>
. H! T* `. j! x$ \#include <mach/da8xx.h>+ o9 A4 l, M+ `' C
#include <mach/mux.h>- G% v% I! }: e, A2 }& `
, I& I* p# Y7 A, M4 r2 q7 R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( ?2 \# M$ U% Q( F- S' P2 @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 a, {8 s' ?6 V1 ]! Z' F) F#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 h- Q# L# o& L) f( `8 a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- g$ ~& Y; d ], [1 W' E0 N" n5 D& \3 O3 f& H
/* assign the tl som board LED-GPIOs*/
+ Y; ~$ z8 k; Q3 Nstatic const short da850_evm_tl_user_led_pins[] = {* g' ?3 D$ w9 q5 c4 {+ O
/* These pins are definition at <mach/mux.h> file */4 p1 O( y; T) w- b$ \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) R9 Z2 X8 W/ t7 K! E: }: N
-1$ H" a7 a* C2 ~2 {
};3 c0 Q3 N0 u- E
* i5 `+ j' y; H& T. Q5 Kstatic struct gpio_led da850_evm_tl_leds[] = {
' ?+ T; y9 q# h5 `6 O& A+ i% \ {4 u( w1 z2 E9 b8 Z" F8 o
.active_low = 0,5 h8 T6 N9 r+ S5 j1 m: \, v0 N
.gpio = DA850_USER_LED0,
1 P# i+ I6 [/ I& B3 z" _1 U" w .name = "user_led0",7 a9 b* W$ |3 G$ K" S& d& A/ e
.default_trigger = "default-on",
8 X: S/ k% z( y; ]8 g1 G( c },/ S, @7 E* v+ D
{
& H6 I) o2 n5 `+ O9 e .active_low = 0,
! o2 E9 f+ F, _5 ~4 } .gpio = DA850_USER_LED1,! j4 x4 ~% m1 s( ~- ^
.name = "user_led1",$ I, A% h& i- K
.default_trigger = "default-on",! _# a" j' c9 B' v6 B1 X" x' r( [0 h5 N1 S
},; P' ^: T. M# v7 _4 n
{
4 L& w2 Y# v& p, V3 j! Z .active_low = 0,7 R( v s2 G8 d
.gpio = DA850_USER_LED2,! n8 H g% L) g v0 K3 g
.name = "user_led2",
; R1 a; I7 f4 h) m$ d .default_trigger = "default-on",
& M4 z3 c8 f9 r* G" q4 E },6 q$ N7 U3 F7 M* t; \- B
{
! u- D4 d6 L' v( p( j) K5 M .active_low = 0," Y @# |- \3 X6 K4 @8 p( Z; Y
.gpio = DA850_USER_LED3,$ Z. X0 V4 O1 \5 r6 t v% x$ M1 O
.name = "user_led3",
$ E" G y- k! x .default_trigger = "default-on",
5 o: O2 o# i% u, I$ x- ?; T },( w& }$ a- N) P1 Q. o5 u s
};
1 E9 t5 W' Q6 Z' d, V5 B$ D6 U' i7 k8 i, J/ [4 b9 X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 o. s. l4 B+ j .leds = da850_evm_tl_leds,
! B, S1 k: F) N2 z# J3 L4 D9 f# I .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. j; |6 w4 Z; E6 V5 e3 x
};
0 `& U+ y4 y7 I m2 h4 `8 D2 w6 P4 E8 c
static void led_dev_release(struct device *dev). E8 `7 P0 p8 B/ A
{4 o) {9 j2 ]9 s6 P5 B. \9 E! L) A
};
8 O1 L- D1 y' d x3 l4 M6 Z; A/ I4 K9 B0 L, X+ J) I) d
static struct platform_device da850_evm_tl_leds_device = {
5 r+ c5 Q: E: }5 E .name = "leds-gpio",
) J; z$ Q0 J5 a% N/ E .id = 1,$ X8 U w* C; Q4 j$ f) G
.dev = {
5 x3 |* ]1 ^4 h2 x, d- w6 z& x2 N .platform_data = &da850_evm_tl_leds_pdata,
: x" e; O% J' n .release = led_dev_release,
4 q: L0 X6 z/ w }
. ?' o ?0 W+ i" C& ?$ d};. |, B0 X3 R3 Z' a s4 b: m
* H3 k' a, I1 ?. a b4 n+ {0 L% L; rstatic int __init led_platform_init(void)5 J6 J$ H" T) r1 S _
{
' f' }) R% B* l6 _* x6 Z4 A; F int ret;
( Y7 f1 | E+ H$ s9 v1 F8 Q#if 0+ a+ f/ P4 E9 C, [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) `! x6 s4 c6 ?5 N1 ]" i# D if (ret)/ k" |3 S' a3 @( Y" Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 |! R# t+ A* \9 z
"%d\n", ret);# n+ {8 `* ]; z* s3 }& T7 s3 B
#endif! _; l, e6 {: a7 m& x: v, q; j
ret = platform_device_register(&da850_evm_tl_leds_device);+ K# r1 M5 q1 ^3 q, J6 P9 f
if (ret)
$ V! R. F% D) h- z0 n4 u pr_warning("Could not register som GPIO expander LEDS");
0 ]: n1 [# ]2 c else& H6 A$ P2 \2 _, O
printk(KERN_INFO "LED register sucessful!\n");4 u" ?: Y' N, ~3 Z/ r# j
; L8 A4 `' b0 x
return ret;
* C: e& w+ n( r3 g# h}
0 ~1 k. d* Z+ H* A3 U
! o' E1 a9 \- v0 I; E K( B( p+ astatic void __exit led_platform_exit(void)
+ k& Y ]* h9 r0 |4 e) n* x{7 m, }! u" d B* N
platform_device_unregister(&da850_evm_tl_leds_device);+ `# D) \% a/ ^, X
" C3 {6 w% s+ z$ J
printk(KERN_INFO "LED unregister!\n");# I! ?6 D9 O4 q2 n# g( a) q/ t
}
" n- v R! Y0 C: I! g$ i" |) ^4 @; h5 S
module_init(led_platform_init);3 @! j5 V* _0 ~
module_exit(led_platform_exit);/ C% L8 W" ^4 q- p* p( z& ~
3 [! J8 M% t2 t) k: j
MODULE_DESCRIPTION("Led platform driver");
3 g2 Q2 w' r1 `+ DMODULE_AUTHOR("Tronlong");, z& \! d+ {$ ^# o
MODULE_LICENSE("GPL");( q; Z: M* O& @: \+ s- }
* n7 e# S7 l; B2 I8 ^9 C- f; \2 d |
|