|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ e6 h* O& o! |% o4 H! w#include <linux/init.h>$ o% C: {- L" S6 V6 D! q
#include <linux/module.h>
+ [' m" y& K8 d a#include <linux/kernel.h>" q* X; `/ ` M) m, N+ [' t Z
#include <linux/types.h>0 S0 z8 ^: o& V$ [' _1 N
#include <linux/gpio.h># f, A! I) `% _& f( D
#include <linux/leds.h>; B9 S5 G( {& l+ ?7 q; t1 p6 {5 Z
#include <linux/platform_device.h>
) d _( y/ R, Z! A4 N, r8 o" h. |9 r E8 N4 s8 e6 ^7 Y2 h# G
#include <asm/mach-types.h>
( O; h. |5 n/ x: w/ w#include <asm/mach/arch.h>
" N; Q& w- A* Z2 Q3 Y- R" S#include <mach/da8xx.h>% C/ r" p# d3 }+ M
#include <mach/mux.h>
, c/ s) y# F$ q" {0 R$ e( M: a' K+ h& c9 O
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): T' ^5 X/ O4 P8 g4 s# A- {, Z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# j t7 Y* O0 B+ q; y$ r. y: a1 x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ R. C; S" ? p8 V# ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) e, V q2 U. {" q' s
8 ]1 _ E" V( u6 ~2 s+ p8 v
/* assign the tl som board LED-GPIOs*/* `8 u9 N6 M6 w3 B
static const short da850_evm_tl_user_led_pins[] = {# I+ ]. E; W5 a& `; z
/* These pins are definition at <mach/mux.h> file */. _* ]8 U- a: D$ w0 p
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
k1 m* X+ f! ^# N+ Q- q' Q! w -1
# r, A! A" C! W: {};
" m" z1 z" Q, O1 U1 N) ^7 a! G) V; L( y2 X/ S& B
static struct gpio_led da850_evm_tl_leds[] = {/ ?7 b" M+ d8 j, g
{) Z* z5 q% {+ g L
.active_low = 0,
+ f: a: k Y0 X1 a1 \ .gpio = DA850_USER_LED0,
: l& b6 p) p$ x$ ?; w& e/ e$ \ .name = "user_led0",5 C; n- ?0 J, j
.default_trigger = "default-on",* h/ U% N$ r9 o7 P- l2 h5 U
},4 [6 s, k( Z' ~! a$ s
{; A, T3 ~/ v: M) _1 x( V
.active_low = 0,
7 k7 G; k$ D; p0 o .gpio = DA850_USER_LED1,( a, F1 `5 t' Z3 S; v2 w- L4 v
.name = "user_led1",. {6 s, {2 M% }" y! o; E" B
.default_trigger = "default-on",
. X. Y% V3 |$ u. v+ l6 k },
7 v) x: R* r1 m; i; S {
, v+ w7 i) a3 S/ v9 n .active_low = 0,$ a+ \# G6 s9 X. L3 x
.gpio = DA850_USER_LED2,7 f; c# v& N- c/ M: R
.name = "user_led2",; d9 v/ c5 k* X6 u( ^9 j
.default_trigger = "default-on",$ U! O& g4 t7 a6 W. s& X
},
% Q8 W" o6 s: d, O5 d {8 J. Z' H+ i* l7 }+ T# j1 v# C
.active_low = 0,
' N8 P* f0 I+ o2 y* e .gpio = DA850_USER_LED3,: R2 k" y$ X8 G+ f
.name = "user_led3",
% S& q0 Z- y- X6 m0 p .default_trigger = "default-on",9 O% }/ E) v9 Q9 U
},
. L! u. L* v8 t" v- z};
. D0 g9 N1 |7 b) v% R1 o3 G7 |3 `
+ u R9 M9 \ K$ Y. n7 k& q! t. xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; U4 Z" Q0 X3 k$ `' m8 P" b% Q* F
.leds = da850_evm_tl_leds,
0 |" r Y5 D4 [$ g* a0 p .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* } F( e4 S8 _# Y
};
/ u- V$ m; f$ o7 n4 r
5 o! {+ N* n. {* Y5 ustatic void led_dev_release(struct device *dev) `" s3 G9 w! {9 G
{
1 ]: V! h6 k g- K/ y+ B};
0 }6 ]" ^+ Y+ e) o+ u& _" W- T7 i( s- n7 g0 A
static struct platform_device da850_evm_tl_leds_device = {$ r7 j$ T" s+ ]+ ?. @* _4 O- ^
.name = "leds-gpio",) n% l Q5 Q/ V. h0 ~
.id = 1,* X( P1 ^. q7 T* u1 t
.dev = {9 w# b+ H3 P4 b5 P9 V4 P
.platform_data = &da850_evm_tl_leds_pdata,1 w* |* H/ n* a% T4 G( t
.release = led_dev_release,
6 ?8 y; g4 k$ \0 h6 \; q" f: g }9 T4 s' q; o8 t3 s: m! P' ^
};
- j; ]7 y& I, [- D; G
8 {7 F# u2 Z3 }/ f& ustatic int __init led_platform_init(void), X& W3 D. E+ }( q; I+ ?5 r
{
/ j* i, n& |& D" h% T8 \$ ` int ret;: K0 Y( ^! m4 E
#if 0
* A3 Q' R0 E! [8 e; K0 Q6 k+ N ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& E8 u) N/ |- K& y+ Q' x$ ]6 J+ t
if (ret)3 R; x/ V# Y: o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :": O- O6 c+ e0 T, w- O( Z! k% ^
"%d\n", ret);, c* }) Q& e$ U+ d
#endif/ C9 N" J [* x3 \; g
ret = platform_device_register(&da850_evm_tl_leds_device);
# u, w9 ?7 O2 I, i( b. c. y& j if (ret); C8 ?2 P2 U5 T. @% D
pr_warning("Could not register som GPIO expander LEDS");$ n2 V5 w7 G1 K. w/ W0 w! P
else
+ |8 D! d5 c! U* ? printk(KERN_INFO "LED register sucessful!\n");
. l3 A, O4 O; M
$ A# y) H) m2 h4 _ return ret;) x# m3 _& h! q; u1 q6 D
}% U, N: L5 r/ N) I3 q5 w1 e, h
/ N5 S& D1 o4 v- kstatic void __exit led_platform_exit(void)
# Y' k: t( G* ` a( i9 w8 o& ?{
: Q. T0 [6 L+ z" z platform_device_unregister(&da850_evm_tl_leds_device);7 ]6 S- v8 X. w
# \5 v9 u K9 i4 m, { printk(KERN_INFO "LED unregister!\n");
5 X: ?+ n9 E: X: N}' q3 F" X. s# ~0 ^ ?7 v
8 ]( K: y9 N5 g4 [3 G( `* Bmodule_init(led_platform_init);, l3 V- n. ^, O
module_exit(led_platform_exit);) U0 X7 x% ~; ^' }1 v9 {6 B0 @/ O
6 o& \& x) _' n* c2 ?# T2 L4 s
MODULE_DESCRIPTION("Led platform driver");* q! @6 X8 F T* N) }
MODULE_AUTHOR("Tronlong");0 t! ?; i) Y7 c
MODULE_LICENSE("GPL");2 R1 D2 p( r4 t1 _& E5 P0 c
! j9 N; u7 b3 t* d: K4 C: X
|
|