|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 K9 K) z& b5 A+ k#include <linux/init.h>% O5 Y) p& c! n
#include <linux/module.h>0 }3 m4 d7 X2 g
#include <linux/kernel.h>, Y5 r5 r6 _& }
#include <linux/types.h>
* k0 b1 h5 }5 T#include <linux/gpio.h>, I1 C1 f- C& T
#include <linux/leds.h>
* F$ O7 _* d# i' ?; k#include <linux/platform_device.h>% P: c2 M; @. C. h
3 j# j% s5 p- i% I; [# {" p5 T" D#include <asm/mach-types.h>
0 ]7 n! J* z% m7 R9 k" U4 x& V#include <asm/mach/arch.h>
' r2 _+ \" d, h0 R#include <mach/da8xx.h>- \2 l3 Y) a g4 z
#include <mach/mux.h>2 ?' q$ Q7 m E/ J
3 a0 Z, D7 f0 o& g) p. J7 w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' o/ a5 N% W; v D3 j: }! R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 x% n( g: L u8 J: D; R+ `7 @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), K( ^+ w7 ~& I6 U2 L
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: G( m( i* V3 |" P( n% ^6 ?$ w |2 A5 W: I0 @
/* assign the tl som board LED-GPIOs*/
0 w# W! m" t/ G5 @static const short da850_evm_tl_user_led_pins[] = {
; e( z. ? l9 g /* These pins are definition at <mach/mux.h> file */9 `8 L/ G1 U% _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 u: C5 [3 @8 v -19 ~/ s2 ^( n& n1 a
};3 o# A/ `! v$ _# p/ w$ a
6 H; G9 S' [* x& [) ?1 {- X9 ~
static struct gpio_led da850_evm_tl_leds[] = {2 R; |$ R2 V* p- b) K" d% \
{5 I {* c+ l" V3 b: r
.active_low = 0,
) f1 X* l5 m$ ]4 [: b3 o6 M; V .gpio = DA850_USER_LED0,
2 O) B# c6 m9 l+ G: ^8 k$ N .name = "user_led0",( y; T2 M" V1 Z+ W8 U6 K2 m, e
.default_trigger = "default-on",* V8 o4 X0 T/ w& Q) U, A
},: ^" N5 e( ?- o+ \, `! T, L% e- Z
{0 V2 K* p# q3 q9 L! ^ F E
.active_low = 0,
9 ~1 K8 t! L& q3 f7 E6 `$ H* w |5 c; Q .gpio = DA850_USER_LED1,
' V0 T0 r$ X1 H& C/ c0 b .name = "user_led1",7 H5 m$ k$ O6 C/ A i
.default_trigger = "default-on",
) T. l$ q! A- A! |6 e1 ?6 h5 u },
0 x0 [2 m y; z {
2 c7 H# N+ z9 E; H1 ^! ~ .active_low = 0,* Q6 F7 ]7 k% i
.gpio = DA850_USER_LED2,
6 N) [1 [' I2 s3 m- ]# R .name = "user_led2",
4 G* Y( R( ~0 d1 M. k7 W .default_trigger = "default-on",
- | Y, Y; _) Q y8 B },
# s* x! a! p. H! N$ a, N' B( I {
1 [2 [7 z' H$ g+ F3 X1 i .active_low = 0,
7 M* h# C- D* f# @1 u& B- G .gpio = DA850_USER_LED3,
) ]0 h: f- M7 A7 H .name = "user_led3",, A1 F; Q, |- y. }$ ?( o f
.default_trigger = "default-on",+ s* q# ~1 x/ J% I3 Q0 N0 W% {" c/ q
},
! X+ z5 N5 y" Q: P# O! j2 I};. y2 g+ Z( U ]
. A: P6 D: B7 r; d* ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" j6 p" i% q5 b7 l: z
.leds = da850_evm_tl_leds,
6 i; G( y& l6 G .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 ^7 _2 a8 p7 n};4 D5 y* M+ P0 u) Y5 q4 e
( F% b" }# T K# c( u& I4 I& f
static void led_dev_release(struct device *dev)
5 {/ m) D! U, S8 `* P{
$ x+ w: {2 [1 I5 A. U};) U( T7 V6 N" w, B
# V) f0 z9 h4 m# T' `: R Ystatic struct platform_device da850_evm_tl_leds_device = {4 x- J) J; z1 _% s" K5 h7 |9 w
.name = "leds-gpio",
6 q* m( c+ @$ W9 s0 b) g .id = 1,4 ~ |) K1 i7 r, B" B
.dev = {0 @! U j6 g( a0 X1 V% X
.platform_data = &da850_evm_tl_leds_pdata,! N2 T" B7 A) I9 U" r4 e9 J; F
.release = led_dev_release,$ i/ J3 R! a7 k! O" k4 i; Y# k. L
}7 y& _# {, w& A8 M
};
" o: }4 e5 D. K3 x0 @: ?/ r# u/ ^. }7 w- f; q
static int __init led_platform_init(void)
; v6 [2 [" ^# P; {{. p# Q: v1 v2 j3 W
int ret;
! l8 w- T; ^7 B; u#if 0) m5 z# ]: b0 c% ?, X, T! l5 [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); B0 h( M) M' e1 z1 B. K
if (ret)
, i! t! Q) r1 a) d' ?6 @' C2 E: T6 G pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- D: m. Z7 b2 J0 g6 U "%d\n", ret);
# f6 Y, o- D. y5 @ X#endif1 V7 I1 y+ }% b) U- w; _0 T
ret = platform_device_register(&da850_evm_tl_leds_device);+ j$ P; Q/ W. u6 T1 V3 t
if (ret)
' Y7 A) W) N& g pr_warning("Could not register som GPIO expander LEDS");
- j& C4 _+ O" M1 `# S) |2 K else
+ P4 a3 I8 \- m2 P/ h/ P printk(KERN_INFO "LED register sucessful!\n");& J6 A$ F; ?' v V0 k2 T
4 J: P8 g! y. |0 s9 k) y! H return ret;
3 w( {2 @0 g9 v. Y& }* F}
' {) B; U0 x& R6 Y9 N$ K9 x6 q& y1 D# M
static void __exit led_platform_exit(void)7 l# E" C5 q% N0 W7 P- W" ^1 l
{- R. q! l5 Y6 h% k! ]) I
platform_device_unregister(&da850_evm_tl_leds_device);
; E( q5 j- }8 @/ l" u+ L: m: G% w; R& ]/ C( e% X( c( ]
printk(KERN_INFO "LED unregister!\n");$ f4 }' E6 K9 u, _! c- N
}' v9 {1 L2 c# B3 x% b
9 I+ J& [. x, D6 g/ x! vmodule_init(led_platform_init);
5 R& B7 p9 |% ~( ?6 u# l tmodule_exit(led_platform_exit);4 @' L4 B/ [5 i r
8 W8 j# `/ w9 D. y
MODULE_DESCRIPTION("Led platform driver");4 }. L) v- }" e2 [6 j
MODULE_AUTHOR("Tronlong");
1 \9 N6 Z& g6 J- _9 m3 [( P3 YMODULE_LICENSE("GPL");
$ ] U: P2 r& f. f2 R& B- w1 @; h# ]1 c/ V9 f' ]) I! ^+ L
|
|