|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 N4 a6 @1 n% x3 q3 Y* g0 K: e! C#include <linux/init.h>
* R5 n9 o+ z3 |" `% ?( `#include <linux/module.h>
; A: G0 E' l1 r7 C#include <linux/kernel.h>
2 @# J: b" E+ ?6 C* m#include <linux/types.h>5 ^ o0 k& Y' t1 G/ [$ d
#include <linux/gpio.h>% @2 u6 P0 p% }: O3 _$ z9 R
#include <linux/leds.h>) M. p" H4 m1 C0 U5 B* [& ?
#include <linux/platform_device.h>, ]1 u2 d0 R0 Z! R8 g, c) Q/ N
C5 Q- r; T* m$ r7 T
#include <asm/mach-types.h>2 m- K, L. k& h6 U! j
#include <asm/mach/arch.h>' M/ |& O5 V. B
#include <mach/da8xx.h>
5 o) S2 [2 g. P4 v2 C9 F! n#include <mach/mux.h>
* [8 p7 ?7 R3 n( }
. Q" P" u/ ~5 w: W ]9 z8 w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! `* q9 k" K) w& x( W# E1 u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 ~5 \3 ]1 m5 ?. N1 a$ ~! z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 I- I' X$ o3 {8 s: }# j; l% f0 R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 S% ]/ b# _2 ~: f* ~( \
( B/ g* M; o4 X$ n/* assign the tl som board LED-GPIOs*/# Z& w* U( y) p4 Y% L
static const short da850_evm_tl_user_led_pins[] = {
$ c$ K. B7 j" V3 Q /* These pins are definition at <mach/mux.h> file */* v4 M1 Y% p* a v8 G8 k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 j; L P) `9 d -1) m+ Q+ ?9 A) Z7 j v; K# ~
};3 ?: E x; {2 B! s/ e% _6 C6 v, r1 Q
0 S/ |/ y X( ~; T$ b
static struct gpio_led da850_evm_tl_leds[] = {
& d- X# d3 C5 {& W5 F7 v# j {0 V* a# n9 y! N
.active_low = 0,
8 }! _5 q3 U& Q' z7 q .gpio = DA850_USER_LED0,1 s% `" n6 l, r* A/ x
.name = "user_led0",0 H, P; `, L8 E5 Z) M) I
.default_trigger = "default-on",
0 `/ p3 N/ g6 l( y% _. o, B },
) B( h$ y$ Z/ v2 ]0 G; K {
/ E0 A* F$ A' k .active_low = 0,
9 N0 q- d1 r: o! ] .gpio = DA850_USER_LED1,$ s9 U- D( Y5 K+ l
.name = "user_led1",2 M, ?3 H- R' s1 G8 M: C
.default_trigger = "default-on",
- g, J0 Y6 s% F: _6 l },7 o8 X) Z4 R# ]8 Z; d$ O
{# U3 r3 Z: u, G
.active_low = 0, D. _7 x4 r" T4 M3 n
.gpio = DA850_USER_LED2,
' Q- L/ D3 V& |1 W3 J6 f2 F .name = "user_led2",
" `: e4 C; _* _ ~9 o8 I. _& u" z' U6 ~/ ]7 K .default_trigger = "default-on",9 A: X' X' D: {# ^" @0 Z
},
% X% B1 n" A s: U' s h1 _# l6 ^; } {
* v3 N/ n, T% k9 k/ V$ o) C- d .active_low = 0,
' i0 l3 o' Q3 e, Z/ }* f4 Y0 @- C .gpio = DA850_USER_LED3,8 z3 H3 ~& ^) w
.name = "user_led3",. Y* z! A: c3 C2 g7 h4 c7 ]9 w
.default_trigger = "default-on",
/ O8 V2 J% q2 E5 i! U; e },) v% ~% K+ T! Q& A, N1 I: s% Z; o
};: U9 \* k2 A0 G5 x% F4 x
+ H3 F! |% O$ w" Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( I3 x1 w, s% ]$ C6 a/ \ .leds = da850_evm_tl_leds,7 e6 z/ [+ M/ f: `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),! i9 ]2 [3 ?$ r9 X' q# p5 c
};9 U, ~' }% x* L9 V
' C, |! ~" V1 D. G8 ?( e" p, i( hstatic void led_dev_release(struct device *dev)- _# F) Q" ~; h9 l3 x; E7 |& |9 e" Q
{
: P1 S) s- P0 u+ I, ?};
- M6 ^( R: P- S$ X, S. [, ^% Z, b1 o! L2 \4 t3 {7 ^
static struct platform_device da850_evm_tl_leds_device = {
+ d7 H' G+ N* l* m F5 I8 i .name = "leds-gpio"," {) L* O1 F+ Z2 f4 C9 v. J6 N
.id = 1,
/ L6 m% M2 g$ q7 I* F .dev = {
" u/ r% U' l( ]& e3 T .platform_data = &da850_evm_tl_leds_pdata,5 i* H3 Y" M1 `/ k# H- S
.release = led_dev_release,
5 [: K4 Y! n& D4 ]# L8 | X' V }7 v$ d/ }0 q$ V, E1 c6 n
};3 l& K! Z, ~+ x9 n0 i
# x7 R2 E0 d; G: u2 j8 s0 D
static int __init led_platform_init(void)
7 X: r- J8 W& E{
) d1 k- p: F& x+ `0 k) o* X int ret;( |/ q) k( c. _) Y( R1 }
#if 0
2 M ~( _* n- R) W/ K8 o5 K* `: ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 ], [4 I i2 v if (ret)0 O6 L6 v7 M9 T2 Z8 t8 \+ R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 H/ B* e* D7 O0 x' n3 _. Y
"%d\n", ret);
; O- l, n5 N/ I# [#endif! s5 F$ e3 ]6 X1 L# Z" }% L
ret = platform_device_register(&da850_evm_tl_leds_device);9 V/ X+ A$ T* o \4 j# Z
if (ret)0 r2 _3 Z# I8 z5 h# e3 O1 [$ d$ M
pr_warning("Could not register som GPIO expander LEDS");
/ g5 k$ O9 V9 F( l: y# P# { else' H+ r2 Y7 ]% O$ y5 b
printk(KERN_INFO "LED register sucessful!\n");
1 S6 M, n% s' ~8 M$ M3 T" p# U. s% p* ?# ~
return ret;" m5 j; w8 e$ Y0 E: z0 h
}6 r1 R+ B. f5 \ Z. L
5 W/ g2 d3 Q g" w" y; e* e9 a s
static void __exit led_platform_exit(void)- q3 g* F5 b' w2 ~7 p, c& K" b; Y
{9 \* T9 @2 v2 d3 x# d
platform_device_unregister(&da850_evm_tl_leds_device);
( M6 w1 \% ~* y$ r: p: w/ ~
h7 a& W7 P1 f) s# A6 h+ R* Q# l5 Q printk(KERN_INFO "LED unregister!\n");
( r4 n! P7 o$ y6 r# n}/ }2 {3 C2 A, h# [5 A8 R
/ L# B( h( X3 c( D/ ?. r7 B
module_init(led_platform_init);
2 ^+ t) \, o9 d# k+ f8 jmodule_exit(led_platform_exit);6 t5 u! w/ T5 d/ S, G
; g6 H1 k' B! }8 r yMODULE_DESCRIPTION("Led platform driver");
) L9 O6 {8 s9 B( _/ GMODULE_AUTHOR("Tronlong");
8 k! {) A6 r% g3 B$ yMODULE_LICENSE("GPL");
* I" S- C3 O: U9 a/ E
. `- y1 h2 R0 h( R& Z3 y1 {, I$ B |
|