|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 }( j) `/ W7 q2 C2 @8 N& f
#include <linux/init.h>
8 ~* \8 F7 q5 p3 L3 K" a5 l9 z#include <linux/module.h>* e& |$ u9 p4 X) }/ q$ I
#include <linux/kernel.h>
3 I4 B1 ]0 P+ N$ A#include <linux/types.h>$ c7 I* J7 W. F7 \) b8 b
#include <linux/gpio.h>
) Z% R7 A) N6 W& L& { j: Z' K5 H#include <linux/leds.h>
1 t- |5 h' B) p( u: T#include <linux/platform_device.h>
3 k& L8 v) ~4 f* n" r8 _3 V% c6 `
#include <asm/mach-types.h>! r: j6 a4 u# z( o0 c! w3 P; C/ \
#include <asm/mach/arch.h>
7 u) B" R' n- o/ I6 w1 \" D; E#include <mach/da8xx.h> ~- x/ T6 w! J3 J
#include <mach/mux.h>
+ B1 e9 t% v1 y) O7 m: m4 ]0 n6 t! b1 \
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- S a. U6 _8 D1 {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 l9 k1 w" u* K. Z/ `& F#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 y* S1 n4 e- \
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& M w/ b& @( x! U( @' t
: D% u5 x5 l _ x4 T9 c5 G/* assign the tl som board LED-GPIOs*/
4 Y' v3 W6 j" S# g. n4 qstatic const short da850_evm_tl_user_led_pins[] = {
# M# X- U6 G6 R: X+ J2 }" e /* These pins are definition at <mach/mux.h> file */
, E5 r& W3 o: I5 F DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 M% S8 _ A3 T% y& U, E -14 o6 A9 c: T& K# v# {6 D
};& H5 Q2 f* S5 Q* l" u9 \, c( ~
4 f/ I4 K0 N% Y. E' j! a; w6 f Gstatic struct gpio_led da850_evm_tl_leds[] = {
7 p5 Z. h% n8 [ {
4 A& L$ m( N. x3 M. k$ ~. e/ G .active_low = 0,
* T, C; ~* Z6 v* ]+ O9 ?. G! Q .gpio = DA850_USER_LED0,2 D% W0 |) `* m$ i4 i. Y2 p: f
.name = "user_led0",
9 p5 N+ ^# p. c; b/ e) A3 u4 K .default_trigger = "default-on",* L9 b. E' {! Z. e
},- t! q2 ~, `; Z
{
, P* O0 T9 P1 u: T: W .active_low = 0, O# T {+ n. U! ~
.gpio = DA850_USER_LED1,; }2 ]& G+ Y% [" C6 T
.name = "user_led1",
( u" z/ o4 V( w$ z0 i/ i4 m .default_trigger = "default-on",7 b+ j3 c o7 H" J8 l
},
8 p- a' C: k8 T7 r% f ~ {* |# C9 V; I1 | n% l* t! v
.active_low = 0,
/ @/ E! [" W* B& A5 l7 ^ .gpio = DA850_USER_LED2,0 i: O" J, |+ h- {4 K [, l1 @$ ^
.name = "user_led2",4 E6 q# d8 Y0 c, x
.default_trigger = "default-on",
- \2 \4 `: C" U; ^: [ },
2 R1 Z* G$ b0 o# s: I2 U {
4 Z# ^. {" `3 o p U; o) N .active_low = 0,0 s: v( g2 P# o% ?* \
.gpio = DA850_USER_LED3,; `5 b( T/ E: g9 L& O' `" c" r$ d" k
.name = "user_led3",& ]* K5 H' W5 H% }
.default_trigger = "default-on",6 f8 c0 ]6 n F2 v, b* p
},
& i# z- U+ B% j/ k& W) O) V};! M4 M: K# {! u
$ O2 c; d# g0 N/ g/ R7 vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ n+ R5 x9 z3 K" ^; Z) j9 S4 ~ .leds = da850_evm_tl_leds, r5 c7 H4 b0 s8 u
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ `. ~, l$ J4 e9 U0 A: C
};
% S3 b' }' u+ |6 \: e$ n3 j( ^: x' c& L# U) P+ _ s( q' U5 h
static void led_dev_release(struct device *dev), F$ G& E* e9 C
{
+ T( a4 _+ z8 p) k# B. G};
8 p$ V+ H4 @ w r" g8 e
5 }! E+ F% J7 C: u2 @# Y4 {- hstatic struct platform_device da850_evm_tl_leds_device = {3 K' E' O! Y8 c' [8 d. T
.name = "leds-gpio",
1 O4 d! }0 C+ s( d2 W .id = 1,
' h/ p( F7 ]" `) L4 f( i .dev = {, _5 S- v9 ~% n3 r) ^8 L8 I/ h
.platform_data = &da850_evm_tl_leds_pdata,
* U1 t( p5 C0 X. Y+ p# `3 y( l .release = led_dev_release,
( H$ o3 s/ z k! v; D( f9 | }
/ E7 L7 b @& ^' I; p; A" {+ _};
: g8 u, B, p% ]8 B4 f7 Z, l
8 \; B: Q2 t1 C6 }; a# G1 a+ Wstatic int __init led_platform_init(void)' j2 `8 ~! i) ]$ u
{9 [; B$ e- D" @
int ret;0 T( A' a& i( _* `9 w7 M
#if 0( L5 Y& n) F. |+ \
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: W7 V8 L6 R$ E* O1 ] if (ret)
, l5 H: j" c: H1 w pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! o( L8 S, W D+ J) ]6 s# e "%d\n", ret);
7 U9 Z2 K/ a& H4 d" P& C#endif! F5 N7 D1 D7 B0 v# y7 [1 o! N
ret = platform_device_register(&da850_evm_tl_leds_device);
# A3 _% Y+ |5 J if (ret)1 s! R3 T. l8 X6 P* }: N' v
pr_warning("Could not register som GPIO expander LEDS");
. l( e1 w9 B' H! s else [1 O4 ~) ]5 l2 [# D
printk(KERN_INFO "LED register sucessful!\n");9 Q- Q" l- S: N$ ~9 }0 a2 A1 h. B
" _2 c% E2 ^! e9 m return ret;
. w% E, u* b* P0 J! D}
3 [! j3 n+ ?$ s. ]0 t! e
) W7 J3 e- x+ _- A# d3 w+ w( ]static void __exit led_platform_exit(void)
, X; G+ Z) g! [* H2 T& x{
7 _9 z) R* L, M5 l platform_device_unregister(&da850_evm_tl_leds_device);' a4 D" T+ j# o1 V6 } r9 C: E. _
' k% V8 i& A! K( F, a% z
printk(KERN_INFO "LED unregister!\n");
1 A& }9 s9 \" o( E}
) h3 Y: i4 S5 p7 T2 {" A' @) {
" c Y6 ~/ y, R% Y" b: W' [, Mmodule_init(led_platform_init);: c8 G K8 L5 i5 O/ A6 m( U4 Q
module_exit(led_platform_exit);5 y+ q9 q/ H3 A a. k% }
1 m! z0 I" s8 J- B
MODULE_DESCRIPTION("Led platform driver");- ^' E- a/ b h
MODULE_AUTHOR("Tronlong");' @" j m. `2 K' d4 `, ~
MODULE_LICENSE("GPL");
; t" n- v0 Y: A& j; B7 Q. p6 o$ e d- c
|
|