|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& x" i& \. n+ B( L: `! f9 |#include <linux/init.h>
; {# E: z2 B- n$ x$ e#include <linux/module.h>+ {2 u; ?4 ]) q$ c
#include <linux/kernel.h>/ d3 m" V) N" b Z) {7 ^0 J
#include <linux/types.h>9 W' G& `; E6 v, M7 a
#include <linux/gpio.h>( O" a- w) s( y9 v
#include <linux/leds.h>
, G/ \0 ~+ Q8 N#include <linux/platform_device.h>
1 w h. j0 V( L) m. ?) p- G' U/ o# x7 S$ ^5 n& s" Y
#include <asm/mach-types.h>
) ~% P6 m: Y t9 x. K/ ~0 f2 Q0 K#include <asm/mach/arch.h>9 I% T$ h0 S+ L3 ~$ n
#include <mach/da8xx.h>5 x) ~3 @6 Z' U# x
#include <mach/mux.h>
' j' o T% y; j+ f3 P: h* t1 ?2 |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! J- G" z( C, ^3 n7 z# V, k. A! @#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& j" |6 B; |; n* {: i% b9 M2 K: ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& z$ _# V2 x) U% [- H% K#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 K) ~) ^/ P% U
1 T! a3 s3 D6 o5 _6 q
/* assign the tl som board LED-GPIOs*/! f( n9 V5 t; ^! \
static const short da850_evm_tl_user_led_pins[] = {6 n# G. T6 `; U- H$ A! [
/* These pins are definition at <mach/mux.h> file */: f* ^5 P1 Y# I( Q( W3 ]( D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ K' t) d9 A$ U! Y5 ^" D1 [
-1 Q( C1 I# I9 O* D2 L. S
};
7 Q% R) U5 B( v h
& z7 T8 e9 g- O/ M* @* |static struct gpio_led da850_evm_tl_leds[] = {
. |$ ]+ j$ f- c, b- v1 k {/ _$ q+ } T8 }% R, t
.active_low = 0,
+ Q% X* s u& N% [% f2 x7 y2 e4 i .gpio = DA850_USER_LED0, B" V( u6 n0 l. {
.name = "user_led0",
0 @) d9 M2 e' d2 c k .default_trigger = "default-on",
2 I0 w: ^7 c. | }," [' p; m+ T2 ~: n# f. i
{
2 G) x/ K, v+ @8 O! j# L .active_low = 0,; N( Q# G+ N# c+ K3 l
.gpio = DA850_USER_LED1,. q6 f/ ^3 Y2 C
.name = "user_led1",
- Q1 @( z1 K2 Q7 C+ ~0 c .default_trigger = "default-on",- d/ ?3 T6 _& X6 Z9 I- v
},2 M2 N8 S1 z7 n' j6 V( B
{
, K; k6 S3 E/ v8 b' S- p% _7 d .active_low = 0,
% d* _! L, D% Y3 c0 { .gpio = DA850_USER_LED2,, v& y9 Z1 t4 E& T U8 b
.name = "user_led2",; k5 x/ U+ {- z3 R
.default_trigger = "default-on",
1 ~: x4 o- V& w" Z2 l },7 h6 j5 S2 R3 h/ x$ K9 U+ q8 B
{! \( v. O ~' n) S
.active_low = 0,; c+ L3 d6 t& W$ n5 }/ g
.gpio = DA850_USER_LED3,
% U- y7 x! m: R4 M5 T5 @ .name = "user_led3",3 ^( t0 y3 Q P, n
.default_trigger = "default-on",: h9 f. b1 ^& \) t' r* I( r" h N
},% v. t) V0 a$ l
};
4 i, W5 V0 j0 P% L' O! c$ c* R7 c, p: a9 h0 r) C3 [, S: |+ g3 X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 K' r* r1 f" t! E& z3 v2 |
.leds = da850_evm_tl_leds,
. {# J. q1 p( ?. ?4 f .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( ?9 I0 D& M1 ^};
7 m8 c) `5 r. E/ e( b# ?+ D9 W1 j
% ^' F* d3 O7 [: S% G8 Cstatic void led_dev_release(struct device *dev)( R& X* ]( j6 v* ^
{
. y' s* n: t4 R+ F# {! i};
( ?0 g/ s! g- O
9 v6 D2 v' c2 i1 Zstatic struct platform_device da850_evm_tl_leds_device = {9 n1 V3 A% y+ F. F! H: J, y
.name = "leds-gpio",% y5 B) P' K1 a$ ?( W, N
.id = 1,/ Z4 q! J' T* R# i* |: I
.dev = {
8 \) i* W1 w- C- R* { .platform_data = &da850_evm_tl_leds_pdata,9 }, e% C m, m. C; J
.release = led_dev_release,
7 F# T! @0 q) _$ a- w9 P) Y }
9 F; `1 K; b& H. { g5 x7 G};
7 k( m1 n/ s4 m* ~( K. J( f
0 ?2 X, D% S( N6 @6 _static int __init led_platform_init(void)8 Q5 W7 G8 q5 ^- Z, ?
{4 L# c e2 V, p# ?/ o' M$ [9 F
int ret;
" y% o$ x# f/ A8 I. B- ]* G# R* C#if 04 ]" C1 j& s& S+ n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% C2 f: a! z6 y; U4 u if (ret)- ~7 t- c. T% T3 D& c
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, i6 \* J! B6 x7 ] "%d\n", ret);
/ a) i1 p7 `( `. I% R/ ]/ w#endif
4 q6 ~) U* G$ ]3 J6 }2 g" _9 o3 R& h ret = platform_device_register(&da850_evm_tl_leds_device);& q1 y9 b$ e% S) ~- \
if (ret)5 P% A& P' ~1 L: c7 w0 R5 s. y
pr_warning("Could not register som GPIO expander LEDS");9 I" ?" V1 i$ R+ R F* ] D, ^8 }
else
* S: g% p+ P' A printk(KERN_INFO "LED register sucessful!\n");8 r1 I8 w% t( Y% [$ z3 W
/ S! l0 G% M8 A; }5 q return ret;2 J ~: P# ^# V% o0 [
}" z; D' h6 x! P+ ^6 _4 A1 b, K
+ h% d9 t( [; [1 e
static void __exit led_platform_exit(void)
+ Q: _" } k- u' d0 b% |) h% K. ^{5 V2 u- e0 w& @% S, q/ W9 Q
platform_device_unregister(&da850_evm_tl_leds_device);
) _, M: f u% Z$ T5 G8 V) \+ B6 m+ e$ C( i& Z4 H- {3 v
printk(KERN_INFO "LED unregister!\n");; ~- P2 @5 g' _; \' m
}
2 ?* i! d( }$ I6 E5 M: G
0 w' w8 k3 E& L N2 i9 }1 Z$ `module_init(led_platform_init);
; U/ t3 h$ U& N fmodule_exit(led_platform_exit);
& Z3 F6 {" @- S; v& h+ V" q3 E% C
5 f; z: r: Z2 Q) C3 W, n$ p* DMODULE_DESCRIPTION("Led platform driver");
1 o# {+ O1 q7 c7 B# U8 nMODULE_AUTHOR("Tronlong");
9 o2 M9 f& [5 F u- JMODULE_LICENSE("GPL");
K1 q8 G; \# z ^% t2 a$ }. H+ _; M) ?2 a
|
|