|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* o, m2 x4 o1 C6 S5 p8 U#include <linux/init.h>5 F* x* z; j! B: V; Y
#include <linux/module.h>
) Z( x2 `" @: K) f6 {' Y#include <linux/kernel.h>* h( L6 X! a- ~% u r
#include <linux/types.h>7 q5 v1 g z4 O# c# K! X& U
#include <linux/gpio.h>3 v' K) ^! g" U0 e- q
#include <linux/leds.h>' r# c: A [2 @+ H
#include <linux/platform_device.h>
& ?" G4 M: b9 f0 W' U0 i3 p) G; _9 G8 E0 X! q
#include <asm/mach-types.h>4 k/ n3 A7 }; _- B& a+ u" f" Y% `
#include <asm/mach/arch.h>4 L4 B- Y- I1 V- ~7 e. G
#include <mach/da8xx.h>
I0 O5 f; N. r$ h' k+ t#include <mach/mux.h>3 @# g m& o" }. O
2 l. _7 j: b. A3 L) F Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 H. b. G' C* _2 O/ w- u
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), u F4 o$ |7 h, v$ M% P
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* ?) r- b T- h& J; t- b* Y8 ]( o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 k& y7 [5 x+ N$ D* ~. c
* _) ?1 {- R: j! I3 ^( l+ r
/* assign the tl som board LED-GPIOs*/% v' \/ W- a8 x6 h
static const short da850_evm_tl_user_led_pins[] = {
e4 ~4 H! _+ Y; p/ A /* These pins are definition at <mach/mux.h> file */
6 Y; u$ B3 Y7 \1 m: {2 J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 y! }% X {- g0 S8 p+ F
-1# c5 e% W3 v' g0 R5 A# P2 o% @
};# ^6 V$ [0 d# _) g
2 E- G7 r z) T, C0 u$ M$ R7 U3 fstatic struct gpio_led da850_evm_tl_leds[] = {- b, h! j) J% I5 ]( j, W* q
{
/ ^: A; N- t6 S/ @9 O .active_low = 0,
3 i* f6 W/ O* g: o0 M$ u% ` .gpio = DA850_USER_LED0,
- r' j9 {: [/ V: I0 d" n .name = "user_led0",
( h* E& \3 f6 l) F; \$ l8 ] .default_trigger = "default-on",
* E: ?1 p9 a: ?9 n, o% g },
7 M' k/ p5 u7 f% |! f {
* O$ g& Y7 D9 L* @ .active_low = 0,/ D; k" d2 N! d" P& r$ B: k
.gpio = DA850_USER_LED1,. I [; Z# X& {8 Z
.name = "user_led1",
' ~; @4 ]7 q- h) l: t% R6 a .default_trigger = "default-on",4 N. r W. Q3 N, Q0 w' c
},
( f8 O2 n3 H7 d: e {
* l0 ^5 L R; j+ V, E, S' G8 H .active_low = 0,+ m& t9 {2 [9 c, S, x) @( P
.gpio = DA850_USER_LED2,
1 v/ I1 G/ d3 J0 Q4 A .name = "user_led2",/ d# m' k ]3 R! }8 U$ S
.default_trigger = "default-on",
4 D: U0 T6 b, V, l },) @# W: z# }$ b$ s+ N/ l6 M
{: G: v# \ M1 Y# \
.active_low = 0,; P6 s; v6 R @7 X& \/ c2 `
.gpio = DA850_USER_LED3,, Z- I$ s7 T/ }. @
.name = "user_led3",6 @$ X* z" h) d" @ N
.default_trigger = "default-on",
7 _' w7 M# \# ] y: X1 Z },& o, }# Z2 G, } T. E# u* }
};$ {9 N9 c" d, M
) \( ]9 |; v2 f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: U* Z+ m! X9 d0 b" B$ ?
.leds = da850_evm_tl_leds,
& l' h4 e; T! l1 I* g% l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( R/ c+ Y9 P/ w @* _. v
};" y/ o8 Y/ J$ W; ~6 H3 ^5 A
7 G _" q R$ C7 Q' J& Q7 a
static void led_dev_release(struct device *dev)2 {5 T# p) _5 F" Y
{
6 k' w' o! K* E6 a: y+ g};
& m$ ?) X9 T& m! V. x
: w' A' K6 e m0 O' _8 pstatic struct platform_device da850_evm_tl_leds_device = {
, \1 x2 Y1 k- ]$ f( p7 q0 w .name = "leds-gpio",4 U3 Z6 t$ r3 g) x
.id = 1,
; H4 `3 v9 C: O .dev = {$ r2 e; x2 K" U- i# |/ V5 J
.platform_data = &da850_evm_tl_leds_pdata,2 Z* L2 G) {! d& L2 _+ I( g D
.release = led_dev_release,
: ]8 l$ C+ C8 d, l' L( T }
' \3 \% I; J3 `};
4 e- m; Z+ l$ d! \' n, v6 W1 Z, B# D7 R5 T+ E. ?
static int __init led_platform_init(void)" L8 {7 f4 U( d
{
9 I$ N, ^& D, w' g int ret;
3 q" C* N; O0 G' b6 w! |#if 06 I0 c! k# C( P$ N. |# z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 \6 c+ H5 C( K- z" h
if (ret)2 i" F) K' ^3 E1 O
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! Y. @6 Q2 T; x8 t* n- Z
"%d\n", ret);
+ V4 H' z, T" G#endif
) _2 W# {, }% N' `( W. a ret = platform_device_register(&da850_evm_tl_leds_device);
/ O# ?4 [ Y0 l; D6 J if (ret)
( k+ a+ g5 }6 ?. s% M5 ]( T pr_warning("Could not register som GPIO expander LEDS");$ |' W% D7 W8 b. J2 y
else$ D/ a% K: c* N# X9 W4 J2 e+ H/ F
printk(KERN_INFO "LED register sucessful!\n");
, J- G" ]) u9 `- R6 H8 ]% E: M, X7 o1 ^& `# W% X' |5 i4 @9 I
return ret;3 ~ P1 R$ Z3 D1 D$ t/ D
}
) g3 X% s% z N2 G" @" l
+ T/ i5 a5 a- M9 v& Qstatic void __exit led_platform_exit(void)
7 y8 j- M8 T8 J/ o' h6 M{
5 U. G, u1 [+ I' M# P- ~0 ]) f platform_device_unregister(&da850_evm_tl_leds_device);
3 D/ Q! u/ `3 B7 ?3 x- }
# ^( Y0 s, d% ^( m/ l printk(KERN_INFO "LED unregister!\n");" N- Z& m- {9 C, s3 d& s- U& s
}
, {( v& i% q* l( s8 H' [: R/ u( _3 R; [$ `3 M; B/ U- k
module_init(led_platform_init);8 {( ~& v" _. x* F
module_exit(led_platform_exit);' u+ v% |& P6 y$ B7 q
. w+ M# s5 m$ L* N# X( l( r
MODULE_DESCRIPTION("Led platform driver");- O: D: F( C/ o7 Z+ e0 l/ a- o U
MODULE_AUTHOR("Tronlong");3 ^4 J/ J% E2 g2 h; b9 y
MODULE_LICENSE("GPL");: _0 S) }6 u% I- _
3 i5 L% K1 J$ M2 w( R
|
|