|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( E( _5 q2 l) w' j
#include <linux/init.h>3 x. A# o" Q0 n9 \
#include <linux/module.h>
- [3 w, [' L9 l/ p% m! ~- } k#include <linux/kernel.h>' z( K7 N7 d& G3 i; I
#include <linux/types.h>
& t, |+ t/ ?4 b. R: B2 x! F4 d0 `#include <linux/gpio.h>& o3 @& P: t4 R5 B. h
#include <linux/leds.h>2 I- d& X+ ]0 [
#include <linux/platform_device.h>
" R; A( d! P5 ?8 \2 y0 U- e/ C& M% [- V% {5 j
#include <asm/mach-types.h>( N4 \0 z+ z1 h: M3 w, x' }$ g
#include <asm/mach/arch.h>7 x: u/ U7 l+ p2 f
#include <mach/da8xx.h>
. ^1 s, Y; `- t9 Y# d; P( j6 I$ H0 Z: c#include <mach/mux.h>
' I% K$ |. f8 j* x2 R( D# V+ }+ I6 |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( V1 K5 E, B) Z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; |( ?2 _8 j. K+ J n+ z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: Y$ R) _- m8 i+ Z4 @, z7 _9 v#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 H7 ~/ e5 {* i2 z# V' s- z8 c- ~1 n- j' B8 Z0 B
/* assign the tl som board LED-GPIOs*/
0 K, T, X. r8 N2 F3 kstatic const short da850_evm_tl_user_led_pins[] = {
- C0 H$ V. Q/ {5 `. E" U /* These pins are definition at <mach/mux.h> file */9 b) W, U$ H6 ^9 F% _: L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ ~" ]% H. @% x; t
-1
8 U/ x: ], p' \9 _};" ?& N2 s; @: l6 p" W) [- X$ m7 j2 F+ C
! S& ~2 V X, J0 A2 W
static struct gpio_led da850_evm_tl_leds[] = {
. C( _0 x0 j) J' p, U! W; h2 ` {" F9 h# Y2 u4 d" I$ W2 B
.active_low = 0,- D) G8 E$ ~- j+ Q7 x! i
.gpio = DA850_USER_LED0,
5 g5 L; Z8 j4 N7 B% ^6 F .name = "user_led0",
" x/ q2 P9 l" y5 r5 c9 w4 F* I .default_trigger = "default-on",
# N' y W) {3 @! w1 Q* R$ X },
8 ~) Q6 \& b" w# X/ P0 g0 ^- a {. I/ ~" ~' j$ j* p% W
.active_low = 0,
7 f p' h7 e" J6 k% ?1 _% q .gpio = DA850_USER_LED1,
* y9 y( Q& k5 [ .name = "user_led1",
: N0 V& ]7 `# E7 m+ } .default_trigger = "default-on",
' Z2 D/ o$ r6 u) ^5 g },' I0 z( ~1 \& }( m( [9 Z
{
8 Q5 O$ ~7 F( X3 O1 v9 ?' q .active_low = 0,
) I1 L* z% y6 v% G5 _ .gpio = DA850_USER_LED2,2 D/ _8 n9 t) e
.name = "user_led2",
7 A. [. D- G+ f; o/ p7 i .default_trigger = "default-on",
1 e8 ^* O3 r, J% D- P, w },
0 Z: b9 E z8 ~' ^& r' j# N {
, Z3 k' V$ b: R1 b( O/ X .active_low = 0,: J5 M5 ?$ V4 c1 J3 X2 U* r K
.gpio = DA850_USER_LED3,2 r3 C) N, V# ?. q
.name = "user_led3",3 C* ~3 r; y, K2 B' o
.default_trigger = "default-on",0 Z, l Y# w( Y; ]5 o
},
0 A6 m% q" X @9 X& J};
1 w$ E [- f. ~( O& q; H
% U% H0 c1 \% q7 Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ o( Q4 I+ N4 }
.leds = da850_evm_tl_leds,7 ]: s# s6 {( U5 s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds), z' D7 {+ \# l0 a0 }: J3 G
};
# ~" u1 s/ R! l4 B$ ?/ A% Q3 s m, y. D! j) T/ p
static void led_dev_release(struct device *dev)& e& [ b4 m0 _+ |
{) q# G9 I1 S7 F
};1 \9 f; {6 t5 l9 Q8 ~
! X) j4 Q- w0 _; d }4 P x4 kstatic struct platform_device da850_evm_tl_leds_device = {
l$ R" h" ]: X% m' \ .name = "leds-gpio",( _8 i) S) R' S% b' S, A+ B! y
.id = 1,
: `8 N; D8 z& G% W' P .dev = {
3 z6 J3 @6 y% J' A& d- f .platform_data = &da850_evm_tl_leds_pdata,, V* c1 z# q5 P+ Y1 i6 E
.release = led_dev_release,
5 k6 \8 |2 j4 b2 Z }' B% g. U/ n$ F5 \
};
% l. ~, S0 O, ?; u
8 u% R# `9 _; m J A6 gstatic int __init led_platform_init(void)
# m" m: s3 d2 \& g0 C{$ W! u M( b, ]8 J0 I3 H
int ret;8 B% Z2 J& j: {" [8 C) q) F+ [& N
#if 0% f4 F1 j+ {# A u& O! ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 N5 E8 G0 M; A
if (ret)
( f% D3 y: d0 w9 J pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ i2 }) v5 F+ B. h7 b: I7 z/ } "%d\n", ret);3 x3 [) @' l5 G/ {0 s' m
#endif
0 s/ c( I: X4 S" u$ L9 b: l ret = platform_device_register(&da850_evm_tl_leds_device);
3 N( b' e! C. p' i: n if (ret)/ P- u2 c* U% ^4 w1 B0 i' X
pr_warning("Could not register som GPIO expander LEDS");+ v% E: d# F, F5 ^5 \5 e1 h [7 ]
else
" G) E0 O, c! b9 z% p printk(KERN_INFO "LED register sucessful!\n");
9 \/ b. u2 }; t, e7 H8 x: ^1 N; a7 T2 s9 Z" F
return ret;
; a/ o2 A* m5 P! r* m1 f4 v}
7 b/ `' x* a( _2 v; ]$ w( m* v. w O: b3 S$ l
static void __exit led_platform_exit(void)
+ d' F: l4 p2 _# y. H v{& L$ r( |$ B0 H2 a# p
platform_device_unregister(&da850_evm_tl_leds_device);
& Z& M K* l. W- {+ k( o/ U; q/ Q% C$ _
printk(KERN_INFO "LED unregister!\n");
3 w, z8 g" }' A; m( M& X, n1 ?4 }}+ Z7 k( J: p0 }2 M" B7 b9 ]
3 C* f3 `0 t. Q9 x( _2 B; rmodule_init(led_platform_init);' ]" _6 l! ]! Y3 n
module_exit(led_platform_exit);5 W' r: h6 Q+ [0 L$ k d9 a" G
" a; e! j) a2 y* rMODULE_DESCRIPTION("Led platform driver");/ g. h* R8 l4 {6 B2 X
MODULE_AUTHOR("Tronlong");
e# t- ^# O& H+ u0 S( UMODULE_LICENSE("GPL");4 k% C1 g. i9 M# l, m! ?
# P( ?0 F l0 Y; t; i
|
|