|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* h$ w3 c$ {' L, _) A! J
#include <linux/init.h>
* K) { z/ ]( l) v9 y#include <linux/module.h>4 ^: g1 i) N4 N1 j$ j" j5 @
#include <linux/kernel.h>: Z: G; B) M& M) {+ y& t5 t
#include <linux/types.h>
9 u! R$ y7 C$ J' B#include <linux/gpio.h>
! j( x# p1 y$ p. C, c4 t#include <linux/leds.h>/ P/ m3 a$ b9 b7 _2 p* C# T5 ~
#include <linux/platform_device.h>6 w/ x- y1 `! k' [$ Q
( w! @$ ?, B1 f8 @2 u#include <asm/mach-types.h>& {. v' [7 L5 t3 O+ g! ?2 e
#include <asm/mach/arch.h>/ y1 s* } P; d' Q; G4 V% z2 @9 }
#include <mach/da8xx.h>
$ J1 {2 b4 U4 m2 ^& T4 t3 f; Y#include <mach/mux.h>
: \- A3 d8 X8 L/ k4 m
( N, R; z. d; ~0 I# H. f#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( _+ ~2 X& E' a$ @( D6 O3 q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; ^7 ?2 [3 V; I( L$ J( T. {8 m r( M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" Y% u( ~7 u; m) O0 t& Z! K% k5 D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) e* Q( `% e- f; M4 [+ g; x( J/ |- k
/* assign the tl som board LED-GPIOs*/$ l' f% }/ U6 ?
static const short da850_evm_tl_user_led_pins[] = {
( t3 r( D: g* t) ` ^ X4 b /* These pins are definition at <mach/mux.h> file */: x- F7 U7 a* G1 w
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, c; Z4 ^4 b7 r2 ~ -1
) z4 t5 J' Y4 D% P6 U};
, J6 x# ?, j: u/ Y
; c4 S: n2 B K$ P, j) |static struct gpio_led da850_evm_tl_leds[] = {
) [) f* p9 X& P) d# |5 P: @" y {0 K! Z2 ?( t" k8 T- I
.active_low = 0,
* X) @& J! g* `$ Z9 A/ o5 t .gpio = DA850_USER_LED0,
6 D' B+ d+ E& y" e% q9 O .name = "user_led0",
5 @- D8 y' @" G2 K) |1 v' A .default_trigger = "default-on",
7 D% u$ t4 j/ \0 `! m },
6 s2 w$ J. {5 r& l3 k: A$ P1 R {6 l u4 z0 x0 i; V0 F, {& y2 D
.active_low = 0,
( h. K+ f, _! [) R9 ^1 L& t; m .gpio = DA850_USER_LED1,
# Y: ^ Y( M. Q5 E .name = "user_led1",+ D; t1 l0 N# o4 A/ P
.default_trigger = "default-on",
1 q1 u( X& p6 r% l1 b2 l; p! ?$ q },
) W6 W; v1 D7 H; k* H$ r+ x {
" Q6 s* j( `' t# Z .active_low = 0,/ R3 Z" Z1 D4 B, h8 u
.gpio = DA850_USER_LED2,
, t, f5 T2 H; w m: H1 u3 r .name = "user_led2",- w& X: ~( x( ^* Y+ V/ W
.default_trigger = "default-on",
- B! K: E2 I- K. ]' H9 Z" M },# ^& i/ S2 b$ Q a6 B
{$ t: V" n7 J ]* y
.active_low = 0,& L, q# X( M7 Z0 ]9 I8 W
.gpio = DA850_USER_LED3,3 T3 A( _1 }6 C
.name = "user_led3",
; U0 G5 U; o2 g/ b. ]2 t .default_trigger = "default-on",
0 O9 k+ n6 g' s },9 p3 v- E2 Z4 J! O1 V" F6 v0 P
};
' x( Y! K; i0 E* j* F. ^- r* j2 u& K' m, K9 a, Q3 h
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: {" g9 `6 n0 ?* u8 q! v .leds = da850_evm_tl_leds,7 g. H# ?4 V2 A" h8 ?4 i$ k
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ v- y6 ~; v4 r5 ?
};
' E2 s) |) x2 x5 K% a3 ^+ }5 Y4 c$ K0 s4 d! ]
static void led_dev_release(struct device *dev)
0 W9 ~8 F7 T3 x1 N8 ~{3 v+ j4 `3 H U% b% g/ A
};" n8 S8 Z* J7 H& }/ f4 w# j
! {7 C5 _5 ]+ z8 U7 m4 u
static struct platform_device da850_evm_tl_leds_device = {
3 N0 z2 Y5 E/ p .name = "leds-gpio",; L6 w$ y' n- x2 y5 J/ V+ d
.id = 1,
4 m: R! [( w# q; Y& N9 K3 ] .dev = {' @. w; M- U. W1 w
.platform_data = &da850_evm_tl_leds_pdata,
' }% @. o4 Q( B .release = led_dev_release,
P1 h+ X: p7 \1 |+ H }2 v! ^ o y4 F2 p+ [# v
};
9 i3 w8 L. D* w! ]
# |3 _9 J8 U" i Y, h# ^9 ]static int __init led_platform_init(void)
& [* m4 f8 D0 J{1 h6 h6 G- z V5 l: c
int ret;; R$ f2 {! ], |4 i
#if 0& p, j* s0 k# _# n, W2 r+ N
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ U7 Z! f1 M! p1 \- B if (ret)8 \( H: Z/ {* F' A; Y, V V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 L* ?0 ]+ e; t3 E, x "%d\n", ret);
, n& S4 c6 k& U |# v9 S3 \6 ]#endif
% P# l# P3 A7 P& i' g x. g+ D7 {* J3 k ret = platform_device_register(&da850_evm_tl_leds_device);+ M; `* i4 j6 }0 H
if (ret)
6 t' X, m4 U3 N2 b- l pr_warning("Could not register som GPIO expander LEDS");3 n" l: v" y' [# N
else
3 p/ h1 H7 r$ | printk(KERN_INFO "LED register sucessful!\n");
- E3 u6 Q: n0 m7 c% }5 }6 K5 y. C# n7 m0 E- V. U
return ret;
, k F$ }" u* w$ U- S}) z4 D& [8 N' P5 l% I' b3 o# @$ r
7 C% C `: S: n2 @. estatic void __exit led_platform_exit(void)
# m% {$ r& J Y2 v& G+ X{
& L( V' A# N! [6 ? platform_device_unregister(&da850_evm_tl_leds_device);
5 q# X: z' U5 A2 a+ S. s3 K2 T: l. _3 }' q$ p
printk(KERN_INFO "LED unregister!\n");/ b( @8 f" C% A2 [( ?
}
- U; p4 s+ X8 ~) N7 T$ x/ w& _
! Y, v6 x& W+ A/ k- Emodule_init(led_platform_init);
. P H# y) ^% O, m' fmodule_exit(led_platform_exit);6 J R! r ]( G" [1 }& ?
6 N1 o6 v9 y/ |" y3 i W" _& IMODULE_DESCRIPTION("Led platform driver");+ A+ B3 a5 @. i% h" [
MODULE_AUTHOR("Tronlong");
3 ?1 u/ r: k4 U, UMODULE_LICENSE("GPL");
& n; |3 F+ b+ U4 e2 r: M% t. a9 C. A* J$ H: s
|
|