|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 Z; g% _3 U- [8 b- }# `
#include <linux/init.h> g! ^- t' m& o+ ]4 j
#include <linux/module.h>
- l+ Q: b. o7 H#include <linux/kernel.h>
' V* e4 q% t/ X* S& k) A0 \# f2 o#include <linux/types.h>
" ~ g5 ~! z" d#include <linux/gpio.h>
8 ] @. H/ g5 ? B) `& f#include <linux/leds.h>. B' m2 J/ L, _% T8 j2 A
#include <linux/platform_device.h>: l2 ^1 K- f) Y5 B% f, r
6 k+ s q9 t! D" Z: d1 K, p#include <asm/mach-types.h>
7 Q5 X! _7 F: h, {: ]#include <asm/mach/arch.h>
( a2 i/ K B; h8 b#include <mach/da8xx.h>
. n s# A1 }- p5 V F ?#include <mach/mux.h>
" [# Y* B, s0 j+ d. f- \" \0 ?6 h* S, M6 e1 X2 v% E5 m3 j2 Q( }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 O. B A; q5 ?$ I8 R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 {3 _ h+ f. r. k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 Q! w4 h0 N0 O4 Y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ P) T. _6 e8 s2 a0 P0 e
7 k; d1 D1 Z- P/* assign the tl som board LED-GPIOs*/
- m- w' j$ [% R- D5 s7 \+ sstatic const short da850_evm_tl_user_led_pins[] = {
3 G" E! J) O0 e. I /* These pins are definition at <mach/mux.h> file */
3 B( J, \6 h0 `/ S: C! P1 Y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( R/ V( t' j% n Z! P6 O -15 Y6 D- u+ b( ^: x) m6 g n( c* z( u
};6 z3 v1 O1 d- Z! K0 Y7 P( ~! a6 @- R
% L; x2 K q N6 n& k
static struct gpio_led da850_evm_tl_leds[] = {
1 p, E1 r& {( ]9 x! V- T {
7 ]7 L- T7 T7 v3 G2 K. r9 o .active_low = 0,; @/ b- T& Z- m+ _; |6 _
.gpio = DA850_USER_LED0,
& f3 p8 x1 K1 i .name = "user_led0",
7 N* L. I, m' X. V5 P .default_trigger = "default-on",
) _1 ?9 q- _! n# F },, ?" d- ^. [5 w7 _5 P( q
{3 c, k2 ~# {0 Z& O
.active_low = 0,
2 ?1 ~7 w* b1 W. B" i .gpio = DA850_USER_LED1,
[7 t" K5 H7 _( S4 m. P .name = "user_led1",) T6 d; {* P. D- S+ |( z7 ~8 @
.default_trigger = "default-on",
$ C. h+ @/ I) E" k, f },
7 ^* d8 B! h9 O6 b1 |# m {# P+ G/ y5 m* g( B- r
.active_low = 0,
" P- e- g9 [; k1 k4 G .gpio = DA850_USER_LED2,
5 V( w) g: Y( P, r; A4 \ .name = "user_led2",
B1 x! \1 A* }# a- R9 z- K0 t .default_trigger = "default-on",
+ N/ t$ T- P) i0 p( b },1 q' t0 N! E& m& |2 e" i. [
{% w1 e! U) k3 S5 D; ~' e7 K
.active_low = 0,9 f. i: J! R/ _
.gpio = DA850_USER_LED3,/ _3 I7 u/ y. C+ w, c( G: W
.name = "user_led3",
) c$ z. f( v( _! Y) T( u" x .default_trigger = "default-on", W& o8 F' ]$ S
}," L$ u6 H* t6 A9 j
};. e: z* ~" g- t
/ F9 f2 Z0 O4 }) r. A) l8 G0 _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 Y7 S3 O& W; g! [* s1 [, A8 p .leds = da850_evm_tl_leds,
: U5 f6 B9 ~1 s1 e .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. M# o+ |$ q$ t0 }4 Q& N, t4 F};, Q! k( C7 {/ s z
/ G* D4 s, R+ Jstatic void led_dev_release(struct device *dev)" p. K# y/ {8 A: A8 B
{+ l+ G. b; r) S* U( \
};
+ {- U1 X# T. |, C S8 B
6 B3 ?. T& ^- N L- T: vstatic struct platform_device da850_evm_tl_leds_device = {
3 R9 B$ {4 y# `8 i% B .name = "leds-gpio",
; p4 b, a- u9 g8 `( i2 f .id = 1,
0 }5 v s4 l; n, l: p .dev = {& m' Y, [) R$ ]
.platform_data = &da850_evm_tl_leds_pdata,
, ?. z7 n9 _2 T8 X9 ^: [ .release = led_dev_release,
, y0 \8 B% U+ H }' u5 G$ r8 \" D3 h8 L
};, D3 S, f) B4 }! a0 |
7 f4 e$ M; A* W0 ~static int __init led_platform_init(void)
& `3 K% h" Q. A" Y( ?{
9 q* v. E8 b$ o, t3 f- ^ int ret;- X% |" p r3 V0 N8 A2 J& o6 n
#if 0
F1 q7 h1 H0 o6 y" ? ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& L" T* m. A0 W, W if (ret)$ `: w- I/ D7 e, H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# y3 R: G9 q. L) F! s, {
"%d\n", ret);
! X' D8 G: S, U% B: c3 g. v, |#endif ]8 b' n7 B1 n1 y5 f F7 ]" m
ret = platform_device_register(&da850_evm_tl_leds_device);
2 F0 u% {* d2 t if (ret)3 ?$ A4 S; z- @. G/ f9 _
pr_warning("Could not register som GPIO expander LEDS");
1 i7 o, K% L V4 U p9 A" Y( x else
! [7 w9 C% d8 M+ I$ e% O, H printk(KERN_INFO "LED register sucessful!\n");& S0 _: n: S. W( R
3 i3 `! c% z/ w1 f7 h return ret;
; u+ D6 a* W; h7 R- `! w}$ ]5 X0 U1 G- u. W+ A
: N/ u* f! \/ g$ |7 `, E
static void __exit led_platform_exit(void)0 S5 L, d8 l' S! a- e
{
* ]- S0 O: Q3 a9 x( p3 ?4 z platform_device_unregister(&da850_evm_tl_leds_device);! b* _1 X; c, {* s+ ]5 c, Q
* \- @$ R: C- W0 q0 P6 [7 I printk(KERN_INFO "LED unregister!\n");
/ w0 B0 K" R; u0 H( [/ {' ^}* G( r5 Y' F5 N/ G# v& W
0 Z$ A( x W% z. K/ m- k* F/ _
module_init(led_platform_init);# q w7 {* L0 h. Y
module_exit(led_platform_exit);
( x9 w1 l O5 S2 Y9 C' H
# i! B$ n* l$ |, \& E8 L: ?$ w/ MMODULE_DESCRIPTION("Led platform driver");; W- A) c0 `' r1 \7 K D
MODULE_AUTHOR("Tronlong");2 x& ~1 f: W2 |8 H8 w2 J/ v
MODULE_LICENSE("GPL");
# a6 l9 a. j! n( s9 d8 q1 N: s7 W6 z, D
|
|