|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 @/ G1 Q# u/ G* B9 e+ [- a#include <linux/init.h> G, L+ H' H, z+ N. i
#include <linux/module.h>
8 s# x9 B9 U) t9 R9 i#include <linux/kernel.h>$ d" d3 A0 e8 }! n, C$ x
#include <linux/types.h>% @. \9 t3 C! u: @# j* f* p7 u8 A6 a
#include <linux/gpio.h># |1 ^/ Y" m5 A$ B9 _
#include <linux/leds.h>
% x; T1 v- t7 ?3 m" D/ _) n6 E2 b#include <linux/platform_device.h>9 [! d0 m; t- s/ Z& \. \
' R m% W# x! n5 o0 e; p#include <asm/mach-types.h>
) D9 R+ B8 i5 J4 Y/ ^; }#include <asm/mach/arch.h>
, }: Q/ ?* T* J3 f+ v8 {#include <mach/da8xx.h>
% y) A, w" ~9 ]" d' V" X. s#include <mach/mux.h>
8 ~2 [. G6 N4 r7 N) [2 D0 c
* }" M$ t( E1 o- B+ ?* e2 X9 O% D1 D#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: l* j5 G5 L9 Y9 p5 \. K#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 w6 L) j, [( s" q* ? |8 ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ P! g/ k0 a; t, y& H$ `% C
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# r! h8 E1 Q( n& {8 @* d
' r$ j/ H; A/ g0 } H/* assign the tl som board LED-GPIOs*/
, V' U# s+ \- s9 a* B6 j/ istatic const short da850_evm_tl_user_led_pins[] = {
5 [: Q! y" N! S7 w; w$ y /* These pins are definition at <mach/mux.h> file */
- b8 L" w- f. I2 u& v# p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ L% [6 B$ @- C) ^8 _ -13 n+ n& u0 u0 ]4 G
};' f$ r E. z6 B/ g
( U, J/ |1 g; @$ Q, j3 k
static struct gpio_led da850_evm_tl_leds[] = {
' d- @1 ]0 E7 S1 j {6 O2 {, z U! t: q# q2 L
.active_low = 0,
: V3 Z( h7 a8 ?( M; U( l9 g .gpio = DA850_USER_LED0,0 H9 @1 I ~# R6 Z
.name = "user_led0",
& N2 {6 o$ k& W* a3 ~ .default_trigger = "default-on",( p0 r$ ~; g& U0 v. |8 Q# t
},
* i5 W6 ^7 H* s2 h3 R# ?' g9 i {' d& v& @/ m4 B
.active_low = 0,( j; j7 ? J- ?5 g
.gpio = DA850_USER_LED1,3 }5 L& e0 q. Q4 E0 k. f+ G
.name = "user_led1",
2 ^% @9 x5 N$ ?4 q5 T+ Q0 X2 t/ P .default_trigger = "default-on",
$ y1 W4 B9 p1 D$ B& Y },8 O) v% e7 c \$ ^/ C8 e
{
* t3 J# T5 e+ K .active_low = 0,
. q0 r% S ~7 X7 }3 b' S" T9 Q .gpio = DA850_USER_LED2,
& f0 J: c5 }+ o6 K ?0 N! G6 k .name = "user_led2",2 i; s" e: u8 X. ~6 d3 ?
.default_trigger = "default-on",5 p) T( _% p; E
}," ^; P# j, r# I1 l5 r
{9 I- r0 o8 I z; L; {; o; f+ W
.active_low = 0,0 U% x& m+ c. z! @
.gpio = DA850_USER_LED3,
# X8 q, `+ |/ j$ G" ~ .name = "user_led3",
! f# o, A$ G" n .default_trigger = "default-on",
}6 q0 z# ]7 M( R# l s },8 K4 @6 A" y% M- i( E2 [) B
};2 ]( m4 C* n- I/ K" `- r
0 ^" U' W; c% ?1 W2 f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. P& T* ~% X& m* [
.leds = da850_evm_tl_leds,
5 y ~- Q( k1 t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) R/ D& @$ ^7 b+ Z8 R
};1 u8 p+ R" A. G, h
: I- Y$ f$ Q7 ~! B/ f. p+ vstatic void led_dev_release(struct device *dev); W, F+ _; S! }+ F; w% s
{- {, a# U3 e8 S- \) c+ x
};
) F; e! I+ r, v, l4 V, t f4 k9 E9 R* Q
static struct platform_device da850_evm_tl_leds_device = {$ G- ~; A, d! m
.name = "leds-gpio",: Q! l3 R8 ]7 M6 @. I0 `9 ?1 J/ \6 j
.id = 1,
2 l2 p. Y0 _& z% W. m) \ .dev = {
: `/ w; `" y0 i0 z6 p- { .platform_data = &da850_evm_tl_leds_pdata,$ n/ x9 I! h6 N
.release = led_dev_release,
; R q$ A6 T5 o/ o, N# c! z& c }" U( s+ I* ^: J Q
};
& B; O; U( |) ]$ c2 ~1 ]$ P7 \: ?1 G0 P8 K; M3 }$ m/ o, I* [
static int __init led_platform_init(void)
4 Q' }) R- F7 Z) f* ~{
0 U. O; }3 R- o) H% H int ret;9 z& C" k: _" v, G; |- D A$ U
#if 0) }! |2 @# O3 k, w* }; e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" x7 t6 E: x+ D4 B x8 c if (ret)8 u5 P9 H% |3 E) n, L9 S, s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 s# L4 b0 a3 `# J* v "%d\n", ret);
. @) Y" l) Q) U- [$ H/ O#endif' A |/ K2 A/ x
ret = platform_device_register(&da850_evm_tl_leds_device);" B. V) w7 E8 c) I+ G! j
if (ret)* h& Y) a9 A, a
pr_warning("Could not register som GPIO expander LEDS");
- ^! p% F: P" z) H( O* j else
, s$ u4 M5 o7 _$ P1 J0 U' p printk(KERN_INFO "LED register sucessful!\n");
' e( }) W! Z+ a+ S
1 K/ t3 D4 b- J" P7 j3 f1 R7 f return ret;- a' G: f. ^+ c6 ^% r* {
}
+ S" o% B; \9 q$ j% m# U: G* U
* Q) l7 A5 m9 M B8 G& l# Tstatic void __exit led_platform_exit(void)& o3 Z" T" I' k: y+ y
{/ B7 w, c0 ]2 K# x* ~5 L$ u* {
platform_device_unregister(&da850_evm_tl_leds_device);
8 ^* H2 M& W, k0 p4 m5 m
, n7 T% w& y( m7 |2 \( ~6 W( z printk(KERN_INFO "LED unregister!\n");1 O- s# u1 W7 x; I8 s: q- i1 p8 N
}' K0 K8 l+ l1 b" f5 G
) F; d7 ]( ^( q' o k
module_init(led_platform_init);' G! p% }& A2 U8 D" I) A, p* W5 ^4 _6 u/ ^
module_exit(led_platform_exit);
1 u6 r# D0 m: [) k @
N' t% t; T* oMODULE_DESCRIPTION("Led platform driver");
. e! W3 p( O4 G5 v2 B! `3 f# F5 cMODULE_AUTHOR("Tronlong");0 w# l/ e$ A9 R# Y: `! ?2 V
MODULE_LICENSE("GPL");
" s4 v/ [* z( _/ Y6 |9 C4 w. \) j6 j
|
|