|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 c" i, z" B: C7 U. z# v1 y
#include <linux/init.h>
* ~! a- p/ N: j3 B) e4 ]) z4 g& t#include <linux/module.h>9 f) e+ O. X( E5 v
#include <linux/kernel.h>) x2 w2 w+ A* {
#include <linux/types.h>
5 x& a: Y. ~7 K0 W' j: y#include <linux/gpio.h>
x$ N3 h# A2 @% i8 Y8 _#include <linux/leds.h>
7 P# S' m) K% F2 T#include <linux/platform_device.h>0 I. V" h K* o
" B% k- J2 ~6 v4 e) X$ ?7 J$ V#include <asm/mach-types.h>
* N/ L' u) x7 G. L#include <asm/mach/arch.h>
: Q7 h/ c/ ~1 l+ g#include <mach/da8xx.h>1 R; O8 M+ K- e
#include <mach/mux.h>) [2 _, ?& V$ {. Q
: g: V, k- p% {0 f" g1 A* |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) H. W: c* j6 A) u( Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# L, `# {4 Z. q0 t: r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 v5 e0 c E7 T. f p7 w: Z) ~8 P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: s3 k* r! l* } I
5 N7 Q2 U. T. |: T/* assign the tl som board LED-GPIOs*/
5 v' w, b# `: I" T/ pstatic const short da850_evm_tl_user_led_pins[] = {5 N- V$ h6 B6 `. Y
/* These pins are definition at <mach/mux.h> file */4 x+ E, ^% O& _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 M1 r9 Z$ M8 v: a0 k7 s. M
-1( ]0 p; L% f J, ^+ P
};1 m8 v1 O9 [4 v9 v+ O2 o* m3 x
: m0 F$ b9 Q, @1 K( F6 x/ y
static struct gpio_led da850_evm_tl_leds[] = {. P. P4 K+ \5 h* m9 K! f
{" Z( I! Y$ M R! T
.active_low = 0,
0 G& o9 I! c+ l' W# \ .gpio = DA850_USER_LED0,. W9 B& R3 d. ?# D; @% `7 L
.name = "user_led0",
9 x; Q$ X# {4 r6 z .default_trigger = "default-on",
3 X9 P. ]8 R: r" i },2 N' P- {5 F" j8 q- r" E
{
) K0 s5 r4 L: d4 m% s .active_low = 0,& K: Q3 p+ M8 e- ?* y7 f: h
.gpio = DA850_USER_LED1,. {- F6 E2 k J2 J$ ~
.name = "user_led1",
5 d# ]" p5 Z, K .default_trigger = "default-on",
8 _ Z4 v. X; R8 m' O },: g% H# \% f( P# A r
{# D9 b, z) Q9 t' m
.active_low = 0,
: T5 Z: F& J6 F7 ` .gpio = DA850_USER_LED2,: o# H+ t9 D3 y. l+ u& i
.name = "user_led2",4 z; l& r: A3 z, | j
.default_trigger = "default-on",1 U% b! Z1 r8 _- S6 R
},
/ U: g$ [2 |: u9 u; e% h {8 T! s; n! M) W" z1 j2 k1 Y
.active_low = 0,0 s5 ^0 O: v- o' X. w. t$ `
.gpio = DA850_USER_LED3,
& R' P/ O" t. V8 I) F .name = "user_led3",
4 f& W! G7 T, ]5 \$ N$ f' ^ .default_trigger = "default-on",
9 x( V; Y, O3 S' s* ~! I },7 z! b, Q9 ~4 i( k# J: q
};
( n$ W- _# |9 c6 A
0 y {5 v- k2 a3 k. X9 Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( H1 L' s# u, | .leds = da850_evm_tl_leds,
3 j# e1 M: \% C- R) s" |4 k; f1 x; a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 e g* F$ w7 N3 t4 m" `3 `8 }};2 _* I2 r/ @4 t% q/ B" k" a
, w4 v7 a* t$ ^2 [( Z- z d
static void led_dev_release(struct device *dev)
) s7 G- ~- L$ M' N$ T+ ^0 m{
`% d! T- q3 R5 I. `5 H- W% s};
2 S5 a% {. c9 Z7 Q } e: D/ L0 j6 T) G! b: D" ^
static struct platform_device da850_evm_tl_leds_device = {9 p' g& T, W$ x: r
.name = "leds-gpio",1 S$ F$ P& l% b" o( ^0 j9 r
.id = 1,+ }8 N& O0 g, c# V' ?1 u
.dev = {
) `+ U, V( d4 L4 V' g; O/ \ .platform_data = &da850_evm_tl_leds_pdata,
( d: D% O, b& t+ N$ f .release = led_dev_release,
* C: g2 K0 M( l* o g }
9 D2 M( F; K% w1 U5 U, k};/ q! I G7 {+ @8 k3 V
3 @9 b' D) L7 T, Q& L4 U1 r) S/ G. Astatic int __init led_platform_init(void)/ Z$ W' R1 J" }8 I/ @6 [9 f& H
{& C1 u! F( O6 @$ W5 m0 N
int ret;
7 u: D0 H7 _9 W a#if 0
9 p# ~% t$ q+ l: V( L! j ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 r5 p3 k2 y5 `. f( z. Q1 c
if (ret)
- I7 ^3 [; r0 u pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: Y! K1 z9 h! {* G% b3 k5 o "%d\n", ret);
* q" p/ g$ ~3 }, q0 J4 }#endif4 Z/ u; I+ N" y! i: w; ?
ret = platform_device_register(&da850_evm_tl_leds_device);
; k# ]1 M I6 j2 h. C9 f8 i if (ret)8 I$ J7 l+ t# Y7 h( C" i
pr_warning("Could not register som GPIO expander LEDS");
( M( k! a$ _1 X( q8 z P3 z! q Y3 f else
1 r+ w, U) m! F. e printk(KERN_INFO "LED register sucessful!\n");$ W$ E O4 ~* r& w/ |
! |8 c& ~. p9 h
return ret;
& K8 J3 X7 q3 Q4 z9 ^}; _; Y2 t! @1 z. W. d+ d. ?
% w) T, K8 \2 S- e7 D$ t' [0 K
static void __exit led_platform_exit(void)8 C( [: f8 p8 E% l7 X0 @. d& e
{
& ]% w9 Y1 \0 j$ f- K4 Y platform_device_unregister(&da850_evm_tl_leds_device);5 K4 t/ ]( P5 [
V6 k, x: ~2 Z
printk(KERN_INFO "LED unregister!\n");
$ Z8 U1 P6 \/ d/ g}
A* v L+ D5 _1 G6 M# w! I, r; C5 g- b$ @, g7 Z
module_init(led_platform_init);
" ^ \% y) g/ H7 M6 Q K9 r1 |module_exit(led_platform_exit);3 w( d" c# q% X8 `! A, F$ X
% A- |4 B5 |3 z9 ^0 h" d
MODULE_DESCRIPTION("Led platform driver");
6 C% \6 f+ N0 b8 [4 vMODULE_AUTHOR("Tronlong");
' e1 U+ z& A& v2 {+ C# l7 ]6 qMODULE_LICENSE("GPL");
7 C+ Q' u4 J. j8 S* e: i
: H- B4 v% H; S7 @ |
|