|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 a$ ~) T/ i1 X* ^' u( C
#include <linux/init.h>
\% A+ u0 s# |2 X#include <linux/module.h>
" T- {0 N/ J5 p( V) H$ E$ |7 p#include <linux/kernel.h>
' C9 p5 l4 C. ^6 B#include <linux/types.h># N$ @0 h, K/ g+ b
#include <linux/gpio.h>* M5 y. j! R: a T9 M: K' I; |
#include <linux/leds.h>9 I7 x$ s4 \7 a* o& l
#include <linux/platform_device.h> l' v! b/ B% \% |
1 W5 h# \7 p9 v7 a$ V- O8 u
#include <asm/mach-types.h>
7 Q S2 e0 S6 x, }7 [7 o; O: n' X#include <asm/mach/arch.h>
9 S% o1 @4 A. [4 N9 n7 \/ f' R( @' ^#include <mach/da8xx.h>
* [0 l2 k' x1 r#include <mach/mux.h>
% X+ d) P) u, t( }9 c
5 W# X+ ~ Q" T0 t/ _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 B/ l! @2 `. A: t( Q/ R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 t, h' }! n, B" l Q1 m) T7 R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: Z' B; e6 }+ Y, |$ |. K ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( Y; O6 f v. j! }& l/ K8 t/ k% |/ D4 u
/* assign the tl som board LED-GPIOs*/
6 P" g+ u" U y. h$ t/ _* r3 _+ k$ istatic const short da850_evm_tl_user_led_pins[] = {
" N9 S. Q. `- v% F% | /* These pins are definition at <mach/mux.h> file */8 D$ \, z0 G, P! U# A5 K) M& C3 N
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) [: D: z8 V5 `$ R2 g
-12 y4 V3 J2 K% F9 g2 W! @# Q# I
};) D, k/ s" V; B( Z9 v$ ?3 o
; h3 _' ?, a, u8 e' B2 q2 i6 g
static struct gpio_led da850_evm_tl_leds[] = {
I# A' A9 O3 V/ l3 D0 j {
; S! s& E% O" [* U N6 r0 S .active_low = 0,6 e# ^, l! P& Z- @) {1 A% h: t
.gpio = DA850_USER_LED0,- {9 N/ A4 Q9 i" X
.name = "user_led0",0 x1 C1 j0 r% ~& ]1 Z
.default_trigger = "default-on",% W3 [8 F' Q9 V, I4 d
},, `% e z* {! s8 I# v+ G
{
* A/ T" y" J% o5 n/ H$ k .active_low = 0,
4 p, ^9 l$ ]# p- L2 A7 m .gpio = DA850_USER_LED1,
; }1 p6 ?7 s0 B8 }) n .name = "user_led1",2 P2 i+ K0 F" e4 F; @4 j
.default_trigger = "default-on",+ c. ^. W- e; P3 k( _! ?
},0 S& | v4 D$ ~
{
7 ?4 ^4 |! X/ m7 I" H7 |( z .active_low = 0,
; ^7 o/ U& V6 h8 ^7 Q5 i* f .gpio = DA850_USER_LED2,
( F* Q* p" y U- ^) A% {! { .name = "user_led2",- v# h# T& h5 i% J7 c
.default_trigger = "default-on",7 r5 j9 Z9 Q! i
},
0 F/ J6 {! a5 _! ~! a% n1 X8 \6 Y {
6 K' b6 e5 b- C) ~0 n2 F* B3 z* b .active_low = 0,0 S) G! T0 B, i6 w
.gpio = DA850_USER_LED3,! V! j0 u! _% }' w6 _% `
.name = "user_led3",
2 }" s& b- S' e' A$ x* w .default_trigger = "default-on",
& U) ~8 E7 Q1 {* b8 ]/ b },
* T' ?1 }- @+ _9 r6 }# R8 }% l9 Y};$ ]' ?0 `# p+ ~9 O6 Z7 V
4 |4 J. ]3 W9 |& y a. Q5 Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 q4 F' V! P( {! A; w3 f* p4 y
.leds = da850_evm_tl_leds,
. z+ b# O8 _9 g% l" h, D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 `6 X3 k- _+ j: D6 f$ ? @
};
" N- Z, I2 K& r+ v$ ?; Y; D7 ?. l1 m1 G( S: m
static void led_dev_release(struct device *dev)
) I1 K, _; q C# d{
. D) }% G) a) D};* R& b1 F1 H |( X
4 o4 ~8 b0 W7 H' K- U: t8 Lstatic struct platform_device da850_evm_tl_leds_device = {
- Z+ ^# b2 C5 m- L .name = "leds-gpio",
4 u* u6 P% n/ s3 q4 x .id = 1,2 J4 d3 s$ x; E( ]& T0 \
.dev = {
/ l7 N5 r& o. ~* b .platform_data = &da850_evm_tl_leds_pdata,
1 l% Y' _4 n0 l% }: R .release = led_dev_release,: I1 P1 I# f T: P6 E0 G d
}2 _' [/ w* ]% V2 v0 |
};+ b: U2 d* Z2 D4 J$ q! A" i* r
6 C# L) x7 j0 K2 ^1 e
static int __init led_platform_init(void), Y, z/ c9 o3 X
{: c% }& t# @' g" ]- ]' j5 R8 k
int ret;
; N4 X1 m$ @: ]#if 0, W8 G7 }: x. _9 J& z6 F& k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 |+ I+ n5 L* H: q' Z8 U1 @; r$ E
if (ret)9 _$ ~7 `/ S- I2 }& _3 A9 P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 }; y& j# e: z4 x
"%d\n", ret);
7 g- o: _) a7 \8 r0 ~#endif
& h# {9 f5 C+ V' q ret = platform_device_register(&da850_evm_tl_leds_device);
$ n: z" d5 i/ f* D if (ret)
; P; @ M- \1 t3 L; c: u7 t pr_warning("Could not register som GPIO expander LEDS");0 \$ N& H% v) A/ K6 x/ B- Y$ Q
else; i0 W. b/ ?, `. V; V0 Q; [: L7 B
printk(KERN_INFO "LED register sucessful!\n");' l2 j9 H+ L0 M# G: J E4 C; k' {
1 z% o# Y/ ]$ R3 X7 r: P
return ret;
7 u4 A5 ~+ a9 S! D% a' W}% O6 e+ K( e O( M5 i- `) k
& G, [5 f6 P* b. l1 P& J1 rstatic void __exit led_platform_exit(void)1 k6 M$ {5 ~: H& P& q7 u8 s
{0 T) j' ]" e& D5 f
platform_device_unregister(&da850_evm_tl_leds_device);
% ^4 @. x: x3 W9 h9 ?/ e/ d( u) |1 J2 Z; f" K
printk(KERN_INFO "LED unregister!\n");4 p( D' G# k* v0 G S7 x; Q8 L
}& a' W4 d& F" x
o* c. S/ C2 t' P/ F/ S- C' v Rmodule_init(led_platform_init);
' r8 ~4 w7 [% e1 w% zmodule_exit(led_platform_exit);) Y4 c' k* N7 h/ o
4 \& ^- w3 D; RMODULE_DESCRIPTION("Led platform driver"); f% ~" @1 J$ X/ t" w
MODULE_AUTHOR("Tronlong");
3 ~* K. Z+ K* A9 BMODULE_LICENSE("GPL");4 {, N- E1 B9 B: w5 S* Z
2 U! T5 I4 e3 h$ @- E9 B
|
|