|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ E% j( D( d! y |' U#include <linux/init.h>2 g' y' W9 N, f* A! V' G, E4 P, }
#include <linux/module.h>, u1 U( t0 I0 F: v! O2 V
#include <linux/kernel.h>6 h6 R2 e J" B( E, B) \: }- W! x/ K
#include <linux/types.h>
7 X( F' X' s# l; S7 }#include <linux/gpio.h>
' w' w+ R n! J _: @* {3 }( l#include <linux/leds.h>
( ?8 X, L$ ^+ b( {, |#include <linux/platform_device.h>
! [" t2 f. ]7 ^4 M9 Y2 e8 Z6 U5 j& l5 [' V' D! x
#include <asm/mach-types.h>0 [, D+ A" l& G$ y, Z
#include <asm/mach/arch.h>, K) E7 a! T+ s( J# ~& R
#include <mach/da8xx.h>
7 k/ r: O( C- z4 {+ m3 N#include <mach/mux.h>
1 P! J# @2 f* E6 y4 K3 R# [' [( r
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% j! O. L1 M& J% }$ R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 e; H8 X2 N9 W9 w' ]/ a+ }- p6 v
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
|/ R* b. H6 o" p& b#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 B2 y- b" j2 G+ }4 o! g
4 Q+ y. l% V: o2 A0 t5 [
/* assign the tl som board LED-GPIOs*/
% k3 E7 B0 |+ A' } \" Pstatic const short da850_evm_tl_user_led_pins[] = {* n4 l6 W" F4 D
/* These pins are definition at <mach/mux.h> file */1 d( h, y3 F4 n* g9 ^% {6 [- }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 h, o2 g' x% _6 ^ -1+ [7 m. ?; i( N
};
( N6 w! B$ l! r1 F& }) E2 P2 T# O& G
% x7 L0 Y+ }& p; ]! o5 ~static struct gpio_led da850_evm_tl_leds[] = {" V: x9 @) ^3 I4 c2 u
{
1 J4 w+ u0 }" G1 ~8 D; W. t1 ~ .active_low = 0,
( T+ ~) m! d* e& u3 t- q5 ?) Z .gpio = DA850_USER_LED0,
) C, G( F# ?, u3 ]8 N4 T .name = "user_led0",+ }. `, Q1 v w1 k8 f
.default_trigger = "default-on",6 w8 A: \8 o4 F' @. G, e
},
4 A4 O" y% p. I$ a. Z% w, m$ q3 L ^ {
! c1 P* E" C d4 M4 l) W9 m .active_low = 0,
2 ?/ P9 w5 J* t# a0 N .gpio = DA850_USER_LED1,! ~( c" k* P# S7 {! c, [; f
.name = "user_led1",
. ^+ w S1 N7 f! _- y: I .default_trigger = "default-on",
/ c- z1 K' Z" n$ f },) q4 G- u, i1 H
{
$ C0 D1 ^+ ]% G+ z l& Y .active_low = 0,
+ W: E- ^$ e& n .gpio = DA850_USER_LED2,
: w: G$ N, D2 v. H4 P. @ .name = "user_led2",
" N& L0 z" x7 n5 K, g( F .default_trigger = "default-on",/ Y. ~4 R- h: w: L
},! f) b) C4 n5 H# r* V; r0 z: ~3 S3 ]) O: r
{) @+ m' P1 R7 y. z0 g! B$ x, k# }
.active_low = 0,
4 I. G, |$ N6 ?+ Z. [' P+ f .gpio = DA850_USER_LED3,
/ }4 p" g7 p8 Q4 a' k7 z .name = "user_led3",
. N6 H* a: i) s* T2 u .default_trigger = "default-on",
9 C' V) o7 Q' s/ N% Q0 \# J },, a8 T& H# Z& R- s n, W) s
};
( S! z3 O* s3 C$ y1 W2 w
& B; l: I: K% rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 t* b7 a9 l5 W .leds = da850_evm_tl_leds,
1 M( @' w+ Z; O! X) T: } .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* K% @! h# J0 z8 D/ }
};( \# Q' E- Q- L; I
$ o- n: S5 J4 } a8 E" \) W# \
static void led_dev_release(struct device *dev)
: b4 G; o2 L% a3 s* S9 V9 C6 x9 t2 [{
/ u# m3 t/ T: T/ R0 t6 ]; y) J+ Q/ A1 V};
! q, N' }* {% b8 H1 r8 x" k" h( w( I& d
static struct platform_device da850_evm_tl_leds_device = {
# y- x3 w; P8 p& ]0 w: g .name = "leds-gpio",
* n; @& u- K4 |6 D .id = 1,
! ^! d0 w0 u$ Y0 S7 Q .dev = {9 A5 W' O9 K, [$ J' K" m
.platform_data = &da850_evm_tl_leds_pdata,# d7 d( | w* F) G% X
.release = led_dev_release,5 L8 c# @& Z1 i8 f7 e/ ?
}
' q9 p3 i. Q% Y$ L};
6 l9 T" \0 h2 ]2 M/ U) ]$ A" N9 _/ i7 O, b& w% |3 G1 G
static int __init led_platform_init(void)& V w4 w$ J/ T
{
2 ?$ g( [/ [: q: }2 p$ t! U int ret;) L! X4 ?% O4 u: b @5 V
#if 0
' b( p( n! |* I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 |' x" G/ z: b& g* N5 M4 G! a2 m
if (ret)
6 N/ N' Z6 O2 ]# r: Y/ m pr_warning("da850_evm_tl_leds_init : User LED mux failed :": B! s& c2 K( H
"%d\n", ret);( \0 |! \9 Q( Z! h1 T9 ^/ }
#endif, `3 p# l* i% ?1 F
ret = platform_device_register(&da850_evm_tl_leds_device);
3 \6 B% O$ W E) i+ c if (ret)
* c" r0 V y" }, `! n2 I pr_warning("Could not register som GPIO expander LEDS");) K5 }2 j, w" _. U ~8 r
else" u3 W" B% ~! B h7 L, ]+ {
printk(KERN_INFO "LED register sucessful!\n");
5 A: E2 N. u* \. W
6 R+ ?! `; S" C( @& J9 {: _ return ret; Z& c" y+ y' P# L z9 Y3 p
}
% S) K8 s- a. b5 c# e7 d2 v; }* Q) E4 Z! N# a
static void __exit led_platform_exit(void)0 I9 [! `) {9 v2 @# h9 V; ?$ ~+ P# g
{
4 V- i d1 T6 b platform_device_unregister(&da850_evm_tl_leds_device);
7 V" a/ q0 j0 q/ q3 T$ }5 d- x& r. | l8 Q& F
printk(KERN_INFO "LED unregister!\n");
1 ]4 X5 h, K }) O) V- Y: l}6 y7 X, v% X1 c6 X* y+ p
! o: U' Q, G* f- s k( r7 d& C
module_init(led_platform_init);
0 I7 Z; L; u7 H# \, I' D( @5 |module_exit(led_platform_exit);' ^' U) G0 l$ F! T$ u6 Q
7 E% b; `6 Z5 k* z
MODULE_DESCRIPTION("Led platform driver");
8 v/ O% X1 O. f. yMODULE_AUTHOR("Tronlong");# I' Y$ T! O4 J3 G# h* B2 X. `
MODULE_LICENSE("GPL");
/ H6 D) n6 x# w, x1 e/ C7 ]( O7 ?1 m& r6 x& C2 ?- s
|
|