|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 g O. x) v) x+ R#include <linux/init.h>
6 h' D5 H; \6 m3 A6 }! `1 ~#include <linux/module.h>% |( X1 e: J) u# {- d0 [9 K
#include <linux/kernel.h>) o6 v" a( N; k5 x5 ?
#include <linux/types.h>7 G8 Z% |5 Z% j
#include <linux/gpio.h>" `. e" l9 Z6 ?2 u
#include <linux/leds.h>
5 O! k5 z( ?" z) N; @3 n4 ] j#include <linux/platform_device.h>
) S) a1 x% g7 h1 C3 m
6 j$ q: W4 z+ z- X3 c$ Z#include <asm/mach-types.h>
; x* c" U$ n0 e$ z; P/ f#include <asm/mach/arch.h>
7 ^5 V7 ?/ g1 |#include <mach/da8xx.h>
$ a' u4 d9 t% F#include <mach/mux.h>1 p# ?" z6 \# l" x$ W9 ~* q/ y
. ]% y9 x" Z. |! P' \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 ~% B6 Q' m; W+ u4 \#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) c( h# w# v$ X: Z. m6 Z; I; m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' F7 y" W8 u7 v! x0 T* l
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 z7 _' H5 n2 e* C6 g. d! J5 k! i* e8 O, _
/* assign the tl som board LED-GPIOs*/6 k* L; j. v; U
static const short da850_evm_tl_user_led_pins[] = {
9 ]1 u5 J. a' {% M0 S( C /* These pins are definition at <mach/mux.h> file */
# d) B4 {8 l6 k5 i; E2 t+ h DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# n# @7 A3 ?8 ? -1
% C7 D' F! P5 X/ k4 X2 V3 i$ e3 O, n};
. `! h9 Y! N# x" o/ S2 J& Q& b- f K% K. D- c1 v$ E1 H
static struct gpio_led da850_evm_tl_leds[] = {
5 O/ s6 ]1 q0 X1 {: t8 n {
" [& _+ z k8 m/ q. s .active_low = 0,6 H8 r1 g' S. p. K8 M# N
.gpio = DA850_USER_LED0,0 B$ ?' K8 U. f; D; R$ b0 N1 J! @) |
.name = "user_led0",6 s1 F; Q) l. K: j- |* _% M' u' K! G
.default_trigger = "default-on",( m0 P3 l$ Q0 t* \7 |9 D- N
},5 ~! b" N. s3 }/ m9 I7 Z
{) `. ^7 X3 z8 ]" I/ @6 u
.active_low = 0,9 y7 f8 ]2 Z" v
.gpio = DA850_USER_LED1,+ K& m0 h1 F$ s( K; U$ S
.name = "user_led1",
. ]; m2 }4 t2 \3 \- [ .default_trigger = "default-on",3 m" {! v6 n- {1 p$ J
},+ A5 [& I4 \- v( r) }7 |- ^
{
1 }% g2 c5 m# g7 m4 L' Y( U) F .active_low = 0,
, s+ c+ M1 T/ M3 L+ c6 C' O .gpio = DA850_USER_LED2,! q8 m5 m# v* T* o
.name = "user_led2",
( _. S( Q8 g+ o8 ^( p! Z) O, Z .default_trigger = "default-on",
9 l0 y z1 L0 ~1 Y2 f2 _3 Z },! O# M; y/ r% t! P2 R/ o
{7 _/ S* i; q X- U% J g
.active_low = 0,
+ m/ E- H# _5 G! a8 M6 w3 u7 ^- ~# T- j .gpio = DA850_USER_LED3,- i+ [1 ]& t2 ^* ]' r. _/ F$ |
.name = "user_led3",( m- R; d, {& p3 {- P$ M- q
.default_trigger = "default-on",! | W$ [3 C7 ?- ]
},
$ d1 S- S7 o+ Q) [& y+ q};. S3 W. v0 U8 S2 W, d& H) W3 V
( Z' V/ D4 y2 o( Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ k4 @9 V. M2 R4 E
.leds = da850_evm_tl_leds,
* t; i4 ?) f6 [2 G6 G# D7 g .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( Q# w8 i, J0 ?9 w6 ~" }7 n
};
7 T( F. W; r& @6 ~" ?
7 r% f% T- {5 m+ J8 Pstatic void led_dev_release(struct device *dev)4 D2 o! C7 W, J! C2 }
{
6 E! {- n A( Q- K1 E; w7 r- r2 n};; h2 k7 E; h# k; J5 L( Y! o& `
+ C }6 k9 {" J/ [4 tstatic struct platform_device da850_evm_tl_leds_device = {
6 u+ Q8 W0 @- o" x* B .name = "leds-gpio",
V2 P/ m2 R# O9 |/ D7 ]* G) K. @ .id = 1,
! s" r, F6 U; J* y# ~4 \ .dev = {
5 Z3 y1 {+ K5 V8 K$ R .platform_data = &da850_evm_tl_leds_pdata,
- c. ?8 t0 \5 K% C" B$ R* ^ .release = led_dev_release,
* J6 z' E5 g |) m- o6 r6 O }9 M r& z+ I7 w
};; [; `; }. ^7 d* i' t7 R0 _) C
7 S* b( X3 p: s, g- Dstatic int __init led_platform_init(void)
4 M7 H# C7 k# t{
" q; a! C& s- Z1 W int ret;2 {% t6 B, w2 w1 Q2 j
#if 0 J3 w/ b) W- ]: b8 L* C( O S
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 E/ Z4 T/ \1 g5 `! B/ R if (ret)
: R/ \: @6 ~$ Q/ n$ I2 r1 S* b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" ?8 \7 m- i1 x* H0 o7 D/ ` "%d\n", ret);, J* B) h% y- c4 p$ S" t
#endif
' c5 ^9 G: G. t$ I6 Z ret = platform_device_register(&da850_evm_tl_leds_device);
`' a+ }4 T' y if (ret)& k' A" ^; I3 T- u4 J
pr_warning("Could not register som GPIO expander LEDS");
1 I: M$ \2 y, Q4 v: k$ j else
" E- U* c# \. w6 ]. P printk(KERN_INFO "LED register sucessful!\n");' n$ g9 Y) L8 D7 A# Y
2 n _& P. F) @ V3 ~+ @
return ret;3 Z- w; }- ^$ W( l. W7 s
}
* m( o6 \/ m7 U' s( `# D/ j4 V6 l! ?5 w4 P
static void __exit led_platform_exit(void)' ]- D1 t) W* R O/ j
{# r' _: n4 H1 e' o+ i# s
platform_device_unregister(&da850_evm_tl_leds_device);3 Z' B& N0 O. [# k4 t+ J
/ S4 O( d' g, i" P# t7 W6 M4 k
printk(KERN_INFO "LED unregister!\n");
7 W+ a, @: |" m" G$ X}
5 V* j- U; g, N8 C5 g- J5 m: Q ]# @ I. |3 Y
module_init(led_platform_init);
! |' k- t+ l( `4 |module_exit(led_platform_exit);5 R e5 y4 ?) V+ n' [
# ~, y% q5 e% t5 q: I. D2 R$ XMODULE_DESCRIPTION("Led platform driver");; |$ d& P. {9 b+ T: O9 ?
MODULE_AUTHOR("Tronlong");
, h; Q/ H7 w, ~1 ZMODULE_LICENSE("GPL");# I$ P: o. i; E9 q) \
6 n4 N9 E) e! J+ x; ~) s5 Q |
|