|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ ~9 J1 }# ]+ w8 x
#include <linux/init.h>+ f( e2 Y" e: {7 L& U
#include <linux/module.h># J1 c, G9 N5 l0 R. t
#include <linux/kernel.h>0 `! H5 w' t5 Q6 n! s
#include <linux/types.h>5 l7 W: M2 m( C& ~6 E( `0 m3 T
#include <linux/gpio.h>
" R. T( }, S2 N0 r( {9 J#include <linux/leds.h>
1 g) Z& c h K. ?5 i5 \#include <linux/platform_device.h>9 y1 x! L- a- |" H
$ o3 r3 _% [& S/ K) A; V#include <asm/mach-types.h>
8 w7 T# s6 Q- i, J# r#include <asm/mach/arch.h>, w# N3 m9 x; x4 u& X
#include <mach/da8xx.h>
0 l. p' |6 [, g! @- g3 q#include <mach/mux.h>
$ P' V0 e* _% e5 T! |/ w p/ b* n+ u" o1 e& o/ [, _% |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 A& a' V3 _# o3 K; v/ j7 R#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! H& m6 v Z2 O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& f: e" z$ c4 Q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 }- b8 N# B( O2 d- g9 ^( W
" m( f1 H F8 w. _* @$ O" \' _! H
/* assign the tl som board LED-GPIOs*/ m4 x$ h: {+ m4 {9 L5 i
static const short da850_evm_tl_user_led_pins[] = {/ o$ f+ s8 x$ @( n' S2 Z& ]
/* These pins are definition at <mach/mux.h> file */. a" P3 P9 ?7 @# j. a2 I6 m0 t y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: h# N7 e; [6 \5 c- Y$ U% u -1
$ f: {9 @# \, N% c$ T' d};& H7 @& o3 s- ~/ m
4 ]4 a+ L. T3 ]4 ~
static struct gpio_led da850_evm_tl_leds[] = {5 N1 ?( `+ ~8 c1 L
{7 H; l& ?' T- J
.active_low = 0,6 D k9 J$ ?( D
.gpio = DA850_USER_LED0,
$ R6 l D# K) {7 z/ s+ _ .name = "user_led0",( l6 F) [+ }3 |1 w
.default_trigger = "default-on",6 }8 Z u7 t* z
},
* ~' N# ~/ }% Z {
! ^+ K$ s4 n5 h2 M. _9 G' _ .active_low = 0,
% I4 h9 U: |3 G1 q- l7 l* ]! ] .gpio = DA850_USER_LED1,0 d: Z1 ?" T+ Z" r# R
.name = "user_led1",
1 J% g$ X6 ~" a9 _) I! }0 ]* X .default_trigger = "default-on",# D2 I8 P k! q6 K& c8 T6 S/ k
},% i* p% g' J! E% u t
{
/ N. s0 S, ~. D" i2 x- i3 b .active_low = 0,
4 B( V& l- S5 R9 n .gpio = DA850_USER_LED2,
* U, N) [; f' m) \$ B .name = "user_led2",9 I8 d* |* _# Z; z Z: \3 @4 G! L+ h: ^2 C
.default_trigger = "default-on",0 `( `, Y p+ ]
},
/ ?' D& V+ {, n; j1 c/ i+ L {" t. T' |3 |0 Z$ b4 e! z
.active_low = 0,) n/ K6 p! c- \0 @. [0 }
.gpio = DA850_USER_LED3,( @8 x2 k* c) z' n3 z
.name = "user_led3",
% Z) f6 s' r9 b) [& W2 ~* o$ w .default_trigger = "default-on",& G6 \3 A- ?! ?4 ?# c, }8 b" I
},3 o$ D9 @) j+ P/ C/ v. t
};
- m+ n G5 k% S# Q1 a! P0 u' c
) ?! n8 d! Z3 r0 T- K$ p5 Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 H& Y; U" n5 \1 d
.leds = da850_evm_tl_leds,- w. Z; X6 f. k* r' P0 e( Y0 W+ a5 X9 I
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' O, H0 d2 E0 _};6 ]. A$ k) ?* N9 O @
, m, ]+ i: C& p$ r+ D# ustatic void led_dev_release(struct device *dev)
+ g8 V6 O6 C! p2 {5 S{0 V# }* i4 g& }. Q
};
0 ^) `2 ^& C& R
8 |, ], F) X- o% C& {static struct platform_device da850_evm_tl_leds_device = {
& F/ a% x' t7 w6 C .name = "leds-gpio",+ F/ d- D. u: Z: f
.id = 1,# f( b- j6 g+ ^$ t$ g
.dev = {
l! |& p1 @# _; v: J" l: T .platform_data = &da850_evm_tl_leds_pdata,
# [9 m5 G6 N( Z7 d .release = led_dev_release,- @. V; e2 i: `" z6 U" c3 D
}3 y$ p1 F+ R$ T. J
};2 P: K u& [. Q F
. {7 u0 D9 l; N, U; Astatic int __init led_platform_init(void)
, W& n) R, w0 L, c5 m+ H, u# [. a{* l* Y! v5 n p# ^, A8 L- S
int ret;
5 E5 C" \0 u& [# c#if 0) t- t I2 C+ b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- [* o+ P7 K5 i% O7 {* a% a# g* F if (ret)
/ E0 f8 V2 H6 y. k5 e* f9 I% V, i pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 {7 V: p, d* |
"%d\n", ret);: m u$ Q* ] |9 V1 h @
#endif
$ j: j6 t; E' U% T, i Q ret = platform_device_register(&da850_evm_tl_leds_device);
+ R0 A! e9 B. F4 s# G* ]4 T if (ret)2 G0 X$ u9 p9 M- U
pr_warning("Could not register som GPIO expander LEDS");
: l$ S: e$ }3 _$ O else
6 K1 J' g- U3 [5 z( Z printk(KERN_INFO "LED register sucessful!\n");0 Z$ }& @0 Z' D' n* Z# }3 k, d) U
) d9 t. [2 [" ^9 A* r! b/ \
return ret;; ?8 b# q( N S- R
}9 T9 b1 {4 {2 M! |9 R
& ~$ Z- G1 ^8 w5 E" O, ~8 i. u
static void __exit led_platform_exit(void)
* p" m/ ^+ F ?) }0 Y{2 C8 p( g( f7 A) H# A
platform_device_unregister(&da850_evm_tl_leds_device);' p( |8 _$ v/ a! M- [
7 |* n' h$ a4 ]: C# p9 E
printk(KERN_INFO "LED unregister!\n");
" E1 W& A/ y* M/ v8 U# i}
a. K: R" o. j1 s; I# _& h$ g g2 M& u/ O7 ?# w" d' u1 J
module_init(led_platform_init);
; `, N+ e2 c% Z$ B5 G& r; R1 I5 E8 Mmodule_exit(led_platform_exit);
) [( z5 ?# y3 ~' F- A x) m7 y O+ J% U
MODULE_DESCRIPTION("Led platform driver");
% ^5 S' F+ K1 k1 Q s+ \3 |9 \5 SMODULE_AUTHOR("Tronlong");! P! |9 ?! b7 m$ Q* W% O# t
MODULE_LICENSE("GPL");+ t# ^# f1 _- N, n J
5 s! s" o) f7 x% X# l" D6 L1 E
|
|