|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 Y8 H( V4 n/ j( P+ w
#include <linux/init.h>$ w/ H- y6 n) r1 U
#include <linux/module.h>
2 N) D w3 v1 h#include <linux/kernel.h>
: m4 p/ j1 G+ B3 {) [#include <linux/types.h>: W: S9 n# C2 O+ i9 x
#include <linux/gpio.h>
% y+ d, ?2 \. I+ D9 ?#include <linux/leds.h>
, K# o) h8 p+ P* w# O#include <linux/platform_device.h>! Q6 @6 S8 w/ r0 q
- q. e. U9 }: c+ \- W
#include <asm/mach-types.h>+ \. F) S+ _: T+ x2 T: s$ a' |: i
#include <asm/mach/arch.h>
L) x9 Q' {) |0 }5 _#include <mach/da8xx.h>
& ?" Z1 B# t8 ?1 X! G7 q$ L3 i#include <mach/mux.h>. |) f4 G" j4 }. b
7 d8 a5 w; s( g( X' U f$ V
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 A: j Y) v2 M+ ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( J }* v) m: r/ A m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; G- {* | z/ r6 }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 y( _. @. S' D0 K8 y, l
# U% l: O3 L: |/* assign the tl som board LED-GPIOs*/' d3 @" j% k& w- }& z* _
static const short da850_evm_tl_user_led_pins[] = {8 U. w G' u1 Q& P' P
/* These pins are definition at <mach/mux.h> file */3 L F& L8 e$ D& K+ Q0 `1 `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 r2 G4 |! {: [! M& _' \% Q. O
-1
- T2 J8 ^3 k2 o9 _# b: Q$ x0 U};
# y5 ]0 z! M/ p! t; L9 N c
8 E5 ]$ j, P3 r' q5 z- B4 o ostatic struct gpio_led da850_evm_tl_leds[] = {" U: [, o" ^' F
{( V) W; s% }- O3 }9 ?1 L
.active_low = 0," r* I' ?3 L' K$ n" B
.gpio = DA850_USER_LED0,: R1 {9 _) O9 ^- F2 {0 g0 \3 d
.name = "user_led0",
" V1 E0 w* i# W, T0 Q .default_trigger = "default-on",% f9 R& ~/ O" ^. }
},- ?6 i: O4 J: y9 E. h P
{* w9 B3 ]5 U% {3 l
.active_low = 0,6 j4 w1 w, i: {9 {4 X! S
.gpio = DA850_USER_LED1,
" ~! i3 H) O! w) d2 @5 c0 x .name = "user_led1",: @' ^! l$ V0 j R
.default_trigger = "default-on",' W( ]- u, U0 x0 ]. c
},: h1 w) u* Y5 K
{
! ^% ~: R$ k5 B4 | |. H5 A .active_low = 0,
1 ^; @* V2 C4 ^% Y0 {5 g: ?" u .gpio = DA850_USER_LED2,* l! X+ V7 U/ C0 z$ P: U9 n/ {
.name = "user_led2",3 k L2 z! q7 l, E
.default_trigger = "default-on"," h1 E- c7 F6 N2 w ?
},
7 T B6 c @+ _+ s4 g: |) ?5 K {
& k0 n' K# W' E) I .active_low = 0,) N4 T; m" ^$ M$ i8 T/ _% i: E
.gpio = DA850_USER_LED3,
2 h% i+ e+ }3 p1 l$ b .name = "user_led3",5 |+ M1 ^; m# A" |0 x/ S1 d
.default_trigger = "default-on",9 Z! O2 t+ L4 H# [- a4 p
},
/ Y8 x1 c9 h1 q" K! E" k, B) I4 W};& |" G2 h: c1 F* w2 H
- E6 O' K* ?4 @) o% k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 G# U+ i7 Z/ P5 R1 U2 k& U5 g' t
.leds = da850_evm_tl_leds,
* J6 J' N! ?2 E5 T8 m% o; s .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ N6 T1 j6 e5 B: D5 |! ~4 m};2 s7 U% e- n3 [- b6 Y% V$ W
* I7 a$ u5 Q: P+ l6 C7 D
static void led_dev_release(struct device *dev)
6 C R( L$ Z) a4 V; i{4 F4 k( {/ a( a- [ \5 q* \( _
};; m; B& A' M& o6 e; g1 b
6 ~9 i ^. h6 x; A: n
static struct platform_device da850_evm_tl_leds_device = {
- L2 O; @3 a3 `. _4 P- B8 I0 v) a .name = "leds-gpio",+ g0 U- Z) p) D* f
.id = 1,- A; g3 h7 H% Q9 K" c7 j
.dev = {5 K* s: K. {; T5 m$ t
.platform_data = &da850_evm_tl_leds_pdata,
9 I1 d% V5 _4 v0 N4 W( S# | .release = led_dev_release,
2 A; E5 F9 J m f3 g8 | }9 u- z: }5 d/ U
};0 g- \2 z$ |" V- p/ A
8 ], G6 g# ~: {+ x" z mstatic int __init led_platform_init(void)& i5 D+ B5 q+ U4 _
{% Q# ]2 u* \. ?0 ?# c, @
int ret;
$ h/ E9 U: D( l# K7 u6 p: m9 Z#if 03 |- L" T- G( P
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); N! G7 z3 f ?& [: T
if (ret)4 J" J3 [" k, M+ j7 d' O
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 \6 a- Q& q4 k. r \8 c "%d\n", ret);+ m4 `4 a/ d B: C9 Q: U, N
#endif
; l- r3 ^; f8 m0 B& d ret = platform_device_register(&da850_evm_tl_leds_device);7 V; f% z) e; A1 t3 |; I
if (ret)
# j- X: R4 B0 r$ S pr_warning("Could not register som GPIO expander LEDS");& ]8 a& W1 `) y2 G. {5 S6 c
else
9 k% r, G# u, Y q9 f6 V' {# o2 z: g printk(KERN_INFO "LED register sucessful!\n");
! e! p# |3 K4 F
2 X! ~" d$ Y/ j return ret;! \: C$ O" I' o0 b
}
6 [! V( j+ L8 |% m: d& T& m! c( e: K
static void __exit led_platform_exit(void); x/ U% B6 R$ E5 K2 [% u) K& q5 U1 y
{
8 l/ p! A! B; e6 g# r platform_device_unregister(&da850_evm_tl_leds_device);
: J' ? Q' _5 K( u' Z; k7 I4 w+ G! E' d
printk(KERN_INFO "LED unregister!\n");
6 e \0 ^1 c. ?4 m! w5 t' l9 l}: B: ~, v- r5 F1 E' i+ ~& d
) q; m8 v- [1 z* t( Z% M/ p' m5 Lmodule_init(led_platform_init);* Q% p# H/ M% ^4 W: `+ E8 ~
module_exit(led_platform_exit);) K- s/ e; ]+ [ S" ?
7 E# O0 l9 a* {1 ]; b1 ^' `
MODULE_DESCRIPTION("Led platform driver");
" _: S6 Y3 O4 c t7 hMODULE_AUTHOR("Tronlong");' r$ M; {5 a# h8 J- z7 c
MODULE_LICENSE("GPL");
2 I8 N1 u( I; l! B Y" E/ w% }! |/ z# S5 O v
|
|