|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& }5 r# P% U- B4 v
#include <linux/init.h>
) @& p; N( y3 }#include <linux/module.h>+ N7 {9 ?9 k0 {' A- B
#include <linux/kernel.h>
1 ~5 h9 }9 c: `$ B' l2 V#include <linux/types.h>( V' m J P8 C4 _: `1 a
#include <linux/gpio.h>6 H, ~- Q: }, z+ p+ O2 C; q
#include <linux/leds.h>
0 b; C% B# m% F1 b% s#include <linux/platform_device.h>
" _0 ^9 W' O" ]6 O+ `: f, E9 u+ j) s- w" G3 ]( ~( ]( `! Z
#include <asm/mach-types.h>& o+ s* J6 L; v- l
#include <asm/mach/arch.h>
3 n1 d3 s! b9 B' @2 ]#include <mach/da8xx.h>2 J8 V: _& J9 S( ~2 Z
#include <mach/mux.h>
0 }" K3 s1 D0 s, o7 z) p9 e7 z$ M r1 ^ s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" `; ` p" A! m7 D8 v, R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# S* G6 D, |; ?+ Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" T+ C- W$ m0 m& [0 D& \; j
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 g9 y) ^2 B- n! X) r
6 J/ X- {& B1 s3 O7 f/* assign the tl som board LED-GPIOs*/
3 I0 S( A( o/ C/ hstatic const short da850_evm_tl_user_led_pins[] = {9 P: `/ {8 r) P6 _& b' C
/* These pins are definition at <mach/mux.h> file */* d$ _( o3 y. m ]" Z$ h
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: r g2 S; y3 U& r/ O
-1
D" ?5 V% d2 D0 {+ M* c};$ L# J- o5 t/ k) }" b# L
P1 b' I0 Y& B5 ^- T
static struct gpio_led da850_evm_tl_leds[] = {
, B. W* C- V, l {1 c: A' Q. U# \+ o5 g. d
.active_low = 0,
/ M6 S# ?) Q6 \7 V- m# M .gpio = DA850_USER_LED0,
# o" C+ n, V$ X# O .name = "user_led0",
3 V( R) Q7 J" F% H% G4 g- x .default_trigger = "default-on",
# {& I6 F9 l; A7 {7 O* u },5 t- l) A c( E S. h
{9 O z/ E1 i6 V2 S8 W
.active_low = 0,
# i( f8 b' y( T1 U, y+ V .gpio = DA850_USER_LED1,+ B& C0 j N) [' i
.name = "user_led1",
t8 u. c! C X1 l, s8 {$ Z: e .default_trigger = "default-on",/ R+ s' h' Y7 e5 h% Z! L' Z2 ~
},/ X# w9 D- N: c$ K3 r9 C6 S* l. a
{; s7 N# T, b% @3 {" d
.active_low = 0,
& W+ K+ G! S& Y2 r .gpio = DA850_USER_LED2,8 M; x/ k4 Z/ m/ c% U4 \6 P6 v
.name = "user_led2", ~- h+ C0 J; o# l5 A& G
.default_trigger = "default-on",8 k, F0 K- a: t
},
0 U: x6 L, }6 S% V# G4 x; M _( h {
2 w" Z- R7 V7 w: Y. { .active_low = 0,1 X" L( L# N0 H; ?5 o/ p& X
.gpio = DA850_USER_LED3,/ f' i* E; G1 i/ U, [/ a# |# m
.name = "user_led3",, U- y" Z" d5 e0 J
.default_trigger = "default-on",
$ |* Z0 B- x6 p7 i |) V" u; Y6 i },6 d/ }/ P2 s, Q3 [8 w( i$ M
};# t: A6 |: O3 v, }- F
0 L! \; t9 ^, u& w6 T% _2 kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { G' Y; G& F- o' {8 |
.leds = da850_evm_tl_leds,
, o% c& d7 R3 Z# g# W4 {! e+ W8 P .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 f8 W* _ t8 Z" f% h7 r& }
};- J8 x4 e# s% E( ? E; O" ~
& @( ^& r9 |8 w9 ]8 \2 `( T- ~static void led_dev_release(struct device *dev)
! |/ f/ x; X Y9 O: w{% k6 N# s; U& U: M0 a
};
, m. j' F5 }: h* J. F- L& h' N5 E
! R6 ~# W V9 w' Astatic struct platform_device da850_evm_tl_leds_device = {- g' R7 r+ p4 q3 P4 T1 E
.name = "leds-gpio",/ o" [: W6 x% |% t% k
.id = 1,. Z; a( ?( N. X5 D
.dev = {
0 ~5 @3 c% E& V7 Z .platform_data = &da850_evm_tl_leds_pdata,
/ V# f# j: R% \ .release = led_dev_release,3 R' e) ]* P6 g3 y( z# z, H
}4 f* Z7 z1 L# L) w* ~% y
};' B* s% Q! i5 e0 w
) g( t. b" T' m. R2 U& ]static int __init led_platform_init(void)
5 {9 V- n: k* h$ z: Q f{
# e& s! ]: W1 K% i$ H- ~" | int ret;
4 W7 I4 L1 t: s! l7 i1 {6 N# a#if 0
$ v2 Q) |5 I7 N( m' E$ J5 o3 I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' K- `% l9 ~- L1 o
if (ret)
. K! n& j! y) q: U2 M pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ R* U/ ?% ~) P' J1 e, h( \5 ] "%d\n", ret);" p R: b% x. g3 V% m
#endif5 k- d& l! O8 ~
ret = platform_device_register(&da850_evm_tl_leds_device);5 K$ }8 X, q3 i* T/ h9 @
if (ret)
& c- k# g4 F) u) _0 n pr_warning("Could not register som GPIO expander LEDS");
s' I: B* v4 R6 Q7 V else5 e* \7 L4 S- [0 ~
printk(KERN_INFO "LED register sucessful!\n");6 ?% G# W7 N9 V+ |. `6 [; |7 t
8 @" d" V/ b( ] return ret;) F/ n7 C- N* r& A% k, ^' ]
}3 O, T# a8 T- \- C: y0 A
; o2 K7 V% s. @& e+ _5 s; d. d6 jstatic void __exit led_platform_exit(void)- _2 e0 t( p) c. f
{
$ d2 P$ ~' ~/ l5 t6 g2 |, { platform_device_unregister(&da850_evm_tl_leds_device);6 q/ r2 e( s3 ^# i/ I$ I1 l S
1 c8 ~( w7 b8 Y! L1 h4 B. N
printk(KERN_INFO "LED unregister!\n");, O8 m0 ^ `7 G2 \3 I+ D$ E! L
}
2 k9 P! K4 [' j, Z6 M* Y5 j( _9 c9 \
module_init(led_platform_init);
4 e3 u* d# j& f0 R7 T8 Umodule_exit(led_platform_exit);% z- o7 E Z# J0 {0 i9 y3 u' o( ^
5 W$ @- f9 X4 j5 L+ |MODULE_DESCRIPTION("Led platform driver");
7 q- c W9 e* ~. y: x/ C7 ]MODULE_AUTHOR("Tronlong");
0 \' W( K7 N$ K, ^9 i; FMODULE_LICENSE("GPL");% S0 u0 b% ]% @ F5 B: p; Y
* P0 T, m3 h n |
|