|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- ~& P$ E* Z7 r1 N9 d. x% _#include <linux/init.h>% @3 |4 `( Y8 @4 i) T' }. I
#include <linux/module.h>8 ~3 }) a) ?% b A/ B. l
#include <linux/kernel.h>
" g) Y8 O( e; Y! S; G" d: {#include <linux/types.h>( T) q. {" T8 x4 M$ E
#include <linux/gpio.h>8 |) k- B% G3 Q! Z3 D' w- d8 e
#include <linux/leds.h> D$ J: e5 w) C9 U2 C, c3 E
#include <linux/platform_device.h>
% u- L- W1 t9 d2 c# o! a
: h e2 I- ~2 R! b% K#include <asm/mach-types.h> Y" X. x e/ j4 q$ s v. o
#include <asm/mach/arch.h>
7 n. z. s5 F+ q ?8 r) ^#include <mach/da8xx.h> M: e! u+ \$ {
#include <mach/mux.h>
: V5 K7 \- E9 ~# k5 Z
" D9 z% C+ u0 x* c K8 U# Z' b* ~4 \" F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). D5 P9 c! `$ \ Q$ k" L% V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 ^; H1 m4 s: J/ f; j# ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 Q* j! l/ Z$ ~; u& }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# w1 z: G3 m# M. ]5 a% V
: b7 @0 K; j+ m* Q, o% l/* assign the tl som board LED-GPIOs*/
1 J* Z# ^* E G2 M1 V3 ^" Nstatic const short da850_evm_tl_user_led_pins[] = {* ?3 _* z9 z5 N
/* These pins are definition at <mach/mux.h> file */$ W; b# y& A7 ~0 P% X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( F' h: F. [! o9 F- f, a( x" I -1
9 K6 k; Y" Y/ D$ q/ X: `};
p# T' A4 n: R9 Y" F+ o( w9 Y+ P. l4 e- L
static struct gpio_led da850_evm_tl_leds[] = {) W$ [ B: h1 z& O* R
{9 N# U$ L+ c" ^ Y' L2 c: D
.active_low = 0,/ Q4 P, Y& d& x" Z' n
.gpio = DA850_USER_LED0,; o5 b& o* y5 a) R. w
.name = "user_led0",
8 R& N4 K6 h$ p' y( r .default_trigger = "default-on",
9 t' o" p( t: h8 J9 P' y },
( [2 R. n# `- h u2 x {% V" a/ W& e) T! k: y( s3 [; |8 G
.active_low = 0,- B4 j7 @* E- I# l0 K. i0 ^% L R% G
.gpio = DA850_USER_LED1,
+ C. Q2 y% j+ v .name = "user_led1",) o; _9 ^8 S2 {8 _6 R
.default_trigger = "default-on",
8 f) [3 }9 \9 L9 s { },
2 f' m- i! ] u! w, Z& q {
& v5 }0 ^1 m% S5 V4 q7 A4 L .active_low = 0,
7 P: ]/ g, [0 V" G V .gpio = DA850_USER_LED2,! P7 V" R' A9 m9 }- D
.name = "user_led2",
) ?0 D+ S9 t7 r9 B .default_trigger = "default-on",
4 t' d) w( t9 O# @+ u },
0 h( g( N1 T+ w& V/ e {
0 }3 }' t" P! w- ~7 ~ .active_low = 0,
1 m: o% [: d9 f2 H( } .gpio = DA850_USER_LED3,
- ?' C* i! ^0 I0 k% o$ H& t .name = "user_led3",! q! h+ v$ g+ F- ]- K& c
.default_trigger = "default-on",0 o! T* L' s( z% r$ P
},
; ~; Q4 X1 d I: b- ^};
/ t3 K+ Z L3 G/ [! D& o
* K5 _3 i$ E8 h' T. ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ s" E7 k# k4 t$ G
.leds = da850_evm_tl_leds,, ]9 @; w3 Z/ t1 T7 I$ Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 P0 M' Q$ \ A) [! a6 }, s
};* l& x9 n1 Q7 S1 u4 z
* v) B$ w [ C$ Q+ c
static void led_dev_release(struct device *dev)
3 H3 P% o) a% c8 V1 T8 y{/ i7 P0 t# M3 |3 i
};
) U+ @/ U5 u6 N p* ^ w& J0 S/ c7 a- q% C( q! k0 ]
static struct platform_device da850_evm_tl_leds_device = {' H/ A% g' p7 q8 b0 l: o5 ~# D+ [4 Y2 h
.name = "leds-gpio"," D$ A. A" T, i2 p U4 G5 w! Z
.id = 1,
2 k; b, `* ?* N7 u2 g- ]" i* X .dev = {
/ \3 u4 W$ T9 I: e( {8 x .platform_data = &da850_evm_tl_leds_pdata,
* `$ W. P0 x4 o3 R .release = led_dev_release,4 z2 l0 ~0 v3 ]7 ]
}( {0 d& w' V1 O" O& [: j( r' J
};2 z, Q1 A- k+ H& Z4 k7 s& V6 d
* Y @- Q# M3 c1 ~. A
static int __init led_platform_init(void)1 K% Q: B& ^' s6 w1 w! j* G# V4 X
{% z- L; U9 _: ?$ y
int ret;
* a3 v: s& q; y1 j/ R! c: j' ]& c#if 0
3 `& @; V( Y/ G! | Y m1 s1 F$ O. N ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 k% D) b8 }' i1 j if (ret)2 x3 h n7 Y% G9 x. \" l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 q/ _; v6 x; a2 T3 h; d1 m, d "%d\n", ret);
' ^7 y, S' Q# T4 i$ p#endif
0 H! B% e O8 x/ j; U( m O( } ret = platform_device_register(&da850_evm_tl_leds_device);; q& {& Q4 a! @, y5 \
if (ret), {. ^1 E2 w* n2 J
pr_warning("Could not register som GPIO expander LEDS");- [/ n& Z+ `- D3 W
else
( Q Q9 q* \% I0 k! X* D printk(KERN_INFO "LED register sucessful!\n");
7 M- @8 M" \% z/ F" [5 D. U* K
1 l7 I* W9 Z# f; B return ret;% f- Y1 a3 ~& W$ k' q$ d
}
" U" \! w$ z. }% V+ ~& I/ q
/ v- y5 K+ B7 x0 Fstatic void __exit led_platform_exit(void): G4 b+ G6 B! f- H. P+ p, i& s
{
& v' u" d( Y; l* F platform_device_unregister(&da850_evm_tl_leds_device);
t& J3 M2 f9 Q7 U, M$ m. x) W+ [; L: G9 X N- j! I
printk(KERN_INFO "LED unregister!\n");0 j6 W4 H. d/ y$ S$ T5 k" a
}4 }' H% w8 i9 B8 G5 S& y% f
! i6 R- f( L0 z/ l" U1 L
module_init(led_platform_init);
* Z; T! r/ R0 q5 V8 ~: `* h9 q0 Dmodule_exit(led_platform_exit);' J" e- [( ]9 t5 U7 F/ B$ G
, A/ z9 W4 ^ E3 J1 o2 I* C, aMODULE_DESCRIPTION("Led platform driver");
) F2 G" ?: |/ |$ J4 s% u, ~0 zMODULE_AUTHOR("Tronlong");+ ]' x1 e2 ?: y6 h1 `! O$ U+ x4 \
MODULE_LICENSE("GPL");
: K, B! k! M2 [2 q6 ^ A( G) p; ~; n: Z" @
|
|