|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; m; |$ V) c5 W9 I: R- I+ @
#include <linux/init.h>
5 Y* ]) {2 e* @, D#include <linux/module.h>( B3 J+ Q+ i& O5 `
#include <linux/kernel.h>" X1 b- \* x3 X3 r% E1 u+ i% g
#include <linux/types.h>4 H: W" }, t5 E! `* A% r8 W
#include <linux/gpio.h>
" r% N# e* Y, e, ]! J* r# i#include <linux/leds.h>: ^8 ]" N* |- @) v
#include <linux/platform_device.h>' J3 B c( w) s( H9 c
B j7 _+ w9 d. {! i# M0 n#include <asm/mach-types.h>+ L f2 t* `; N- W" c9 b- f
#include <asm/mach/arch.h>5 i6 V C( |/ {+ L
#include <mach/da8xx.h>
- C1 w$ \7 n; H7 n5 |* F& ^4 x; ?#include <mach/mux.h>
5 F2 l3 A; ^' V- f9 {* J; j7 l0 W% c! a: x
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 W' p8 b2 t9 E) u
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ h; _0 V- H2 Q" Z- ?#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* W; x$ ?, ]+ I7 s/ o#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# R# U8 V- P! H+ i, _/ i/ z1 n, q3 h& ^
/* assign the tl som board LED-GPIOs*/- R% g' O0 f$ R7 d2 h0 ?: W$ H3 j- K
static const short da850_evm_tl_user_led_pins[] = {. B b( O4 M+ A# t- u
/* These pins are definition at <mach/mux.h> file */
5 |; r8 A! p$ v4 [ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# J @5 S0 O+ R2 }. E# V
-1
3 M! j! k2 R" Q4 P, W4 C B8 X};; h4 I, i+ \# ^' S0 _* M
) T" l1 v* M$ |7 T7 x5 @% K
static struct gpio_led da850_evm_tl_leds[] = {
# d( Y; [/ U8 G( T3 e8 _ {6 u- @9 W8 ~2 A5 W
.active_low = 0,
' K3 a6 ~! X' _' n: f0 } .gpio = DA850_USER_LED0,
& X% [, _% t! v% M .name = "user_led0",
- M/ W4 e9 a4 W$ ^1 t .default_trigger = "default-on",2 T9 Q& T" v" Z$ Y* P$ \' n/ ]
},
9 _" F [# H( \, _$ g4 r {
5 F6 d" G3 G! u" C, f: T3 f .active_low = 0,
9 ~/ M4 m5 H. k8 E$ u7 c .gpio = DA850_USER_LED1,( M8 d8 ]4 h7 b/ j S5 L
.name = "user_led1",
2 U; ^: K; L( C4 T3 I" @ .default_trigger = "default-on",3 R: A* T4 v- ?5 @" m$ F
},
# x6 }6 d, @0 C; @6 S {
* A [, Q% Q9 P O" w .active_low = 0,
F/ R. x) X |7 F, Q .gpio = DA850_USER_LED2,
1 c0 o: ^- Z* w1 e$ q, W. T .name = "user_led2",
$ L4 j2 l' |* k9 Y. b .default_trigger = "default-on",* a7 ?( C% |5 |; F4 v
}," C6 y& s% e7 [
{
; I% K5 u- z/ y* V: w& ^5 Y .active_low = 0,
, l) M, t/ H( X .gpio = DA850_USER_LED3,
, i$ d! A+ A3 V) F0 g9 t .name = "user_led3",
: P: a8 H% T0 p/ g& A) F: } .default_trigger = "default-on",
% D/ Q/ K" L5 z: \9 R' l },
+ Z# ~- Z) y1 g/ \0 \};
7 @7 ?/ l0 Y! I+ T4 F0 ?' d P; j1 `1 Y4 |* p1 p Z3 V3 Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 R/ p% \! @7 D/ r; v( t
.leds = da850_evm_tl_leds,
0 g$ Y/ d% t; t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 [ c# y, A4 q};
- F* K+ A9 e0 U" Q2 p+ l; d! D, E8 V/ s1 j5 j2 O, z- r+ ?
static void led_dev_release(struct device *dev)
( G4 K/ z6 d; [! ^, e. a) c{! O& N$ D: L P
};
. a8 ]/ p) j% a% o$ q7 A
2 ^! u; ~) f M0 Sstatic struct platform_device da850_evm_tl_leds_device = {! e5 b" o0 q3 }: U" P+ L# b
.name = "leds-gpio",
; r r F2 i! j8 s. K- W* F .id = 1,
, T3 V1 L6 J2 }( \( U) o: C# Y- S$ ~ .dev = {" X l0 I6 v9 z; p- P2 ?
.platform_data = &da850_evm_tl_leds_pdata,3 G' Z4 }: S5 }9 @
.release = led_dev_release,. a' [+ w/ h8 f/ g. {) P7 r
}$ K1 C1 e1 X' C& K* I. j: K
};
4 k7 k$ v: f8 b: T( V" ~6 h5 t# r, i$ q5 B* x/ r& M- ^7 S/ }3 a
static int __init led_platform_init(void)6 p) r9 I. q v1 V
{
; C3 {# h+ X6 g- u2 C% z int ret;
0 g* K4 [+ y6 v4 X; l#if 05 D! b( C, ]3 E9 B) D, ]) B
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' a# ?# X+ I3 M( y
if (ret)
1 @. U a7 t) v" b7 r pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 M4 Z# T, z' n$ b
"%d\n", ret);
+ k% R# s \: a! ^4 y% N" l#endif7 T7 q1 Y" @) ]
ret = platform_device_register(&da850_evm_tl_leds_device);
& F4 h9 m2 e# N. W if (ret)
! F h% ?- n* E! [ ] pr_warning("Could not register som GPIO expander LEDS");) n0 A+ V& [& P% r
else
& ~& n6 `8 e% z4 A7 ^% [% b printk(KERN_INFO "LED register sucessful!\n");
& d7 {* V# G% k+ r& ^
% _0 ~/ H( u# ? return ret;! f1 U3 ^/ p4 h5 ~" E) b
}$ U; X3 \9 m7 I( v: y9 j5 X$ O6 I* A$ S
- t7 I# a. }2 _ \static void __exit led_platform_exit(void)
% L5 m2 g0 z. R" C1 g{
! W- L1 V6 S; u$ A" Y, T platform_device_unregister(&da850_evm_tl_leds_device);8 P, O0 j' H* T7 f7 E6 U' {
1 ? N) w" @* N, f0 T printk(KERN_INFO "LED unregister!\n");
+ j, t, B' J" U/ i7 w' k, j3 I6 R}# I i! V+ l( I W
) H& K# r# c7 M$ L1 ^/ j4 Vmodule_init(led_platform_init);
) x0 m; x3 l F* Z( hmodule_exit(led_platform_exit);
* F! A" i% r" O
7 H) R% j, x! N b7 n& zMODULE_DESCRIPTION("Led platform driver");6 Z" x( q$ H) |( l
MODULE_AUTHOR("Tronlong");1 \# f7 L) ?! A4 v) e- P. P4 F
MODULE_LICENSE("GPL");
0 L/ k: C5 Z4 K( C1 g
1 T. l" j, N6 G( w |
|