|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 P9 |, n7 f) J" K
#include <linux/init.h>
1 X- F- `# ~8 @# X2 o- G4 a#include <linux/module.h>
( `( A3 A! G# x#include <linux/kernel.h>
9 |) v1 o+ ~' t0 I#include <linux/types.h>
( [4 n4 g1 L: a1 N1 A! Z: d#include <linux/gpio.h>* B& B& F+ L4 n" O
#include <linux/leds.h>& O% K) I) w8 @2 n2 U' m& E. d
#include <linux/platform_device.h>
@' I7 J$ P6 @) T2 S; C$ E% e( ?0 @5 [7 [
#include <asm/mach-types.h>4 m( x3 f1 ?1 J0 N9 V: M
#include <asm/mach/arch.h>
K# \* G3 Q+ {: a4 D#include <mach/da8xx.h>7 O6 a) y* [) n( ~
#include <mach/mux.h>
, B" t$ F+ X- q* X6 n5 `
# D/ t& n, m# Z: B+ L1 E2 M#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( [" \) ?5 b7 X( e0 J" c7 P3 L#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% Y. L" Z* U$ O. G#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 G9 N# D! I' B& W ?6 D+ b9 e#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ r. a: m! p( |- ?9 e& s0 _
& {/ e" ^) b j1 g
/* assign the tl som board LED-GPIOs*/& N" c" J$ R. M, h
static const short da850_evm_tl_user_led_pins[] = {
# T' x8 T6 T$ U8 R2 r7 p /* These pins are definition at <mach/mux.h> file */
6 E. _! W- m7 P( M1 x' y: d DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 U X9 Z% W+ h5 l8 T( Y -1* A m9 [: D: @0 ?6 {8 U
}; m# r+ N6 z6 c
5 o) V I& {$ |; W# g& R
static struct gpio_led da850_evm_tl_leds[] = {- N; g" f- N* h
{
: w3 c& s- K/ a- R# `* j .active_low = 0,, e {) s% S+ J' S8 ~, Z, M: r0 K0 j3 G
.gpio = DA850_USER_LED0,
! i( N9 P, G2 r8 _2 B .name = "user_led0",
L% \& [2 n7 u2 @- _ .default_trigger = "default-on",0 s6 B& {* S4 S9 B- M% a
},
7 h9 C' z1 A1 H {- y- e6 Q" T: r
.active_low = 0,
0 Q* @: x q) n3 j; E .gpio = DA850_USER_LED1,
8 M" `* h! t( ~/ [" q& X# x- d q .name = "user_led1",
0 n+ m# x/ B3 J, E- s2 I% q: N$ r .default_trigger = "default-on",- R, r% `; F, i9 s$ V& p
},
* M( j0 t3 W, [$ t" Z8 r8 N {4 h0 Q p+ n% |8 R, p, q. H: k
.active_low = 0,+ F7 U! A5 v1 V3 Q( L$ ~
.gpio = DA850_USER_LED2,
: H( N$ U6 i9 A. g1 G& G9 y .name = "user_led2",' ~0 S5 ]! ^7 ?# l; @
.default_trigger = "default-on",
& @- I7 Q- x, c },
* M6 c! G: \+ M% T! e6 F$ T' F {
) r( o' X9 d# K5 w! ^! {0 F+ ?% ] .active_low = 0,
) H$ m# U9 k6 @( [4 x# g) j4 E .gpio = DA850_USER_LED3,% S+ ?/ M. n4 D; ]4 m; R
.name = "user_led3",0 H, R+ q: d( \& U _& H
.default_trigger = "default-on",( o% ~ b& }, T5 c: @
},' v% X, \/ w' O( {' \
};' A- \3 R3 t* \ ~
' h5 T$ t" @& T+ ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 R3 ^1 ]; u+ W! m# x. \- \/ B
.leds = da850_evm_tl_leds,9 S1 g5 S' o# S0 s0 n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 ]: |! L) \$ A+ l5 M; V
};5 {1 W- r+ Y( L! P2 c8 G! u- M' s
1 ^3 y" a B! O& \
static void led_dev_release(struct device *dev)
& t- X- {$ l: z+ R* {) N{
7 q! ]6 i5 v2 T: n1 b: }};9 O2 v8 l3 C7 M8 q
6 e% ]& T) }; p0 M$ ]' S" }8 Pstatic struct platform_device da850_evm_tl_leds_device = {6 y8 a/ z7 ?8 L& V$ I7 X, Z! d3 S G. i
.name = "leds-gpio",; y4 O" `! H' Z' j% J
.id = 1,
) k" P% O5 c* a7 d' Q V .dev = {2 M% Z7 N9 p! F* y7 j. r
.platform_data = &da850_evm_tl_leds_pdata,% s+ I3 s/ Y, {3 G1 R9 a5 _
.release = led_dev_release,% s+ ]; a, ~$ j, K# i2 L" s1 S6 ^
}
6 W) q% c4 N4 F0 A- ~( e};
1 _ m, Z( z) E
6 M7 ~" b. w; H* B9 }9 X! rstatic int __init led_platform_init(void)
$ Z3 z5 z: i. n{; c. l+ e! x; i8 k' E$ Q w+ [. F
int ret;. I2 ^; l. f* E# T! p7 c
#if 0+ M- X! t2 G% x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ V( }+ h: h% n/ H# p! u# a; T if (ret)
: s% j: W- x" M' I7 j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! j" @3 h. D# D; u( D6 c) N
"%d\n", ret);
9 w6 k& P$ W7 k. w( c: i#endif& a% c% Y# B( l7 N; `, k$ A# I
ret = platform_device_register(&da850_evm_tl_leds_device);% S. s3 z1 h* e8 E' c) T+ V( `
if (ret)5 a @* O. k* g' ?3 G* [4 ~8 A
pr_warning("Could not register som GPIO expander LEDS");
6 X% L _/ v- w9 Q' _% L7 s% Y else
% j8 N0 Q. W9 F5 \: A printk(KERN_INFO "LED register sucessful!\n");' T9 q- [5 m4 d+ j6 Z0 _
$ X) V3 V4 I* _
return ret;
4 i2 ?3 G& t8 H) t}# U) j( I- M! x2 \, c
r: }2 d0 E- V8 g) f
static void __exit led_platform_exit(void)3 j. D5 t+ o" k- g
{6 Q6 L! C4 s; |- i- |+ _
platform_device_unregister(&da850_evm_tl_leds_device);. h) s) d7 K& X+ U" J" z
8 E7 A8 R" c& U: p' S2 X
printk(KERN_INFO "LED unregister!\n");$ X1 N$ ]. {8 Z9 \. D u# A: n
}
$ s. B( X0 i! {5 M6 e$ H2 }9 Y, n. K' H3 q
module_init(led_platform_init);
+ q! K+ j6 X' p( D% f5 N6 L$ Lmodule_exit(led_platform_exit);
* ^: r+ Q! [1 j. h: W
. ]* d; X# t- G A9 VMODULE_DESCRIPTION("Led platform driver");
% X+ Y6 R( D9 J) H% H- v9 c& UMODULE_AUTHOR("Tronlong");
- ]1 K+ ]5 y/ f3 l7 l* UMODULE_LICENSE("GPL");5 W# j# Y/ ^- f* O. l2 p
2 S+ v: b, b, p3 ?' j
|
|