|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( Y2 ~/ A- B8 \( _7 W2 U7 ]: [#include <linux/init.h>
2 O2 _+ }$ p6 }4 n6 S#include <linux/module.h>% A- U& g9 W1 g; a4 w- W h9 c; m& m
#include <linux/kernel.h>& p: @+ S1 R3 Q' j6 ^ B; N
#include <linux/types.h>- M* ?) C# a0 S! h# B
#include <linux/gpio.h>
2 P" v6 H6 `! x/ W#include <linux/leds.h>; }# u! |3 h1 j, s
#include <linux/platform_device.h>
) a' Q, I7 G/ r. y c- v" E8 B$ _2 h( @
#include <asm/mach-types.h>
- M# K+ o) S! ]. t" a#include <asm/mach/arch.h>% k+ w8 ?& R) V5 W$ u. q
#include <mach/da8xx.h>6 p* K6 ]8 v% s) R& q; V
#include <mach/mux.h>
& c9 _0 m- I1 O4 Q& t+ s# c9 t' ~% l: a# x+ j$ l1 }; p) x* ]
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 t6 d7 j: y3 C& U" U# R1 O3 d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! X/ [1 r. W" g: R8 f! |: [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 k5 D# P5 A. I$ E D7 A! Z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. h! X5 b$ Z6 m' J( [( a/ l, {* j
7 y8 v+ M% ?( [* n* d4 y3 }" ]- T/* assign the tl som board LED-GPIOs*/) o; C8 b. z) ~0 |/ j5 Y
static const short da850_evm_tl_user_led_pins[] = {
/ l$ ?: @3 `) k& |! ] /* These pins are definition at <mach/mux.h> file */
, l' n' ~$ L( T, K2 _/ g0 Y" M DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" u, {$ `! K# Q3 c9 W( t( h- @2 g1 X4 Q -1' Z9 D6 P# y1 A1 z+ D0 b
};
( Y: U. f9 _; E8 ?( U/ D) R8 J% Y( F3 U' K4 p# {& e
static struct gpio_led da850_evm_tl_leds[] = {% S( c+ m' }8 b9 y
{( V9 y7 l; t; m" z; J8 y0 }
.active_low = 0,5 ~( P1 r3 Z5 d8 O3 J+ O
.gpio = DA850_USER_LED0,
4 u* C8 \+ k! _% l .name = "user_led0",
0 y n- q9 W0 ?. J+ ^1 z .default_trigger = "default-on",3 c& A# E( B$ F9 h6 R3 W
},5 ]/ ^4 i2 G3 q% u
{: i# D4 a4 ?' k3 K, b6 M' x% L
.active_low = 0,6 w# Y1 d$ r T) l& n) B- y) k6 E) G
.gpio = DA850_USER_LED1,
: b- [$ s3 \8 X/ f( n* w .name = "user_led1",
8 `) q' w. C, C. T .default_trigger = "default-on",0 v3 J' \2 D% R1 M- r/ e
},
/ g5 N( c8 I3 d) ^ {
$ B% b: c _4 ~' k/ g/ z .active_low = 0,
4 V+ h* w7 a' p( ]3 Y, P0 s .gpio = DA850_USER_LED2,
- E+ T4 ^9 H1 P .name = "user_led2",) o. C3 n6 L& F3 m" m: o
.default_trigger = "default-on",
% k- r# Y# e/ U1 B7 R },8 N7 i4 S6 o% [8 F2 h8 K
{# t t1 \9 f {1 W
.active_low = 0,
4 x; j4 P: V; J; N. J, L' n .gpio = DA850_USER_LED3,7 {2 F& k2 x( _ y- p' P6 d1 Y( ?
.name = "user_led3",
% R( R+ |. F2 w0 Q .default_trigger = "default-on",/ E: v& }( V7 ]# I6 W7 I
},' E' {0 G9 d" s3 X, V% b
};& X% Q" s& M/ ]6 `: W
: h& r2 l a# [$ S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; m, X6 s$ K$ d2 i+ q# Q .leds = da850_evm_tl_leds,: [, I6 r, \+ u; q3 G, `# N# x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 n5 ^+ G7 Q' ~5 ]- X! ^8 i
};6 s2 s0 L" K5 U& B% B$ O# X' f
' G5 D8 R2 w- l, R6 J7 nstatic void led_dev_release(struct device *dev)
4 B9 x" \9 Y: l: f$ u3 l{3 e$ }4 d, m" m: y. X2 m( b
};
% g0 @3 s! ?8 D! l% O
3 o$ g5 e/ p6 Z/ J/ O' xstatic struct platform_device da850_evm_tl_leds_device = {
& B: O, m! g* o# G$ E .name = "leds-gpio",
7 n% C; C( F/ {" ]7 \% c .id = 1,
! K+ ~9 E+ S1 k/ ^5 S8 }8 N9 Y .dev = {
+ ` L1 Y6 E4 N7 f. Q .platform_data = &da850_evm_tl_leds_pdata,$ j$ |8 t7 R+ u! @3 E; g
.release = led_dev_release,
* e, x6 t5 S. j: J( F/ Q* y }: V2 y3 M. t" e0 Z" S0 X
};' F7 p( D! D N: ]$ Y$ q
/ G4 ^/ }" \4 b
static int __init led_platform_init(void)7 p+ S2 ^0 P# Z
{9 a r7 B& H$ k3 a) K$ l
int ret;2 {( w, X7 d/ `. z
#if 0
, x7 g6 N: q9 ?& @* G& `) D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ q0 O; p0 ~, Z$ j% I if (ret) A" p: [6 v: n c, K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, G8 v6 c1 C. I B) H- E C( K4 T& o "%d\n", ret);- t; A5 L" n+ p; F
#endif
1 f' t; A+ s. F, B ret = platform_device_register(&da850_evm_tl_leds_device);
$ U$ T0 f& e; n. ^( ?2 o6 i if (ret)
7 H f4 w! s# u3 h pr_warning("Could not register som GPIO expander LEDS");
. a: w* M' ]3 f' z. N% ` else
2 L# Y9 x ^* K& B+ M' X1 ^ printk(KERN_INFO "LED register sucessful!\n");8 n( d9 z* W; }
- _* D" ^2 A0 }0 @8 a
return ret;( B. C( N- e/ k# o2 ]# ~( r
}! ^! |8 F: E8 S+ o+ q2 d x+ A
7 D' M+ t0 P; {( q# b4 M& Lstatic void __exit led_platform_exit(void)2 G' I1 @/ ^ T) t: E8 d k
{ n% \1 O6 u) n5 i4 ~' M
platform_device_unregister(&da850_evm_tl_leds_device);
) {9 r+ a4 I& t& t+ j: [# e% }1 b% |
printk(KERN_INFO "LED unregister!\n");
1 A/ g) h3 a4 m) S& T( V}0 y$ m; m! W4 n9 G1 G3 [" h/ _' u( t
8 H! }2 i8 d5 ^' Y; f9 s
module_init(led_platform_init);9 G& v) {8 H+ }+ `7 `; K
module_exit(led_platform_exit);
8 T9 T! J) U7 P* X
& k/ t1 a3 o5 k' }; a! D3 sMODULE_DESCRIPTION("Led platform driver");
+ R6 P6 y+ Y- TMODULE_AUTHOR("Tronlong");* {2 @/ @$ r" L) R& f% @0 e9 {) u
MODULE_LICENSE("GPL");
5 L: s' Z$ U& ?! P" X i' x8 |+ X$ B7 h* Q) u
|
|