|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, U b/ |1 P0 K9 C8 h
#include <linux/init.h>
* X0 t+ Z; U9 K/ I#include <linux/module.h>
5 S+ \ o& f5 `/ u' `' N- N! [1 a#include <linux/kernel.h>) N5 C3 h; b2 p c0 \& B
#include <linux/types.h>
) D v) I: W5 z7 V8 _#include <linux/gpio.h>8 q" X. q' p0 g0 Q6 m w: \! _
#include <linux/leds.h>2 f# u2 V4 ?0 p, A; o1 \' j$ U) `$ G
#include <linux/platform_device.h>
2 D% d% w! Z- T) q/ R. W6 U2 [0 s, i' ^. e
#include <asm/mach-types.h>( ~2 N: P$ T7 v. x
#include <asm/mach/arch.h>
" Q9 ^& w& y* a& y#include <mach/da8xx.h>" `; C$ }. @! F& A! @ S0 b
#include <mach/mux.h>
6 M c0 L" ?- q& s5 f ?
( @9 b( L5 B8 x) {. K, b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& \5 X! C- ^, h: c- i- u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# _: S1 ]/ i9 O- C; D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" j: ^/ e8 D- h; @. k0 C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: L" o0 D+ n5 n2 o2 ? N% [* q* X% E' T; O1 P$ ~. [
/* assign the tl som board LED-GPIOs*/, ^* T6 _: R9 u* d a* S
static const short da850_evm_tl_user_led_pins[] = {- u7 E8 l! b) K- A! z/ z
/* These pins are definition at <mach/mux.h> file */+ x- ?# R+ d. K! E# z3 Z: R8 Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) X: z# p; A, J# q -1, a6 V9 Q2 w x8 l2 \
};
7 w) n6 ]) e+ S6 Y+ @5 N! e6 r8 }
" e7 t2 E, R$ C7 q7 E6 fstatic struct gpio_led da850_evm_tl_leds[] = {0 J9 t& o# l8 U2 |: h
{7 k+ J P; X% K& F$ U8 C6 \
.active_low = 0,
; I3 [/ A6 y( I" q .gpio = DA850_USER_LED0,
8 b: k, O0 a+ h. c .name = "user_led0",: V8 A' f) d# I* y5 l
.default_trigger = "default-on",
/ ^5 v$ J! y( Z2 m# g3 s },
. C" W4 t X! D! }$ ]0 q {
4 q5 }2 D; ~, ~% B1 ] .active_low = 0, I6 t+ h: N7 v2 @' N0 u
.gpio = DA850_USER_LED1,2 \* C1 [8 U9 L. v+ R
.name = "user_led1",
7 b+ S8 W8 X1 B, |% v* G ^! o1 o .default_trigger = "default-on",- A1 ~3 N: d3 ~( j* K( G
},
/ v8 ?' C1 M( G6 o1 R3 q {
! U9 H1 t8 Z) M .active_low = 0,
9 O) J9 K {' W5 Y/ j+ [ .gpio = DA850_USER_LED2,& @$ B% J3 q/ A5 f
.name = "user_led2",
X/ D& X& @6 H" B/ X) u9 t+ m .default_trigger = "default-on",
$ {( R; Y5 W! s( k# v% x },
: d9 n% H( F9 F. Z3 I" ?0 [ {
6 |7 _/ [3 V* K" ]6 J .active_low = 0,! m4 Z1 a( u( M: k8 J
.gpio = DA850_USER_LED3,
2 \6 X0 \+ | x' f' D6 Q, B! r N .name = "user_led3",
) @( ?& ^% j8 Z& X/ ~! F .default_trigger = "default-on",
& e# f, i* s. l* r. {1 l },
- p, c# K3 _) Z0 w, G( M, F3 n) o& _};$ P3 k+ {. _( t
7 K( q/ n6 [; y8 e6 b8 {7 astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- h- N( S! S a5 ?8 t .leds = da850_evm_tl_leds,3 L: M5 w! Y. i& D
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ R+ G& b- }/ l, t5 R};7 Y2 I0 R! v9 [
+ L% b8 {' C! U* b) W i
static void led_dev_release(struct device *dev)/ Y( A/ j7 \2 M* I# c
{
1 o) U2 c3 b1 N9 k};
1 v, Q7 @# w) e5 Z4 I% @) E
3 u: R O& d2 I4 c2 Mstatic struct platform_device da850_evm_tl_leds_device = {/ C8 I4 u7 n, Q% e$ P
.name = "leds-gpio",( c% a, f. p0 g H1 s& @, D6 S
.id = 1,
b& Q6 u; e4 K .dev = {$ X& m- |2 d+ N8 v# K; o
.platform_data = &da850_evm_tl_leds_pdata,
8 C8 n% l9 w- ^6 e5 r .release = led_dev_release," Z" ^% N* o+ O
}
, j4 k7 I; N+ D, P! s+ K2 t) _" ]6 V};
" n1 y1 c( n4 U5 a9 [" z9 Z# y, ~$ Z& m1 J1 x
static int __init led_platform_init(void)
* V8 i7 C2 ]0 k{+ g9 S) j6 z( R& |! x
int ret;
/ W* M" X( k/ }#if 0' E& L8 w$ Q3 ~1 ?, D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! Y" k* v4 |# j7 X8 z
if (ret)
- U( ~1 w7 i1 j) d X pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 p& E7 z- x$ _ "%d\n", ret);/ L$ N5 i8 m" f/ g
#endif
8 B8 k' M) ?1 j1 d ret = platform_device_register(&da850_evm_tl_leds_device);* p1 ~8 i+ `& V$ t2 \: N* n+ C: W
if (ret)
# Z, Z0 k7 E/ ?4 k pr_warning("Could not register som GPIO expander LEDS");
! c% r7 s8 k" t; W' H6 k$ t else
) c# S% u* p+ }& |. }( Z- |2 b printk(KERN_INFO "LED register sucessful!\n");
: @ L4 `" m9 U8 T$ H9 a. t: K- X3 F: X4 E
return ret;2 r8 R5 J: V! A; F
}
. k8 _$ o" Y; O, _: ?) E! N
: x ?! l$ [0 J* H8 Gstatic void __exit led_platform_exit(void)+ D' k* x' l# \; x4 W
{
4 _$ Y" Y: \- w3 c0 k" I: V platform_device_unregister(&da850_evm_tl_leds_device);5 B; h2 M# R# s+ W$ m; l+ }
2 E; a! A3 T3 }4 _
printk(KERN_INFO "LED unregister!\n");
& o1 K5 c" e$ S1 R$ a}
5 ~; I V" X _! h$ Q- k9 ?* L# ]3 d8 k9 T$ }
module_init(led_platform_init);
" W9 s5 Q- O2 J# ]/ E/ o# [1 R" lmodule_exit(led_platform_exit);; T& ~/ d' S4 l4 n- b3 d- E
0 ?. i" x+ [* d% F: tMODULE_DESCRIPTION("Led platform driver");
: T n2 e2 K% A: M3 ?0 UMODULE_AUTHOR("Tronlong");3 w4 S( p4 J2 T2 }; \" S
MODULE_LICENSE("GPL");, Y( l- ~) v0 R0 R3 C3 b+ {
+ u O+ a! S: ^( H( Z. i2 [5 N
|
|