|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* `+ u. a* Q( h% T7 s) W3 w#include <linux/init.h>, d2 ~9 ]6 U3 J. m6 L9 b
#include <linux/module.h>
o& e& \0 S' x2 Z* o, n#include <linux/kernel.h>0 L9 h- b: Q) D
#include <linux/types.h>2 F |) d H1 b x. r
#include <linux/gpio.h>( X3 N% P+ ~) ]8 j# O+ E( u
#include <linux/leds.h>
! K" T& r; c8 o! I$ X0 r#include <linux/platform_device.h>' ^+ a7 W- s' n6 |* t) K0 D
6 ?9 _- P( L7 l; W#include <asm/mach-types.h>0 d7 f& a! [9 |& @0 m. Q
#include <asm/mach/arch.h>
( C' Z3 T" t% N) {8 Q' }0 ~, F$ _2 V5 ]#include <mach/da8xx.h>) ^& v+ W# \0 Y3 J6 q
#include <mach/mux.h>7 f; V7 e" y# F& l1 v h. r1 ~: [
! |# t2 w+ l# W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): U* }6 X- k3 p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ D; j! h, }' w. I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ \2 J* f$ O! b& r! k0 N$ s
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 R# b5 l; ]7 y. Y
' q9 p; E; |/ c; B/* assign the tl som board LED-GPIOs*/ J7 ~. Q3 F- T; [2 X
static const short da850_evm_tl_user_led_pins[] = {6 s! I' ?- V& o
/* These pins are definition at <mach/mux.h> file */
8 Z5 {5 u% h0 b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( R8 z* f- r1 G7 A
-1
5 E2 i8 b$ }+ U1 I3 p! e2 ` }4 m}; K1 I7 R( M/ l1 Q( C F
1 ^& G5 j" |+ E8 a/ O8 A4 a3 |static struct gpio_led da850_evm_tl_leds[] = {
* z$ {7 k& x- {# k- y, a {- u9 c! _! J& e! P) m4 Y
.active_low = 0,
" P+ U) H* Q8 d! M: p. W4 C, ~1 A .gpio = DA850_USER_LED0,& O7 P2 [- ~! N. K- y
.name = "user_led0",
( i/ K- m Y: K6 A1 z+ d .default_trigger = "default-on",( X C& {$ C! \7 q# g
},7 s3 m$ ~& l: S
{
8 F* t7 @6 _# G1 S- T: }3 Y .active_low = 0,0 L9 E- e$ p) L" Y
.gpio = DA850_USER_LED1,, b! T! }$ u" Q- a: e
.name = "user_led1",
/ n$ X& z0 K$ G9 Y4 b0 s% w2 q .default_trigger = "default-on",
$ N7 @2 J" e* h0 U5 X2 ~& J },& u, V) v. T2 p. r( W( k/ m
{
8 p9 [" e( U$ T .active_low = 0,: z5 {2 |2 Z2 [3 u2 W
.gpio = DA850_USER_LED2,
- P j( c1 _$ [9 B: {- k4 J .name = "user_led2",7 \3 o; ?$ v( z9 v+ v
.default_trigger = "default-on",
5 w- M/ L& w3 _8 w5 B$ g" `7 X },7 Q1 e0 P6 R1 @/ W* s. Y* p
{
5 | w7 N" K- N% U; p .active_low = 0,
4 c: ^- B$ Q# U5 p5 |" {& b .gpio = DA850_USER_LED3,, P2 u7 Y/ V1 z
.name = "user_led3",% G' W7 t. [8 @7 d
.default_trigger = "default-on",. Z7 w6 I5 e' I: ]5 G
},0 d+ b3 W: S* z6 @" D
};
* q6 N5 \8 w; v" ?4 C4 o# W$ \; _, a- i8 t6 c; l1 v9 T6 |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* k. ~2 Q: [& {, w% D. A$ { .leds = da850_evm_tl_leds,6 S% V2 t0 m3 |
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" K3 W2 b( C1 s, |5 @$ t1 K4 m9 F};
' {& p2 x+ G& f) w, R5 ^3 \" P& F4 C% I* S2 x
static void led_dev_release(struct device *dev)
- _: ]3 E& Y R4 ?/ _. v{7 S8 Q. o1 l4 K& ~" j
};3 D4 a) O' D. Z9 v8 J
# Q* J# M6 D: v$ m5 d5 estatic struct platform_device da850_evm_tl_leds_device = {
% z; p# p3 ~, ]% ?% Z1 q8 b# M .name = "leds-gpio",
' w" @& w7 Y5 k& o' j6 C0 a. w$ `3 v* W .id = 1,! a# Q4 B7 v$ f) f" `
.dev = {
1 G$ v% g' b& k, B& A4 z .platform_data = &da850_evm_tl_leds_pdata,
, l0 M3 ?" z7 B- v: X @- c6 d .release = led_dev_release,: D7 P2 g* N$ t) c3 Y, o B5 I+ ^' j
}
# `4 X* z$ k. X6 z* t) @* ^};2 O" M: T/ m9 }: j# V
, H/ m- K- d3 F+ I5 D
static int __init led_platform_init(void)1 w* q8 N2 O% j! l8 W. C
{' j2 a- ]5 `2 ?' s% V
int ret;2 X5 m2 ^+ `. f: A& N% O
#if 0: D% H5 \0 {" E* d' C E9 Q/ T- \: P
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 ]( T6 n2 I- y& B
if (ret): U4 j+ j7 V5 q! R/ x* }$ h! M! p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 \, a, x( r+ u. e1 {
"%d\n", ret);% l# l" g8 A4 s
#endif
J7 g$ h c% ~; H) j ret = platform_device_register(&da850_evm_tl_leds_device);
# g9 J/ V0 b8 G0 L- l+ B if (ret)4 F _$ A: O0 M+ B- o) [
pr_warning("Could not register som GPIO expander LEDS");* A$ l7 `+ P2 H N2 r3 V! H% _
else
6 u! m& ?0 \/ ^1 { printk(KERN_INFO "LED register sucessful!\n");1 ?* B( Q+ Y' L+ g$ @4 }0 ?7 K4 K
9 q3 A# {% B1 j) N0 u/ h1 H5 \
return ret;+ E8 H. Y/ C0 g0 Z4 f4 l) l
}
' B5 W' W) J C. |; y3 W
* E1 V1 B1 b4 Cstatic void __exit led_platform_exit(void)4 [9 @: v }8 Z
{" p/ L# d# ^( K/ m
platform_device_unregister(&da850_evm_tl_leds_device);' r1 @* v d% l9 u
" I) t( O2 S$ S! Y8 U6 @9 x printk(KERN_INFO "LED unregister!\n");- T9 W+ d" @# H
}
9 S- i: [5 h h6 D: @/ V* S8 J; ]" D# l* J6 F" \5 n1 [) x1 G/ o
module_init(led_platform_init);1 r0 j+ Y. y* K3 A
module_exit(led_platform_exit);
( f' q; R: G" b4 F: e* Y' f, c4 V! Q- Y" o7 s4 ]
MODULE_DESCRIPTION("Led platform driver");
$ J7 j: { F7 F8 ]$ Q! {; M( i, ZMODULE_AUTHOR("Tronlong");; p6 z( V4 _6 Z5 u$ q
MODULE_LICENSE("GPL");
# G. m/ S% l: Z7 c9 s3 W& ?# z ?. s9 U% b* i* p& P0 p
|
|