|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ b6 Q; T/ m5 } w9 C: r
#include <linux/init.h>, c; ]1 Y' {. o1 r
#include <linux/module.h>4 y8 m$ ]# F. ?* ]
#include <linux/kernel.h>) c2 M5 v# A# r6 w$ d# @
#include <linux/types.h>
; i# O' P a( I7 z* ~#include <linux/gpio.h>
! w) w* S0 S/ s' t" J/ `#include <linux/leds.h>
* X1 n- ?) _# \! X+ h#include <linux/platform_device.h>( F8 E1 a& C8 O" i7 V0 A& C
, g) _; P8 r N$ [' w1 d, [. c
#include <asm/mach-types.h>
$ L3 R( q; k- n h5 t0 l+ r7 k+ \#include <asm/mach/arch.h>+ j& I9 D1 c- i$ ^
#include <mach/da8xx.h>
+ M1 Z# a* x* [! Q#include <mach/mux.h># G! I$ w; H+ z+ l
1 q. B, M" S7 ^6 h, y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ s6 Y4 z& o4 W% w$ y7 m3 H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) ?( d& S$ }6 k2 S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), Y% Q& }8 y8 |8 e: C
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 r3 N: h; ]+ P7 R' ]" i
5 h+ o, @: ~- U7 S& M; a3 Q' {/* assign the tl som board LED-GPIOs*// [0 m- R1 B; X5 g+ B# U2 ~& l2 r# q
static const short da850_evm_tl_user_led_pins[] = {
- {" E) }0 V/ b+ M1 c /* These pins are definition at <mach/mux.h> file */+ S+ @% O7 T' U! m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" A' k' I a; y5 ? -1
, C$ b% f' t/ g" z3 D3 h0 }7 u& S};
9 P& p) F) d5 g: t8 @, R3 N5 _3 E: G/ t" ~
static struct gpio_led da850_evm_tl_leds[] = {
2 ]# f: c; K+ w' A5 d {
/ S4 B8 F u d L8 q1 M! C .active_low = 0,
- Y, ~ I I( A0 ], q" e .gpio = DA850_USER_LED0,
3 E/ C1 G5 [0 ?) B9 N' Q, F .name = "user_led0",
6 {8 y$ s* w( ]# C; b9 A O5 o .default_trigger = "default-on",! g% q( T( G( a# t
},
( j' ?3 d! a% f' j {
* g+ o$ X) |8 Y5 x! P; o3 Z .active_low = 0,
9 N1 I% L2 G) X8 [ .gpio = DA850_USER_LED1,' G1 }8 w ? E E1 ^
.name = "user_led1",
9 E( {. t6 N7 f8 f* D* ?2 b .default_trigger = "default-on",
2 A$ E/ E, t6 N% M },9 P: c; D% p& `+ j* D- |
{
: G9 d4 Z8 l% o: r% p+ N+ j6 ]% q) n .active_low = 0,
# W& w& n' m- l3 c! j .gpio = DA850_USER_LED2,
4 V0 Q% V/ k; }0 T8 @ .name = "user_led2",3 t$ ~, @$ x' m3 f v. K1 O* }
.default_trigger = "default-on",4 I. ?" J: V: y2 h- \$ j7 O
},
( d x4 E, N! H) i/ i. ^9 x {" H, c. f* I9 o4 H, i$ J4 x: `& J
.active_low = 0,
+ K. M R& \" d- [2 S% R9 n" m .gpio = DA850_USER_LED3,7 p: m/ J# `* W6 ~+ E. y
.name = "user_led3",5 o. H7 y6 n* m/ X6 q: I1 X" C: g
.default_trigger = "default-on",
( \% T, H* \; C0 H% N },
0 h+ z9 ~ O2 D) X};
! q- e0 x) Q! J- C9 ^4 M* k
5 G3 j" X3 _/ t9 h0 J* s ~6 Q; N4 [, mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% l; `9 o1 \0 o- J) I$ j
.leds = da850_evm_tl_leds,
/ ^/ h( B. s k .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# A1 E% @% ~: e& `};# t1 Z! a+ f' K. k* b- o5 X& T
6 A& m8 r* d. g { W/ ?static void led_dev_release(struct device *dev)& T2 P+ p t7 m# o0 M) r) @! e
{
; c4 c' e# W6 t# F) m p, w I" E};
! V, S7 L3 G/ v1 j- X
# W8 b7 t+ Y- v- E" ] istatic struct platform_device da850_evm_tl_leds_device = {4 _9 e" g2 y x. \9 U
.name = "leds-gpio",2 J% U/ P, u3 f9 L/ D: }
.id = 1,; L9 x- O. C: K' f! `/ J8 O
.dev = {/ p* ]1 z7 H8 Y" g& m. g. J$ i2 G
.platform_data = &da850_evm_tl_leds_pdata,
3 K4 v! w. _4 @* Z4 @ D+ G" b) G .release = led_dev_release,
! O- r. z* ^+ h4 U }
7 N/ Q- j: S7 P5 H/ J& O( w};
) [6 k' d7 D6 U" d8 x& W9 p
7 O. Q* {4 j* V7 F) Y* k6 wstatic int __init led_platform_init(void)" g' O- [3 y; z4 O5 A9 o1 s
{
" }2 h' ~* a. W int ret;
8 A8 X& E5 Q% ]7 o5 M2 U#if 0
7 w" Z3 p. n9 a Z9 |& X* x$ e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" u& H4 b+ _3 r! c4 E
if (ret)
3 H+ i' h+ z: t pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ L" [- e: n/ g7 e8 i! V- ^ "%d\n", ret);
2 c, P& z# l( p* [#endif
* i2 Z0 h* b7 L: D" T% c ret = platform_device_register(&da850_evm_tl_leds_device);" b. K# G3 \+ Z7 Q: p; |
if (ret)7 Y8 @5 G. M( x7 n
pr_warning("Could not register som GPIO expander LEDS");4 @3 U- E) N* K' B
else
: X% c' q# O- w8 c9 E printk(KERN_INFO "LED register sucessful!\n");' W- g5 X* S4 h2 Y. w
# } e5 Z h5 d8 w8 D
return ret;) u7 `: t4 O: q3 ^5 a
}8 t, J b' n7 Z' P# [! x
2 H$ J0 a: q/ tstatic void __exit led_platform_exit(void)2 T3 y, U; v8 A+ i& s$ u
{
5 Z# ?5 N. a/ k& q! g, R6 I platform_device_unregister(&da850_evm_tl_leds_device);
: E W8 L+ u8 V8 M" a+ y! r" H: Y% _ ?0 |% \
printk(KERN_INFO "LED unregister!\n");2 {3 n0 `; U- @/ [
}+ F" s& s4 f& V/ ~% g( v
- n6 V c! f. o4 p/ fmodule_init(led_platform_init);
% B9 H7 |2 D/ r5 t# h4 c- K. _; wmodule_exit(led_platform_exit);% f$ K4 q7 G3 R1 L. q1 a& B
+ f8 o# ?6 O! Y& M; e
MODULE_DESCRIPTION("Led platform driver");
% A/ |5 f# @5 B* \4 R' `MODULE_AUTHOR("Tronlong");* D% _5 M+ p/ f! x2 U
MODULE_LICENSE("GPL");0 i& o3 |. o: q4 s
: z" g: Z8 D7 Z5 e
|
|