|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 h0 i7 }; q8 h#include <linux/init.h>' q4 g/ B' \' s: ]
#include <linux/module.h>' [. a8 K6 M8 x* k8 P
#include <linux/kernel.h>8 B5 g- q2 v+ ^: A# K3 f: \* f
#include <linux/types.h>
' P2 {& T- @! ] K6 L#include <linux/gpio.h>
" C( ]% n+ f5 _1 _+ W#include <linux/leds.h>
4 ^8 x6 ~+ H) p7 t! b3 C#include <linux/platform_device.h>
( s7 J4 i _( a- ] [. q! |
; f6 p5 w' u0 {0 p#include <asm/mach-types.h>! R3 k: h" q( B) ^& r! @, w6 Y+ m M
#include <asm/mach/arch.h>3 @% M/ J! H% g
#include <mach/da8xx.h> B3 @ W: p$ F" q, _' G/ z
#include <mach/mux.h>
) w$ R, ` T1 ~* E% ?4 n
* l3 r8 V5 E. b$ v1 ^#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% Y+ W. j3 S4 B* L: E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, O# r0 J+ \1 ?% }! O0 N6 R; C q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) S O# h3 h. h" E/ Y) U' p; w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 c! ~& n" y% d, \8 ]! W
8 O2 D3 X3 }2 P) y8 O/* assign the tl som board LED-GPIOs*/( ~- k- \' a6 ]$ c, L
static const short da850_evm_tl_user_led_pins[] = {1 v% v8 C J+ p- l
/* These pins are definition at <mach/mux.h> file */- t4 ]6 N4 R! ]1 P( L% K' d
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% x$ Q( |" M6 W V; d: }7 n1 _6 r -1
8 l( j& g6 {/ D2 g};% E5 B- _0 c/ G
" v5 r* O& n- _static struct gpio_led da850_evm_tl_leds[] = {
/ ]0 b5 t4 P5 Y u {
$ B0 a' Q7 _5 E* V5 k' s% } .active_low = 0,
# w: ?% k/ N8 z# {2 p .gpio = DA850_USER_LED0,
' p- s9 x; `, n! \$ Z7 @- A .name = "user_led0",7 }( l9 D3 ~2 n( `9 Z* g* H2 i
.default_trigger = "default-on",# z+ j& i2 N: ~2 | P1 Y6 o
}, m5 _ a" z, r5 {! v
{$ v6 r' [/ c$ j6 d& D# S
.active_low = 0,
: C1 r: ~2 ?: {4 b .gpio = DA850_USER_LED1,
% i1 d8 k% y* _! z7 L& s: e7 B: P .name = "user_led1",
5 g1 q7 o: P7 T/ u- q& B, o .default_trigger = "default-on",) m' p. V4 q4 n0 F6 ~
},6 G7 |1 @, c; a2 H
{4 f e6 m6 l, M6 A% W% y
.active_low = 0,3 g9 p9 ?) T7 p# P2 i7 @
.gpio = DA850_USER_LED2,
4 W% f. s3 A# w( h5 k' w .name = "user_led2",; ]. L ~- q+ E/ _$ @& S; K; j6 u
.default_trigger = "default-on",- C' w! r0 G% p: C
},' I3 F9 m' p8 ?' ]' P, t$ G/ h
{' C$ N4 S( M- D( H1 {$ E; V- r. O/ N
.active_low = 0,1 Z. n+ ]# L; j
.gpio = DA850_USER_LED3,5 J* A9 N. `7 o
.name = "user_led3",
% ~# j% q1 P& L- J .default_trigger = "default-on",
/ U& K8 {' a% @" l },4 f" Q6 x) [4 {1 D3 j
};( W2 e. [2 H4 {7 ^! D# t' j
# |5 B% D9 }9 @2 estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 H$ s" m" D# C, F; R) ^
.leds = da850_evm_tl_leds, I: B: _6 }5 H
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 ^' k5 K( O$ ~- f0 g};4 w# t, ]) B l! p5 f0 c q
1 Y% X/ v* j9 z, b& A; j8 i5 O* T; Fstatic void led_dev_release(struct device *dev)
`% Q5 G' O+ K; n0 S) ]! \7 R{ M4 f* ]0 n8 k. V. J9 j2 {
};
$ J+ u) R# g( _) \0 o& r
$ c* g; E- q+ ?static struct platform_device da850_evm_tl_leds_device = {9 G% c' D! a# Q+ O" l$ M+ G
.name = "leds-gpio",1 f5 Z r+ w" h: L* I& d
.id = 1,* N2 v% w( g0 j' f3 E
.dev = {
6 C4 w8 k( ]( X# `- m9 {$ U' ?4 x .platform_data = &da850_evm_tl_leds_pdata,
# \% z, C2 X; b .release = led_dev_release,! f3 s0 t* [& |! c
}
: i5 {9 a& n- e2 ~. |, o};
- U) S! n* r4 L8 `# Z" a6 S* N/ S( q! {& f9 j. c0 K4 k) p1 n$ g ?
static int __init led_platform_init(void)& V. ~! O [3 i% \" O; F& i
{
O5 E3 d E2 L int ret;
) J4 r% M- G' B#if 0
2 o5 {7 w0 j2 {# t! E) h: ~ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ _3 X/ | F3 B$ y
if (ret)
* N! t# o; X; t pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* K% B! J/ T4 _: A" C
"%d\n", ret);. `3 k8 H0 c" }2 ^7 A
#endif3 i8 V4 \: j1 N/ X2 ~
ret = platform_device_register(&da850_evm_tl_leds_device);
) C' v' J9 V! n* N! g% L2 g, F+ Q if (ret)+ ~' T) v) c7 j, @7 a; {: L
pr_warning("Could not register som GPIO expander LEDS");
3 T; b; f, j% w- C5 y* \( r6 Z else1 h" v: \" s# Y
printk(KERN_INFO "LED register sucessful!\n");
" W: m% r; e/ N! F; ~. W0 O: U) }0 T+ V! G6 X: c5 t2 x& r
return ret;
3 l* }5 ]( V+ W; f0 B/ q% a& i6 G}; _+ c5 `' @: y$ b
3 X- l: j5 k* x c: ^4 n! y7 B' j
static void __exit led_platform_exit(void)
; e) T( h0 s% a @* \; Q3 r, y{" r/ E6 c6 b m* O
platform_device_unregister(&da850_evm_tl_leds_device);' X: m! d: A# ^+ ]5 s$ G6 I
6 ], h% l7 W. e& I3 l9 t" T( H* e printk(KERN_INFO "LED unregister!\n");
( y$ ?: v8 m$ }4 J! A* K}
( n" Q8 e; J$ L7 B
5 [7 Z% F7 G2 pmodule_init(led_platform_init);; V _; j$ a6 B D2 H# L4 a
module_exit(led_platform_exit);! g+ e m9 C/ j, ~
4 k& ?+ M7 |! W* K9 j( U! R
MODULE_DESCRIPTION("Led platform driver");$ x! U4 K/ ? B, p
MODULE_AUTHOR("Tronlong");4 K( A: s$ w. ^: m9 t
MODULE_LICENSE("GPL");
; j/ m! N0 y. y7 x0 z2 ?9 v
- ]8 r: S4 g. H |
|