|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# O7 U$ e' M- h; U
#include <linux/init.h>
) X( w& L, _5 p#include <linux/module.h>
+ ^# q8 P7 H% `$ `9 O! S#include <linux/kernel.h>
6 u5 o( f# F( S9 n! \/ X6 P- _0 G#include <linux/types.h>; Q# _* j- O, ]( m
#include <linux/gpio.h>
7 J) q+ L' ?2 |9 w; W; e+ y#include <linux/leds.h>' _3 g6 j0 r9 e
#include <linux/platform_device.h>( e% e, @/ d( t/ o e! f; ~
* [8 R7 A& y* V
#include <asm/mach-types.h>
F2 o8 m5 ]3 K#include <asm/mach/arch.h>
) c0 x. K. V0 K: R$ {6 O#include <mach/da8xx.h>1 e+ B- h: }. @& Q7 ]
#include <mach/mux.h>
9 Q) N' X. Y: e: F8 m1 g5 P9 c$ S& G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% [, {4 ]; J$ d/ t2 S! H* Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 d- Y# ?9 u x
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 H0 W. g) j0 k$ Q4 a8 E1 v$ a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; E4 i, f1 ~9 S1 C1 F! o8 c0 { T2 y# ?6 |
/* assign the tl som board LED-GPIOs*/% W1 Y p# ?* {5 w Q! Y+ X
static const short da850_evm_tl_user_led_pins[] = {
" @1 d6 {+ z+ k0 V /* These pins are definition at <mach/mux.h> file */
: h8 e' W+ ~& h DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ ]2 k5 o* J0 ?- K
-11 o |- W+ p" n% ~
};
& @6 ^3 L B! n: ~% g# s
" ^( N" T1 X+ R$ N5 O1 Zstatic struct gpio_led da850_evm_tl_leds[] = {8 T( Y2 D4 |. W, w6 p
{3 u2 {3 e4 [& U- r
.active_low = 0,2 v) W5 r4 C1 |0 G) i# J+ M
.gpio = DA850_USER_LED0,! n9 R. o# b$ Q% `: L# d& t
.name = "user_led0",, b% C" I; b" D! b5 K" g
.default_trigger = "default-on",4 y2 `1 r& \" T
},2 B& b1 e* q. I6 d; X
{8 O9 f E9 h* U# |) N- F
.active_low = 0,1 s# V5 _8 ^( c
.gpio = DA850_USER_LED1, m, \2 U" ?7 r# K9 b# B- ?- j' e
.name = "user_led1",
( @) |9 K, H, [/ ` .default_trigger = "default-on",* ]. w/ F2 G9 u
},0 c9 q+ `, `& |, K
{9 |( T- [. `$ L1 r4 I" M+ z8 u
.active_low = 0,7 J2 [5 |& D |, [, n
.gpio = DA850_USER_LED2,
3 L* l5 c3 l, g" {# z3 N9 x .name = "user_led2",
1 M3 f: C( x( L, U: x& ]4 S .default_trigger = "default-on",
4 m; V% R$ {9 O' G V },
, b& D& z" ?. f, F" n {
3 K6 m' |5 g0 v. m/ ^, c: o6 r .active_low = 0,
! D$ B/ ~- q5 a5 ^* H" x .gpio = DA850_USER_LED3,
2 s. ^4 e; L# @+ A .name = "user_led3",* S5 k: `' _1 g- r& a
.default_trigger = "default-on",
7 Y( B3 }, O( l+ f },
7 P" P8 G$ [! t$ z6 v1 V8 v};
3 ?5 B% C* i% r# x# d% |8 j. `7 _: h# i1 }! L1 {
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 b& o% y5 Y& v .leds = da850_evm_tl_leds,
8 [1 I6 D! n3 b5 L! L, G: t# a' ]5 S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 l# g3 x, A* l! y. Q X# H+ X
};' n9 B, ]; \; K: p0 F$ S" l5 W+ _
8 _' E0 R. E8 f6 ostatic void led_dev_release(struct device *dev) c/ I# A' J! f
{ _# E5 z0 I9 `0 n" g
};
& g, m; S8 }4 |& ?+ A& ], ?9 X) N1 g" z* r# i3 ]
static struct platform_device da850_evm_tl_leds_device = {
" W4 h$ y8 i9 f( v& i1 \0 | .name = "leds-gpio",: l8 A1 i5 r! z& D0 q
.id = 1,! M ?- X& B; ~) z$ w, X f
.dev = {
8 q9 m" _& F: s1 n K .platform_data = &da850_evm_tl_leds_pdata,
5 f, W H8 X6 J) ` | .release = led_dev_release,
7 `- F H2 g3 a }
* R' D2 c! {$ g( k3 f};1 V- ? F# Y. r3 r/ Z9 |; Z \" }% M
! s7 a/ a5 e+ o7 c q9 p6 g0 @( ~
static int __init led_platform_init(void): q8 R& g$ `3 X# d/ _) [/ a
{
- U3 ]8 O' m1 | int ret;
! m/ y1 G9 ]6 `#if 0+ \" o% @9 f% N1 _
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# [" N5 v. o( V5 O( Q" a8 k
if (ret)# f! [! \* A) u. G- q! E
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 \4 [2 e; T& R8 a9 D" T7 @
"%d\n", ret);
5 n& ?/ i# D7 O6 f#endif5 J# B" x+ o3 H7 I: g7 k: }# s
ret = platform_device_register(&da850_evm_tl_leds_device);6 i% @: J- w. a
if (ret)
# x/ `5 q! q2 Q1 E1 ~; h8 O pr_warning("Could not register som GPIO expander LEDS"); n' s! U, y+ o( c
else% K u1 H% O; ~) V
printk(KERN_INFO "LED register sucessful!\n");% b) C% g. Y9 A
. K) I- ?3 p9 X) `( [) ]7 N. F* g return ret;. T8 X. w8 }. ?& a7 a: u
}0 N! L- E- r/ f/ o! L+ J; ]# ^, p
9 Z0 Q$ U8 @0 t& l; \6 j+ _- ?static void __exit led_platform_exit(void)2 C0 _9 m# h7 K" o
{: U& ]! K# o5 ^, B' S' J! X3 [
platform_device_unregister(&da850_evm_tl_leds_device);
- _/ x- p- s* h
8 b+ r7 r3 d9 h4 Q0 i- N5 J printk(KERN_INFO "LED unregister!\n");# W' i; O- \3 m9 J" r8 N
}+ _, S1 w2 v# @& x
/ T6 o( b+ a& x0 S& ?$ o" umodule_init(led_platform_init);5 D: [% c2 c7 g3 B s7 {
module_exit(led_platform_exit);" f: j4 l% `% M( ?6 R) U
6 c2 D% r" S8 m/ uMODULE_DESCRIPTION("Led platform driver");
! \7 I/ }4 Z6 E% F+ BMODULE_AUTHOR("Tronlong");3 z3 n! V3 b Z: L
MODULE_LICENSE("GPL");: W4 W# j1 |4 w6 i" w% ~+ ^
# P" o, u1 C# X$ {+ \
|
|