|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ F% B% u* i1 ?9 l- G5 o#include <linux/init.h>, h* s5 l6 h" b. O: V% e1 H
#include <linux/module.h>; Y9 Q# n; ?; ^8 {
#include <linux/kernel.h>' K% i$ S+ b( [7 n: t% ?. z) u
#include <linux/types.h>
. G8 J( m0 O1 X: j* E. T#include <linux/gpio.h>
" ~( a1 ?( ~; f0 O# V#include <linux/leds.h>
4 `, I. O1 w4 o' B9 B; ^! @! X/ |#include <linux/platform_device.h>5 L2 e. g$ W6 J8 S" m4 m4 G
( i5 S6 {: ]/ c# [# \0 x#include <asm/mach-types.h>
6 v6 q$ w! g2 ^' x7 X& x1 Y7 O#include <asm/mach/arch.h>$ l4 j& W. } K- `
#include <mach/da8xx.h>
( }* E& n+ [6 L7 M) Q#include <mach/mux.h>3 n9 w: |$ ~% o: Q
# v1 B/ O" N. p1 w1 @0 G e% x# z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- B3 T+ S z' }#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 ]2 _1 S$ T6 X#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 |# @8 ?( I% k! {5 q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, v4 H; J" f6 s1 f: M g- r6 ~
8 G6 i: {4 r4 h* a4 C8 u. X/* assign the tl som board LED-GPIOs*/
, p1 |4 W7 K/ x! t" ]/ \static const short da850_evm_tl_user_led_pins[] = {+ T+ W3 _4 g4 J. I4 M
/* These pins are definition at <mach/mux.h> file */
- S1 q n, z' {7 i DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) l' Z0 T2 X! n -1
; `6 n7 y% h5 |, @7 U; B};( G. y# a7 w" ~+ c: D$ Y) w* j+ S
9 J: h0 W4 K7 c+ G; C) @; s5 C
static struct gpio_led da850_evm_tl_leds[] = {
y$ X5 m' `: z* T$ N {
& x: p1 P0 x- [- Y, @ .active_low = 0,: R7 [/ B9 J" {: G0 D# V" {9 w
.gpio = DA850_USER_LED0,- t2 `; M, i5 M) `1 q+ Z- G; k! L& N
.name = "user_led0",, r1 L) ]* u: J& R7 ~: E, e
.default_trigger = "default-on",
/ i* W2 @9 S1 | },7 P% U* H# G; Y* R+ q
{% D, T# w" ^* g- e3 _
.active_low = 0,
, i4 u/ N9 e* l* A0 F .gpio = DA850_USER_LED1,
7 d! {0 U( H4 X: n9 i: f5 I1 J .name = "user_led1",8 N: y# D6 l/ i
.default_trigger = "default-on",
( n L% x( A, f2 A2 p/ Q },( k/ t1 y/ t @( s. N: e. ?# M
{
1 A+ ]) R8 D% G8 B% r .active_low = 0,: L5 Y' [! H$ J6 ^- G
.gpio = DA850_USER_LED2,
7 c6 O5 e5 c# Z3 \ Y9 S( a; m .name = "user_led2",* N, M1 }" R) {
.default_trigger = "default-on",+ P$ R7 r6 \# m" X: {! t3 H
},# \- E" k# e. K
{8 n, ?! R$ _' s' w
.active_low = 0,5 u- W" [8 @* y# B# H
.gpio = DA850_USER_LED3,! l% o/ }* H# s0 g8 G, q
.name = "user_led3",- ]( M; j3 W7 u8 W2 i+ `7 k
.default_trigger = "default-on",1 c" Y6 k# ?6 ], n* _
},+ Z* v+ Z E+ s S
};
3 o4 P& z9 U d; r U5 n& b
( R% U# C& P% Y, L8 b9 U' k3 dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 I& f# j) m+ Q
.leds = da850_evm_tl_leds,. b( _5 H! C2 q7 n5 h) o* j( ^* A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' x, [% z4 }* m# Q0 I W
};' u; d1 R% P' ^+ g
( @# U7 `# ]9 D% ~* N: M; Rstatic void led_dev_release(struct device *dev)
/ A$ j! D! p8 [; E0 U' h2 I{4 e5 T5 ]+ P7 g0 T, ^
};1 G' p1 w% U) z/ a
4 z) x- ~4 p2 C: M, V( gstatic struct platform_device da850_evm_tl_leds_device = {
/ u. j' ]4 V! n: {4 s% l" G9 h2 W .name = "leds-gpio",
8 z. P5 a+ A0 O' @( r; l .id = 1,
1 m, u/ P+ g9 d4 r8 p .dev = {" @9 i# |9 b+ X, }- P
.platform_data = &da850_evm_tl_leds_pdata,
# I. u8 z3 D$ m: L/ F. \ .release = led_dev_release,% X) [/ t: E) E1 o+ z$ E1 e
}- d% m( ^8 W8 j w) ^
};% Z5 C; T$ C/ h1 L0 d/ m9 b
& E0 }0 F! H Hstatic int __init led_platform_init(void)7 N4 M$ v: J5 s/ ]4 A& E/ B
{
0 R7 ^( _+ l' v: y2 Y5 Q int ret;" B( U1 l) ]7 n3 J
#if 0# d P1 G7 W7 W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ Q/ F/ e# c. s+ \" p if (ret); F' m8 l, u+ Q6 s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! \5 R. Y& }3 N m) i& d
"%d\n", ret);( D1 [6 C- D1 \* I$ I, c- W% W
#endif5 @8 ?! V4 T, {" ~" e' a9 a! D
ret = platform_device_register(&da850_evm_tl_leds_device);
/ C2 |. d k- |4 B5 a3 I if (ret)
9 F3 E% T$ ^- M pr_warning("Could not register som GPIO expander LEDS");
3 X5 M4 O/ @! b# ~4 i" u0 ? else, J% Y% O, Z# x4 L. C
printk(KERN_INFO "LED register sucessful!\n");
1 L2 D8 T; l$ G4 }; P3 U
7 T: U' j) j7 r8 @# G, P. `0 p. \: r return ret;/ k" h8 m% v' g0 L
}
- E8 a5 |) Z$ V; ~8 ]/ l0 }4 d/ N6 X) W0 @% o
static void __exit led_platform_exit(void)
3 K: F4 Y3 e3 v5 V{
" m- s% ^. Q: y( Q l! W' j# t platform_device_unregister(&da850_evm_tl_leds_device);
9 M) a# |# m- ]9 J
; V& z' x4 q# F) `& W) a printk(KERN_INFO "LED unregister!\n");6 q4 O$ \7 P4 ?- d5 ^* @9 z
}: M- K3 g& S8 r
* z: W* m+ x3 ?' |
module_init(led_platform_init);
6 h4 T+ Z6 ]8 O$ amodule_exit(led_platform_exit);
. \0 T* L( S* U% v( V, t. A" Y7 J+ Z
# m( y7 Z$ `. p8 fMODULE_DESCRIPTION("Led platform driver");" a% [, s, D# a* |7 ~
MODULE_AUTHOR("Tronlong");3 t+ l0 K$ p& t/ p, S9 g& A
MODULE_LICENSE("GPL");4 g+ ~% P: n! j* |
! g+ B3 y) V: P' s
|
|