|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ S/ _9 f9 [9 n& V2 i# w* k
#include <linux/init.h>- U; T! Z: a0 u
#include <linux/module.h>
1 |5 n% v: ]; Y9 O! Q6 @4 t#include <linux/kernel.h>
- D4 M# u" ~: K8 ]#include <linux/types.h>. ~1 R" j7 `3 O! q \" F. {( c+ f
#include <linux/gpio.h>
; v4 I5 p7 G# [9 k" ]" C#include <linux/leds.h>
V+ y" |; Z: K7 T) T#include <linux/platform_device.h>
6 r5 P/ C# M+ U- F- s) W, {4 q* W
#include <asm/mach-types.h>
! Q- Z J$ O) }1 ^#include <asm/mach/arch.h>
3 ^/ Q! h* X% J7 \) N3 X# p% ^- b#include <mach/da8xx.h>
0 ?% H7 L/ H) R, C#include <mach/mux.h>5 X5 \3 E' H$ m6 U* @4 J, Z% j/ u
, [- M+ z3 J4 H5 Z1 R7 a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' Z) z0 P! n' v1 L# Q$ H" f#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( B+ T+ E8 D2 Y/ y7 G7 B#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 g( R( d, l( r$ J) ` _2 h& W( w; [#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ ~+ [+ [& S9 J) h1 y/ p% p2 @
7 Z1 F s1 o/ g# Q6 q, h/ q
/* assign the tl som board LED-GPIOs*/
$ \0 ?# @4 w2 r* K$ cstatic const short da850_evm_tl_user_led_pins[] = {' E1 f% F( t, n6 Q( |& ]
/* These pins are definition at <mach/mux.h> file */2 G/ b, L5 q) s: ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* ]4 f, \ V0 p: f
-1 p( _2 V/ Z" v* f* K( t6 d" I/ G& f, q
};7 G$ k+ j) V5 E+ h$ V0 R
: q2 L$ V) I1 h+ A+ o9 Y! n
static struct gpio_led da850_evm_tl_leds[] = {
! ]6 i7 S' T: ]1 p9 \3 `! a {
% L s! J- a$ M .active_low = 0,
7 C* q3 \4 H! E8 L) E e+ w .gpio = DA850_USER_LED0,$ ~$ M% }/ G3 A; Z7 B
.name = "user_led0",4 ]/ `7 V Q8 F/ {0 {# C8 B
.default_trigger = "default-on",
2 l/ c0 m1 d( |0 L4 z4 _$ y },
+ |& ^$ g7 {) }! V, S/ u2 H# | {6 W4 |. H( m1 e
.active_low = 0," q( s6 w6 e5 N, z9 A2 i2 z
.gpio = DA850_USER_LED1,
* |% ^ D6 v. s! r! z: w .name = "user_led1",0 S. O& H8 v# }6 L9 p0 q
.default_trigger = "default-on",
1 s; `* a; W) Y0 l$ g8 i. z) ]0 k },
( E9 O# y6 d0 H6 z$ I) m {, ]0 b. x- ^* g$ F& O+ ]$ C6 ?
.active_low = 0,+ U A% B W8 X
.gpio = DA850_USER_LED2,/ m i0 J/ {, i
.name = "user_led2",
$ D$ Q% `3 H8 R- S5 M; f6 @9 H8 y .default_trigger = "default-on",
& a' R/ d3 `4 h },
+ b8 [6 V: b4 z5 ~& j' v' u5 m, l {6 V4 f2 w8 t8 X8 f; }
.active_low = 0,
8 |0 f/ f% |+ j8 K a .gpio = DA850_USER_LED3,5 @ z7 H* E+ c. a B" A
.name = "user_led3",
% d- t4 T% H8 ]' K& @ .default_trigger = "default-on",
U6 b0 L, l& s! U0 V },
4 E1 M- I) P" g' F) V. @ c};
: y- e) N! M( ]$ n3 |2 G( J" W+ Z# ], m* s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 G w% r: W5 A% f0 i .leds = da850_evm_tl_leds,
' |# q( o" S7 y9 I: T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 _0 \7 b3 b7 I9 ?( t( c6 _
};& V8 c( ]* v1 {% \8 b" s
3 y, Q: a. O* A5 Kstatic void led_dev_release(struct device *dev)
" H0 V5 e5 W! {8 A+ |/ o$ m{
% }' \: V. p5 M ~% } ~};8 [0 J. `) j* o3 M+ q
, A6 C% s4 o- k1 J, [
static struct platform_device da850_evm_tl_leds_device = {
% _9 t" T5 [% G) Z3 w+ Y .name = "leds-gpio",
8 L: a, A: s5 H" A( H4 C .id = 1,& w1 t6 x: m' K- E( P6 A
.dev = {6 E5 o4 ~; m& t; z5 B* m" M
.platform_data = &da850_evm_tl_leds_pdata,: `, ^7 g- N+ S; y' j6 {+ o) R
.release = led_dev_release,
! _2 k4 s9 I5 ]7 n, V+ |5 |: M }
( H+ @: z, f" r1 E};
5 H' b) i9 A8 q t
9 a9 o- z& L9 ]& F+ l) Qstatic int __init led_platform_init(void)
2 X/ W0 M# D4 F( t: k8 @% G5 @; \{6 [$ W6 R* o5 n! D
int ret;
: _7 ]) ~7 K1 R4 z$ x. U8 I#if 0
) `- R4 V* k4 _7 W6 @9 U ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 e! r- ~6 ^$ m$ A% c& s& t' h
if (ret)
% o0 k- b% h5 t# ?' i H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ C: s3 g! F% M- y [) K
"%d\n", ret);. n3 C- f) `( }
#endif
* a* A0 `3 ]! V; o5 l ret = platform_device_register(&da850_evm_tl_leds_device);& x. I6 ~% }: I# @- Z0 ~4 \
if (ret)9 x2 ^* G/ o: s4 ?- q& t& s* x
pr_warning("Could not register som GPIO expander LEDS");
+ L. u- q3 L. S0 T else
3 X; Q$ A$ L! W+ e- t7 ` printk(KERN_INFO "LED register sucessful!\n");
, o" E! ^3 L' R; Y1 B6 f5 P8 Y
return ret;1 w3 p4 X* p" p% U- l
}
o/ ?- e4 @5 Y# v5 y @( H9 m8 I( {! E( z, r+ l z
static void __exit led_platform_exit(void)+ H, D0 d6 D( h+ }1 \
{
$ p# `% z1 z# o* ?. K% r platform_device_unregister(&da850_evm_tl_leds_device);; h( X4 W" L' O3 M0 m1 o, H
: R7 \7 f5 O3 `: \ printk(KERN_INFO "LED unregister!\n");3 x* Y. q! {0 J0 h( T6 S# q
}$ J% W9 r+ M0 t$ S) W3 h( T+ ?; K
( B; B# N; ?' g
module_init(led_platform_init);& c" A1 ~8 ?# b7 w8 D/ z; ]
module_exit(led_platform_exit);8 N2 g6 _. F$ k5 p, |6 P8 ?4 m
9 |5 e# `. P% }, J- \( s
MODULE_DESCRIPTION("Led platform driver");
% R: z$ N4 b- A/ B p$ r* I+ Z8 q ~MODULE_AUTHOR("Tronlong");! U( W6 r! F, f. {# U0 F, z
MODULE_LICENSE("GPL");
5 |+ \4 V& E5 {1 m9 z) z2 _# K, D6 d% w
|
|