|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 d. p- U* P7 b& Q& ~& W- f4 k#include <linux/init.h>
" O6 N& R% S) @8 b9 ^#include <linux/module.h>
/ p, z# g9 Y0 I. K9 C#include <linux/kernel.h>
1 n6 E1 j! [" H& u#include <linux/types.h>
, L6 n9 ~- |% j% k#include <linux/gpio.h>
5 `2 Z( L: p! g. L7 t! s+ O D#include <linux/leds.h>
; O( `" ~5 g( a% X$ P3 ]#include <linux/platform_device.h>8 Q1 O4 q$ z7 A; J6 h% B% S" B
' e; f( b% {% ^8 l#include <asm/mach-types.h># f' f' ?$ _4 w
#include <asm/mach/arch.h>
0 b8 f' v: s5 P3 K4 ?0 B. a* ~/ [#include <mach/da8xx.h>
7 W7 [! f! b* [- @3 p' c#include <mach/mux.h>/ d7 Q4 \, _) }% n7 m9 Q0 |
& l- x6 }9 a5 Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 x H2 U& d/ w3 r+ o1 e2 S/ s#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 y" `0 _3 [# U1 W# h/ x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* F- t" f; q: F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 l) L% W+ \# B+ Q/ I; ^4 ` |/ I9 c [
/* assign the tl som board LED-GPIOs*/
) ]3 `, l# _: S: i. _static const short da850_evm_tl_user_led_pins[] = {2 [$ o7 A2 p+ x
/* These pins are definition at <mach/mux.h> file */5 i: t4 _6 {; y9 ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" _2 B3 X: w' u7 { -1
M# L3 \/ F; s0 a};* z& N/ M; N6 S, F
+ t5 C6 J! E0 y& m, Q3 s6 o# Ustatic struct gpio_led da850_evm_tl_leds[] = {
! _* @7 j% c* u, W4 Y, B {$ C4 K5 J- Q. I; s) H
.active_low = 0," S1 V1 g7 t! t* O$ C
.gpio = DA850_USER_LED0,2 | m9 ~. a& a- X! A" f! G& I
.name = "user_led0",
( v5 I8 @$ R# u' N .default_trigger = "default-on",
. O& b3 e0 t* H },/ T* F' L |8 A) A+ U/ u
{: |4 l* p- q! l5 E ~0 c
.active_low = 0,
5 r3 Q5 X# e, I .gpio = DA850_USER_LED1,
, `7 T, t' ~9 s$ n .name = "user_led1",
/ m/ f5 }8 ]# p$ L5 T3 `% J .default_trigger = "default-on",& z2 N5 Z. W$ l3 q! G/ f8 m G
},1 M6 n7 y1 V" u
{
, D6 h$ x1 c" }9 }% k: u .active_low = 0,
8 \- E+ D; L9 ]: \1 X& z .gpio = DA850_USER_LED2,4 W j) m6 q+ w+ J# R) K
.name = "user_led2",
# n- D; ]: [5 Y/ V4 p& B .default_trigger = "default-on",
+ C- w$ Q/ M8 u },2 r; ]! c- w$ v- m# _
{
# y( n6 ^/ F6 q$ D7 P .active_low = 0,3 Y9 K; J, Y, z- S+ D% c! \
.gpio = DA850_USER_LED3,
5 i3 G* Z9 C" C' g+ C .name = "user_led3",
6 c4 u% ?4 S& j0 M b4 G .default_trigger = "default-on",' @5 ^) C, u; ?( P: D
},
: R# E' D" V- l2 @4 C};/ a1 M8 j$ b+ q6 a) J
! i: y& o I$ s7 ]% Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) t$ i) G+ ~! E* b1 [
.leds = da850_evm_tl_leds,
7 f6 b8 q: Y* Z+ @- R$ D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. v( K1 Z& \3 W \) ~/ d};9 Z# [1 e" n% \" W" Y
' }. ^2 s3 l2 l! u: a+ @/ s5 ?static void led_dev_release(struct device *dev)
. S# I3 P5 x6 l- p q) W0 p{
y: V' P% U, V0 R* {};
& Q- i% r2 L" A, O7 N. ~* S) p ^* l' O1 Q% Z
static struct platform_device da850_evm_tl_leds_device = {
' R0 a% s P8 _! ~( n3 S .name = "leds-gpio",
0 D! Y f( l7 N0 u, H: T, h0 J .id = 1,9 Q6 [3 @0 J2 `- \- \
.dev = {
, `0 I* V2 S5 w' o( Y* q" C .platform_data = &da850_evm_tl_leds_pdata,4 p' D' w% {& t, s! R
.release = led_dev_release,
* X' E, q9 n! d- q! ^! N }3 t' W4 S4 @: }# J
};
3 t% R5 F; K# H% J& i* r4 u/ }- G) @! d4 C' O" e
static int __init led_platform_init(void)
0 _( u0 C2 h$ t& r. {$ a{1 d- G n4 E; l) x
int ret;5 ]/ J, p( Y, Z& }& L8 V
#if 0; k. D7 p: h0 s+ T" E# H+ i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: c/ s/ F) |/ b( u8 G if (ret)
8 q: w2 {( `, L3 O7 I2 Q; f pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' y3 G/ Y& q* k! _- A% E8 l" z
"%d\n", ret); L1 G* N, \# V# {4 i3 E& |
#endif
- `( h M: U ^* }5 D s# Y( m ret = platform_device_register(&da850_evm_tl_leds_device);4 o1 v8 v, R) a8 F" B5 S
if (ret)
/ d/ P4 I- u$ [1 C4 p4 Q5 ? pr_warning("Could not register som GPIO expander LEDS");
' Q- b( A, X# g* O1 @ else
i0 F+ O' w8 U6 c; d9 o/ I8 m printk(KERN_INFO "LED register sucessful!\n");
* r' z, d. r* W2 W$ R T2 R5 k5 E C' Q: ]8 p, x! T* }* w, q1 g
return ret;
2 {% O3 E& G" j}
. S" x' i; I) Q. \" x2 `% u7 R* d7 S( Y; T: I, H: s; j
static void __exit led_platform_exit(void)( b9 x9 R" W, D0 M
{
9 ~: q" l5 T' o9 X- b9 @) Y; W+ g+ H platform_device_unregister(&da850_evm_tl_leds_device);
) }! `9 }8 U) J; W3 O8 o% L' o s4 \+ ^/ S/ {0 Y% c# Z$ {- {) L+ j
printk(KERN_INFO "LED unregister!\n");+ d5 |% V, T* R: y9 A; [8 O b1 V
}
3 H" x& `) z N: g3 \
* K5 B( S }3 l7 Y4 q: Nmodule_init(led_platform_init);
& U( Y* |4 D% V) b6 J1 M n( Kmodule_exit(led_platform_exit);
3 U8 M% v5 Y- F
; D" w- m7 S% y7 ^, H2 Y+ gMODULE_DESCRIPTION("Led platform driver");
# D6 ` ?9 |( O. LMODULE_AUTHOR("Tronlong");
9 a) k+ \0 M/ A% x! @0 zMODULE_LICENSE("GPL");
' ` S& _: q* I# e0 @
! [' B. P: k" b Y0 X5 R7 \" T |
|