|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, X8 s G/ ?1 U4 l3 Z#include <linux/init.h># B* C! M+ x$ \6 {& g2 l; C3 R
#include <linux/module.h>( o4 N5 J+ h1 T) o
#include <linux/kernel.h>) _6 G) b# r" D3 }
#include <linux/types.h>- ]4 @( M. Q- h5 `" Z
#include <linux/gpio.h>2 j( n& n* ~. f* e# k& Y
#include <linux/leds.h>
I& r, C, i, j: D8 P#include <linux/platform_device.h>
8 K8 b% D2 Z* Z
1 Y* K% g0 P$ f/ l, m. q#include <asm/mach-types.h>1 y% @: w0 F; P# X3 N( m2 L* @. Q
#include <asm/mach/arch.h>$ o8 F' Z* E4 T5 y# ~' }
#include <mach/da8xx.h>
- G' \% e& z8 R+ |% z* V#include <mach/mux.h>
- U) T7 P( l) [) F* [' U
; D8 g1 j9 d! @) E& V6 B#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 M2 ?# m3 \3 r1 F0 h8 t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. C- I8 q$ x2 {4 }0 p* L+ R7 s; T% x) T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% U) [0 J, T. }; v( m9 F
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
H, D w% o# a' V2 J; U$ _8 @$ u
- S! @. O# Z4 M1 d" |. z1 L/* assign the tl som board LED-GPIOs*/& R' y6 \. n# {& E$ H" c1 R& d
static const short da850_evm_tl_user_led_pins[] = {
' y# x! z3 f. m2 q /* These pins are definition at <mach/mux.h> file */1 [. f W( b7 {' z. v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 A) V& x* V I# U8 l* I5 i8 o -1
8 M, ?. B- ^0 ?% x& c};
; {0 @( _# @ f# _1 [( Y7 Y0 U: H1 J. F
5 S1 |, n3 o F" u. L: Pstatic struct gpio_led da850_evm_tl_leds[] = {# X( Z' [: R0 e) G* i
{
8 I/ s9 D* d. V9 I. e! S .active_low = 0,
. ]7 C/ b6 Z, O$ O* Q .gpio = DA850_USER_LED0," l7 }# O6 G. S3 l7 T% w
.name = "user_led0",1 r6 k$ f( A" e4 \5 O* E
.default_trigger = "default-on",1 c; \$ h# G& G1 d! Q* P2 R3 t; d, }5 P) i
},) D/ Y1 p# P& P7 \* y! x9 z
{1 @( l( u/ O" Z! k
.active_low = 0,$ F; c' k) ^8 k
.gpio = DA850_USER_LED1,
: T8 b- Q z4 i% A: C .name = "user_led1",
& q; b$ T M6 C$ j .default_trigger = "default-on",& Z( y+ ?# q3 V) j$ C
},
5 g2 b4 O$ R% w8 O {# N+ q# {# {# z& r N8 o: M
.active_low = 0,5 N/ X3 _0 ]5 }; `. v
.gpio = DA850_USER_LED2,
1 S d O/ u+ V$ y8 p .name = "user_led2",& D/ R. m2 @9 z. O b& n! t: n
.default_trigger = "default-on",. o9 {9 u/ Y4 y0 d0 z7 z
},
2 l7 ]- u" ^7 [: p {: c# ?0 |# J6 F5 K/ l
.active_low = 0,: _6 Z, M( L1 ^) }
.gpio = DA850_USER_LED3,( t) g2 M) v1 O. c6 m: |
.name = "user_led3",
& j. G: p, b8 G! b! s/ _# T .default_trigger = "default-on",
8 Q4 K8 W( r) c6 x! J0 q; T& P },( k3 y( A, X2 D' u; s! C7 ~. R F! o
}; f7 q" i9 E/ [. e7 U. `
4 X% N+ `* _* i- q) n: nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 l; }' Z- B6 ^" P0 l
.leds = da850_evm_tl_leds,
. B J$ w f/ n& a# j: c1 y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 M3 l" S$ z* F3 U. n: c0 a
};
6 A: f! M" E; v$ O( `& c8 P, l. X7 ?6 m, b9 u) M
static void led_dev_release(struct device *dev)- V% t+ O+ j6 M1 \/ W& M
{
2 n- I$ o5 G {7 a ^5 L! u+ u9 K2 t};( q/ ~2 e ?! r/ c# t
0 G: h0 p. [% Q/ g5 U# G
static struct platform_device da850_evm_tl_leds_device = {
P- b9 M4 j0 t f7 F3 S9 X .name = "leds-gpio",- ?" J1 `" ~( g3 B4 Z! N7 g
.id = 1,- ]+ a" g: H; i5 @1 }& w3 U
.dev = {
: z; a* G- }" x Z- Q .platform_data = &da850_evm_tl_leds_pdata,( {- I( b8 c& a; z% u2 O
.release = led_dev_release,& E6 O" f2 c& ?' i( _6 r9 w
}
1 u$ `- p/ M9 y# \5 K};
3 \! J7 e& R6 v& F+ A7 G5 j- T, E# f) m. ^7 I1 O+ c; [, D6 y
static int __init led_platform_init(void)# Y, |2 O6 ]- k( A; e
{7 {/ x5 R% Q+ Y
int ret;
: S3 Z) l6 y: B/ Y#if 03 \0 g! P( A* P! p" s5 B4 R& q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 G0 A+ s" S9 Q- u" s! t: q
if (ret)
4 x- t; J/ g {6 k pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ ?1 B% k7 R& I: \6 P "%d\n", ret);
, e8 s' e: g7 ~1 s/ p" }( D k! h# k#endif2 {& B7 `- R3 Y
ret = platform_device_register(&da850_evm_tl_leds_device);9 m; n+ W& R1 n, p
if (ret)
, V3 F5 w2 O5 f pr_warning("Could not register som GPIO expander LEDS");4 U, D& \9 v- A2 f
else& |" {% q0 H+ L
printk(KERN_INFO "LED register sucessful!\n");5 Y. b: l/ S6 f* C3 E
- V' M. B9 x( h' Z) |3 ]7 ?
return ret;+ v1 U, H2 O5 R, b+ W$ N. w1 S3 j
}& h6 W [$ M2 R. v9 R' X
0 i) v: ]: z5 C& h( o8 Sstatic void __exit led_platform_exit(void)6 S0 i+ G$ f& z5 M, r1 B
{
7 c, Y5 N9 G7 e/ s9 s/ b' @ platform_device_unregister(&da850_evm_tl_leds_device);
2 o, h" m* [# v9 Y# }+ J
6 G7 a# M" c O printk(KERN_INFO "LED unregister!\n");0 s1 U, Q- @/ Y6 v
}# N+ I0 F/ V, [" c9 Y
8 u; F$ ~6 S: A/ F/ A; D8 X d
module_init(led_platform_init);
; R6 J8 C; E- q& Z- gmodule_exit(led_platform_exit);
, U) n) ^, D( h7 A" v5 ^
! A$ v: P: N; z# R5 OMODULE_DESCRIPTION("Led platform driver");" W$ E1 n/ K1 |4 G) _0 m
MODULE_AUTHOR("Tronlong");
& q, J* ~1 C3 i+ C! {" U: ?# |: D7 S2 GMODULE_LICENSE("GPL");8 B& J/ m# z* X9 C5 Q5 N4 K
7 O: q7 F; S) h% V9 x |
|