|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) h. t$ [& Y. [. w0 r#include <linux/init.h>
. G& F7 I( s {! ^#include <linux/module.h>
+ X6 J" w' J5 X) w3 ~#include <linux/kernel.h>" V" V/ V5 X! ]4 c8 `7 d, z
#include <linux/types.h>
! x6 H& M% `6 U) V: w#include <linux/gpio.h>
& h5 ]3 a! f7 h0 r#include <linux/leds.h>
) o$ s9 U0 r5 ^' L9 Z+ C$ V#include <linux/platform_device.h>6 O T, G ^4 I+ L. r
4 L( U: v0 n5 f: _#include <asm/mach-types.h>/ U& N7 \' S/ [, C$ e- M9 @
#include <asm/mach/arch.h>
N/ L" R5 @5 G. ]) z5 H#include <mach/da8xx.h>
3 o% p0 K$ A0 X, m6 E6 W i#include <mach/mux.h>
2 y F( @, x$ z& Y: d; w& D3 H
! k) u1 W. R; }! b2 k6 n#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- o0 ]7 \% H/ X- e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ G; T1 B, }, e! f0 Y( z# j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. e+ ~8 P i2 U3 x! B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% p+ D' q9 D! M7 c) v8 n5 u
, C% e: g H' O, b/ E+ U
/* assign the tl som board LED-GPIOs*/
( T6 ?5 e( `7 n8 h( @static const short da850_evm_tl_user_led_pins[] = {' M* c" F( D- ^# @
/* These pins are definition at <mach/mux.h> file */7 G; q% Y h1 u7 }0 q4 v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 V6 ]; s3 c# M, r5 _0 v4 I -1
* h; e5 y1 p0 Q/ }0 {};
0 Z& G4 C Q& j4 \$ F( f: ^& s
* J8 Y5 t E3 y }9 q2 lstatic struct gpio_led da850_evm_tl_leds[] = {
% p6 ~2 V5 _; j {
& o5 b; ^0 c# M0 \) `9 a .active_low = 0,$ p& O- l* u& }& }0 o% z$ K
.gpio = DA850_USER_LED0,' B3 g) `3 e/ j6 R
.name = "user_led0",
. | k/ ~1 f7 W4 C) y) G, \ .default_trigger = "default-on",+ l6 l) P. `, y8 r: r X! [4 \
},
G1 s* Q! o% y1 Y8 c% m {
7 p0 e/ k2 p1 e' U. Q6 I .active_low = 0,
) v8 f4 X0 t' q4 \* x .gpio = DA850_USER_LED1,/ h3 ?. }9 ] a% r
.name = "user_led1",
9 n% g7 p# ~1 y& H: h0 P2 E( \ .default_trigger = "default-on", A! d$ Y% [! e$ g* s+ f3 `
},1 O) l4 u4 J" K9 x/ m
{( e1 b; M8 e' |! { P0 B
.active_low = 0,! C& t/ {* R D4 g$ E9 f7 ?
.gpio = DA850_USER_LED2,
8 D' P/ Q# Z/ G0 j) B .name = "user_led2",5 u+ `% g& ~5 K/ a& w/ W, f
.default_trigger = "default-on",6 `1 Y0 R3 K# _3 d
},
7 J3 P, |4 P2 O' W {+ {: a: A3 I6 q$ Z3 x; N) _. x
.active_low = 0,
7 U' c+ \: A$ ?& B0 p3 A* M .gpio = DA850_USER_LED3,7 g* g$ }: J. a) ?$ M
.name = "user_led3",
4 r" o" } E# V+ r .default_trigger = "default-on",# y/ Y1 E5 J9 y
},
% u/ D$ n! S+ h5 l3 v};( `" l( R5 {8 ?$ h, G2 G
& k3 b$ x- g; v" j$ `
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" U, \) u) A$ W; q" S .leds = da850_evm_tl_leds,' Z8 h* ]( U! c4 l2 _/ r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, N1 f, O6 u. |( ~
};4 w- S: z$ N% d" s) I* B/ _
/ U$ G( ^4 }" E* p, C
static void led_dev_release(struct device *dev)9 t% B& i& L u/ {9 V
{+ c" z! B2 A3 }% i5 {/ P
};
7 {- \) {2 G3 h3 s- c% R" w; w8 I* Y5 |" |( r
static struct platform_device da850_evm_tl_leds_device = {
/ N' K+ p8 G. f" s7 J0 e+ g .name = "leds-gpio",
& m: y$ [9 I2 }& s .id = 1,
. d) F; I, |( f- P3 K( B .dev = {
& B4 S6 j4 {# y .platform_data = &da850_evm_tl_leds_pdata,. R5 @+ {' U0 C; j. i% N
.release = led_dev_release,
% P( F' T7 K: p4 o! t7 ? }' x6 u' d4 }8 l1 Q
};
& U9 C3 N- V8 `) r, T/ S% o
) g) l5 M+ [! m/ X4 H. O0 B# Fstatic int __init led_platform_init(void)
4 e, S4 k8 N* v* I* r{
$ t; v$ u1 f9 @& Y4 |9 o" y) A int ret;; q9 ]1 ~, x5 f" t( P. n2 e! O- e
#if 0- G6 I+ F" B5 B# Y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: \9 q# p0 r) L* s' t
if (ret): }( U- b8 }: {3 A
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 q! z7 Q Z, m) T! C
"%d\n", ret);
# Y* U: O$ d! l' I3 b#endif* r" J4 c; c# L- ^# s; a; B: ^
ret = platform_device_register(&da850_evm_tl_leds_device);
* @# ?2 L- q: @- O if (ret)
6 N( Q, P% w4 Z- v. P pr_warning("Could not register som GPIO expander LEDS");
G. [8 \) ^4 y. z else
2 B) H$ K0 C: e3 {5 i printk(KERN_INFO "LED register sucessful!\n");
+ J/ T- e0 [! o# L) }
6 v+ E2 R1 C% P return ret;5 T" H) B1 a ~0 z
}# r6 d0 b/ P- J
* k1 m' i: s: { {% O0 L+ hstatic void __exit led_platform_exit(void)
! C& a* M$ a: @6 j [{* D a7 b9 Y- Z( h7 b! g
platform_device_unregister(&da850_evm_tl_leds_device);
/ [! ~ q2 [) N, C& w' `. i4 d! |6 U( K
printk(KERN_INFO "LED unregister!\n");
/ R3 J6 n% L# g6 Y}* E- e n, m8 z
0 Y* {# j5 ?8 i2 Y% L
module_init(led_platform_init);! R9 I- o3 U: k7 W" \
module_exit(led_platform_exit);
0 u- G0 N7 I9 k- W9 D
( Y' p/ r) E) C) B2 mMODULE_DESCRIPTION("Led platform driver");
5 _3 G9 {3 v( c- E3 p F4 B% y2 f VMODULE_AUTHOR("Tronlong");
o% y, K! X% q3 I3 y; Z7 oMODULE_LICENSE("GPL");8 G) [& K( u7 v. z7 {( E
8 m! `) r6 ]! H! Y7 O
|
|