|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 [* v: c) o2 V! U S
#include <linux/init.h>
' F1 ~9 H& M2 x#include <linux/module.h>8 j" h: G! _' Q& e3 e; N# R; H
#include <linux/kernel.h>
/ @- D, p# Y j. X" D#include <linux/types.h>
" j. p, B* A- T3 t6 \ H#include <linux/gpio.h>2 q( p, |! k$ t5 `- }
#include <linux/leds.h>
' a4 |* ?8 ^) j4 C, f#include <linux/platform_device.h>
! G6 W( M; P. [/ i- S3 f. u5 O8 ?
#include <asm/mach-types.h>$ I! v2 U3 p5 O( v( h! ]9 }
#include <asm/mach/arch.h>
; j' D& C6 I: }, |5 {7 U; P#include <mach/da8xx.h>
+ |8 Q: D( r- L3 U#include <mach/mux.h>
! Q; S3 x/ J5 y7 O6 E, {! P1 k
) y& x6 g) R; b# O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# ~' H3 ]' t9 }; h, @; P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 j" Z$ C8 E0 F% ]$ P#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ H. u/ h% Z3 r# q8 \$ x& x#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( W: Q8 P6 q9 p
: x4 x5 T. b j1 X! e/* assign the tl som board LED-GPIOs*// t7 i$ k2 A+ b- u) w
static const short da850_evm_tl_user_led_pins[] = {+ Y, h6 H( f0 \' [& ]
/* These pins are definition at <mach/mux.h> file */$ B9 }' E, S! s
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 k/ I, @" G7 e, v7 U3 v
-1- K% K* I; H ^, |/ q
};
: X' ^! |! _2 }
# Y, N2 l- z* t _3 D0 }static struct gpio_led da850_evm_tl_leds[] = {" [/ {) N% g M" {: Z- J6 a
{
, q* G+ f$ d. \$ s" V# g% M .active_low = 0,
5 N7 r+ u0 a2 b: U W. d; o .gpio = DA850_USER_LED0,/ Z& T+ [ M, a C4 e# i+ T! S
.name = "user_led0",
% }2 Q. \3 H" C+ c" R .default_trigger = "default-on",
% \4 [% y3 M2 ]& j7 h4 C$ d) Y },
+ u( N1 {7 Z4 d/ H3 m {
# W8 ]9 U, U" M/ D$ ~ .active_low = 0,
E9 M5 l/ u3 g .gpio = DA850_USER_LED1,$ D. d% u/ E1 S% Z* M p* @
.name = "user_led1",
5 r7 A8 u" {8 t* i .default_trigger = "default-on",
# v5 I2 W1 Z; g+ x. g, X; W( A },
s8 t# ]- R6 z7 y2 s1 s5 H: E {
( a/ Y% m* }& s B8 k/ h4 V6 G- p .active_low = 0,$ t7 Y [0 A- B5 x: O0 h* w" b
.gpio = DA850_USER_LED2,
+ X! ]: b* m; g9 k .name = "user_led2",9 P# h7 {+ \ H; F- v: M
.default_trigger = "default-on",4 |6 w7 U# A2 s; Y6 \% W! i
},3 a9 d2 ^/ V ]# l
{) C4 U4 q3 k7 _ D4 n8 d& E
.active_low = 0, C6 t- D( R0 L& _
.gpio = DA850_USER_LED3,
/ ]* T- N' Q2 ~9 S .name = "user_led3",
/ j4 n5 |2 ?2 o d, Z% K .default_trigger = "default-on"," E1 T- E. E5 ~2 C
},
' r: _7 z) Y y};
& p( l* _# E6 N8 P2 k/ b% [6 y. H. x. d( I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
r$ s S' Q$ @& W .leds = da850_evm_tl_leds,
3 R, d* l( A# t4 j$ i* B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ Q) Q# V9 E. ?; R, r/ c0 \/ I
};
6 o9 R3 {8 Q ` I
# t6 a, J! l& l. h jstatic void led_dev_release(struct device *dev)% g2 I9 M" d1 h9 @: {$ S
{+ x9 P" F7 X. P
};. _- W: h9 Y4 t1 |7 B( C
' _: o8 N) S+ O7 Y
static struct platform_device da850_evm_tl_leds_device = {% w' ]; @+ a# a# |6 }2 [0 K
.name = "leds-gpio",
; `0 y9 ]; o8 m9 |, U9 j5 Y .id = 1,
" x/ o/ T6 H) |7 ~+ u: t .dev = {8 E" r' r Y, I2 K" j- f3 f
.platform_data = &da850_evm_tl_leds_pdata,8 Q2 s$ @8 P% ^# q! i
.release = led_dev_release,
8 w, Z! V: j. l7 B$ n" u3 u. I }% a, C4 \/ @0 v6 }& \' ?3 |
};. {6 r; l# Z$ ^
/ X0 U' E) P4 K4 H
static int __init led_platform_init(void)% K. e" |* g% i1 ?# _( ~
{7 d6 l" Y7 U5 P$ a# n
int ret;: x2 N0 N+ D: G8 _" `8 h, R3 Y
#if 0
( w5 \7 B9 l; `6 S3 t- X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" O; R5 E9 \; [6 r8 \ if (ret)
) U5 f O# ~% u a0 O1 k: | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' B2 e" z1 |6 y" L "%d\n", ret);0 L7 [+ U# o* y* g" i/ {% I: R$ _* r7 X
#endif
, Y; D6 z% a0 @6 ` ret = platform_device_register(&da850_evm_tl_leds_device);
! m% S. b+ g1 b if (ret)
0 O/ i1 v; a( T% A3 A) C1 H pr_warning("Could not register som GPIO expander LEDS");
) o5 X$ t1 o$ g" V/ T else
3 |' J! {6 z$ b: X printk(KERN_INFO "LED register sucessful!\n");
; H- @" E: b; b R: @- R: }/ j( R9 @ G) P
return ret;& R1 W5 O3 y5 e
}: u( Q4 B2 Y' E# ]
; r. B+ w: \3 E8 G6 s0 k+ c' S6 zstatic void __exit led_platform_exit(void)
" W Z2 r$ N& E6 o( r- q{
2 T0 G, j9 x) s- y* J( O, s) z platform_device_unregister(&da850_evm_tl_leds_device);2 O8 U0 Z/ v# c. K: W5 e
5 n6 [% ]' k# U2 Z7 y printk(KERN_INFO "LED unregister!\n");
7 x# n7 u. O: l2 V" @0 E}
& G. J1 h3 `1 G n. _( M: H- ^, Q2 [3 k" X0 ^& ] W) j2 ~6 N% G" q
module_init(led_platform_init);8 k# R! m9 |+ b u: Z" H* m
module_exit(led_platform_exit);, C3 X3 y# n$ r, [7 R
' ?) G! V$ W1 z+ c* r0 {% T
MODULE_DESCRIPTION("Led platform driver");
a6 I; ?2 z0 ^/ l% s5 E7 XMODULE_AUTHOR("Tronlong");: M* N3 t+ l; Q. u1 I
MODULE_LICENSE("GPL");
: r' r9 F, N$ s# d1 M6 ?8 b
/ h1 g4 |; P% l& f0 B: N. }0 R |
|