|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! b, s5 m' l* u& t# N P#include <linux/init.h>
* ~* {* ?: Q$ X0 `. }0 x0 ^#include <linux/module.h>1 {" {3 d+ R: @1 j" x; y8 n
#include <linux/kernel.h>3 @/ U9 H8 ]# ~6 q
#include <linux/types.h>6 G4 ^% X2 N& I8 q9 V1 s: p; O( s5 _! k
#include <linux/gpio.h>$ C; \9 F1 I: ]5 |: i
#include <linux/leds.h>
! g- |. V" i. K5 u& H#include <linux/platform_device.h>! m: E3 L# S" P7 y x) J5 E
/ o5 `( y- s+ Y, w
#include <asm/mach-types.h>
) b0 i# h3 i: D#include <asm/mach/arch.h>
L; J* u# i2 N- k8 ^' a1 v#include <mach/da8xx.h>
% J8 g3 c& a) j7 l1 j1 L, N#include <mach/mux.h>8 i( P, I. o5 v2 f1 B
7 Q6 f" U, f. c: C) n5 f# M5 u#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! }. t0 I# Q1 C, F$ u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. O8 i4 [0 E0 v- _. X1 `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ ]: _& N* f- a% c
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* z3 d4 P$ Q8 H
0 l' ^- i% f0 T
/* assign the tl som board LED-GPIOs*/$ }% E6 i1 U: f1 E4 J1 K
static const short da850_evm_tl_user_led_pins[] = {9 i6 Y) b6 i4 }6 Z3 t; ~& L; O7 c9 n
/* These pins are definition at <mach/mux.h> file */, o' ]9 w' X a2 Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 y% w/ Z$ b) R( F5 I6 c9 }& M -1
. D; w- T1 j/ i" e& m};
1 a, N6 Z: X+ Q2 @' t F7 L( v9 v* [' J' o: v/ L& W
static struct gpio_led da850_evm_tl_leds[] = {. t Q5 H! E2 ]/ Z1 S
{5 g) k5 c; a. {: P% Y0 H* i' k
.active_low = 0,5 U! v' Y! R+ r! l9 W- `5 t* L2 w! b
.gpio = DA850_USER_LED0,. S F+ |6 [6 h" r
.name = "user_led0",. C3 c/ n" @% d
.default_trigger = "default-on",
6 E$ ]' n Z$ q9 D0 K) X: N: g },8 w6 B( z$ V% R% T8 R
{
, N* R5 M: s8 R5 f, U* E .active_low = 0,! G2 F/ d; e4 q% l9 o+ A
.gpio = DA850_USER_LED1,
8 N/ \ q5 B3 I) u3 `, l; z# N .name = "user_led1",0 g& _9 |7 w* ?0 ^
.default_trigger = "default-on",
8 h) u( b, a9 V4 R" L( v },
) M1 S2 Z( `( l8 R. e5 | M$ o. t { W) U" p4 X" C9 s0 I- t9 L; S0 L
.active_low = 0,/ _$ \$ F$ M3 A9 _
.gpio = DA850_USER_LED2,
# G) U" A: F! K5 C3 { .name = "user_led2",! T( b/ u7 i; T b- p; G5 ^2 K
.default_trigger = "default-on",6 ~! D6 i* _% b
},; y( ~" V7 t" s9 S ~$ E
{; T" f0 O+ U& f
.active_low = 0,* J6 e' {( h- |
.gpio = DA850_USER_LED3,! N$ I. G$ d. {; ?
.name = "user_led3",$ \8 b* @ M3 A) v# q% g' B
.default_trigger = "default-on",4 j2 \ G1 S3 k0 V( B; A7 o
},1 [. i9 c* c% t7 Q4 a
};6 l( R2 r$ G" M. Z8 \# k, Q
1 e3 O) Y3 k; F" Z6 i" U X5 n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 U: r2 Q3 r- n2 h" `2 ]$ k
.leds = da850_evm_tl_leds,
" r6 d) `3 n$ F+ ] .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! K: ], p% }4 R; T
};; I% T8 c D& a5 O, X
/ C3 f# z: X5 X, b
static void led_dev_release(struct device *dev)
3 O: i1 \7 o! P1 q4 w{8 R% Q1 o6 x g* B/ i& R% Z; D! d
};7 B" O3 e( R$ X
' J( s% t. T# [static struct platform_device da850_evm_tl_leds_device = {
7 u/ |' o, j; I- Z .name = "leds-gpio",
: q/ M, a8 C; C8 s .id = 1,
0 T6 v. V8 O$ |3 F' `& ~6 g .dev = {9 u9 z7 A3 W+ W3 ~: N
.platform_data = &da850_evm_tl_leds_pdata,7 J4 S5 x! Y+ D# `$ u+ k* E5 o
.release = led_dev_release,
. h4 d9 o) Z2 M" m: p* A5 G }: E1 J- y! B0 m0 i; X# X) a0 H
};0 w: D9 g* c7 u, O
4 L$ E8 ^& p! O9 d& ?
static int __init led_platform_init(void)
- x& E- T9 s' [8 K$ C# N' H: F{
+ a! K; S; C" F' e8 i int ret;, C/ Q* {3 {5 \$ O
#if 0
# C3 e: K- r* ] ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) f" Q0 K* l, _/ Z' s$ v if (ret)
8 w8 |) T: }% U0 O pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 ]( j, y* Z7 m7 E! }5 v "%d\n", ret);: c. y; P6 ]: O& U- w. N" H: Z* W
#endif
6 N; @% w& t4 L+ ~ ret = platform_device_register(&da850_evm_tl_leds_device);9 _3 f) r, b3 w j
if (ret)
& H$ Z9 q/ O a pr_warning("Could not register som GPIO expander LEDS");# z# J- B# o7 f) U2 D
else2 l3 C2 y, R1 M& g6 }
printk(KERN_INFO "LED register sucessful!\n");& X9 K( C; C) q4 k% F! N, _
" x) n8 D3 o0 \8 N6 l) x5 o+ a& x: r
return ret;
) Y+ t) _8 g4 i! A' n2 X& Z7 a* K}; N+ M" U: `" g8 H& R$ x: }
+ q7 s O- o, r5 u) R
static void __exit led_platform_exit(void) Y& O6 c; ~6 o0 R5 K, X
{% f$ T2 |: W" T1 S+ d6 v
platform_device_unregister(&da850_evm_tl_leds_device);; a; T5 M) T/ x y% M9 |, N
1 K9 F+ L1 C* s, }" \, u+ u
printk(KERN_INFO "LED unregister!\n");( @; E& k; d" _6 i# b; N# H* J
}7 p* A) P- v& m8 ?. Q' k1 B
1 y: F% _' ]' o) ?. _4 `& A
module_init(led_platform_init);
m* l& T5 O" n: c) e* F5 y! qmodule_exit(led_platform_exit);+ I A7 F. e" r' p" V0 r
' p9 Z/ k' t& [/ ?- ?
MODULE_DESCRIPTION("Led platform driver");
9 g2 y) |* y: l; _9 S" iMODULE_AUTHOR("Tronlong");* T2 g2 u5 j) G) N( s
MODULE_LICENSE("GPL");
- l" s0 i* T5 h, H! i3 b# d! R" J: ~3 N+ `6 ^
|
|