|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 ]$ t2 x% y! {, G( U#include <linux/init.h>8 J' \" L" i* y7 i. Z
#include <linux/module.h>2 A7 i _+ S# r7 ?" }" ]
#include <linux/kernel.h>
& S. u- s/ E- X6 f; ^#include <linux/types.h>
5 K3 J+ q8 h8 u. v#include <linux/gpio.h>/ _8 c$ z- S; h q: Y6 q
#include <linux/leds.h>
/ ]- k+ U& c5 V#include <linux/platform_device.h>
9 ~7 S7 I0 U/ X5 b0 U3 K6 x* _, _8 c( S! B' H7 _* H, b
#include <asm/mach-types.h>+ c: E. i( G! m/ G* Y) g1 I! O e) N
#include <asm/mach/arch.h>
- E$ t+ Y' D! \#include <mach/da8xx.h>
5 ~: k6 Q9 O/ N$ ?3 o1 `* |#include <mach/mux.h>
m9 _$ B* Q/ [3 O5 g8 Q6 i3 W# O: B3 A" W5 ]: ]! I
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 Y! z! H2 |( Y6 h& z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), z. A$ h& j1 r% m) D3 F7 _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& D4 X: e/ H0 }6 F" a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# D h5 j! S, E, k1 Y7 F2 } `: D M3 N
/* assign the tl som board LED-GPIOs*// L6 ?0 N: U' ~: j8 c
static const short da850_evm_tl_user_led_pins[] = {! `4 v& i: d* h- W
/* These pins are definition at <mach/mux.h> file */% q+ p' q' U" d1 Y m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# K; M2 w- Q6 I# {, p5 g5 _ -1
6 D% T& X# K5 C5 Q1 u};2 c- e+ S4 e" v5 _ w; E# v
( |4 i! B: i% x( K6 L- s( _static struct gpio_led da850_evm_tl_leds[] = {
5 F' p( y5 P3 j+ `) x2 b% ~ { b% Z: z C# K1 E+ R9 H
.active_low = 0,
. Y5 e/ E9 |5 R( T .gpio = DA850_USER_LED0,; a9 w" w1 y H2 l, V2 A
.name = "user_led0", m& v6 y( Z7 K* N
.default_trigger = "default-on",
- D% w7 A' t' [ },
! a% F. g0 }3 ~' X% ~ {+ `+ G8 I) j! ?" a! o1 t
.active_low = 0,
6 I0 U1 n8 b* @& R0 X .gpio = DA850_USER_LED1,
) }! b, B+ x9 [( ^9 J1 s/ }$ A# [+ V .name = "user_led1", E( r3 o- E' w$ E0 s1 @5 R- N+ e
.default_trigger = "default-on",0 T/ K5 \ Y" F5 R% f; z8 O- ~
},9 N1 o2 M8 y" z. s9 g+ J: _
{
2 D2 s. z2 O: F& Q .active_low = 0,
4 ^( {+ M: [* w. M l .gpio = DA850_USER_LED2,
: p- }, v5 J9 P* s. D) \& p4 o9 L .name = "user_led2",
. @0 M& m" B: [1 ?( ^ .default_trigger = "default-on",
7 f5 A7 H6 D! _2 e8 }. M },
( v% g4 J" f% H, B {& M: I/ ~* N* _0 D* r
.active_low = 0,
; ^" C; a0 N, T: n1 Y .gpio = DA850_USER_LED3,
% X `; ^! ?5 a/ i% o+ D9 b .name = "user_led3",
7 {# r# f @9 @6 t; V$ L8 U) c .default_trigger = "default-on",
9 s" C F1 G. H! \9 K" e! R },# i- B6 b+ Y) d, N
};
0 Y7 t. W2 Q- D
* v) m5 H5 ?# y2 y9 Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 E6 w7 x' u- L( M0 v: u% D .leds = da850_evm_tl_leds,
( N1 A3 g7 n. i% _# o2 ?! i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- P$ o; s h! M7 J! X6 W};
8 t' _ i. i9 m+ s, ?; \6 ^% p$ r+ z4 j5 \. U1 Q5 T$ i
static void led_dev_release(struct device *dev)
! d7 l& e& N/ |- G! b{" b3 R8 X7 }9 O+ w; M! `5 d4 D. T7 R |
};/ X3 ?' _4 r5 v2 f
4 J/ Z3 Q5 g0 n8 @static struct platform_device da850_evm_tl_leds_device = {+ O! d" }7 d) R1 k# ?( x
.name = "leds-gpio",
# P* z' V! y$ z% v D: } .id = 1,
/ b8 m" e8 W' p% t6 r R. m .dev = {
) Y7 I9 b. Q+ j .platform_data = &da850_evm_tl_leds_pdata,
9 e2 v V4 d! c2 t; F/ Y .release = led_dev_release,
9 o) V; a, b' v% f7 [. q* v$ j0 M0 j' c, Z# ` }+ O" T* g6 Y0 Y) i- G% W
};0 `1 T. `/ x8 Z
% A5 S* m* N, j+ C4 o% e
static int __init led_platform_init(void)" X) H: x, p4 M& k( q
{' D8 G7 u9 y1 H# W* h: [
int ret;! _0 Q% w1 H; j$ k Z. F2 M
#if 0
( m; ?4 M, x4 G2 \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: a9 y: q) l0 }3 t4 P
if (ret)1 q6 V4 V( c# ~' x, `% \
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") F! F5 ~9 S* \( q
"%d\n", ret);# o0 b7 ~, \7 V# d" [. ]
#endif
2 T0 K% `/ |. B ret = platform_device_register(&da850_evm_tl_leds_device);, z" I8 u& F1 P0 r/ c6 P, A
if (ret)
1 c- x E0 O7 j% Z# t pr_warning("Could not register som GPIO expander LEDS");' `- G: E' P0 }# \$ Q
else. R& a% N$ b/ J5 V8 u6 `* s2 e
printk(KERN_INFO "LED register sucessful!\n");4 o& I+ W6 ^* j; x
; v6 L3 u. F8 A
return ret;, F, D; k8 v) [" a+ N- F7 n6 u0 _& c
}
- h, O9 p. f! o
& b* l. M+ R- K2 jstatic void __exit led_platform_exit(void)
- `8 V$ ?5 ]" l4 f9 _. b" j{
6 }, W8 p7 ~! a/ ` platform_device_unregister(&da850_evm_tl_leds_device);1 v/ i; Y( \; D9 g2 E
, m4 m6 m; Q: ]* B" F printk(KERN_INFO "LED unregister!\n"); T( j8 G* v+ p" m9 V3 c- k
}0 F$ z( O3 F: D
' j( h% a# _0 E, w, c; }+ Z( bmodule_init(led_platform_init);
) y; @4 a$ A0 o, ?+ e, o, wmodule_exit(led_platform_exit);
/ |( D4 J0 Z* R G
) l: Z' L7 H7 v3 S9 _$ BMODULE_DESCRIPTION("Led platform driver");
& V0 ~5 ~: K. b, p% Y+ PMODULE_AUTHOR("Tronlong");
6 |4 i. H$ ?0 t. h0 RMODULE_LICENSE("GPL");
2 G: C) e3 k; ^3 ~% @
" B5 t- I0 _* r6 j& W0 T* Q |
|