|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# |; B2 U" `$ O t#include <linux/init.h>
- G# x7 ? w( K#include <linux/module.h>
- B- s- ~! o, @! B V9 ^#include <linux/kernel.h>
8 y! t) f% |8 K' Y; L#include <linux/types.h>
/ d ^# i$ {3 Q b! |: j#include <linux/gpio.h>
0 ~# C% v9 _7 N6 _#include <linux/leds.h>
, ]8 x& j; J0 Q- q9 w9 I4 \: i9 Y#include <linux/platform_device.h>
4 F* _( Y) m, c) w* b% ]; j* a* y7 v& B+ ^1 c* _ @. O
#include <asm/mach-types.h>
8 f0 n) |7 G, I. J) o/ Y4 p#include <asm/mach/arch.h>- O* ]0 |2 r8 h8 d r
#include <mach/da8xx.h>
7 i3 w: ` ^# O4 n9 k#include <mach/mux.h>
$ S' w, F' ?# Z7 g' l: H( x, j8 C6 M3 Q8 o6 f* ]% h
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 K; r# V$ d% `& [5 [#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& }' M2 \1 \7 s1 |% Y/ ?9 v2 e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); L+ g! t; \2 I( W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). T* {/ B( W: e& y& V7 R
: c+ r N/ p: ^" _+ M E
/* assign the tl som board LED-GPIOs*/5 A/ c) ?! B! P/ d; {9 w0 `2 F7 p
static const short da850_evm_tl_user_led_pins[] = {" n7 N8 S) S: |7 V+ e+ {( l
/* These pins are definition at <mach/mux.h> file */- k6 B* B/ P3 S0 Z5 j6 q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# o8 w$ r: p: `" @( G' E) Y
-12 G% N8 H3 h: V' p$ W
};
6 A4 V" Q3 M( X4 E7 v- y% Y4 S- {8 W* y5 L o8 ^
static struct gpio_led da850_evm_tl_leds[] = {. w8 j6 o. |# k. s1 R7 r
{0 r) e( P% y$ {% ^3 i3 V6 j! L
.active_low = 0,5 R4 X4 h* |3 H
.gpio = DA850_USER_LED0,
. K4 n: H# F0 Q- @# O .name = "user_led0",
7 B/ x( L. Z8 c .default_trigger = "default-on"," b* z! P# k6 R, E$ o3 d
},
+ ^6 q, q& ^2 h {' e* C1 c( H/ k; e$ t5 c0 @
.active_low = 0,
9 @% n4 N2 M( u' t4 O .gpio = DA850_USER_LED1,
/ U( @$ ]" k. }" i .name = "user_led1",& D, q ^7 Q2 I/ a7 H5 \) ?6 j% G
.default_trigger = "default-on",
( W- V$ K6 C- k& }- P1 [ } },: H3 E. C5 o2 J8 {, ? J9 M
{! t: \7 T$ T$ L1 _9 a3 U$ R
.active_low = 0,# h" w5 m; w$ ^+ l- H3 M0 G) E
.gpio = DA850_USER_LED2, t$ n( i; A2 o. h2 @
.name = "user_led2",
+ ?/ o8 i( G0 I7 E# C! m$ e .default_trigger = "default-on",
4 b3 x! C1 `4 D k% [; F, a },
# `4 n6 [; o2 ? {; C2 M. v6 Q8 v9 C2 W
.active_low = 0,
5 \* S5 h8 Q) g$ N' {) W .gpio = DA850_USER_LED3,
0 C2 F: p2 O: r .name = "user_led3",2 C4 s' H" s6 ^7 U" C, r7 d, y
.default_trigger = "default-on",: @) M- v5 |3 Q( g! j- b
},
: H' l1 s* J' b};
+ X; H+ L3 k0 T% g4 g
* }* J+ J6 v6 O! u: M1 Q+ w- qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- {! T) k I2 ? .leds = da850_evm_tl_leds,
4 S& r* q" b& a7 c; Q* n& t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ F% _* Y, o/ M( |6 Z4 |};
J/ ]9 d1 @4 ~, w3 z0 B) K
* x6 t# d* l7 A# I D6 }static void led_dev_release(struct device *dev)
$ P x h c- y# V0 o; S{8 o s( I( F% w% S4 A! q5 t
};
6 `$ `6 x) @4 ~) S; `! n# q7 D. z+ A. J# i
static struct platform_device da850_evm_tl_leds_device = {( h" U; F9 J9 i* d% f
.name = "leds-gpio",& e* r( A; O! ], |, |# P( o4 K/ [
.id = 1,+ i! `) o$ w) q% D' q$ [2 L; U
.dev = {7 D3 ^2 y9 s8 Y$ O7 L
.platform_data = &da850_evm_tl_leds_pdata,. _: ]' Y1 c/ ^9 ^& X" j
.release = led_dev_release, l2 Z5 a1 M9 {
}; l9 u' ? S" K# B5 ]( ~3 G
};
7 i" V7 H1 j' x
: E/ Z) p: N6 |static int __init led_platform_init(void)
( ]5 [ x: g# E4 i: @) f* Y0 d{. [# s; H+ a" y, I/ J0 [. } h: x
int ret;4 @ p; H& m8 ~" l5 Y8 D6 p& M
#if 0
, l6 c- l0 E a( D+ T. p( [ j ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% F; q1 x* F r9 q3 j
if (ret)
' A' x) p. ~* a pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ V6 W5 ^9 N, ]# j }. t( O
"%d\n", ret);, c% s% p3 _8 B) V( i* y
#endif& j3 y( O, \& Z5 Q1 p0 b
ret = platform_device_register(&da850_evm_tl_leds_device);
" n8 v) ~8 Y0 I# G9 v" Z Y! k. E if (ret)
) U9 ^" f# L* p6 O pr_warning("Could not register som GPIO expander LEDS");/ o6 F& W' G8 k2 N# W
else
6 `5 O8 D: s4 C! f, I( C' B printk(KERN_INFO "LED register sucessful!\n");, h0 U* {& L2 b# B
, @( Z# e% ?8 l
return ret;, V! k% ~6 r* r
}- d% n3 \3 f+ W! Y3 o) Z1 ?. ^
; P j# n6 q1 K7 C) g, j9 @: m K6 A
static void __exit led_platform_exit(void)
5 O( `* I5 r6 Y6 Z! T+ v- a5 W{/ i" d- d4 U& O0 b7 V- w
platform_device_unregister(&da850_evm_tl_leds_device);: W5 }" C8 s N) G$ m
" W' Q7 I# o2 c1 T: A
printk(KERN_INFO "LED unregister!\n");- M. }. Q3 O4 ~
}' E* D3 Q5 v4 S* q6 G0 X" Y* G
, ? m" u) L" ^ g- _
module_init(led_platform_init);
5 e/ K5 I3 D V/ j/ z% S3 I# M! Jmodule_exit(led_platform_exit);
$ _: Y5 d( _! y. P
. o1 e1 Q& w5 s& A8 g0 U; X# d; RMODULE_DESCRIPTION("Led platform driver");
& Y4 } Q, _3 S; S9 W7 W" N3 {$ GMODULE_AUTHOR("Tronlong");
- A/ ~5 e3 s) _6 a8 g& \MODULE_LICENSE("GPL");% q" l' d! S) w* c* V' T2 ~
" R! {1 } u4 F+ `1 `4 V
|
|