|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 l; A9 b6 M4 U#include <linux/init.h>
" D( X! M7 a: v+ b" d( u: j#include <linux/module.h> e2 {0 }6 n+ T% M* F
#include <linux/kernel.h>, \+ Y B1 D- Z; T) u
#include <linux/types.h>
/ x8 I8 X& A% x& F* b2 g#include <linux/gpio.h>3 }* q' V: F% B2 {% P
#include <linux/leds.h>
! q' O* d4 f) O! e: w#include <linux/platform_device.h>
4 z! |! ]# e6 s
6 M) R* F* F& k, }#include <asm/mach-types.h>
. [! |! A$ k6 Z6 m. L#include <asm/mach/arch.h>
% ]7 I% X# `2 r#include <mach/da8xx.h>; b% I, _ f8 u
#include <mach/mux.h> U/ ?+ S/ m6 S; N- x2 ^$ b5 Z
k$ L/ J" G' w- R, X! ]2 L, r& H#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) P: o7 t6 F& W4 W4 t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) ^, h T- ^! [$ T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" Q( }1 [7 Q9 w#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 U) \1 d Q/ g! E0 W
' f! J4 Q% @/ d, U* [3 ]
/* assign the tl som board LED-GPIOs*/
u2 h' ^ T% @1 ?6 qstatic const short da850_evm_tl_user_led_pins[] = {* ~% q' m& ]# E8 Y+ v. ^
/* These pins are definition at <mach/mux.h> file */
/ h# g* D8 Y! _! B J6 l' [* O DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 q. c# T1 m5 [7 U1 q& s; b -1/ ^/ i C; R2 J# @9 @
};
5 B: d; G) p4 D5 P' C5 a* n& {8 E
static struct gpio_led da850_evm_tl_leds[] = {
1 {& R7 @2 E* P: U: x2 k {
3 D, [, V2 F0 Y( K .active_low = 0,
5 G4 S0 F4 b: ?. x .gpio = DA850_USER_LED0,
. L7 X# p& f: }4 V! N6 U( V& N .name = "user_led0",
3 k) N9 T! k5 K/ R2 h0 X% s .default_trigger = "default-on",
9 Y# k; L1 \) r: T },, n3 I4 f4 i3 h8 P; l+ Z* @) V. |7 c
{! z/ K% M0 V. H. |
.active_low = 0,
, J+ }3 L$ ]) D5 ]0 \1 m .gpio = DA850_USER_LED1,& `4 F3 I) \* \* I7 w$ d( o; \% s9 T
.name = "user_led1",# r- b4 g6 P' c' r
.default_trigger = "default-on",
$ x7 _& ~& v. {3 X },
4 E( |0 ^. D h1 l2 { {8 Q0 \! A; F! L: S
.active_low = 0,) y' M2 T; [* i7 K
.gpio = DA850_USER_LED2,
- x7 i; }. ^( Y) w+ k .name = "user_led2",
" J4 L% Y0 a& Z. P' [4 f .default_trigger = "default-on",
& x# B1 A% m- w7 c* N4 K6 c },6 v" {# ?+ D7 S$ S0 _9 Y
{
9 y$ H5 H: A/ k1 p5 z) o .active_low = 0,/ E) t1 V; g$ O1 L( K3 K- ~
.gpio = DA850_USER_LED3,
$ e) t8 Z6 e! h9 x6 Z .name = "user_led3",
( l4 M0 m- Q9 ^' h9 h! w8 a; Q .default_trigger = "default-on",
# w( b4 Q& E' ?$ x },# g0 m0 l9 U* O. w3 F+ e: X; E
};
! f- w9 ^+ f9 [, i8 [. s; A/ K/ C
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 X, Q+ i5 p" r5 x
.leds = da850_evm_tl_leds,& O. c8 C* C9 C# ]+ Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ Z; e- b4 S5 G) u! U7 z- ~};, V+ ^# x7 L$ l6 j' A, ?4 V
& j! c% N( c. y' Y; F% r9 K8 X
static void led_dev_release(struct device *dev)
; O6 y' {* T0 u- Y{
d/ {$ A' J3 C; D7 |};
+ H. y1 O+ L% q
: O2 L# |# N" g% ? s1 p: n( ystatic struct platform_device da850_evm_tl_leds_device = {% G7 O$ x) l9 Q" m6 C0 N
.name = "leds-gpio",8 p8 r" f+ Y1 o/ [2 p b# \
.id = 1,
: s# M2 P4 x* n9 r9 b9 |4 m, C .dev = {1 l6 Q6 h- k6 K5 |! } u# e
.platform_data = &da850_evm_tl_leds_pdata,
# d0 j* ^$ D) }' P C' G. K8 w7 m .release = led_dev_release,
) f, h' o! }6 v4 {- Z8 `) x" | }5 ^7 D7 Y) ~3 d8 t/ _
};
+ {* I( K1 W: w/ ?3 V9 @4 D Q& R: V
9 f( }# a8 d- [! k/ _static int __init led_platform_init(void)$ `/ K" E( c/ E4 ]
{, o) ?$ k5 K5 b0 ~( G5 \$ |
int ret;. F5 \6 H6 H2 ~$ r, G
#if 06 h6 T% q( \" c- H' X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. l O* N) S# `/ C- x; G! n
if (ret)
3 s) F, r0 c/ d* C- l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 K7 n! K' E* B* j
"%d\n", ret);0 C8 r, ^+ R% ?8 I0 T
#endif
* d: f( v) Q L Q1 s ret = platform_device_register(&da850_evm_tl_leds_device);
4 E9 U- \; r. n2 U, r0 | if (ret)9 Q- n, y" Q) O: V3 _
pr_warning("Could not register som GPIO expander LEDS");
5 y; x, E7 e2 h2 ~# c/ z) y M else/ F4 ]1 R5 E: o' [6 ]
printk(KERN_INFO "LED register sucessful!\n");- V4 i) j9 u0 Z6 J* _4 {" H
2 Y$ I. J2 d/ X/ R. u
return ret;/ u7 c+ ?+ m7 {! v3 j
}
* f3 i/ t3 }4 R* M, [; ]! t3 B- ^* r4 \# `3 n+ H2 L
static void __exit led_platform_exit(void)0 C6 Q* o& R- w0 O' g+ g9 l
{
! m1 y( F% l" a platform_device_unregister(&da850_evm_tl_leds_device);
6 @0 I% O! y' C9 @6 y
$ ]0 V. d4 f K printk(KERN_INFO "LED unregister!\n");: K1 L; A2 s( N3 X
}
4 b( v9 s {7 z6 ~
% H/ \' B& o( N9 A; @5 o1 ~+ Vmodule_init(led_platform_init);
# {0 S, m( t* w* o8 a, ymodule_exit(led_platform_exit);
# u, m% U; O* t* O
3 U$ v' e2 w! @; W$ GMODULE_DESCRIPTION("Led platform driver");
, g( u: B4 l. hMODULE_AUTHOR("Tronlong");
; L8 W" k6 c# ? M# F( eMODULE_LICENSE("GPL");
2 R3 _' h, D$ O. ^3 X |6 b
2 U! a! S9 F- u: ?9 {* c& K7 \ |
|