|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ L1 C% x2 Z. F: b1 D3 J# }
#include <linux/init.h>- E$ _0 x3 C; _3 ?2 O, W. s
#include <linux/module.h>
8 H( W* Z; o. T4 v0 L#include <linux/kernel.h>
- }: k! C' R; ~$ s- Z#include <linux/types.h>. u% `6 M, `( U; L/ q3 J: B! f3 O
#include <linux/gpio.h># u4 f! G: A8 Q: L
#include <linux/leds.h>. N' N5 b! m6 f q1 s3 C$ p* F7 |( B
#include <linux/platform_device.h>! j$ q- m. i- t. M- H9 N
+ k7 c7 w8 w7 k Z6 h6 ^' W' Y#include <asm/mach-types.h># o9 x7 }3 l( C1 N
#include <asm/mach/arch.h>
+ V; r. ]2 g, w* l* D R. @#include <mach/da8xx.h>
- L) \8 c6 a- y5 W+ x% t#include <mach/mux.h>8 N4 q" ~* V+ \) m) G
1 L: i) i$ \5 H6 F' \# Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 g# ^, f8 O" }8 L% H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( O H$ h$ } o# U3 n R0 x/ a! n
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ A/ ~. ~0 W0 X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) H* d- n* {: l2 t! _
) E: [7 H6 ]' A5 c. Z/* assign the tl som board LED-GPIOs*/9 P# Q' q1 {9 r8 X
static const short da850_evm_tl_user_led_pins[] = {* m3 ?# T* [9 f, S$ V) K
/* These pins are definition at <mach/mux.h> file */% Z: P" d. K' s0 C
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 G2 `: P5 P, M7 P
-1* H9 t; s$ h; r
};% M! y# J& {# [* Q
' h* D0 N: u$ E1 s" J- L
static struct gpio_led da850_evm_tl_leds[] = {
: s( u5 B% ?7 Z Z; H) E0 G0 N {; _0 E" u- [6 }' h* o; S
.active_low = 0,
" F: Y- n& r" ?0 Q .gpio = DA850_USER_LED0,3 _8 F9 H7 _3 p+ w7 ]0 q
.name = "user_led0",
9 ?# d9 ~1 c- }5 a& L. p9 f .default_trigger = "default-on",
' u: [1 L8 ~( q" E },
/ f/ Q/ G* G" U& X% V0 Z! Q" u {
2 D' q0 O) M1 o9 V( R+ f) d .active_low = 0,% {9 v* r( S Z8 x
.gpio = DA850_USER_LED1,
" E' N7 U' y, j .name = "user_led1",, T- e Y/ U1 ~. k
.default_trigger = "default-on",
9 v- X' X6 j( V8 L+ F1 B },5 {9 ]) m2 R. ]
{3 |0 [; F2 k" M3 w9 v' Z- e3 O
.active_low = 0,
* k0 }$ N) e7 C% _; g& Q .gpio = DA850_USER_LED2,
+ R2 c- L; N3 S. _ .name = "user_led2",
: R# A- _% V% g& S .default_trigger = "default-on",2 V8 m& v8 X: l9 Q. L( ^
},
4 T! Y9 H5 U4 d {
* k. j, ~* T6 T! c9 Q n E# O4 _9 t .active_low = 0,
( A0 n t; |9 C1 ?5 Q4 m) D .gpio = DA850_USER_LED3,. w: j- n) Y, N% w/ T) D) i
.name = "user_led3",
# `& K% P- ]3 `& R6 m& _. c+ o .default_trigger = "default-on",
: g3 U4 T6 m, s6 L: d6 G: { },' z: C3 t! I" L
};
5 u6 O, H7 V( Q$ H4 j5 I- }- k$ n# G4 G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: I* n& m! }- D+ Z3 a& E3 \
.leds = da850_evm_tl_leds,
' I5 ^ @& k- l8 U+ [8 L) ] .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# G P, L7 ~. o# y# O( ]+ H};. J2 v, S) x! | y8 v6 H
a5 k; }( t3 y( ]* {2 A% L `% z7 ?static void led_dev_release(struct device *dev)6 w* o1 I, n/ {% y7 b% I
{
, |: E# H$ H7 h( S! g8 b4 L};
- n1 I) E6 o8 C$ w4 |* t
8 n) Q3 B2 e' u2 V" c l6 nstatic struct platform_device da850_evm_tl_leds_device = {
9 c2 S" |% w( O .name = "leds-gpio",
, {7 @3 j9 p/ U% N5 J- S .id = 1,
1 y( r5 ]7 }1 i* k .dev = {' N, H; c( e! y; P% i
.platform_data = &da850_evm_tl_leds_pdata,4 V9 F4 ~" Q6 h" `2 c5 |. s
.release = led_dev_release,4 y+ ^: ^8 w: k3 b
}8 s, O1 \; [0 x2 Q* ~ E' v
};7 O# J% T* ?/ D& R
8 r0 L4 r2 o/ |) h4 Rstatic int __init led_platform_init(void)
, a8 S+ R: f9 k1 p2 J1 Q/ w" |{
4 G9 h8 X( b( k int ret;
9 y! y* b d" x7 d0 e#if 0+ a/ e. F: \- `1 {5 t
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ u8 K9 r1 A2 J4 ]2 c$ ?! E if (ret)
3 N P& s$ J d* Q& q4 N4 P" ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 k k# y [: I A
"%d\n", ret);
7 `$ D6 [! }, ?9 s5 w* d#endif4 |0 x# h8 A2 [ g, y. ~
ret = platform_device_register(&da850_evm_tl_leds_device);, Q9 |0 z" e- T8 V# L$ m9 t
if (ret); s3 n/ @" J) x- q, A) y- X* [1 R
pr_warning("Could not register som GPIO expander LEDS");
8 K: {3 w5 S2 } else+ b( K) B# d3 ]3 o
printk(KERN_INFO "LED register sucessful!\n");; v s5 y V' x- x6 ? j5 Y! ?
# t/ C% o# ?* Y& t, b& M7 ^+ M
return ret;
6 `9 T+ U( I! h! y3 P) C4 e}
+ ^* p8 P# ~4 A# X' O' ^1 ]
U9 r( n0 m% Cstatic void __exit led_platform_exit(void)
/ f" k9 A. b8 f0 k& H{
, i: j- P, R' K platform_device_unregister(&da850_evm_tl_leds_device);
* e; d- H/ a" J$ q3 J E2 j9 L
8 H: ]. A6 y$ @3 y! R printk(KERN_INFO "LED unregister!\n");$ g+ C- o {* c: N$ q1 e8 @3 R. V
}
5 G9 [) D! t& G0 A
) J3 Y) v' X( Z! Nmodule_init(led_platform_init);; |) h) e$ T6 b# j9 `+ \
module_exit(led_platform_exit);, e: @7 W. v* s- d% D9 l+ ~
* o3 E4 g+ l" v7 R) z y+ x
MODULE_DESCRIPTION("Led platform driver");
/ |9 c6 \, Z4 o. W: TMODULE_AUTHOR("Tronlong");. a( _/ L: r' h% q
MODULE_LICENSE("GPL");0 b& v( P" y# \; J
* m5 ^3 @! a, E$ S9 p9 w |
|