|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* B! |( r+ J8 h9 `4 }#include <linux/init.h># w4 b. Z5 Q: b' J0 ]
#include <linux/module.h>
- _+ I& Q6 W7 @% y8 s1 `6 H#include <linux/kernel.h>' Y8 Z. Q* n1 [# t3 l+ p2 W6 c
#include <linux/types.h>) ~& a1 S! j _3 [: d0 H7 J! A
#include <linux/gpio.h>
( f. G7 v# [9 R) |; D$ L9 R#include <linux/leds.h>
: i4 w2 ^. S* w1 x#include <linux/platform_device.h>+ ?6 r# Y1 F* w! r, e( P6 C3 F
& V* H; W) d9 S5 S) m; {+ X5 }#include <asm/mach-types.h>- V G$ Y- q' v* q% m2 r
#include <asm/mach/arch.h>
: d: P. A6 Y4 ^# W7 s4 Q+ y#include <mach/da8xx.h>( R, I5 B! G2 E4 @. B( V) R! |% M
#include <mach/mux.h>
' N2 ]$ z2 V' t) m+ W! E: m ]0 h0 Y, S. L) P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& H1 o3 ~& ^: V$ x% b- X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ [/ Q1 Z6 P: ]& }$ N/ v
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ A' y7 Q1 n2 z9 U2 @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; e- ]" N5 s1 w! T. c8 ^) i& v, m* y5 R6 h: R( e1 R0 X% M
/* assign the tl som board LED-GPIOs*/
& j# [, B- C3 a$ k# d, U" Bstatic const short da850_evm_tl_user_led_pins[] = {" c l, D9 {0 f7 ^# Z2 c# a& A g
/* These pins are definition at <mach/mux.h> file */6 g. L9 ]/ V; v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# R* M5 f0 A# s/ K& [7 w
-1
, |" I( y( @0 t7 l3 @. w};
% N0 `. w. I, E/ L0 v% y' t5 d+ \6 m6 v6 M7 r$ Q9 u# [ L; y
static struct gpio_led da850_evm_tl_leds[] = {
) i% k9 E# j) |' j5 x {
# K3 q9 t, q' N$ j" x" ~9 h .active_low = 0,
( g5 X. a* o: n) S2 g: H, C .gpio = DA850_USER_LED0,
# X4 y) h# a: Q5 B, f. n .name = "user_led0",& ^8 a1 a: K; T4 \
.default_trigger = "default-on",& ]2 u: M9 v, K7 r) b+ J6 |2 b
},) T1 h9 A9 ~9 \. K F
{
' |9 b2 N4 j5 J/ e .active_low = 0,* f L$ |9 x1 A* ?
.gpio = DA850_USER_LED1,7 A0 A9 I8 D* g. @
.name = "user_led1",
2 }" b# q% ?, V. H .default_trigger = "default-on",
& Z( W* \& F; E) i$ h& d- M },
' k0 p! V4 O/ A3 G {- k# K; W- T# n2 [/ W
.active_low = 0,9 w; H( i% q& Y8 W7 }
.gpio = DA850_USER_LED2,
9 G* w& x1 e. l5 u6 Z' }+ P .name = "user_led2"," }2 Z" [& r- I" m+ `
.default_trigger = "default-on",
; w8 _% }& |/ i }," w) ^+ }- w. q0 h- C2 }
{
( Y5 ]- n! G9 n: W .active_low = 0,
( V& R2 o$ C+ S* p, _ .gpio = DA850_USER_LED3,
1 x4 ~: |7 \; }. [ .name = "user_led3",% `! p$ o/ T. b: \2 j1 u& G- e
.default_trigger = "default-on",
* f! n$ U% V1 i/ g },, j/ a% g( o0 }
};
# h7 a! j# G% K9 a+ X$ k! Q1 H+ R# ^; G4 @: G3 J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. X# y( f. P$ s3 S) J .leds = da850_evm_tl_leds,1 c. [- \" D3 S
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 |1 D, L3 P* Q$ u$ [- S};
7 j& P) Z" ^7 W, Z1 F4 U4 p9 H2 l% i5 ^( l/ G* b3 I( `- E1 |3 T8 F
static void led_dev_release(struct device *dev)
' |3 F# R7 `0 R' K9 A{1 S5 D6 Z0 p" s" C* r- a' i7 K
};& [+ w( B1 s0 O! N, n8 r, [
' C. J! l% a, ^# Tstatic struct platform_device da850_evm_tl_leds_device = { G% }! I! Z& a/ ?6 T1 A; w# W: r- p
.name = "leds-gpio",4 L A. j7 J8 U) \' ?7 E M
.id = 1,
8 z3 |4 s$ V. w# k- @; R) X .dev = {1 ]# Y3 |8 H$ T# z! K$ _' d b. Q) Q
.platform_data = &da850_evm_tl_leds_pdata,
$ i3 b0 V# A2 L- V: b7 B6 I .release = led_dev_release,( a$ w9 Z' F# O) _
}* M' c {9 a% ~: Z) C, ~1 F
};
7 ? `8 z! s) p! q
6 p" ~8 x Z% a. D4 c5 `static int __init led_platform_init(void)
& J E$ F9 m. u{4 O5 Z. o& C' l% P
int ret;
^/ s! K. G6 v5 h" _4 t0 X. |+ j#if 0
1 L/ \1 G& u; A# F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ V0 V' }5 ~1 l7 y& S3 W5 M
if (ret)
. T% I, X7 K/ ] pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% d. \3 Z3 q+ } "%d\n", ret);
1 T) \* J' _- T2 l% }! @#endif& {5 x K/ d$ w9 B
ret = platform_device_register(&da850_evm_tl_leds_device);* T( f+ `, p* n8 T) \
if (ret)
8 Q% |4 o. |8 O pr_warning("Could not register som GPIO expander LEDS");8 y$ [! m3 a5 W6 g* C ^- K8 s% G
else7 q1 w7 ?: ]0 Y
printk(KERN_INFO "LED register sucessful!\n");
9 E. Z3 t$ d% e/ ?/ V; c4 F1 h5 v: [( w# g
return ret;/ o# X6 Z8 C# [. w! ^
}
+ |& a' m" B, q& q) }; a
0 A' Y. Y/ H+ [: L8 cstatic void __exit led_platform_exit(void)$ S1 S' }/ z. q0 h# O4 Q# }
{
' x. I+ E0 ^9 _8 D# x0 h' z platform_device_unregister(&da850_evm_tl_leds_device);; S2 z+ R, i V, J' y, p
/ T2 X1 C; n5 O printk(KERN_INFO "LED unregister!\n");
/ s# u y/ D5 M5 j}3 V$ D. k' C" }% p
7 |! I! D* \4 ]( M8 \! {) Amodule_init(led_platform_init);
1 [" a6 z# v0 i: K9 ]! A7 tmodule_exit(led_platform_exit);% C3 r; Y6 s. N1 f5 Z% C+ P* z
, k$ T- A# D5 ?1 n
MODULE_DESCRIPTION("Led platform driver");1 R* d: ]/ \" K& a. c5 n) Y& ~
MODULE_AUTHOR("Tronlong");, e! _" {& T% {2 V3 f
MODULE_LICENSE("GPL");8 Z' d7 `( O) p
% K- l3 i; P. a
|
|