|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 o* W$ ^8 O, \/ K% p5 ?
#include <linux/init.h>
' N! {" }6 U/ d7 Q# v#include <linux/module.h>" q4 F1 a2 ~& n) T# f$ g
#include <linux/kernel.h>
8 { O5 b/ Y+ Q d0 x#include <linux/types.h>5 D6 v( \5 J J: b" G+ {
#include <linux/gpio.h>0 [1 T$ a7 r6 U0 o0 x' H! }& v/ \
#include <linux/leds.h>
% w% P( l( j/ }" C( r#include <linux/platform_device.h>
! J% D- y9 P! G" \# q. [" Z; y0 n( Y' R' \9 h* d
#include <asm/mach-types.h>
# i) C- w3 U. Q A) j T0 y# f#include <asm/mach/arch.h>, P& j& R7 e4 A( f9 q
#include <mach/da8xx.h>7 }5 i3 |& y" I- d' t7 b
#include <mach/mux.h>/ C9 a+ X+ K2 K
! s0 U' \# s' Q$ I. j! R$ d: f. Q" }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); z6 `$ |3 Z. A: L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* v7 p$ `6 C4 ^( w2 T& q4 E
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 S/ W7 d6 \. C- _/ Z7 j& ^5 h$ s#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ r1 V) R# T( `9 @+ P
( s( X$ \1 @- \6 k5 D/* assign the tl som board LED-GPIOs*/4 [5 y; F0 L3 y! h+ k/ \1 r% J
static const short da850_evm_tl_user_led_pins[] = {
( Y! ]% [6 Q' g) ~! p /* These pins are definition at <mach/mux.h> file */, z% ?3 x: i: r$ ^! _* ~* k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
A! G" P& H- |. }8 f0 {7 j -1
! o1 K* }4 a5 m, e) H7 U! p};( r6 T. [) o" z
$ u5 S# w1 s* r2 m) d$ L1 I0 wstatic struct gpio_led da850_evm_tl_leds[] = {1 B; k4 a1 e2 [3 P3 @3 j& x0 j- e
{
1 F( ` i. o' A8 [6 O .active_low = 0,
; z) O/ g8 g3 c; T. F .gpio = DA850_USER_LED0,
7 [6 _+ r) a' E+ O8 f& C1 g, X1 F .name = "user_led0",
: U. m) ] a1 u( [+ y$ B! G .default_trigger = "default-on",8 z3 e9 I$ c7 a; o' h2 J4 u$ D G f( d
},
$ @8 T/ K6 I6 r9 s7 r {% U ~: w: N: n+ W% r
.active_low = 0,0 }4 v) o. o5 U+ {+ }. _- ], Q
.gpio = DA850_USER_LED1,( t! e; _2 P0 A/ h7 G
.name = "user_led1",
7 D; F6 d( \' d .default_trigger = "default-on",
1 W5 Q7 k" N3 t: c },- k0 T+ X7 l; p8 D* M3 k" i# B
{6 P t8 p% L* I/ s
.active_low = 0,5 P1 I. a* s$ ?
.gpio = DA850_USER_LED2,
7 m1 o# E$ \+ i3 B7 p .name = "user_led2",
9 r( y' @2 q' S* z9 l7 Z! M# q: |3 ? .default_trigger = "default-on",
c. u" h$ q q4 t5 { },
* i8 Y6 I1 a/ R! R: [ {( J6 X* U- s: t
.active_low = 0,
4 d, s" J) S. F. w, H3 w .gpio = DA850_USER_LED3,$ ~& l3 O2 S" ]" c
.name = "user_led3",, o9 Q3 U8 O6 p* T
.default_trigger = "default-on",5 p, Z# ~" ?9 z8 b' c t% C
},
% B( X( |9 `& j; W1 V: I};
- f: F1 w$ o* H8 [0 f
/ R; y; k; _- Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 u8 ]6 W+ [. m* a0 E9 w. j
.leds = da850_evm_tl_leds,
4 y2 h8 Z& \ {8 i8 L; V .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 i) S+ h6 G% ]( x};
" f" ^9 O7 U) |/ Y9 c: O7 G1 f1 g
static void led_dev_release(struct device *dev)3 g+ d! P7 i9 K- }0 b5 g# n- Z
{ V# D5 d3 {, Y1 K, q( U$ g. N8 T
};
3 c4 S. M& m% d* e* j% {* ]" i
) A \% |0 B: E6 Vstatic struct platform_device da850_evm_tl_leds_device = {0 l% K# S" h0 @- w9 X6 R: h
.name = "leds-gpio",( M. ^3 h H8 S: ~ _! c# v! G+ u6 @ Q
.id = 1,. ^; I; a3 [0 P2 i. z- B3 O! i
.dev = {
W. \0 c# Z0 y9 d9 A6 q .platform_data = &da850_evm_tl_leds_pdata,; p0 C8 L. i! Q8 J, M9 [) Z
.release = led_dev_release,) E8 G$ G; H& u/ M9 H5 g+ A# ], W
}! T: @ j; R+ U! ~
};( P8 D$ K2 a* {' t! o" @
- Z( R- a; d {2 j% g
static int __init led_platform_init(void), J& B& d1 M; j' H+ t
{; U- ^7 S5 E0 }1 y
int ret;
3 ^; `9 G: P+ x& u, b9 u#if 06 V- o" e' ]3 W: s% b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* p l& C9 G# R" ^9 @2 V" `# o- W; h
if (ret)% C6 \) p2 B1 @) @# o& n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :". G) v+ z4 Q3 S' Z' x2 M/ X. t
"%d\n", ret);$ R5 I1 i3 ?1 p) p' e; ?' `
#endif
# i9 ?9 B5 d$ V' Z6 X ret = platform_device_register(&da850_evm_tl_leds_device);
2 J4 _; ~" o2 |* n- j2 b. R if (ret)/ [5 s# B. k6 Y' c5 d2 c3 z+ s
pr_warning("Could not register som GPIO expander LEDS");
+ F( J) [/ t6 V( y% e8 p else
' |9 A# m. U0 D printk(KERN_INFO "LED register sucessful!\n");, [9 I4 Z3 J5 T: d( M4 e: O$ a
9 b) Q0 Q ?4 c% g. T3 r h
return ret;
% R3 u% D9 Y3 ]/ E6 r+ a! y a}# U: f9 W6 c$ g* r6 X3 {3 t0 X
# s. K' z- m0 I0 Y( D2 \/ ]static void __exit led_platform_exit(void)4 I+ d) @6 \$ T2 @) E6 k- }
{
3 S- x3 H/ q3 u" W platform_device_unregister(&da850_evm_tl_leds_device);
( M: {% c. S' n" ^6 ]
; j6 x$ M( o/ o+ |7 J* y" G printk(KERN_INFO "LED unregister!\n");# W+ S/ S) m+ f' _0 |: B
}- ^& b3 U! U& F& ^
B' C( G/ Q- y. T! U; a/ w
module_init(led_platform_init);
, b1 W& N7 Y8 ]* w, bmodule_exit(led_platform_exit);4 t) S$ t/ Q* T
. |1 q2 K W0 M4 s. |( o& [3 t9 d
MODULE_DESCRIPTION("Led platform driver");
8 f. q p2 P8 s# }5 `' RMODULE_AUTHOR("Tronlong");
! I- z0 o3 d- b" y: k# R" \MODULE_LICENSE("GPL");* S ~, I9 s M: y
6 r" @7 v( |+ F, h: l- a U
|
|