|
求大神给下面的程序做注解,请稍详细些,谢谢。/ N8 M/ Q& X+ R: t/ V) m; N
#include <linux/init.h>
6 ^# H9 ^5 N- V0 ]4 g#include <linux/module.h>
% K& L/ ^' r5 P: A#include <linux/kernel.h>1 d( K* T8 _! B0 w+ h9 x
#include <linux/types.h>4 e% N2 u9 I0 p9 Y. U
#include <linux/gpio.h>. G" ~4 C4 r/ J5 }, O( r
#include <linux/leds.h>2 W- ]& y( U# S* h9 t/ G7 v- Y) B
#include <linux/platform_device.h>4 ~9 x3 q8 [; K( k- q
" f4 L& ^$ i" y/ m0 n9 c
#include <asm/mach-types.h>( }) {+ i- r1 |0 D
#include <asm/mach/arch.h>
z3 d6 x7 z% T#include <mach/da8xx.h>
; j% ~& G4 h6 O% O3 ?8 k#include <mach/mux.h>. F! ^3 G f" _8 v5 Z! G' |
; z% u& ?% H' Z0 Q1 D0 T
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! f9 C7 P( x$ _1 c& [#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 q' k7 {& R- g: p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" k2 G3 k0 V O3 t5 _# f2 |#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 r/ z1 U, y% b5 `" L0 c9 k4 Y
! V: ]4 H- {9 v
/* assign the tl som board LED-GPIOs*/
* T; ~2 {" Q- J0 [* b, Vstatic const short da850_evm_tl_user_led_pins[] = {
9 p& ]0 E3 e- V" a. ]+ O/ z /* These pins are definition at <mach/mux.h> file */
, ]: s: K' c9 r& ?0 A1 g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* L3 C: P/ D+ k, k, p -13 m6 x$ Q$ l. s
};. O* l7 v5 B3 T- U# h
; Y' [: T- B5 L7 x! Rstatic struct gpio_led da850_evm_tl_leds[] = {6 W( u3 X* u4 I7 V: Z- ^
{! }$ |2 c, F# k& v& \8 K' K
.active_low = 0,
& ] G- [* r* `- }8 x7 n .gpio = DA850_USER_LED0,' |2 @6 j2 K* _- i
.name = "user_led0",
2 x/ K+ K/ D' H* i0 w; I1 Y% J .default_trigger = "default-on"," c1 t8 N* b! j# b2 f: M$ v
},% h. s# j4 }$ @% Q9 s6 Q
{6 Q: w$ e' D3 m( L/ a" w- ]
.active_low = 0, Y1 |9 }" W0 x+ T' N
.gpio = DA850_USER_LED1,
/ j8 P2 z. ?2 M. q .name = "user_led1",* g1 x: c- X0 [
.default_trigger = "default-on",3 M0 u, z5 Z% I9 v6 X
}, n) y8 b! j; I
{4 ^2 A% M0 Z8 I& L2 @# m. G" C
.active_low = 0,$ i, N( ~% F5 U3 f) p. d
.gpio = DA850_USER_LED2,
4 S$ X( r9 J, h: d: {8 q/ k& z2 G% T .name = "user_led2",6 D5 }7 G* P4 }. U" k( L( F
.default_trigger = "default-on",+ n! W1 X9 W' H
},: e$ h$ r8 T/ O: r1 M1 q9 m
{
2 B3 [7 \, F& c2 o' A) U8 v$ A .active_low = 0,
! o: u# f4 l i( R+ D .gpio = DA850_USER_LED3,
- t' N/ G" N: j& @* f9 Z0 r .name = "user_led3",; W9 r. f/ m, I# D3 d! I
.default_trigger = "default-on",
1 s# ~! G/ j+ K- D6 E },
* s1 b/ {1 s3 b% O8 G% o};0 w* q6 L7 S# V! g1 m
0 f9 `9 R, i8 k ~7 N* B6 K6 S ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 K8 N0 z* V, L' {
.leds = da850_evm_tl_leds,
$ j# G) E# w/ T' G .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- _: D5 ]. H5 a- {6 S. s};
- j% ^/ x" |% ?1 E) \4 A+ Q
0 F0 J7 f7 [% Astatic void led_dev_release(struct device *dev)
; s/ Y/ U- n# G5 ]{9 R. Z- J- N( t+ [2 z) b& B
};
/ a" @" K4 Z. X; h: q2 d) J
( [: v, E, w8 ~' S) n; x" Kstatic struct platform_device da850_evm_tl_leds_device = {8 Z- o. I0 N r2 b8 F' O
.name = "leds-gpio",
2 I8 j7 Y& X' |! B1 H; z% A .id = 1,0 m7 C9 \# O0 Y, f5 z
.dev = {3 O5 g9 Z7 s0 P
.platform_data = &da850_evm_tl_leds_pdata,# u. w6 U/ C6 V5 o5 Z
.release = led_dev_release,* W# c0 A( x$ n( |5 J
}% N! L- Q5 V, E) M8 [
};
8 n9 z+ v* G' Y2 c" E
7 L6 a* A2 Z7 S3 p: ?0 nstatic int __init led_platform_init(void)
5 a& G1 y) W( r$ n$ e) T# Z{
0 _1 P7 f1 Z4 X4 }- b2 R2 C. a! d' a int ret;3 B- k% S; g V% b3 d$ y! h
#if 0: S) ~! r# Q* R; s$ C F# @* L) y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ T) Q# i1 O8 X- I
if (ret)2 O! X1 u; a( L5 f5 Z. ~9 ~( Y6 H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# u7 `! }# L# J6 P6 k2 n
"%d\n", ret);5 o9 b2 C9 Z- M0 O2 ~
#endif
9 p& ~& B; D( E% \ e ret = platform_device_register(&da850_evm_tl_leds_device);
1 ^& q2 q: ^: F& d1 N2 P* ?( O if (ret)5 K. j! |2 r' ~7 d; \; J
pr_warning("Could not register som GPIO expander LEDS");% j! J5 W0 Q& S9 n
else- j: c1 _8 ]1 O% K- D5 [3 P
printk(KERN_INFO "LED register sucessful!\n");
: Y& @4 Q& t6 A Z$ R6 M* h. P% C6 e
return ret;: v5 L/ k. O( A3 Z& t6 M4 I
}2 M" G R( Z, h/ N
/ B9 B; K0 s8 P5 m+ V
static void __exit led_platform_exit(void) F- }9 J' ? I2 g* u
{
, g! L: W0 p+ L# }2 p platform_device_unregister(&da850_evm_tl_leds_device);
, x: e, J) T6 X: v* T9 f) f5 s7 ]4 ?: P# a6 K, j* q
printk(KERN_INFO "LED unregister!\n");
1 H4 e1 ]( s2 t( ?}" p$ g0 r0 ]5 A5 Z1 L) u
( m) f2 [ d( |' a! y& i/ H8 S1 @module_init(led_platform_init);6 j/ } o) {: V. f5 v+ U/ _& q
module_exit(led_platform_exit);8 L% Y# S, F! [! Y& Y( V& r
) L" l0 z& k! {4 v5 Y
MODULE_DESCRIPTION("Led platform driver");, z1 e S4 \* u3 @& q3 K; q, ~
MODULE_AUTHOR("Tronlong");8 P" x/ v/ U- [1 @* J! u; S9 k
MODULE_LICENSE("GPL");
# H, @; Q" e$ d5 f- C: h* f! Q9 k, `+ B: P* K- v6 O
|
|