|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ G9 _- z/ a7 ]' {6 Q# v% z5 f: D#include <linux/init.h>
. Z+ o+ n4 |& Y g2 U#include <linux/module.h>: P/ N3 h% F/ R! A) d, P
#include <linux/kernel.h>
8 f) }' q' k, j0 `* O/ S; m0 }#include <linux/types.h>
$ y' ~- D/ V& p4 T/ I#include <linux/gpio.h>
) z# q' X9 k b" k, e9 N' P0 U% }4 Q6 N#include <linux/leds.h>$ X, \" p- ^3 F; W6 |
#include <linux/platform_device.h>8 {( U8 m+ w. L: [
% |" A7 L( D! e" B
#include <asm/mach-types.h>
{# i7 Q! T7 n, R#include <asm/mach/arch.h># H0 d" Y0 u0 q9 q j! [* p
#include <mach/da8xx.h>
; F; ~$ U% P# S1 n# w, R#include <mach/mux.h>; r \# y9 D3 s* i( c, q+ K
% M9 \ p8 q8 L/ h; v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' l$ P7 J0 M9 s$ R5 J, n' Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! J# d9 }' I+ F% O \# X: f
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) J, \9 x: O# W( j6 X. X7 y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ ^. w# C+ t& q: ^
L: i: i/ v/ M$ Q# F4 v/* assign the tl som board LED-GPIOs*/
, g5 G; j. G; T3 [# vstatic const short da850_evm_tl_user_led_pins[] = {, @" g9 |7 A, u
/* These pins are definition at <mach/mux.h> file */9 G2 K2 |/ {. k: Y# [4 [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 \: ^4 l+ f$ ~ c
-1
3 i' B) K0 ?) k4 ?# [' y9 r2 [; |};% ~7 M8 @9 g7 U/ ^% D0 ~8 e0 w
% G, G# E4 [1 ]+ Z: rstatic struct gpio_led da850_evm_tl_leds[] = {8 U! Z% q! i1 m/ L
{$ {& o4 x$ [7 [9 C
.active_low = 0,
5 R2 |6 m5 ^9 G' u E4 u0 u9 ~ .gpio = DA850_USER_LED0,0 ?& K$ H* ?! q2 u* M8 i
.name = "user_led0",
) [+ z6 A& v9 \6 S w .default_trigger = "default-on",
/ y4 a! A0 V3 W, {5 b% ~# X },
1 W+ `; @$ w1 H3 E8 T9 H1 K' \' j: t {0 }- p# w, R' B2 B5 P
.active_low = 0,( C8 z+ v5 {: |$ {) y
.gpio = DA850_USER_LED1,) a% X' F) g" C V: h' C, a
.name = "user_led1",: ]& T# z* r: s6 w9 F3 g
.default_trigger = "default-on",( r7 Y* p8 ~( Z' |9 E* u
},' W+ c8 A- B* s7 C* ]
{; \( {7 V a4 d4 B. P* X
.active_low = 0," }" \$ s; w. W3 [* o' i8 P/ w/ ]
.gpio = DA850_USER_LED2,
2 u5 P+ W: C/ l8 Z0 J. N/ q: h$ T5 _ .name = "user_led2",3 ?$ Q# U* `5 n l
.default_trigger = "default-on",2 B2 V2 d- T, K6 `
},
e" P- R3 W# \3 a {
( w$ E& q# [( R3 \: z .active_low = 0,
8 u5 z9 w/ j& h! V( c .gpio = DA850_USER_LED3,/ Y) K# i, j- t" R
.name = "user_led3",
( }0 T1 R( x+ m* N$ Q' x .default_trigger = "default-on",
6 N9 w# K& }' x `1 m },
7 b% t6 |. B. f" J* B};" |! T: b7 I: O5 C. {3 Y; P# a
. y" V( d1 y% X0 _: @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 v/ E6 y2 B* G9 U .leds = da850_evm_tl_leds,& }. s1 M: J3 |: X) ~0 I
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 D1 h* O+ i7 U; A; K* i5 d
};
; w: D/ e P) s6 f' l8 b
4 ~/ d1 P8 Z- @0 T( D5 v! I. Lstatic void led_dev_release(struct device *dev)
; D; Y0 W: Y2 Q. i1 F{+ Z4 T f7 Q; X
};
) z- \. ?2 J0 T! z: N9 O
1 g) j9 e2 o* {* V! a; n) zstatic struct platform_device da850_evm_tl_leds_device = {* N" e& e( A( t" H' l
.name = "leds-gpio",& h$ V! K% G( Z4 [1 @5 S1 k
.id = 1,
7 t b6 o I% J+ p" I4 a .dev = {
6 ^" s9 l# j' |$ V .platform_data = &da850_evm_tl_leds_pdata,
& \7 n' I4 h) j* @8 j E! p .release = led_dev_release,8 \+ o$ B: x# W: u6 P: j
}
) r- I. F& s) }1 C3 k$ b+ r" g};" n: r3 K# ?4 c9 h4 g7 U0 ~
( Q$ r: y0 H; s6 R X
static int __init led_platform_init(void)4 v% {* K$ i8 v- N
{ ?3 p- W! a0 R- h8 M9 q2 \" U7 f
int ret;
) c7 d4 [9 H+ Y9 f#if 0
, ]" `4 [9 O5 B% Q2 G l# z9 Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 u) W0 s5 M2 Q+ B# M1 p$ V
if (ret) W, ?) J& _* u, w: L, D
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# L* P/ O, C- K, }1 G4 j "%d\n", ret);% d/ O, {0 ~9 p" Z5 i1 v- @
#endif* s( z9 x$ h$ v% w; X1 P6 n- e
ret = platform_device_register(&da850_evm_tl_leds_device);: u& b5 q, v/ ~' s; I* T" M4 h
if (ret)6 j% \/ Z- N- f" i% h$ G6 }, p
pr_warning("Could not register som GPIO expander LEDS");. M6 x* F% D# u0 C; G
else' y/ _$ s7 Z- B& b
printk(KERN_INFO "LED register sucessful!\n");* m& F) r7 w+ x: K3 D/ B" _
: F5 U- t4 Z y, D, k$ L% r! ^2 K8 L
return ret;+ D# r: g* D1 U7 O; w
}9 a% O5 o& @4 O; z$ n$ T
& ^8 A1 l' l6 A: n! M3 a
static void __exit led_platform_exit(void)
0 D4 x' G) q4 }( }( U" f2 i{( W; _/ w/ L) b2 g
platform_device_unregister(&da850_evm_tl_leds_device);
' H: f b! S5 x/ ?# \3 S1 y5 J! `; d+ e; Y& X# c c \. t+ G
printk(KERN_INFO "LED unregister!\n");# Z4 t f. y |/ V1 y1 a9 q
}
- v0 ?- z- V7 _5 ^
) _" J) G+ H5 }- P$ u9 v2 H0 Ymodule_init(led_platform_init);
# O4 M! \) `' u0 K: g! j# rmodule_exit(led_platform_exit);
& I9 [1 [6 }) M5 D5 I2 `$ { v, A) M- [1 e7 X+ h" ^
MODULE_DESCRIPTION("Led platform driver");+ Q1 n- ?; H. y6 W
MODULE_AUTHOR("Tronlong");
# v+ z: i+ l% I! P( v* A, F/ [MODULE_LICENSE("GPL");
7 |& m# R. U T) T2 I8 r" }5 K+ r3 D# B! j" w. F& ^1 F" n
|
|