|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ D, m6 C3 Q6 i8 p5 z* e
#include <linux/init.h>) u" Z7 D( E+ \- e& A
#include <linux/module.h>1 B+ J6 @7 a/ C5 ^
#include <linux/kernel.h>* |3 l& E1 C5 K4 U* w% M3 X; d
#include <linux/types.h>
; p& a2 u& m4 Q#include <linux/gpio.h>
; x! E( ^4 @6 o$ {+ y1 l _#include <linux/leds.h>
' u x2 Q& N3 [. U5 e0 ^" s' j/ L#include <linux/platform_device.h>
/ r! S6 B! x$ z: C- p9 i* c$ l3 n" R+ Q$ ~1 @
#include <asm/mach-types.h>
; D; p$ l7 B3 @' i) f0 `#include <asm/mach/arch.h>: b$ F# l6 i% f7 a4 H4 \2 e
#include <mach/da8xx.h>1 z: G' M& ?5 R: a* {7 T( G
#include <mach/mux.h>; \" R3 y( [) J# _9 G/ U; ^" z% m
4 p: u; _5 N. z/ v# J#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 D& B/ e" ?0 w& Z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* t& ^6 E' `' w, c$ f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. O2 v3 g6 f9 d. I6 |1 n6 C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 Q* [! c9 `$ m; t: O
9 {8 X: z& q% p6 j3 ~0 b$ D& h5 s
/* assign the tl som board LED-GPIOs*/
* n& ~% c9 ]. f* O: cstatic const short da850_evm_tl_user_led_pins[] = {
7 _: N4 s# ~; K9 n- O /* These pins are definition at <mach/mux.h> file */
/ J' u4 j! y7 z# y# L; p0 g( y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," V- b% s, k# O/ H3 n" q5 K
-1
O+ ^2 T) l! ?* a2 P};" F1 k) Y1 X/ O) ^$ r/ u
" @7 E6 l: {, G+ C/ J/ r6 H5 Y
static struct gpio_led da850_evm_tl_leds[] = {
. j3 W/ I5 r/ p' u Z$ V* F {! E4 {, I& t, _% ^( ?. w9 S& z# o
.active_low = 0,
0 @1 S7 F* i i, S .gpio = DA850_USER_LED0,
3 f7 f; m( P1 i1 j( Y Z) J .name = "user_led0",& V0 C5 r8 C- ^8 |. J
.default_trigger = "default-on",. L' a4 x* ^/ s$ ^4 D# n
},
2 \- j& {: ^7 I+ f/ V; Z2 r {( G, Z3 y2 M2 [) N7 C8 b* \
.active_low = 0,! x. L( n1 R' ]) _1 C# I( K. U+ Y
.gpio = DA850_USER_LED1,
4 j; r6 B' U l1 n- G% q .name = "user_led1",4 H: [7 M' J: F
.default_trigger = "default-on",
" U3 z5 U# V3 g7 B o+ [' w8 K$ n! z },$ L/ C+ D+ i% E% o4 c {; y& T
{
. x$ @ Q4 C2 r .active_low = 0,. Z* O2 b! \9 T: C p5 U
.gpio = DA850_USER_LED2,4 C% f) c: I& O7 L- I
.name = "user_led2",
) y+ f( p8 f8 O7 }1 h: c' {, s .default_trigger = "default-on",
: G0 E4 n7 ?5 F2 T& k },
( N; \# U( y% k: l4 S. ~3 R6 w {
" A j1 K8 e" L* a! X7 W7 ]& y3 E3 r .active_low = 0,
) f1 o/ h4 D# Q" q* Q* U6 l/ n$ Y .gpio = DA850_USER_LED3,
6 G! n1 \% Z6 [. W" r/ ^. T .name = "user_led3",
4 p1 R6 e7 A# n: D .default_trigger = "default-on",
6 c& G# m( O2 c },0 h! L/ D: i& v/ C) @
};
9 r4 g4 d6 m e" ^
) x5 n+ U1 p: _2 t7 ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ g+ H7 m8 y4 w6 Z& C8 G, P .leds = da850_evm_tl_leds,4 x7 ?- f, B5 V, _ C9 x5 R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 |) t; M- K3 j. R7 t2 g
};
p c1 G( T$ O, k1 x7 L& S
7 W9 O- j3 G6 H7 ?( Jstatic void led_dev_release(struct device *dev)& b! G7 i" c1 \1 K. f; |7 m
{
6 F, ~7 `( Z& V};
- f q' C' e* i& b5 I8 R
1 q* c+ ^# T2 ~" E( L6 J- C. kstatic struct platform_device da850_evm_tl_leds_device = {
- S' j3 J1 ^" W( E+ ~6 H) m9 g .name = "leds-gpio",: O8 c! u. U' q9 e( e
.id = 1,
& s2 P& t) Y' y3 z .dev = {
, x+ V# A0 d8 G* v% {6 { .platform_data = &da850_evm_tl_leds_pdata,0 b2 e7 I& i1 K7 J
.release = led_dev_release,6 X8 J0 d- c0 L, A& `1 Q( A
}
* V" o/ w+ c5 ?5 R3 ]. E- T! p};4 b! g7 k& X$ O0 [6 h3 z& L
7 @5 ?9 f# r) e# o- N5 Wstatic int __init led_platform_init(void)
: H4 Q9 g( f4 v d8 J. w0 Q{
+ b: ?; Q8 R: } int ret;
' J+ a9 n8 ? h& Z% q" U#if 0* S( p2 [4 I9 o7 i7 I5 q* ?, M
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& `6 @' `- ]. ~7 o1 o" \6 g) x if (ret)7 I2 r4 V" d [% m1 C. U1 j3 ^9 Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& \* `4 |; O* V. W' k "%d\n", ret);4 ~. B! M$ n1 ?# u/ O; W C6 P
#endif( I3 E6 v3 i4 G Y( _& T
ret = platform_device_register(&da850_evm_tl_leds_device);" d( R% O3 C# W
if (ret)
% G; n9 r" A0 d7 q4 x pr_warning("Could not register som GPIO expander LEDS");( U+ y- a, V. `; p
else
1 ~: I7 K( S& h) z printk(KERN_INFO "LED register sucessful!\n");
+ N5 f, J* U. q% L, F: S! T
( m: T2 }& T+ `. S: @# e return ret;+ x+ ]* S0 x+ y" K
}
6 ?6 V, Y* x, f& O: Y3 Q2 f1 a' O7 _- v: i! Z
static void __exit led_platform_exit(void)3 ~+ [/ B# \0 R/ ~2 j) p% e
{# ^& S# Z; k& y' ?- t" ?
platform_device_unregister(&da850_evm_tl_leds_device);
: V5 @, Y% K; F! x. g0 ?8 _# J$ y8 A1 E ?2 m& }
printk(KERN_INFO "LED unregister!\n");
) I' J# e& M+ y m} ]5 m) \1 [' i5 S, R
( ?" G! v2 N8 ^) L' Amodule_init(led_platform_init);
: r. `% Y5 e- H6 V) V; jmodule_exit(led_platform_exit);+ @2 H: S# J& Q L
0 X8 O7 d3 Z% J" }$ o" S# Y/ T
MODULE_DESCRIPTION("Led platform driver");
4 I3 |$ u! Q4 {MODULE_AUTHOR("Tronlong");
5 O+ O( m! d* W4 C6 ?6 H' F FMODULE_LICENSE("GPL");
0 L ?: t- m& `+ g0 q5 d3 G7 S/ U" \
|
|