|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 k7 [/ q- g7 Z" e/ w" \
#include <linux/init.h>) D" o# i$ E. {
#include <linux/module.h>
3 Z# H6 ]' A* |2 G! y#include <linux/kernel.h>
/ v. l$ r6 `5 F' E6 z- Y: a- ?& W# y#include <linux/types.h>
$ U+ t* X0 \% L; M. P#include <linux/gpio.h>1 u" c8 p$ T9 a# U
#include <linux/leds.h># S$ O: W, @2 d9 _* n
#include <linux/platform_device.h>, M2 g6 n( F0 ~- p/ X9 w8 ~
, m- g; c2 u, G7 y! ?7 m7 n( }#include <asm/mach-types.h>( Z5 R8 x, t1 q% ?) N) C
#include <asm/mach/arch.h>
6 T) I/ J2 R2 j' E# X y F8 k#include <mach/da8xx.h>
7 Y! @& A/ h6 u#include <mach/mux.h>: K" a7 J4 P# f
1 r' t9 b4 q9 {$ J* D4 v# x
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* P- Y) w Z% F& F. q* `/ n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" s$ j3 f' v* f) q6 |6 s
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); _: G8 H6 ? D. x7 H
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! \; r- z; r z4 y
1 Z$ I9 s8 M" e: x% D6 j- [/* assign the tl som board LED-GPIOs*/- n. j7 |6 h2 m: A$ l2 d0 r
static const short da850_evm_tl_user_led_pins[] = {
8 ` t! r* @4 o9 R$ j3 z /* These pins are definition at <mach/mux.h> file */! j" V- r2 B8 s4 b+ }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 d% ~! R" A) J
-1
8 k+ z: `8 }! z0 k& t, \+ e- G};. M4 Q% R; u& i9 C
; ?% O* V0 ]; H* `static struct gpio_led da850_evm_tl_leds[] = {
7 S" l; I9 m b- v" R {9 ^7 P4 o* ^2 q8 \2 N: T
.active_low = 0,% H- _5 y/ V& D; {' N8 b+ e6 R
.gpio = DA850_USER_LED0,
7 ?) [2 Q) S8 x3 T .name = "user_led0",$ c7 `( i" Y$ E9 H
.default_trigger = "default-on",0 d, @! j/ L" o8 ?+ Y, D3 M: v
},
7 ^0 ]9 A$ [& f; {* s5 ?$ `) @* X {- D/ M6 [& p) u. c0 u# F! M
.active_low = 0,
5 [9 h- N$ \( u' a& ]! d7 i .gpio = DA850_USER_LED1,! @' `/ n% m! B' h' E& N
.name = "user_led1",* J5 s& ~( S. A' S# Z
.default_trigger = "default-on",3 z: E4 X& c& _
},) u L, M5 {6 O z, F; e8 b* q
{/ P! q \' ]" E! Y/ H4 H
.active_low = 0,: C& y4 L( d0 d% E* |# Y0 Y: Z
.gpio = DA850_USER_LED2,
# n+ g# u( f; o .name = "user_led2",3 m6 `% g" j! e) V. l3 E* z3 l
.default_trigger = "default-on",% O. p5 l- V# y- P+ T9 A
},9 g8 m( a8 S* H: b; V6 q; Z3 x" G
{: [8 W# R$ C5 W& P& A
.active_low = 0,6 D5 @& G; b9 o
.gpio = DA850_USER_LED3,9 w% r; s1 g' }, t* K
.name = "user_led3",) }$ k0 A8 j: M
.default_trigger = "default-on",
" \# N1 ?6 d+ w+ P. W },( O$ E6 X; B9 ? Q$ z5 G
};
3 z) o/ r7 p( b. `' J) t- y6 O# r+ Z; u4 D; P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# n8 w' w! ~$ }/ s/ A; c0 V' J .leds = da850_evm_tl_leds,; G' n- D- a! m H t" r; A( [
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' t4 x( K" n1 K" |
};2 x9 e& Q/ _' J' }& O$ i
* q- o+ y+ F& \7 ]! C& i2 Ostatic void led_dev_release(struct device *dev)
4 {# J- e ^) {; R' n! Q{
6 e: z4 r2 @& r$ K7 b};4 s2 S# g5 [4 r; u
9 O# I3 u* _4 G! k8 v% v- H; \# Ustatic struct platform_device da850_evm_tl_leds_device = {( s! R& h5 D4 ?
.name = "leds-gpio",' C$ \8 b j: z4 _
.id = 1,
, c3 t2 W) Q, x( }/ y4 _ .dev = {! G; M! I4 n$ N( E- T
.platform_data = &da850_evm_tl_leds_pdata,% s9 R/ }( x; X7 z
.release = led_dev_release," {& ]: R- I# r. X
}
0 Q% J# e- @* F) ~, H};
$ O7 w/ H7 _8 G8 R" J$ I1 e
0 j* s/ w# \( D2 J; U2 ~: lstatic int __init led_platform_init(void)/ t8 S4 D2 V& m: S# D$ G# _" \
{
% y( a) n+ S( D int ret;
& l# R3 J3 \$ I. p. H#if 0+ Y0 r5 d" F1 S! {3 q. o; s! [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% Q4 _5 p) {4 Q7 s, C2 J
if (ret)
H J, b1 a$ C pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 u+ _8 C) S" v
"%d\n", ret);
5 s$ |' [9 T# n$ r; T#endif
8 j3 K& }0 C$ {) ^/ c ret = platform_device_register(&da850_evm_tl_leds_device);. q/ a, w" Q0 u
if (ret)" z' K# x) u9 D& C0 d. Z
pr_warning("Could not register som GPIO expander LEDS");
+ i# g9 C% I" g, B6 J m else
$ J) j/ M* y9 t/ A6 n3 U1 b printk(KERN_INFO "LED register sucessful!\n");) t d0 P! s j8 X. x( s$ p
' f, E3 I1 W, V) ?4 B3 \0 k
return ret;
4 {7 Y3 a3 ^0 t- y% X5 ^. b( e}- |4 A' [+ A8 F, e* W
! e: N A3 T- N* Kstatic void __exit led_platform_exit(void)
4 I" x; {- g T/ E O8 x9 z4 `% u{1 O, v( `! z7 i
platform_device_unregister(&da850_evm_tl_leds_device);- i ?9 T. b1 o) [% W0 ~# \
, h* U8 u! J/ j( d$ s; N printk(KERN_INFO "LED unregister!\n");
2 s' L. H8 m5 a5 H+ h& S+ y3 W' I5 u5 M& G}
- d9 l3 E7 [) u9 q& {7 b1 V
. v. z! c+ l+ z5 g% N( [/ Y4 xmodule_init(led_platform_init);
' k5 K7 L* y6 k; ~: G& omodule_exit(led_platform_exit);
5 r T% R4 N* {+ k C/ |6 R7 `0 D' K$ }( g
MODULE_DESCRIPTION("Led platform driver");! U0 ~4 U- Q( k
MODULE_AUTHOR("Tronlong");
- e; Y4 {6 K9 Y* X* GMODULE_LICENSE("GPL");4 V& k" b; C% V
3 g/ w3 K; h# b2 Z |
|