|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: X& y+ x9 p% S% I; c$ K& R#include <linux/init.h>
1 N/ h( t& c9 a: N# Y#include <linux/module.h>) A& j- N5 U; N8 s6 \. e4 o
#include <linux/kernel.h>" L T- M; j6 [+ h5 a. z
#include <linux/types.h>
, S/ W2 {, A% Q#include <linux/gpio.h>+ g5 v- z, P3 Y% x& v. M* d
#include <linux/leds.h>5 w; c4 ~( A) O) E; q6 H
#include <linux/platform_device.h>
4 M0 }$ n8 B1 i
% Y& e M' @. T$ r, k* u$ f#include <asm/mach-types.h>) p1 I( P4 D" b; Y
#include <asm/mach/arch.h>
) S3 N4 |5 g! F#include <mach/da8xx.h>
, S/ O* l4 g ]5 z6 X$ G#include <mach/mux.h>
6 Y) e0 Q7 R: {# V# t& b0 @6 ?9 T* a% n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& {$ K9 L3 n2 U# N) W2 c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 E% y# T6 p: O$ @) Y; L1 e+ y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& s9 T4 y7 L: q& i% [#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 G2 A9 E J- [9 U& l7 O
: {0 v. \$ a6 [, B0 y# r; |/* assign the tl som board LED-GPIOs*/ X$ K0 l/ M# C
static const short da850_evm_tl_user_led_pins[] = {0 C" X3 o) M+ }: R9 R
/* These pins are definition at <mach/mux.h> file */2 S# W2 K: j2 ~9 O* O
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 v- h, G% Q, Y( g! N# i -12 X& P% b8 G- u, B( L
};- d" l4 y4 Y9 ?
1 @0 t+ Z' Z3 U: [) K- a" Xstatic struct gpio_led da850_evm_tl_leds[] = {, d! c+ b& T) v. M: _( N( f( Q
{
! x6 R7 }3 m ~$ \& V0 L2 d .active_low = 0,6 Q7 b% ~& j2 V+ k: }
.gpio = DA850_USER_LED0,
- K* ^6 C! C( a) J( Y2 l% r$ g .name = "user_led0",
' `6 ]% f& A( g7 v5 B .default_trigger = "default-on",: L) C0 [0 }/ b' t
},/ A* I$ q/ K; \, Z+ _- \
{7 ^9 n* X% {- i
.active_low = 0,0 j9 ~* ^& \& v* K; H
.gpio = DA850_USER_LED1,5 P0 B e4 {7 {; n, v$ Q
.name = "user_led1",8 ]8 y& j- k7 V3 i! k5 Z$ {
.default_trigger = "default-on",% H2 P* X+ Z0 S, \ {) q+ e; w
},4 `1 h/ ?. H5 D
{- ^2 N- n t4 c4 O
.active_low = 0,
" e: \/ } d4 I .gpio = DA850_USER_LED2,
6 |- W- l; m* T ~4 r9 H .name = "user_led2",. w$ v2 @- b+ J- Y
.default_trigger = "default-on",
- d' I( L1 w: n+ E4 ]+ H6 I },
; o5 Q4 u% ]* y6 ?* p% r3 M E {
9 h: q3 W0 F( Q* ~, ^6 [# w' ~ .active_low = 0,) ~2 F! Z+ h$ }
.gpio = DA850_USER_LED3,
1 f8 C3 {. o9 T .name = "user_led3",
. j5 T/ T) A5 n' n .default_trigger = "default-on",
5 r w/ C) y* z: K7 [2 M },/ w) Z! m9 t2 Y" m8 v" M6 G* U/ w" d. ?
};, Z, l* ~3 p2 C
+ U( Q: t7 @- R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 @7 E! ]2 w }. O: q
.leds = da850_evm_tl_leds,
- K3 z; o" i8 \1 `' r+ S! o9 \ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; }' w! h* i" r+ H' O+ E};
6 y9 d6 C2 ^* Q
$ W; n; U1 @2 h1 x' cstatic void led_dev_release(struct device *dev)
, O! Y, z! d: V: e0 l% l& S{" l% I x1 J% H5 E! O0 Y, \+ l
};
0 x$ B* V) d) A7 o( ^) `
6 n) Y- _) }0 a! D/ {/ N% Istatic struct platform_device da850_evm_tl_leds_device = {4 [" ]5 T; |2 ]
.name = "leds-gpio",0 g- `, X2 L& i- |3 P' t' a9 t
.id = 1,
+ m: A) `5 X! G' |9 j4 `6 Z .dev = {
* F1 y4 L( P0 s+ j1 @ .platform_data = &da850_evm_tl_leds_pdata,
& A* I e5 C# m0 _& N# e6 _* E, D$ Y .release = led_dev_release,
! N3 c4 q, c. g# Z }4 T/ |; X! y7 C% _+ W* b) n
};
+ {) ]0 l# [+ F) N1 b- Y
/ @5 {% e- l: ?- [2 p7 E3 \& `( Z$ {static int __init led_platform_init(void)! A1 Y4 i- ^: B @
{
& }, ]3 a. x7 y9 n int ret;) X6 b2 N. s! r# r: U4 b
#if 0
1 b: d7 X c$ C/ h& t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 L( A, G4 d4 I7 [8 |9 i/ ]5 w if (ret)
, T- S0 L; w: a2 @+ G pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" F3 V7 Y6 |7 j; ^% d- \1 Y3 _
"%d\n", ret);( j$ ?3 K" P$ J
#endif
z9 J% a* w; a" P( ~* h ret = platform_device_register(&da850_evm_tl_leds_device);1 i: T" N# @: G8 k& l; I) k
if (ret). f" e: z% |6 n: z3 X# Z
pr_warning("Could not register som GPIO expander LEDS"); }: y) T/ G- V1 s
else
+ d+ ~4 q, d/ A9 T @# V( K( t printk(KERN_INFO "LED register sucessful!\n");* F8 j: H# s* ~; K- C# [' f0 Y
. X& A0 S* P% ^$ ~
return ret;1 d4 T. x5 L; P2 w: D9 @5 q
}
/ ^( X a: a2 m- I; M7 q7 v- C- h/ O4 c/ C9 _
static void __exit led_platform_exit(void)
- k$ a: R' O5 c{
! V2 H8 V% r! Y9 A platform_device_unregister(&da850_evm_tl_leds_device);. k/ ^& I9 z: S+ m8 u1 I
5 J' k! b) Y6 R/ V, ]4 \2 T printk(KERN_INFO "LED unregister!\n");
! d3 y4 x1 C" w5 j}0 m: s' r) m2 p+ M; c
( l! @- b8 @) _. D7 O9 ?' B
module_init(led_platform_init); _: i/ N3 d7 X; ]
module_exit(led_platform_exit);
, |* |% w6 w; _1 Z
0 J; s F6 k# U5 K7 q8 rMODULE_DESCRIPTION("Led platform driver");; R9 c6 r4 E# Q9 n2 {
MODULE_AUTHOR("Tronlong");
" I: a c! {6 C0 \/ p. i- g+ U+ fMODULE_LICENSE("GPL");# o+ v2 t+ J4 ]! N6 K
4 i4 r. W; b6 T5 n8 w
|
|