|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 k7 U- o) f% Q! h% F
#include <linux/init.h>
, N4 k9 w3 B0 `+ B7 Q' X( m#include <linux/module.h>! ^- Z! l1 E0 G5 Y" U6 b$ f* i
#include <linux/kernel.h>
0 b& E$ v ?) f- i. ?: h#include <linux/types.h>2 T' T; J" n! F' }2 z+ }5 x
#include <linux/gpio.h>% r% x/ G: E$ e* m, u
#include <linux/leds.h>, n$ j- P8 T) l1 ]
#include <linux/platform_device.h>/ Y, P! d( h: e% v
5 A1 i: L3 V1 G
#include <asm/mach-types.h>) @) T! _' ~8 e1 V( L
#include <asm/mach/arch.h>$ e6 o& O F4 m1 }5 w5 t: A
#include <mach/da8xx.h> d" c; I/ w2 q# y
#include <mach/mux.h>
+ V! X0 e. f/ V3 S. Y* X# E2 r/ B, U6 l. Z# V0 l' n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( j! U& }4 I' [/ X) O2 |: F, t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): o" A s9 F# B$ c$ X& C4 o' i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 g( t: k0 A* C" G9 H, t
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& O8 G5 G- u% ]; ~6 r r# \3 g
- ^9 y, e: t8 v5 d6 v
/* assign the tl som board LED-GPIOs*/" {2 C( A6 G7 B
static const short da850_evm_tl_user_led_pins[] = {- s) ]( b% m3 A; S0 D
/* These pins are definition at <mach/mux.h> file */
0 j. H! o3 v$ V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% t! P/ h, |* Y( V9 l7 y1 g -1
' G1 j- s4 J+ r; p, o};
2 B1 C( F0 S0 R2 Z% m! C: U
5 k h; s3 U, S8 g4 w* d0 w* ]static struct gpio_led da850_evm_tl_leds[] = {8 n4 U; c0 e, R( P3 M1 H
{
7 t5 D$ I( j' [* o4 S5 s .active_low = 0,
( ?& O. x) |* J4 E4 g .gpio = DA850_USER_LED0,) f9 S. q- _0 y6 ~2 r9 k/ N3 \
.name = "user_led0",0 S! k6 B- @+ F! f
.default_trigger = "default-on",
2 ?1 ]+ k' T# X },0 |6 j) c2 [5 S* N( ~/ s' C
{6 L- u# i- C+ e2 p, g* c h# z( S
.active_low = 0,' n& R* a8 ?: ^
.gpio = DA850_USER_LED1,0 H( z6 c8 o/ e0 o7 _5 T! H
.name = "user_led1",/ A3 D, h& y) U; d6 b0 O* N" H9 {
.default_trigger = "default-on", }* Y$ q& K3 b. t; X2 G
},, X. g- L. `" k! j5 B' T
{
3 r7 \9 D4 X6 }$ L( U .active_low = 0,
6 Z6 K8 u) y( p' C8 _ .gpio = DA850_USER_LED2,
, z2 U( P8 Z! j" f .name = "user_led2",
+ N( B& x& B; Q# H3 c .default_trigger = "default-on",
% _" u+ D- d0 B9 X f- H+ d },
$ }5 I% m0 d, A7 K {% u1 X( Y( @ |+ p
.active_low = 0,
* x P) Y& A# F. ~& Y .gpio = DA850_USER_LED3,5 P, W: K8 q; Q0 O$ Z
.name = "user_led3",
# H* t# R- q6 `8 l) ]. @& p, A3 j .default_trigger = "default-on",
9 K e' m8 S8 v- ^ },- z$ w" y% }- e! \2 O9 {6 |
};
6 N! i, O& g b) Y" J T2 ^4 X3 \& D" Y9 R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 @2 H! p( A8 a9 L
.leds = da850_evm_tl_leds,5 c8 e( Z0 \" x K; m. ?5 _
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, f+ E8 ^* e; d2 R- M) X( r) A" K
};5 V9 u4 G& X, O& b/ Z0 ?
5 y# x8 G' R% a+ A4 ` ^" O
static void led_dev_release(struct device *dev)) u1 h) s6 a8 D0 h; ~
{
2 D# L& F" {6 G8 B! u};
5 m2 q# x/ @) |3 n" C+ |
- R2 \6 \8 O( O! Gstatic struct platform_device da850_evm_tl_leds_device = {
# A8 j: t" }5 ~6 T# o .name = "leds-gpio",1 ]- H9 X1 w# b( U0 C' O+ F5 X3 i
.id = 1,! E; a: H+ G7 p8 ]6 _- g T% L
.dev = {
) B2 h( I4 [' W; O: ] .platform_data = &da850_evm_tl_leds_pdata,
. S5 |$ g; T" b1 i- D8 q3 t .release = led_dev_release,1 [- Z- z$ I3 m! h: g) i% ~0 _) ^
}- p1 n8 N( y* e8 V
};
; p, R4 O& g' \+ ^/ d F
3 P' i2 D# W% U# [; Ystatic int __init led_platform_init(void)& Y: B- L$ S0 X
{* b. L5 T f6 r
int ret;
" d3 q7 w9 m: t! T#if 0) ^# X/ H- ~- f8 u& W; g
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. r1 H' `& h- V; i& n" Z7 _, E
if (ret)
1 t( X; d8 d, c- q0 l" d9 X pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) o' L" m" F m9 \5 F5 |6 q) j3 `$ P "%d\n", ret);
7 M. y2 H' [7 L7 M3 t a7 a#endif
5 b+ }* W6 s5 n: A% N ret = platform_device_register(&da850_evm_tl_leds_device);# o8 X1 Q( t$ E, l2 U2 b D
if (ret)$ z& G+ s l6 G: g+ |# k3 ?0 d
pr_warning("Could not register som GPIO expander LEDS");
( A; \# w2 a% }5 b* e4 p8 `& N else, |) ?% n* ^' r7 p% J$ V- E
printk(KERN_INFO "LED register sucessful!\n");1 c5 @, L5 g: E; }2 D; g* j
! a5 b6 H9 M9 M4 ~3 l
return ret;' [- e& `) i( s# F' {
}* z2 k% k9 g. q/ C, e/ q
8 r' @- [0 G+ F( T* y2 Q% astatic void __exit led_platform_exit(void)' q( Z( ]( ?& c% L0 S: }
{; ^; R5 y1 V( |- e R! f3 C2 {
platform_device_unregister(&da850_evm_tl_leds_device);) I5 Q/ |2 }. w W. K
3 |; C; m% D4 f5 e2 S
printk(KERN_INFO "LED unregister!\n");
0 t" d' [3 e! ]1 d8 M}- s7 r, Q h2 P X. f
& h" S# y+ B( f' D* W p
module_init(led_platform_init);1 H" @ o i9 t4 ~
module_exit(led_platform_exit);2 {! S" ?. V9 a& f
9 h) \0 }$ \2 u
MODULE_DESCRIPTION("Led platform driver");
1 m/ ]4 O( y) h1 w8 X/ @( m' `MODULE_AUTHOR("Tronlong");
' o- {1 U6 k) ?/ IMODULE_LICENSE("GPL");
0 {) }0 S9 `1 w1 W I4 P4 p
6 ?% X3 b$ Z, Y$ B |
|