|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( L1 F: w, [+ z5 Y# z
#include <linux/init.h>& \- [) @" M {( K
#include <linux/module.h>
5 A. I* I$ \, u1 U#include <linux/kernel.h>" k2 v# t0 v; x0 m
#include <linux/types.h>: a! A8 Y& A) f
#include <linux/gpio.h>
& a: M/ d, J6 ?( w( _2 y#include <linux/leds.h>
) |# [# @" Z' S#include <linux/platform_device.h>' F. z8 D5 I, T- J1 L
( y5 t, V& W a. `" K1 S#include <asm/mach-types.h>+ c* {# o: ]) L% I
#include <asm/mach/arch.h>
, b: @, p; L0 x# L; v! S4 Y1 Q#include <mach/da8xx.h>7 Q. v9 c' Q5 R% J1 z, w
#include <mach/mux.h>. Q, s f$ I$ ?, L5 n
9 D7 d. j8 h9 R; H) l#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' K% N* E' k* `0 `4 z* h#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# H5 d! S0 D! O+ \#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) W. U5 |/ J! `4 L) u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 u6 S3 p; j8 |
* W4 R! Z! [% b
/* assign the tl som board LED-GPIOs*/2 @# {4 Y1 u" L9 E
static const short da850_evm_tl_user_led_pins[] = {
5 R1 C6 Y: z5 I; _. t7 M/ e /* These pins are definition at <mach/mux.h> file */+ m* C; l0 | D; E) u( e
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: d. `. @: Z& {" n
-16 x7 C: Y' C& Z& r. h8 l) l, m
};
9 @3 U% _+ i7 z- a7 ^
$ i6 d$ f% P) V6 Rstatic struct gpio_led da850_evm_tl_leds[] = {
- Q! k3 M0 T. s% M {
) b/ e5 }) X: L. N9 v6 h4 k .active_low = 0,
6 y' D& m7 }5 \. s .gpio = DA850_USER_LED0,7 l+ c- ]2 ?. T* @
.name = "user_led0",
5 b, M2 [, S! T* v4 e6 ], s .default_trigger = "default-on",# p/ Y: _% ]6 {
},1 X% x) E+ m7 P7 y6 }( s- H2 P
{
@% N: y' x$ s8 s7 C' A, M b5 R .active_low = 0,
1 l1 A, j+ P) H5 S" _: c7 G6 N; r .gpio = DA850_USER_LED1,8 C7 D% \3 w( }5 O& T* g
.name = "user_led1",
& b+ _( V* e+ k .default_trigger = "default-on",9 \1 ?# g8 a8 f
},
8 C; C& G2 r: F9 k {
7 f3 f& c9 p ?, _( z7 T .active_low = 0,
9 g7 T( m! q7 N$ N8 C .gpio = DA850_USER_LED2,
6 R! k1 }0 r Y) g+ x4 o .name = "user_led2",% }0 b h' q0 Z3 Y# g, h* r r
.default_trigger = "default-on",, }4 @5 i/ ]$ ]8 N
}, B; z* B, f6 u4 k5 z# C- I
{
: X' e; f6 ?3 F2 ?( B; Q( w .active_low = 0,- T( P5 Q* v+ g2 x& O6 C0 _( ^8 x
.gpio = DA850_USER_LED3,. C# P) K/ s8 \1 G' m" H3 } c- b
.name = "user_led3",7 y5 d. W! ] _( b. e+ ]
.default_trigger = "default-on",
* L2 o. h4 u4 E! v },
4 G. i6 H1 Y4 R: ^4 u}; e- Q/ F* {' J* {
5 }* s% b) q. |; ]: v. y0 M
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' h% {+ O7 k1 W! b
.leds = da850_evm_tl_leds,
! \/ i* k9 Y' ^) B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ |) E0 O- }& I9 \2 b! B
};
( V; k2 z2 N/ U- i* O5 L8 Q+ u( f6 n
static void led_dev_release(struct device *dev)
# P9 [) p2 ]! r4 s2 V1 b) ^{) ]$ {- G8 X" @( ~ u
};
3 S: B: T+ D( S7 \0 K7 b! d, d/ G1 I2 U& r4 I
static struct platform_device da850_evm_tl_leds_device = {8 ^/ K3 @9 e1 o1 Y8 M8 P
.name = "leds-gpio",0 I' S& w- P0 x( T* e
.id = 1,4 F( }* s. I: O4 V; S7 ?- ?9 f
.dev = {
) y; A+ m" m/ ^1 {3 T. I; P6 {9 ]* V .platform_data = &da850_evm_tl_leds_pdata,' l' S2 q- H/ A+ ~7 j
.release = led_dev_release,: P2 q4 u" f: e& s
}9 B% J# ? Z; ^0 Q
};
! I' M/ {% ^! [) G8 R3 x- e1 G4 y7 P: Q- F- F( R! R9 f% S4 k
static int __init led_platform_init(void), @" H4 ?! n! |- W: B6 D. C
{
1 O8 W" \! R1 R( g5 w4 a int ret;
& f9 l# ]: z" z- A5 O. n#if 0! f9 V, Q! A- k9 N; A! [0 T
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ m# d' d! r: o- r$ B if (ret)! [4 f& ?, V8 D" {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- @8 j$ v% A) ~# j "%d\n", ret);9 v) ?/ O- @6 X G% J
#endif
* b& A$ e3 U" B4 x9 l8 U% A" _( X ret = platform_device_register(&da850_evm_tl_leds_device);3 y3 m$ o5 E1 b5 u
if (ret)
3 B, S# {& I( k: R" q pr_warning("Could not register som GPIO expander LEDS");
& A: w( i+ u8 }- S+ |- R else$ k* A2 }' u& j
printk(KERN_INFO "LED register sucessful!\n");9 m/ a2 d: Q% i
7 C! J( ^7 F' a: d' d$ L return ret;
: |% ]* E0 R, Y- v}
! d0 E9 L0 U9 ?* \
4 @1 f" j* |$ c" astatic void __exit led_platform_exit(void)
1 o7 C$ T/ b6 U( V( y @4 _. A{
t- \8 c6 r+ W0 R& Y: O platform_device_unregister(&da850_evm_tl_leds_device);
0 X+ B2 s7 @0 p" P; `& o4 F2 J' p# G7 S" m. G0 N& X" G+ {
printk(KERN_INFO "LED unregister!\n");! d7 ` j% k. z! E# r9 k
}
( @" V3 [9 o, R) w, t$ L4 S4 M8 j9 j: `7 J/ y$ w; Z# W
module_init(led_platform_init);, R- z2 X) v1 a3 @
module_exit(led_platform_exit);
6 i! j% @* B6 z5 O h- u* c' X0 U$ F$ v' ]; H& y* P7 e3 h6 G
MODULE_DESCRIPTION("Led platform driver");
7 s5 K0 i: b+ [& I P- cMODULE_AUTHOR("Tronlong");
) N8 }* x8 _: \- k- oMODULE_LICENSE("GPL");
- ?# s4 J- s8 Y W- x
$ ^* n. Z( o. V* P& X# W |
|