|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 y% V% X* L- {$ ^0 @, b0 i
#include <linux/init.h>) x1 o* G5 p1 U- q
#include <linux/module.h>+ x' J$ N( ^/ A: Q& N
#include <linux/kernel.h>; x0 `) f4 Z5 K' `3 |; \* Q% L5 r
#include <linux/types.h>
" Y. N9 j. [$ g( C T5 h- u#include <linux/gpio.h>0 b& |3 V) c6 j* s9 Z
#include <linux/leds.h>! D$ x1 Q9 e \) B
#include <linux/platform_device.h>
, H8 X+ l$ C0 y0 l( ?* W% Y: z. F; x/ `
#include <asm/mach-types.h>; o0 C9 |$ K `$ O; |& \8 M
#include <asm/mach/arch.h>3 v; L4 `6 \% P& s! J5 Y9 y- G$ _6 e
#include <mach/da8xx.h>
7 ]) s- u( p: x5 ]9 F! a#include <mach/mux.h>
/ ~/ \+ o% y& P$ g& R0 r7 Z4 E& b1 b1 f
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); `9 O( L" ]* x$ a6 X- B+ o* V* `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& o' o( A6 D0 s e! H1 O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- b! t4 b! @+ f$ r
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 S0 o( y" z! K0 y7 p0 w
# ^; k {' m1 j: U7 m3 C/* assign the tl som board LED-GPIOs*/ P0 o/ U* _3 }1 m
static const short da850_evm_tl_user_led_pins[] = {
! L( }& O# ]( u r /* These pins are definition at <mach/mux.h> file */, Q6 g9 p% t" u9 |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 G! F8 Y5 C3 J: m, I2 [
-1. ?' q* B0 G; }* t+ K
};
# u1 [! `* J7 ?# v' C) k7 t% ~# r* v. d6 y
9 V% X. N+ e" }' F. R8 sstatic struct gpio_led da850_evm_tl_leds[] = {
! j. m# I0 k- Y( ] {* _- z8 S3 I+ k, e" Z
.active_low = 0,$ R% E' m/ ~; Y a4 i0 P
.gpio = DA850_USER_LED0,
- @$ z; U/ W" @; D. q .name = "user_led0",
, R' U$ y, [. L0 e$ p$ {9 i .default_trigger = "default-on",
2 N- x/ W; ?3 m* E k6 u' t },7 P) Q8 U/ R! i1 ~, d. E
{$ w" h$ f4 C: _- @0 T. @, \4 I$ p
.active_low = 0,
* S( I7 M/ W( P .gpio = DA850_USER_LED1,5 `, }* j8 x5 a- J) p
.name = "user_led1",' s, h: ^ B" T+ t
.default_trigger = "default-on",
( g; B2 p/ b: v, }+ `; l: ~3 N },+ _- r) `5 h5 Q- F# r
{4 c5 M- l" U) Y% O* g7 X3 J
.active_low = 0,
L) \: ]) Z. g, i) `7 Z M& x .gpio = DA850_USER_LED2,/ v+ U# G$ @) R0 G5 @. O1 }
.name = "user_led2",0 y3 z+ ~* e5 D( h. Y
.default_trigger = "default-on",
9 e J w5 F# q2 M! f },
7 [, @' p. v! X4 c% { {8 |+ f6 P% j4 Z1 |4 ~2 q" R. M. y
.active_low = 0,
! T- l0 o# }+ V! f% F .gpio = DA850_USER_LED3,% f8 c! c0 d V! F8 ~2 e/ q @
.name = "user_led3",- y7 H7 G) r" a+ P7 Z
.default_trigger = "default-on",
4 y7 y% i" F7 k! c8 l; d+ M },3 ~* b" h2 N) m' ]; {
};9 j+ k, [9 C4 m/ Z
" s. ^7 d5 }; K7 V2 @3 y; n$ \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' B$ ~) b) U- i" a
.leds = da850_evm_tl_leds,7 }# f0 n A; G) P" h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' A% I. m1 A0 s% ^; f- Z5 p3 \' D};8 X6 @* a0 C/ o5 z) s5 q* G
6 q. I' n. _5 z7 ~
static void led_dev_release(struct device *dev)
' Z$ s* e$ k$ ~/ X0 F' T% \8 n{# ^( [6 y7 a+ A7 E
};
; U1 E5 Y) s) ]' Z* X- R
2 f( W9 b4 p# E/ ostatic struct platform_device da850_evm_tl_leds_device = {" _; s- l0 V) l# i1 h
.name = "leds-gpio",( J2 y- B, g& h
.id = 1,& ^; m1 z& C% W6 ?; T( r4 e
.dev = {
, q0 ]& A/ _9 b! S" [* j' V* ^ .platform_data = &da850_evm_tl_leds_pdata,
# T' _' J% i9 Y .release = led_dev_release, F' I( L% I, X# }5 U2 P; N
}
3 u/ c8 d0 m |, H. V0 G};/ Y+ V& I# e/ Z9 v% ]$ o {
8 m! H+ N; t+ W! [; l7 K5 q
static int __init led_platform_init(void)
5 H. }$ `$ h" Z% f% c{
; t7 [, L2 a' `! @6 u int ret;4 i ]7 e, O" c$ {" k$ q3 Q
#if 0
" F5 I) J, v' F2 [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 |. n7 u$ G) R1 u; e" y; k
if (ret)
$ O) D0 j3 i, `; r( t' G0 ] pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ \# l& y- l3 B* Q+ u) H) `
"%d\n", ret);
8 r' Q; k" I+ g* ^ t0 S- K% l, w9 p#endif4 \& E, L# P+ H# c; p2 y7 b
ret = platform_device_register(&da850_evm_tl_leds_device);
# H4 J; ^3 \" b% {( r! | if (ret)
; k& D, C6 {+ K! ]8 a, z pr_warning("Could not register som GPIO expander LEDS");' N5 A/ w7 @- R4 r& z( {
else& O9 M) x1 }+ U8 P0 j% @& R! G
printk(KERN_INFO "LED register sucessful!\n");, k* a; F. u# z0 ?0 [7 }
' R" Q+ H+ X9 f1 K3 m
return ret;
4 |/ w6 p' X* P0 k- @2 U4 d}0 [8 V/ T `7 O, P* C& g( N
! _+ c9 O6 i \& Dstatic void __exit led_platform_exit(void). b: w* Y0 |% E% a
{
" y( |/ P4 I5 Q5 w3 f# v platform_device_unregister(&da850_evm_tl_leds_device);
, O& G: a) s! U+ C3 h) T0 ~' L
$ ~% C2 ^3 N t* Q$ D( J8 H d printk(KERN_INFO "LED unregister!\n");
! ]; J, ^! i) _: E0 S7 k9 O+ Q}
/ u0 g& s- E8 H" ` g/ U/ N" M
6 M' o8 j( N0 O3 |module_init(led_platform_init);
- X- d; _4 K. c4 J- `module_exit(led_platform_exit);
4 f* H) v! l, e$ A% N& H# |4 h
4 J/ [; m3 ]* n! w% ~/ L. WMODULE_DESCRIPTION("Led platform driver");
7 W5 ? [* e" dMODULE_AUTHOR("Tronlong");
. B' D2 K$ G" x; @; L7 f6 b' |MODULE_LICENSE("GPL");% H, t! F* \7 h9 \% x4 x
( z! K0 d& W- Q( w! s6 N
|
|