|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( E. `' w8 j3 ?% Z# i; E#include <linux/init.h>
7 ~: ?# t3 |; \! @#include <linux/module.h>
' \5 X% p- {) X G ~0 O#include <linux/kernel.h>( r8 L. V; ^5 L; l5 u
#include <linux/types.h>
0 E# C, d; R5 O& U( B8 f#include <linux/gpio.h>8 Y2 o7 o7 n5 ~0 X1 i: u5 J
#include <linux/leds.h>
2 l9 Q( A x: Y* k* r/ U% i#include <linux/platform_device.h>; O3 P% D* p0 n9 B
3 ~* e" B9 r( T
#include <asm/mach-types.h>
9 |$ K, J: ~3 U0 H3 j& V#include <asm/mach/arch.h>
u% I2 S4 t+ R% L#include <mach/da8xx.h>% ?- o/ g5 F2 _, K7 Y
#include <mach/mux.h>! J- p9 r$ T8 \1 n8 U
( J; q2 D! f# U0 e( J# w+ o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" x" M& T! M4 L* d* e* r8 d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): e' k: a$ C( R' c; w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 T/ t; m+ u4 @9 s+ i, t1 X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 E3 y. }7 A; M/ \% b, D' r
# ~6 o5 Y( L; e/* assign the tl som board LED-GPIOs*/
: i) S% V3 Y' fstatic const short da850_evm_tl_user_led_pins[] = {; Y, E" }; W/ }# a: H& C4 t% r
/* These pins are definition at <mach/mux.h> file */
& L& H- S4 H: y# e, S DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 p. c! Q: w% e9 _* j
-1
& D+ d, j2 f+ ?2 Z};) p6 R2 ~- f/ B! P1 n" T0 J1 m
2 w5 a8 x6 V5 L- ?
static struct gpio_led da850_evm_tl_leds[] = {
& U! Q/ V7 M; O+ C) z {
- X8 n/ U6 V1 v- h4 w9 E5 b .active_low = 0,& n# M! g2 u) g
.gpio = DA850_USER_LED0,
( _0 U- b& g6 n$ u .name = "user_led0",: i. b+ t# p; t9 C$ ~) ^
.default_trigger = "default-on",- H4 B* I0 S# M! i+ q- f
},1 G2 e( ^& L! h
{
+ n$ k: |+ H1 N1 g0 x .active_low = 0,
- a/ s3 |: u( B .gpio = DA850_USER_LED1,
0 @ S9 O( U6 j% {% Z; O& J .name = "user_led1",
2 w m/ o/ L* C. Z) @1 ^ .default_trigger = "default-on",* Z) ^/ z8 L6 x; e/ w& u
},% _/ u- W) J. L' n8 |6 x$ J) i
{
3 A" t0 p& L# r6 M/ T5 n. G y .active_low = 0,& O) c+ G9 S7 j+ ^' H" ~1 {& H
.gpio = DA850_USER_LED2,' N3 p5 b) z5 K" x) P) \
.name = "user_led2",1 m# f: B, R9 v+ w& c% G
.default_trigger = "default-on",) j/ @: D. R. P4 Q* }4 F: U, O% o
},* r. `; r1 M( P0 j/ J
{
* L, f1 ^' \0 D5 ]1 |/ f .active_low = 0,$ i# w1 H3 m, y, m" }/ Z+ J- F
.gpio = DA850_USER_LED3, H% N$ r* g- q6 R' B; s
.name = "user_led3",
" F: M& S. P7 }7 Y1 @ .default_trigger = "default-on",
2 y' w! f$ `6 d/ p: v2 t' I9 D },
( ^3 f4 h7 r% p; s: d};
4 z3 G+ Y/ C4 U& x% f7 O; \
& m& m/ g0 f$ b' o* @# @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! [$ _$ y) u' ~6 m+ q/ R
.leds = da850_evm_tl_leds,& o4 u& d$ z, [
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ l$ q. D' y2 R; [' i
};$ ^! z' B7 D" @% N6 e# ?
/ F, h2 S: S# G1 M. T2 z3 L3 p9 Tstatic void led_dev_release(struct device *dev)) G8 N( f3 V0 u* {( H$ l% U
{& J2 u$ h& E7 r. C8 ~
};; O% Y9 K1 o! y; K$ B [4 P
; E! [! L4 Z7 Z, J5 tstatic struct platform_device da850_evm_tl_leds_device = {
3 }+ c% g% o$ F; @ .name = "leds-gpio",
7 n5 t! T3 ^6 o" D$ t7 | .id = 1,
% n/ U9 m1 i q0 f7 Q .dev = {
8 |/ m/ v' ?( I+ q" Q3 D .platform_data = &da850_evm_tl_leds_pdata,
) G0 D7 [$ T$ |1 \5 n4 c .release = led_dev_release,
3 W0 m) M% [0 ^1 a# R. d$ { }
) [0 R X* R2 B3 ~+ r! R: j5 m0 _};. j( Y+ g9 ^4 H i8 a. C5 M
" I( A" }: o. ~' V6 f: Z: }
static int __init led_platform_init(void)+ O. }1 l) F) `% l
{+ l" E1 f+ A+ a0 v H
int ret;9 [- O/ b4 ^# g- F1 \
#if 07 y2 t4 h8 `- ]+ C; v! G+ ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# k8 i9 d/ G/ {. u+ P# L8 j$ v
if (ret)9 `6 ~2 \- b' Z7 E& c
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! u9 {( v7 J) a, G8 M3 d
"%d\n", ret);1 ?; W! @# j2 u: v
#endif
5 J4 ?4 `- `" n7 y- a. T8 S ret = platform_device_register(&da850_evm_tl_leds_device);# J4 d. t9 e; s+ g# i
if (ret)
. H" U) d; F& V& @ pr_warning("Could not register som GPIO expander LEDS");
a0 i! ?' ~1 S9 ]& r else
3 p4 b' \& u* F& Z& H printk(KERN_INFO "LED register sucessful!\n");
8 F) S9 ?1 ]$ |. Z# h( E. E7 N
0 N" a$ ]7 a+ t* z2 H4 A/ p% D return ret;
1 _7 J2 H$ ~1 s1 p5 w) ~/ ]9 Z* x}
. p5 R) o$ @7 X1 ^* g& F5 g
) ]1 `5 {0 x$ s: Hstatic void __exit led_platform_exit(void)
$ P, i/ Y% \" @; {. S* @7 U+ e{0 m: |: H( M3 g/ d: X0 J
platform_device_unregister(&da850_evm_tl_leds_device);
3 a) r8 z2 z7 o# i" n. ?
I% G) r: w$ m7 M9 e printk(KERN_INFO "LED unregister!\n");! l _+ g* {9 F7 u* q/ c
}
: \ H* k K7 j1 r) q# D. K/ Y. F5 g* R' |
module_init(led_platform_init);
) h9 Q$ a' A7 S6 j' mmodule_exit(led_platform_exit);. a, i& h* O6 @, O
|- D8 F7 D0 z( ZMODULE_DESCRIPTION("Led platform driver");
" P3 [9 p3 J2 ~MODULE_AUTHOR("Tronlong"); \. A; `# C- D2 h& ~4 A* t9 u; N+ r
MODULE_LICENSE("GPL");
N, Z0 x" Q2 r. y
5 B c5 E* l! S/ L |
|