|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- d$ f. S- Z3 R! l! }1 W* w: U# ^& c6 _#include <linux/init.h>1 s. U, _) H- S+ o3 G5 T! h% Y
#include <linux/module.h>2 Z- C5 C. b# }0 e/ x
#include <linux/kernel.h>
8 a* s, s6 T# c2 f+ W/ c7 S#include <linux/types.h>/ P# Q5 k. k4 [7 T' q8 _
#include <linux/gpio.h>4 ?/ x3 _, p e/ m* w
#include <linux/leds.h>
0 C' {' C5 n E4 S& X) Y#include <linux/platform_device.h>
/ D% S7 j. b' _" ?4 ^7 @6 o- i* o; ?6 V7 k7 I2 Z" R
#include <asm/mach-types.h>. i$ F# G( S& O0 S8 ]8 R
#include <asm/mach/arch.h>3 p* g$ ?6 F k; p: i R
#include <mach/da8xx.h>
5 H& g5 |% H4 Y7 M _0 B#include <mach/mux.h>
2 g* b, J1 W4 w0 T6 v
* r7 C3 U5 x( [ i! N: U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) C' \2 _ J5 P, H" d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" |" Y5 R" |0 T9 C#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! @! D+ S- o: C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ L G& P Z, {" g; v/ }( u' _7 x
/ e% ?6 \2 L: s0 h5 O3 `
/* assign the tl som board LED-GPIOs*/
o$ H0 d( B1 ^7 o) b- jstatic const short da850_evm_tl_user_led_pins[] = {
1 O0 F8 m: P, p# b+ P /* These pins are definition at <mach/mux.h> file */& u; F! d) y* i" q+ C8 V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 |& a' x, C, N% R1 |/ ~
-1
/ _$ {6 V7 d$ a}; X+ j7 b* r" z
/ X. I {; Y2 D Z
static struct gpio_led da850_evm_tl_leds[] = {
0 l7 n7 ?2 N8 Z6 d {0 u0 A$ G5 M3 Q; M7 f0 U
.active_low = 0,6 ~# q8 T& Q( m9 N; O
.gpio = DA850_USER_LED0,
/ B3 v) T, m* M- X5 S) _+ v: z; N .name = "user_led0",
$ Q J2 c0 G, U; l' Y3 l% h! d .default_trigger = "default-on",! x% p' C1 A" D0 ]
},
( C$ _; q! s9 I! o; F6 @" |0 u7 L {
\* ]+ Z H, _5 K5 H .active_low = 0,7 ?& u8 F7 v1 O) p* R& X1 R6 Z
.gpio = DA850_USER_LED1,6 q9 N) b0 d! F- u8 D1 t B2 l
.name = "user_led1",
, }7 i. K$ i: A7 w4 M .default_trigger = "default-on",
) g" {+ i9 Z, g# Y },
: H4 m8 O8 T# J0 ?5 C! T" g {3 E% ]/ M/ m5 [5 H1 O* H( J
.active_low = 0,
* p& R D7 Q+ Q" C .gpio = DA850_USER_LED2,
& [7 q" Z+ t' o: b9 ?- j6 s .name = "user_led2",
u0 |8 ~( u: V .default_trigger = "default-on",
1 F% _2 H# w o1 L- Q+ o },
3 n5 m# s) v- O# X& ]8 g {
0 f5 b' d3 R% V7 K! V4 i" m2 n .active_low = 0,8 n: y0 b- v6 ~& m! p# ?0 t
.gpio = DA850_USER_LED3,4 E( F0 x* O8 O/ x
.name = "user_led3",
: e! j4 U& q2 n .default_trigger = "default-on",
3 j; r7 a3 \8 \1 S1 t2 C/ o },& b# M+ t! r) o f
};2 ~- I! ?" g0 Q2 u9 K
8 \! V7 i6 S9 h. d* {; X! j9 Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 Q& G2 z9 E' W1 T( o4 b% v2 A
.leds = da850_evm_tl_leds,9 S, ?- g- N! x$ ~* v8 }3 t+ c
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ b0 A5 j" {; s};+ L' P/ c& e9 b' r& Z+ U' e' w
0 e0 M) C7 g7 o4 nstatic void led_dev_release(struct device *dev)
3 I) ~0 w1 I* c# P6 \% Q& d{ q$ o8 P4 D' f W# c9 }
};
* f' N: D: L% R7 `. V$ c( R9 _5 O' y% m0 x+ c: Q
static struct platform_device da850_evm_tl_leds_device = {: i: H7 p4 _/ [6 ~0 L
.name = "leds-gpio",1 z$ [7 G1 @' _. J! k
.id = 1,
8 N4 @, Z( N) m% T" s .dev = {1 u( ~6 n4 ?9 f. P5 y, \3 p$ ]
.platform_data = &da850_evm_tl_leds_pdata,- D7 Y* m7 T h' A
.release = led_dev_release,4 `' {6 A/ p( r2 o3 F- N0 i. c$ }) Q
}
6 ^2 c5 T) W6 q/ S8 C3 c};
* c- ]3 o( D* ~5 S, ~6 C, ]+ m- H8 ~; _. l# y+ a
static int __init led_platform_init(void)
7 S2 x b% `% U2 B. }{" l1 k, z* z' @2 T% n; M
int ret;
Y9 Y+ \% w, |' E8 H#if 0/ {% v1 y0 [& }2 q8 E* U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# j, l" y5 E: L) t# M" m: [ if (ret)
- |% p$ g' g [6 R8 W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: Z, g( y' ?# L& K "%d\n", ret);) y* s8 O. u, Z8 o5 P1 r0 k
#endif# I4 D3 N4 c( C
ret = platform_device_register(&da850_evm_tl_leds_device);5 f- q7 z4 ~; ]8 P% \1 e+ e
if (ret)
6 J5 ^0 A$ I5 B( ~ pr_warning("Could not register som GPIO expander LEDS");% e, ~$ B, Y0 N2 |! |+ _
else6 o; z# \2 N* p3 f, k. b8 h
printk(KERN_INFO "LED register sucessful!\n");
4 Q! \1 I3 `' k' i' A$ ~% H, I6 W! y7 G$ Z2 Q# v( X) v1 ?
return ret;
1 H2 l- P3 b* j+ t X; U1 [5 m( ?}
9 X( `' I; {5 q8 {) ~+ s, B; N: O/ M$ M- t1 D5 Q* o5 O$ J
static void __exit led_platform_exit(void)
1 e/ K; i: R8 F7 ^' P. [{/ d$ f& t' b$ U, E
platform_device_unregister(&da850_evm_tl_leds_device);
( j% u1 @& g- K9 C1 N' c7 v* r: V" S) I
printk(KERN_INFO "LED unregister!\n");
* {, r& M' @/ n( T$ t- H! }: f}0 O/ C/ H/ t" G+ y) S! w% f* o, I$ L+ q
) L" h* [6 i1 w9 W, C5 D) g
module_init(led_platform_init);
' w! Q, I) ]7 L8 t; l+ l% N! W1 o8 Smodule_exit(led_platform_exit);( g$ a4 V0 X" ~( I6 [& i
5 j+ a1 p7 V- k5 U$ m$ }MODULE_DESCRIPTION("Led platform driver");( }0 o9 I3 [+ {1 o- v# j; e
MODULE_AUTHOR("Tronlong");: c7 T+ ~; S6 N+ P
MODULE_LICENSE("GPL");4 Z" p2 |8 U9 P4 Z" D, G* C* s
; q! c6 K: p: F9 R |
|