|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# i$ G4 @+ t5 b' i
#include <linux/init.h>8 E9 y8 G9 S) y! v
#include <linux/module.h>
: W& R& ?% @' z/ }8 U: X#include <linux/kernel.h>3 u2 P- W2 j! x2 n6 F* k* ]
#include <linux/types.h>
" F0 M7 @& e$ |5 r) A4 h: w: X! p#include <linux/gpio.h>$ x# k! v( w( ]) H& \! J6 z$ {
#include <linux/leds.h>; }; P2 D! ^$ C5 c
#include <linux/platform_device.h>
9 O1 W% | Y( u9 U) `# E' e3 N# X9 k9 \: i& s) S1 u4 i
#include <asm/mach-types.h># _3 V* ~- T* c- h V# m- w3 s; J& W
#include <asm/mach/arch.h>
, [" c) `; h1 h7 F% ?+ p#include <mach/da8xx.h>; k8 P% \0 u1 e" |+ G
#include <mach/mux.h>2 P @% N) P9 \* T* x
+ u; H1 T" t# u#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; O6 f X( Z( v2 Y9 D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 y3 H( b9 k: C Z' W+ j( c
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 j% B6 _0 j; i2 ~2 c: w, _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( Q z8 I, c1 [) R" o3 {: ?% P' V. S `6 d) M9 z
/* assign the tl som board LED-GPIOs*/1 }3 J# i! n# O5 a
static const short da850_evm_tl_user_led_pins[] = {: @, ?* W* {* P8 q3 _- a$ q8 d
/* These pins are definition at <mach/mux.h> file */9 B. g; u* H. L0 ]; D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. t; B/ v7 D( p; K6 [) d -1* g7 v; w9 {9 k6 V
};3 R5 k) _, z: o( `& O D
; {# d- v" i* @' r" v
static struct gpio_led da850_evm_tl_leds[] = {! F' i- q6 m5 l! F% T4 v4 _
{
- I3 B! `" f& V .active_low = 0,
. ^+ m7 a. F1 |( ~1 l& `" e .gpio = DA850_USER_LED0,# a: D( [" y9 u) x/ ?0 N
.name = "user_led0",. J2 R5 k9 M/ G
.default_trigger = "default-on",, v8 m- b- M" W. w2 H
},7 s: q/ j0 V* w. y
{
S8 ~# J; S9 I, x .active_low = 0,' `$ \) Q3 Q* t
.gpio = DA850_USER_LED1,( T ^$ P! Z) R; l
.name = "user_led1",% h3 r* h' R7 u( r
.default_trigger = "default-on",7 F3 d: n6 c Z5 s* O) S
},
( G4 h* G6 B9 g% t: b! q( k {$ Y$ `/ f- a8 i& K" F# _( V
.active_low = 0,/ d+ M2 Q' W& R, Z; o0 n3 S
.gpio = DA850_USER_LED2,7 {& j' b' Z7 `' L" o. w
.name = "user_led2",$ J0 }* N/ F6 ?) g: N
.default_trigger = "default-on",
( l4 r; A2 g4 ^# o7 a: R },% c/ S( D q9 a" [/ u3 P2 D
{
r4 j& L) E' B- y; f .active_low = 0,
) D4 j) P: t2 s$ s3 z. H/ l .gpio = DA850_USER_LED3,$ q* H, t' }( N8 d; d2 y V3 ~# i$ Q
.name = "user_led3",8 [- v( B2 ]" V" S
.default_trigger = "default-on",
# d' O' V7 C: d9 ^ },# w' `2 _/ M8 B: O
};5 F6 ?" u" V7 ?
! O1 B" U/ F% r" q4 Y4 Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 b+ _9 S0 C7 R3 @2 e1 m .leds = da850_evm_tl_leds,* U5 Q& D) ^% T; L( |
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ w( U2 |, N8 Q5 N, b% _9 J};. a4 P( z8 x4 M
' c: o1 I4 ?2 e' Y3 h
static void led_dev_release(struct device *dev)( Y1 d* |& u& Z/ O T' Y
{
- f# T9 ~) Q" u$ N: O1 g0 ~};
& ~; s, x4 z P* ` `
' K2 A4 Y9 G- C3 ~static struct platform_device da850_evm_tl_leds_device = {: ]7 L8 Q0 C& z2 T
.name = "leds-gpio",8 E! V0 W& l( T
.id = 1,! I" I* s1 A K- d1 b
.dev = {% g9 F) C# J7 X+ ~2 N3 @( f0 [
.platform_data = &da850_evm_tl_leds_pdata,$ n3 O3 d) T8 o' X" h9 x U: Z
.release = led_dev_release,/ z4 c2 A$ ~( _4 G2 B
}
1 `9 P' g) F w9 h/ u};5 a; q0 I. T; Y0 V
_$ ~$ d2 Y+ M9 u7 ~, N1 F
static int __init led_platform_init(void)9 H& g! a0 ]; }% @; p6 L
{# v6 z/ c" N% p) M# B+ Y" l
int ret;5 y* g5 d% ^7 f) y! w- ]
#if 0
0 G' M! M" l4 F8 x; g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
i! U1 T N( T# z( A8 B! D% c" O if (ret)4 O2 |; z; U0 I3 B4 |
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: T4 U5 h, Q$ ]! m5 N "%d\n", ret);
8 i0 M( R4 b- K: ]6 M: B. b#endif7 P# @5 U: F7 Y) F7 Y
ret = platform_device_register(&da850_evm_tl_leds_device);. S; b# W7 d. v+ b2 L
if (ret)* f( z: S% I( p1 G/ g! u
pr_warning("Could not register som GPIO expander LEDS");
8 X1 ?# k1 k: w& E8 m: ^( m2 o else
. Y, c4 @8 J7 ]- J0 R printk(KERN_INFO "LED register sucessful!\n"); ~5 E2 s- [8 X D# Z) p
; |" E; a/ L1 d" C. N! h return ret;9 h5 S. W. P! d4 J, x
}
, R9 X S1 U. B( @+ }& o5 [5 O( }
_6 M7 w0 b7 sstatic void __exit led_platform_exit(void)
; P, A: x( J( [8 D0 \+ ]; j1 c7 H{( U9 ^0 z4 k" f% R) j3 _
platform_device_unregister(&da850_evm_tl_leds_device);! m [* T) C* S0 k6 |* I8 q
0 u. i( g9 X5 @: o* h0 n0 O/ S. q! A$ M printk(KERN_INFO "LED unregister!\n");
% @/ w* u. h) U& R6 y# {7 d/ G7 N}
) W; _5 l/ L4 h/ f) r# W2 a. V' y" V" _% j: O
module_init(led_platform_init);, x) S& j! |! I! u+ u. {. Z' S
module_exit(led_platform_exit);+ @& k8 c. A8 L8 H/ f1 o
8 |- F- f2 ^5 C' \8 E! \MODULE_DESCRIPTION("Led platform driver");- o* n" e$ J3 j: @4 d8 h+ Y
MODULE_AUTHOR("Tronlong");8 e# t: }+ s* U- Q/ j ?
MODULE_LICENSE("GPL");
5 Z+ O# `: s. T5 o; S: U
. a9 p. X( p5 P; K- u+ z. l: I$ Q |
|