|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ z& ?6 ^- j+ n0 b2 c$ o _#include <linux/init.h> K3 {( c" Y# @, L$ R8 B
#include <linux/module.h>* ^0 D/ m, @8 w; [
#include <linux/kernel.h>% v+ O8 P7 X' f- @+ `: ?
#include <linux/types.h>- P. R5 \3 i L
#include <linux/gpio.h>
# G2 Y0 N, x6 E% C#include <linux/leds.h># G3 A5 y0 p; k
#include <linux/platform_device.h>9 i5 b5 |4 ~& A6 M$ `2 l+ \6 n
s; \ l4 a. X; H) k* w#include <asm/mach-types.h>
9 Q) T% f* f" }# c% f#include <asm/mach/arch.h>
& }( i; t/ I1 X. R#include <mach/da8xx.h>
J6 w* i2 }% d#include <mach/mux.h>
b, |* W" M* O+ U8 |9 m0 w
% N4 [, K: j$ s6 Z5 c$ _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ R! Q9 O& }6 k4 w6 f+ W) Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 S! X% i F$ m* B: M9 d* j4 \#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 J1 Q8 x/ r9 `; u4 d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* A. G5 A3 D7 I# B# Y8 j
6 L' H$ d7 M$ U) w: s/ I# e5 X/* assign the tl som board LED-GPIOs*/3 r! _0 T& t( A( X
static const short da850_evm_tl_user_led_pins[] = { |$ t- U* j+ E. ]# V _5 Q+ p
/* These pins are definition at <mach/mux.h> file */
+ Q* ~: R6 g8 {4 |. P DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 L8 K U- B( U: K) N* [$ E
-19 t- F* |! u$ e9 V# @ T
};7 \7 E) n+ `( g* _
1 u& }0 H% ~# K! \: r( Hstatic struct gpio_led da850_evm_tl_leds[] = {
% X: b% `3 o. a' [ {
8 t" e$ {( X) ?+ {) F4 C# T .active_low = 0,' g& W4 P/ K3 W: g4 Y h5 B* H
.gpio = DA850_USER_LED0,8 V; D/ K0 h, g9 B' K
.name = "user_led0",1 Q B' f* m$ S
.default_trigger = "default-on",2 c4 z+ c. Q- ~2 g! N+ Q0 t* d$ x' f
},$ T) w& h; p$ ?* b
{
( E" k/ }1 {5 @& B .active_low = 0,7 L! _. ]0 e D, i4 g d
.gpio = DA850_USER_LED1,: y$ X5 F2 {- Y- `" g* B8 O# o
.name = "user_led1",9 n/ h" E. m# @" p8 C" b* n% i L
.default_trigger = "default-on",2 I# U- u3 l+ r" |/ S+ V9 W
},$ c- H) r; g4 Q9 B% ]7 @
{' Y6 S; m9 y3 N: l! H, p
.active_low = 0,4 F! n$ c$ K3 X! \9 Y& X* V
.gpio = DA850_USER_LED2,
# X: v7 Y# Q% d1 H/ v' y' ~ .name = "user_led2",
+ l5 L7 v( b* b) S9 q, S& C .default_trigger = "default-on",
/ |$ H3 y& H1 I+ B },
9 E* [/ G3 e. e1 Q7 G) { {8 `( ?9 b8 M- c' L2 [* M& J
.active_low = 0,
- D5 r2 I7 x5 M5 k6 W" _ .gpio = DA850_USER_LED3,8 t3 ]- {/ s' \% u9 P( c# J
.name = "user_led3",- O7 S5 M7 b$ v) n7 v+ y
.default_trigger = "default-on",6 W& Q7 l: M+ g% d7 x
},
# y+ L7 ]# B6 a) ^1 A};2 d6 L% y" I" ~; S, ^8 B
( D( I7 L9 v+ c3 f( `3 C' tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 l( E- {: `9 q: B. P, V( j .leds = da850_evm_tl_leds,% [- v0 a& R4 I$ w) N! U, s- U! q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* Z3 T" s5 @" P: U6 j; ?* B6 r5 F};( ~8 {4 }. y, _
( f% d& ?- ]9 m9 @! |" Xstatic void led_dev_release(struct device *dev)
6 s# g4 o2 x2 E7 y3 P{- l: s5 o6 V) {' s5 X+ Z
};
6 z2 J8 r. G. b+ t0 i+ @8 c
; H7 K0 P1 r+ G4 [7 zstatic struct platform_device da850_evm_tl_leds_device = {
: x: K2 U- ]8 `& Y/ U .name = "leds-gpio",
- p9 _+ o/ M# u: @ .id = 1,
7 \# {) w1 Q e7 h4 O .dev = {
0 `$ p: f. k' @3 L, P3 t+ k .platform_data = &da850_evm_tl_leds_pdata,
% ~/ A2 j4 R& m .release = led_dev_release,2 y2 G9 _4 S8 K9 \
}0 y8 H! h+ m4 q% s6 @3 _$ j% L
};, P' ~6 o1 q& H
) \7 S; v1 c5 c8 E! D
static int __init led_platform_init(void). U& F2 \" ]- J
{
3 _' e( M+ ~7 E6 r int ret;8 B* q2 W/ y5 h7 X4 t ^
#if 0
6 j8 t' F- K- ?1 N' {* ~) _! p ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* E* S9 r! w( _# G2 T3 s9 B if (ret)- R! r' `& x2 y) f2 T/ n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; H4 u& {% L' M; y4 X: K
"%d\n", ret);
& P" H# ?: n0 N! _% W" Q#endif1 }. h1 x1 V: A M+ l% S0 ~+ l* `) V
ret = platform_device_register(&da850_evm_tl_leds_device);
+ j# Y7 c+ L: b if (ret)9 F4 U' t: h) r$ y
pr_warning("Could not register som GPIO expander LEDS");- L/ s! \ j* j& d6 B$ U& b# k
else% Y- N* i# H( z8 h4 x' A. j, [
printk(KERN_INFO "LED register sucessful!\n");8 M1 o G, k1 X. o. X
. g( I' Q. C6 y4 Z8 ? return ret;
8 o X6 O8 h6 C3 S X; i+ x9 x}
+ h: A/ T: l$ N( r: w i! p4 N6 z2 f f) d# Q4 y* p3 R
static void __exit led_platform_exit(void)
7 l% K( J$ V6 x/ j0 _+ N) c{
g" r" q7 a) K" b* f" p) [ platform_device_unregister(&da850_evm_tl_leds_device);
S% Z5 P, l& s3 `: k: N* m& w' M6 {. i) r
printk(KERN_INFO "LED unregister!\n");
& }* d0 `# K1 t4 B9 p) u% _}
& }& \8 r& b/ i6 m$ f' G
3 q) A, k; w( Wmodule_init(led_platform_init);/ i0 h% ]& x+ Q* a7 }; `/ L/ v" S
module_exit(led_platform_exit);. p0 i6 q) e% A8 w
& w V! {4 p2 @$ SMODULE_DESCRIPTION("Led platform driver");# I% p) l6 D% j# i9 o4 |
MODULE_AUTHOR("Tronlong");( B M t3 G5 z" m) p! K1 Q
MODULE_LICENSE("GPL");8 i. c0 t$ k! |, ~
. x6 s; h+ `% B6 r- N0 D) ] |
|