|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- E/ r Z, C3 |' e7 H
#include <linux/init.h>: A- y0 {9 A( i7 E
#include <linux/module.h>
3 z$ a: G& j& u0 g+ T#include <linux/kernel.h># q4 u: l* I6 T1 n. k
#include <linux/types.h>
3 N: v. l1 Q' L, y! P#include <linux/gpio.h>
( B6 L6 c3 t) q8 M+ e' n. S#include <linux/leds.h>
& V6 J" G+ s' ^9 w" c$ z [#include <linux/platform_device.h>/ C8 H7 }% A! r
: d2 u, U9 [- d0 Q2 W" z#include <asm/mach-types.h>3 g5 U/ I/ ]7 N+ Z& d1 Y/ |
#include <asm/mach/arch.h>
$ ]( A+ x5 }& H" I#include <mach/da8xx.h>
6 G) o# w' Z+ j0 \3 \, Z5 \#include <mach/mux.h>$ j3 s) b6 f6 N/ L5 L; F
( v' f% \7 d. ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- l/ q5 }! ^ H' e+ d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 O' O& b. u* m2 w! `$ s
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). y% E. L' C7 [5 V5 Q+ `- k+ @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& k7 |. o8 @9 o: k& v# I. L& p
2 {" p$ V: \( A7 ?% K+ ?
/* assign the tl som board LED-GPIOs*/
- N0 h O1 f' c" astatic const short da850_evm_tl_user_led_pins[] = {' i I* b& a' s- x. x2 ~7 K
/* These pins are definition at <mach/mux.h> file */
& F, j7 j) e" y: ^# M3 O/ ?" k4 n DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ r1 G! R- _5 Q -1
. v+ F7 M& M) _};
0 _% c- Q& ]! s* P$ ]( b# H+ m* X0 a- x' C7 p5 W/ S* n* o+ w
static struct gpio_led da850_evm_tl_leds[] = {* K* C+ Z# ?- t* O+ d, r
{
, _8 l }. f5 K4 u" i .active_low = 0,
: c, B; n4 l# |$ {% K .gpio = DA850_USER_LED0,
3 k' {, h1 Q, E6 v1 ] Y# N' C .name = "user_led0",
3 ~% \; k% ^' p6 B .default_trigger = "default-on",
/ C0 {, z! R o S4 O3 e; h, F- | },
2 }/ G7 L5 V4 x, E" r {6 D- n% p0 l7 J2 Y0 R" ]
.active_low = 0,
& n5 A6 H4 p- `& a .gpio = DA850_USER_LED1,
- Z! O- K6 Q/ p .name = "user_led1",
8 N6 J$ b, u5 ~2 q .default_trigger = "default-on",6 J4 q8 `. C! `3 t7 T
},
K3 E, c% d" M1 ^! a& ]' [ {
! z/ G* V4 h+ L d .active_low = 0,( i! s4 M- R% t6 s- M
.gpio = DA850_USER_LED2,6 {: q6 M0 U# Z, c; u N
.name = "user_led2",
/ E, J, J0 g( U* E9 Z: ~; e .default_trigger = "default-on",4 K6 W6 f* O0 c( t( b
},
6 `9 k' X; M7 Q9 M7 Y {" X& W" k- E/ h6 d# ~& d% m6 K
.active_low = 0,- X1 c; m F# R9 M" g; P
.gpio = DA850_USER_LED3,( H$ O5 `" v+ }7 _, B6 W4 A
.name = "user_led3",- h6 T" {7 J$ M4 { Q* r
.default_trigger = "default-on",; G0 H" o( l. E
},; R |) }3 K4 O2 f( i! B! _
};
( ~; r4 a9 ]7 M6 W+ k6 t! [9 p2 x# f3 @. ?5 g% I4 s* S3 B* ]4 l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 H+ }3 t7 a, e, G& Q7 ]- ]9 d .leds = da850_evm_tl_leds,( `8 g3 u/ b$ @& e: F
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, w5 W7 u& d0 e+ \% K};; @4 }8 N- ?# s0 @& E
. X% h. o9 G; F4 Wstatic void led_dev_release(struct device *dev)
/ R5 I" V; c9 i3 j4 [9 X{
& k7 M; G+ Z" t/ l6 n7 o};
1 X1 a: z( i! M3 j2 u
4 J! F. @2 E9 U9 V+ l: v, M2 h( `static struct platform_device da850_evm_tl_leds_device = {
) n }' Z1 u/ T6 k1 m& ` .name = "leds-gpio",
& T! x5 h' S) e& M, s9 U$ z .id = 1,
6 u) e4 x6 i. x3 F .dev = {
+ X- A) a1 u3 d. t .platform_data = &da850_evm_tl_leds_pdata,; }. B* Q/ g; N+ B
.release = led_dev_release,& j" T: v; }! i" A h, `7 c/ B; g( {
}, ?3 A, X7 A, `2 Q
};
) y5 t7 O% w# p( C
0 ]* u1 v8 b* N: r. z6 `static int __init led_platform_init(void)' M! X* y+ y* r. m/ ~" @; e- R, K
{! O( O& w! S0 g, p9 T+ b
int ret;
" \5 N. l+ l8 C3 e#if 0! d5 |' n2 Q s$ v# e/ @; A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! C* U) F9 l; C# `" v+ d% K/ c
if (ret)% g5 `1 u" ?5 M1 D8 F
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' S5 o6 g! ^+ R( y+ C
"%d\n", ret);; H; \: s: r1 Q/ k' T2 r* A3 i
#endif
3 M5 x" o2 s: u9 H& J0 E: H ret = platform_device_register(&da850_evm_tl_leds_device);/ I0 c% Y* h3 k/ f) l# {* }
if (ret)
! m7 h* Y2 `' J pr_warning("Could not register som GPIO expander LEDS");8 I* g. E. b M, U. y
else
7 s6 F! e) ]( ]' O) V8 z printk(KERN_INFO "LED register sucessful!\n");- {- h+ u* ^3 \ e) s* ~
6 `+ f+ v, Y- X2 G5 [ F% G return ret;
" e5 g% y6 n0 |0 }: k0 {. f5 r}
: `) B( {, C0 J! S. g
" B% H, v+ w" P0 I; `static void __exit led_platform_exit(void)
5 |5 b' ^6 X* c, E, U6 v{
" o9 I9 C- N! w0 u) _" }" `( f platform_device_unregister(&da850_evm_tl_leds_device);4 Q9 x& \) s, v4 ^
. |& {& u5 _. D1 R) ^ I4 U4 N& g
printk(KERN_INFO "LED unregister!\n");
+ a. X2 {% r% h; y) j {0 C, d}
3 q$ L; S y8 g3 Z
5 L' f) K0 i7 q! z3 q9 fmodule_init(led_platform_init);
3 f$ s; B/ j1 Q; |! o0 Gmodule_exit(led_platform_exit);
' O, x9 A) Q: e6 i( P' p3 U! W. r$ u
MODULE_DESCRIPTION("Led platform driver");
# }" H. J0 u" K8 {! W! X6 g5 C0 q+ EMODULE_AUTHOR("Tronlong");; E( Q7 L) J1 z# S4 J
MODULE_LICENSE("GPL");% q/ E- h1 f) w, A
$ [( d9 [/ ]3 N3 k3 K- p |
|