|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 y# g( O' }2 w' e2 z& N4 r5 E#include <linux/init.h>
N+ `. G6 v( V& a* b) U! x+ Q#include <linux/module.h>' k" O, ] t( N
#include <linux/kernel.h>
) [) B. C2 x" c! Q; N$ p- ]#include <linux/types.h>3 c* O0 |; e$ V* l( j W* K$ e2 z, J
#include <linux/gpio.h>
' c( B# \% f) s ~$ r* j" T i! \#include <linux/leds.h>
7 Z" e# t& A* l' h( f" n#include <linux/platform_device.h>
! c1 ^& ^! |/ [* f/ Y; y8 [* w0 s# n. J. N1 U: c' x
#include <asm/mach-types.h>
& y1 a) d, g6 W7 H7 k+ ?, Q \, R#include <asm/mach/arch.h>
2 E3 H2 m, |7 X+ N, D) S3 R#include <mach/da8xx.h>
6 e3 h6 F9 P5 N0 Z: q R. E' w, l#include <mach/mux.h>
( {4 N! n9 m& g$ C+ x4 Y2 [2 n" y. h6 ~
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 X f3 r1 [" y& Y* M- U
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ J. D* d6 ^9 [5 z/ u
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ r* d5 R+ W5 C/ D1 N- b1 O! g- F
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* h( ^& e+ N k/ }$ E
- e1 ^* V) a4 E" s% k" m+ d; G5 D' B7 F/* assign the tl som board LED-GPIOs*/, x4 X$ o/ G6 f; e( U7 [
static const short da850_evm_tl_user_led_pins[] = {
$ q# H: t# C3 B: ]+ h5 o I /* These pins are definition at <mach/mux.h> file */ g, o# G+ k6 l+ @3 s9 V7 s
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ F7 ~. z: K2 ~ x6 \ -1
6 o" K% z( `6 W7 S% o};
$ K; U" K; r8 e! L
4 \" p3 g* n1 ]- q7 }2 Z& nstatic struct gpio_led da850_evm_tl_leds[] = {
( S( |$ t6 R' v, V/ S2 i( V {
- k, I% r$ x! s5 g/ C .active_low = 0,% N3 \& p* F' D8 \0 D4 K. M
.gpio = DA850_USER_LED0,
' y8 v# r3 U. K; d8 k .name = "user_led0",. J: }* c1 v2 e$ l
.default_trigger = "default-on",
2 Q# X8 w5 u X' X; O },2 e) v5 E" p( ^9 }% E: I5 C
{
* P2 I; x0 E* Y9 Z" ~0 x/ p .active_low = 0,) N' f0 H6 }7 p1 _2 |6 Z5 z8 x& z
.gpio = DA850_USER_LED1,) Z% I' s9 e3 W) l# g; Y$ ]# n- d8 o
.name = "user_led1",7 D3 ~0 R* L) h% L, q! `
.default_trigger = "default-on",+ \2 H5 ?- a( p3 L U; w
},
; K- ^# V, r: [6 V/ J w0 G2 i {
. ]% R, R. ]5 Y5 V( V" B .active_low = 0,8 r* v( A5 d, e) z: x
.gpio = DA850_USER_LED2,% W. V1 y7 `( _
.name = "user_led2",3 C1 @! W/ F( ]8 D; `2 A
.default_trigger = "default-on",7 \; @- z! t# ?; }5 m V8 ?4 ?+ W
},6 N L5 Z2 i3 O1 h v
{/ y9 @1 O; j" F$ d
.active_low = 0,
) }4 o$ s' u6 k( v0 o. S3 t .gpio = DA850_USER_LED3,8 x, q- _( X" q2 l8 m
.name = "user_led3",
: g0 w+ z4 @/ f( r! r' Y3 M .default_trigger = "default-on",
& B, L) {! M2 d% k8 ~ },( A. R% b, d' n# Y
};
& W8 { P4 Y2 m" {
1 g. F7 l( i9 f3 m- ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 g7 H3 K5 m; z5 @! y& [% [1 }7 ]
.leds = da850_evm_tl_leds,
& |: I! y7 e0 E .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* h/ b9 p( \" X8 V; {- A1 e};
( D7 P0 c3 i$ t* s
# V8 G0 ~0 F- u7 Q3 D# m+ g+ Dstatic void led_dev_release(struct device *dev)) \. U+ t i P: n. a
{ N2 _( }! D( ~% u5 O! I, w2 I
};
: T6 \6 N7 j2 l9 o* m0 j1 R# D
9 h" B8 Q* g& c! Z" vstatic struct platform_device da850_evm_tl_leds_device = {
& Q& Z6 J% P, p* I W9 r5 @0 M2 r. x .name = "leds-gpio",( \" T: C6 x4 g* j
.id = 1,+ u/ |3 J: D8 g$ E6 p7 Q5 v
.dev = {& U& X0 t t; g2 Q) j
.platform_data = &da850_evm_tl_leds_pdata,2 J5 o6 S# u0 n# Q6 U! I7 a
.release = led_dev_release,
" V$ C; U: v5 R1 ^+ y# m: W9 F* V }
$ t- I2 [6 q% o- e: T- f};
) F4 R: c9 E4 q L; p0 ?
0 B: J8 w. k% F; k8 t) Jstatic int __init led_platform_init(void)
8 ]% j4 D) b/ S% g+ v{
9 d4 ?$ G6 n" |, u8 \3 \ int ret;
6 ~% p, g! q( j4 c G7 k9 Y% W#if 0
8 r+ r# f0 d: M! ~ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% z: ~0 z5 V! n# F3 n if (ret)
3 k5 H- ]6 N) X4 E5 l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) f+ _ o: A0 m4 N6 s "%d\n", ret);
! w; N6 r' b9 V) a#endif
& s4 }% b# l- T( L ret = platform_device_register(&da850_evm_tl_leds_device);
$ O1 ]- [: Q& o if (ret)! o& l' H. X6 m) o2 y% ^) H+ j) u
pr_warning("Could not register som GPIO expander LEDS");
y/ B3 `! [8 z6 Z7 R! m3 } else0 B+ M/ F" ^6 B9 ]7 X& e
printk(KERN_INFO "LED register sucessful!\n");. B( N" U1 W# ~+ [
5 X4 o% `. @5 B- p+ j return ret;
0 i" [/ v, m7 i5 f, m9 m3 N6 y" u}" v' H4 L. ]: s/ T( q' U6 ]
' j- X6 j4 W" b7 j2 w5 rstatic void __exit led_platform_exit(void)/ r6 A! B. K- Z- `1 v
{- q4 |+ w$ L7 D0 ?6 M. D# z% x
platform_device_unregister(&da850_evm_tl_leds_device);
. u7 ^# F' c" H0 ?5 O" k# \: e8 i1 h) g" a* |6 f3 s
printk(KERN_INFO "LED unregister!\n");
2 t1 s+ ?2 ]& W6 [) n$ p}! o% o# M' C3 L- W+ k5 U2 _
- Q) d {7 K& h3 k' Xmodule_init(led_platform_init);
6 ~: @7 l; Q0 }; H( c- a' ]3 tmodule_exit(led_platform_exit);$ Q8 H) V1 U' k* N1 F0 {3 a" j
& _7 A$ A& ` q; J7 H
MODULE_DESCRIPTION("Led platform driver");7 k: i+ g/ `/ {% o l8 u
MODULE_AUTHOR("Tronlong");
% _- y6 ^% g' c" z; x8 gMODULE_LICENSE("GPL");4 e$ L( |1 b& b1 d% H+ |# J5 X8 w R
/ } Q; `2 E3 O; C- s F T
|
|