|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ S# {+ h" P+ \( `#include <linux/init.h>
8 Z( G. o) g5 m: v8 v8 x#include <linux/module.h>
5 O8 S0 M3 ]8 d3 ~; ?5 }5 U" M4 r {. q#include <linux/kernel.h>
; W# W5 b# J& Z% g5 N3 \#include <linux/types.h>+ k8 N% C0 d( l, J4 V
#include <linux/gpio.h>
4 q e, l9 b' v2 E# @$ M#include <linux/leds.h>4 U7 ?, B2 ]5 v( F& b. J* g
#include <linux/platform_device.h>
7 N, t1 r8 Y" _
7 F) P5 X$ |$ W3 N#include <asm/mach-types.h>' X1 [6 {* b$ g2 {6 e7 _$ Q
#include <asm/mach/arch.h>; w4 S+ K4 L8 {$ F
#include <mach/da8xx.h>
d& V+ g% e0 ^! o [, V0 k#include <mach/mux.h>
- A x" |( D3 e8 D+ g
8 ^6 U( {% g* }8 O: P4 T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ n: R0 T3 c3 c#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), G" u" ]0 p- c# n1 B" M: e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 \% V+ M* V ^1 j, Q; E) z: L, B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) p$ p$ G9 t$ q5 m Q2 o: D
3 v& Y6 A( ~7 Q# O7 x T9 z/* assign the tl som board LED-GPIOs*/
! A) T* U6 ]4 v9 @6 Zstatic const short da850_evm_tl_user_led_pins[] = {* g2 t4 @ M, e- B" z) Q, y
/* These pins are definition at <mach/mux.h> file */. a- G+ Q& N( R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ m8 g1 t+ ], H1 Q6 W5 r2 X+ r+ S -1
9 j' k" k% p9 X7 k, q1 @" f};6 e" @3 U. u: B( \4 z, i
; f$ r: b. H' Z% v6 T/ c
static struct gpio_led da850_evm_tl_leds[] = {- q! d' G( c. W {% U" L7 K9 J; y G) w
{- M# d* p4 B; c' ~
.active_low = 0,
& d3 S5 g5 O/ g7 ~: h) S* H .gpio = DA850_USER_LED0,
7 X. h+ k0 O$ o/ O$ K; { .name = "user_led0",
# D/ U/ U8 b& P0 v V' r1 B .default_trigger = "default-on",
8 O0 D$ L2 c1 C, p' [8 ? },
7 q$ s% o8 t# Z. o3 Q; y2 \1 f {+ R: z2 r$ X+ p7 Y9 A3 L) J
.active_low = 0,2 Z7 H4 I! |1 D
.gpio = DA850_USER_LED1,2 b T! Q' x* l6 _, d" m5 t
.name = "user_led1",2 l4 P2 b* [# U- p* a, V- E. g
.default_trigger = "default-on",( q7 b1 a! w7 u9 p( M/ N/ p
},0 G) r: Y) x/ I
{
4 {+ [4 F( B( a/ J% b .active_low = 0,
/ k; I% l- f; E .gpio = DA850_USER_LED2,
3 I; ], O) V C0 B/ c- G .name = "user_led2",
- j* P6 t q0 x$ k2 V3 S }5 [ .default_trigger = "default-on",$ S; ]& b8 z9 \( V
},% d9 l! Z8 U4 [) G
{) l7 K% d8 P2 q* ~9 V
.active_low = 0,6 R# l# k. s- }4 b, f7 L
.gpio = DA850_USER_LED3,
/ t! `7 d2 b+ @( Y$ [ .name = "user_led3",/ A2 ~/ t' \6 I% Y
.default_trigger = "default-on",: R; J: ?- ?/ _# O( ~
},
& a; l) `5 E; w5 m l};
' W; c( A. R4 \8 v" P: t, p' w+ z( U- B- Q# p L1 \1 O. Q9 i* u
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: O# w1 h- Y4 U$ z2 U' f .leds = da850_evm_tl_leds,/ K& |% m* s* ]1 q2 K5 ]' `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, a2 \% T0 o2 z7 M7 ?$ _};; \7 R; R. }5 ~9 a2 a/ m
, o8 K2 p, E0 V) N9 K2 D; H
static void led_dev_release(struct device *dev)
; F, m6 B _" z+ V{$ c6 W {; w, R3 ?
}; m' \5 N' _4 N3 h
) Y' M5 J0 x3 Y a3 Mstatic struct platform_device da850_evm_tl_leds_device = {
3 ^# K# y2 u3 M- C! U: X .name = "leds-gpio",
6 d9 c4 A. {* E .id = 1,$ `4 |. S; Q( M z# z, t2 T9 I8 V, ^
.dev = {" L# f& h W1 Y& h# }( }
.platform_data = &da850_evm_tl_leds_pdata,
2 _7 H( m. G/ k' x .release = led_dev_release,
) W J5 Z" P, [( j }: w% K( q9 E3 i' I6 J8 [! i1 t7 S
};
- r6 J+ r5 \7 B- o8 u
1 T6 T t' z5 Q0 f+ I$ x V3 s; Bstatic int __init led_platform_init(void)
u' E+ |9 b2 x{
! O0 |% Y2 X" V9 c3 E int ret;8 u5 w: j5 d# }0 A2 U
#if 0/ T% D% c0 U" X. o1 {& U" f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 A9 k- ^$ {$ |' X. C; Y9 Q4 D if (ret)+ y0 B( p7 Q g# ~' y, z4 I! B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& p. C7 ?2 w2 e/ A" @4 [' j: u* H "%d\n", ret);" X+ \% {" w2 r
#endif
( Q: g8 x" O- I# b' z ret = platform_device_register(&da850_evm_tl_leds_device);- x- A1 u; h: H L: j4 P
if (ret)
& [, u5 e2 U) F4 }7 B9 W7 p$ d pr_warning("Could not register som GPIO expander LEDS");$ S' c. a+ t9 l4 g
else
; J4 x- ]' j! d4 W3 x printk(KERN_INFO "LED register sucessful!\n");
* ~8 T5 s' h$ B5 B3 W8 D" }
9 G; N( `" S1 t# Z7 e return ret;+ d/ p: d9 O+ X, P
}
: z2 D8 y% e4 f' B3 e# C% i4 T/ w( ~
static void __exit led_platform_exit(void)
5 U, g; |$ ^) ^% O0 |{
; o8 l; _: Y$ H/ H platform_device_unregister(&da850_evm_tl_leds_device);
" p6 B4 S2 a1 `+ B: b) L+ P v# [6 K+ J8 l
printk(KERN_INFO "LED unregister!\n");
/ K9 J9 Z/ h$ g9 S}1 z5 Q" b/ ]5 O9 W6 y/ C
# M* [2 ` }& c* umodule_init(led_platform_init);
: O) g* ]- R+ U' jmodule_exit(led_platform_exit);/ o i& g6 T/ U `0 _' D
: B' ]1 M; t% i" H( I5 JMODULE_DESCRIPTION("Led platform driver");
# s! w' a+ @6 t8 b- W) X0 y: R3 kMODULE_AUTHOR("Tronlong");
5 _* V% V: Q3 t" Y* C& g0 pMODULE_LICENSE("GPL");
: g# ? w; E$ F+ p$ e! d5 m9 R, [5 |; p! \
|
|