|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 I" m; C# }' S4 m7 a4 p#include <linux/init.h>
7 T. ?3 ]% I) G9 _5 @* K9 x#include <linux/module.h>+ \- R. k6 b/ v8 a9 `9 b9 b
#include <linux/kernel.h>& A3 r9 E; R# b. A* O. G
#include <linux/types.h>; t/ F c$ j# T9 E! p8 p" Z; F0 {* T' V
#include <linux/gpio.h>5 ~. g+ m! k& } I/ ]$ p8 y
#include <linux/leds.h>
- ~5 J* M/ E1 X& B, m9 C#include <linux/platform_device.h>2 F# d6 O' n* u' v( \
1 ~0 i* F& [+ O$ @5 }- d+ F# O#include <asm/mach-types.h>: [' R% j9 B1 V
#include <asm/mach/arch.h>! R4 w, U5 @3 y& R! l
#include <mach/da8xx.h>! {( r* Q- O& D7 ~. z+ A) S; L9 G
#include <mach/mux.h>
+ ?, ^/ C+ ]) t! A
9 V3 I( D' V2 {/ ^6 i n4 N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 K! o! F ?3 C: Q2 r$ J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% ^' W( E4 |9 O% `9 c9 {% f" d4 i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 G5 r8 i, J& f# b- W#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 @$ W5 [: b8 r* {4 u0 O0 m
+ s. r) z# T5 f) \9 R# v" l( F: U/* assign the tl som board LED-GPIOs*/
4 B& U/ N; \0 O- R2 lstatic const short da850_evm_tl_user_led_pins[] = {
3 I/ \ \" l1 _* ] /* These pins are definition at <mach/mux.h> file */
' N' T% w/ _- o' p0 _4 U5 H, a9 H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 a6 w" ^# l5 F! q: ]0 Y -19 Z5 I2 u* a; b3 ^8 l
};8 P9 }( u" T" H+ H* x; F# b2 N
1 ]0 T/ S" w: U2 v
static struct gpio_led da850_evm_tl_leds[] = {
/ e5 l) |2 A" f. }% S {9 P3 h; ~6 ]0 I1 b3 A$ ?- ` J8 S
.active_low = 0,
6 g4 l: t% Q7 ]$ i/ W .gpio = DA850_USER_LED0,( z: J) s/ P! z' g/ |
.name = "user_led0",
1 ~: z( t$ D4 B' L% o' h .default_trigger = "default-on",
; j6 G) Q3 p; O# f0 l/ U8 B },% c) N: ~7 u6 X' }0 E: S
{* b! t2 `2 {) P2 M% u
.active_low = 0,
* q5 y, [( X! x, l8 e( B .gpio = DA850_USER_LED1,6 z- c6 r6 t( @2 O2 f' E
.name = "user_led1",9 h: M" T/ g, h1 `" c0 r
.default_trigger = "default-on",6 r4 E/ ^! W/ D+ p
},
( ~& r$ Z3 C9 e& {3 v {$ e. ^ a! \7 ^4 _+ c( e
.active_low = 0,) @9 X& Y" R7 ?5 }
.gpio = DA850_USER_LED2,8 w1 b2 ~1 J& w- ]& j! p, j: c" f
.name = "user_led2",
8 t# a9 c$ L) Y/ N: p" t .default_trigger = "default-on",
0 T% f, ?% \* w& j& u+ k }," r/ G' m: }2 k8 B# o- j4 l
{- E. O! ]2 s4 Z3 i
.active_low = 0,2 i; U8 E5 |' o/ Z3 n
.gpio = DA850_USER_LED3,/ R$ k5 F% _6 U0 K, }
.name = "user_led3",
- @ d# e& I. O1 b6 g0 k. N& z! Q .default_trigger = "default-on",! d& M" u" ?, A2 w
},
1 F8 {2 L$ x, ]};
* G* n: c! K/ F7 {2 k x, B2 z& P+ y+ O8 l1 h; V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. L$ @( n# l1 B; S. S
.leds = da850_evm_tl_leds,
+ k9 v+ A/ L! k. P. b( m3 B6 A .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ t" k0 P/ C4 w& e) R7 |};
$ A. X. o# g3 a2 @/ E6 l+ }7 J8 q! e( U8 e
static void led_dev_release(struct device *dev)
- l! W3 h, D3 ~{
' c8 \& j) u3 ?6 m9 V2 |- N};
* V$ F7 m# X1 Z
7 a6 z' ^; o: g ~ _static struct platform_device da850_evm_tl_leds_device = {) l% q) g; D0 {3 H! m
.name = "leds-gpio",% h* t( A8 Z) ?
.id = 1,
7 j) o" _1 `- ~ .dev = {
0 p8 S, E! Z! _! u .platform_data = &da850_evm_tl_leds_pdata,
* M2 d: x# {; ]' Q .release = led_dev_release,
( [. v: E" J0 l0 V8 D0 ~6 Y! ] }
' t4 a: X/ C- u# q+ v. b+ A6 Y};& @3 Q2 i- S& b: Z
% K9 \. {' X2 z) y% E. U
static int __init led_platform_init(void)
$ L! j* w2 Z P{, N1 c6 z' z& W& B1 f
int ret;
; ^$ m5 e; X. K4 J/ |& d#if 0* d8 @6 b9 \4 ]& J' U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 r6 W6 C c: \- r% d
if (ret)
+ w5 U; w0 W% v$ r( u( e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' E; @; Q7 m- O( e( l% Q1 q
"%d\n", ret);
! Z- v/ I; n5 j5 d5 O: q#endif
; X5 h& k! d& t% c ret = platform_device_register(&da850_evm_tl_leds_device);7 F4 ^" @7 y. X
if (ret)
2 W3 R* t1 `: e/ \+ }7 `, e, k+ T$ u pr_warning("Could not register som GPIO expander LEDS");6 ]* T# [/ H& D4 J& Y
else+ f* F. f' m" }" n. W! q
printk(KERN_INFO "LED register sucessful!\n");$ o, J' [6 B; d
, r3 {1 ^, V; B" W& J" I: x1 M; Z return ret;5 B8 f* { I* o: @# E
}
$ ~% O) ~$ i ]5 w k) z
$ Q: r3 X9 P+ t6 h+ l" v% Rstatic void __exit led_platform_exit(void)( M! h" h; M0 d$ U* Z
{
6 r& X {. L+ c6 v7 T3 ]. N platform_device_unregister(&da850_evm_tl_leds_device);' d" Z; Q" j3 l8 [
# O7 _( {: B$ R M% i! ~3 V& ? printk(KERN_INFO "LED unregister!\n");+ @0 E* o! k6 }- Y9 `
}7 U y2 [ \/ W& O! T7 p+ _
: B' D, M; X' ]. m
module_init(led_platform_init);
& ]* G6 Z l# J# y/ d- P" x, smodule_exit(led_platform_exit);/ k7 |! J) d7 U- B: e
3 D9 _: O; _$ ^" @" o H4 eMODULE_DESCRIPTION("Led platform driver");9 `4 ?4 H5 ^1 H! ^' d
MODULE_AUTHOR("Tronlong");
; `& D2 V W( R8 x- eMODULE_LICENSE("GPL");
8 c: f9 X+ V# [7 L. i9 x* C. Q$ e3 A/ l7 K
|
|