|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 S* \) L: w/ J7 K7 b3 i#include <linux/init.h>
$ _! T( F o8 \$ M8 Q6 X. ^! s#include <linux/module.h>
4 W: Y+ N* P5 t6 W! z#include <linux/kernel.h>& |' p. |- K. s# X$ M
#include <linux/types.h>: ?# N0 q( x! i# n$ Q
#include <linux/gpio.h>5 \( O6 i; t" b- g, \" [5 A, v& I" x
#include <linux/leds.h>* N. w. f2 O7 l! z' y6 ^6 [' r. k
#include <linux/platform_device.h>
" h& d* g! U$ I
3 a) G0 H9 r5 t/ d. y#include <asm/mach-types.h>
0 c5 t3 ~6 O) n ^#include <asm/mach/arch.h>$ Z3 e5 V# }) B, k6 d. [3 J
#include <mach/da8xx.h>
8 e/ q6 m0 G$ R& P% T#include <mach/mux.h>
0 X* |) Z0 p$ t$ e3 ]/ U8 m6 x
; z: D" m# i0 H: N& U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 B: r2 y" }# e! q- L#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 p: |: F" Q# Q3 w0 R9 P
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% X5 u- ?. \3 e. F9 B7 g. n; n#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 ^$ D" P/ k2 Y% }+ c& M, ~( Q5 C+ O: L- d7 Z, u
/* assign the tl som board LED-GPIOs*/( X) o- F; \: C% p6 }+ C8 [. m& a
static const short da850_evm_tl_user_led_pins[] = {/ _* z1 T% L6 [; z4 n
/* These pins are definition at <mach/mux.h> file */
) E# D+ ^) w4 @+ I DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( G2 h X7 B# Z, W& F' \ -1
& g. w0 X( i+ L t};; z$ s5 _% R4 \1 n
2 w: z `- ]" d
static struct gpio_led da850_evm_tl_leds[] = {1 d! @! n/ x6 V0 @3 {; g. W
{
. i* h3 }0 ]' e .active_low = 0,
5 A* F- K7 Y+ Y( G* c5 }( x .gpio = DA850_USER_LED0,
" Q; n; Y% J: v# ^6 V' h .name = "user_led0",' r0 |0 e: g! c
.default_trigger = "default-on"," ^( F: ?' T% i$ k* h" y' t) Z
},
' o& ]2 } N1 M: ]& K% H( _ {; |# I+ \+ D) u# ~
.active_low = 0,
' o9 `# h6 s% q .gpio = DA850_USER_LED1,; p# N5 x0 x# o# o# C: J, U
.name = "user_led1",
) c$ s! [+ q" ?0 X .default_trigger = "default-on",1 ?* T. r/ C& Z8 o
},
F/ w( N5 I+ M: x# Q7 A {9 f5 a! ~5 u- u8 j
.active_low = 0,( x' H/ @$ [1 ]% H. a3 O) `
.gpio = DA850_USER_LED2,
' O5 L' ^- }6 p" I2 U- J1 n+ H .name = "user_led2",
s+ U" ]+ z9 W" i2 \! a .default_trigger = "default-on",9 @% b: z" Q1 n$ |8 d/ Z
},
+ z5 Q4 [6 J# y0 s( {; I/ w, l {- n! d2 Y* K+ l6 L" G0 ?# @& D
.active_low = 0,% X8 ?, }# W, c8 c4 u1 @: ]! g
.gpio = DA850_USER_LED3,
X5 i* f3 t1 L* o0 p1 S- h .name = "user_led3",% d" Q) `+ P- |4 r4 _$ D' t8 v
.default_trigger = "default-on",# j, ?- H9 }- q6 T
},
! R( Z1 n- |$ S) y4 e, c7 c};5 u7 T2 L. `, {! |, h7 b- e# L
- x' @0 ]/ o B6 ]0 S. x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ ?4 |" ?- O" u% `) ]) G$ [1 G .leds = da850_evm_tl_leds,
9 H& Z0 _! `+ c .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) d8 k. k& {& [& p( I# y7 r& y; T/ y};
/ m- N9 B. m% r' X$ X
0 i9 c( K2 Z$ B* S# w8 Y/ K3 |# Rstatic void led_dev_release(struct device *dev)9 X6 r. V' I6 \/ S* p
{
6 H0 t7 w3 v) \; u" a};
% h- j/ ] K: O5 F& T0 s8 M( u3 W9 V: x3 k+ Y5 H3 f5 `" p2 ]8 b
static struct platform_device da850_evm_tl_leds_device = {
9 \( ~& R0 S0 P: R .name = "leds-gpio",9 {( |% _( p! G z" q1 Z$ d
.id = 1,
* X6 l% G# J6 P; u! K .dev = {- A+ e1 m. U9 [: N. i
.platform_data = &da850_evm_tl_leds_pdata,
: X: m( e7 S( F .release = led_dev_release,' e) ^( p8 o4 @6 `: ]
} a8 T$ m9 c/ o1 g v
};: H9 p, ?) i y( F( z7 V+ J
5 `' f' E" ^- t( j9 p
static int __init led_platform_init(void)
9 R, j% f( n- U9 ^{5 s a9 n5 ^! W: G1 @; \* y
int ret;
1 Q0 j+ v; H% l; p a: b#if 0
3 J% U. i& M9 C; J& v7 Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 K+ c2 K% b% H- Q' I3 R if (ret)
- B( A; {7 h) c' G1 h- w pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 { d P' x: a9 a, Q7 W! Q
"%d\n", ret);4 B+ d1 N P/ D4 m0 |
#endif5 c8 m8 a* G+ F: E
ret = platform_device_register(&da850_evm_tl_leds_device);3 k: S1 \+ o7 F" H# L/ B1 X
if (ret)
) G( S0 C6 `) `- E0 d pr_warning("Could not register som GPIO expander LEDS");" M% R" v$ o7 T/ o: U
else5 b. o8 h/ e! n1 Q5 |8 v
printk(KERN_INFO "LED register sucessful!\n");9 `% e+ `" u' k- s: F! p3 d3 B
7 S; U! ~7 m/ S4 Y
return ret;# p$ `% i/ ^( H$ V6 F+ `
}
0 r% o: ] O% q% S3 `! U5 F
3 Q& a9 a" r- C, @& q2 Fstatic void __exit led_platform_exit(void)
2 ^. X8 q7 N e$ M{
9 C; @7 O3 e$ z platform_device_unregister(&da850_evm_tl_leds_device);# X3 ?& p/ r: y! l
# W O2 ]9 W+ Y# H) D5 g2 F printk(KERN_INFO "LED unregister!\n");4 j7 p5 U5 ^' c1 e- N; Z: h
}3 q" ^ o) U4 F$ }. [# w' E2 [
# f$ m" ~, l5 C6 t
module_init(led_platform_init);7 U% j5 b7 q4 A$ M, o' Y
module_exit(led_platform_exit);# f. z7 \ T! K/ o
: e4 E) t8 B* J9 wMODULE_DESCRIPTION("Led platform driver");
3 R# l/ y8 e! w' @4 `) kMODULE_AUTHOR("Tronlong"); ]! V B; U$ y; B# \
MODULE_LICENSE("GPL");* i8 y: O: z# H* J6 E* s2 z! b, \
! n- U! w: T" k" S- Z7 r
|
|