|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 G3 ^' U* k/ o
#include <linux/init.h>
& t4 q# F6 Q1 e0 ~#include <linux/module.h># s% E5 @3 b1 D" c7 _8 r
#include <linux/kernel.h>' n% z9 g2 T+ x+ i, Z) H
#include <linux/types.h>, M0 i! ~7 V4 j0 G9 K9 }
#include <linux/gpio.h>
; o' E% h2 o+ u; G* P8 S( O: a#include <linux/leds.h>
) [; e5 J8 A" \#include <linux/platform_device.h>
1 C8 M; y; G, j) p" u$ M/ X0 p/ G& ]3 o9 U* X- h4 C
#include <asm/mach-types.h>0 k4 v' @- \# ]& s
#include <asm/mach/arch.h>
! c3 `& X9 n6 R, ~, @#include <mach/da8xx.h>
( F' u$ Y/ x G. w9 Z#include <mach/mux.h>
$ V$ m1 @/ R P# y4 T7 T. Z: E% {' ?* i5 c4 B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ a f' Y9 n; X( ?* Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) G0 P. Y# n8 t# D
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 _$ C+ f4 ? ]3 [' A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' Z5 `8 u# j! B8 l8 Y2 M4 a5 n0 ~1 k9 y
/* assign the tl som board LED-GPIOs*// B- b# f+ ^; K4 x3 n# y6 p j1 x
static const short da850_evm_tl_user_led_pins[] = {
+ l; i8 d0 Z1 o9 ^$ c /* These pins are definition at <mach/mux.h> file */
s" v% M% N) P, v$ B: A% P5 j DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- O+ K9 ]# x$ n# ^1 E7 P
-19 j0 v( f5 f- E# R1 @
};! s$ g& k; G: X& r
, E5 Y; _4 G' x7 S7 J4 |
static struct gpio_led da850_evm_tl_leds[] = {5 D* H. T& a) g* X" w3 v( \% c
{
1 B4 e7 }; u' E# ?- ] .active_low = 0,
' A0 Z5 V3 ^" M' M .gpio = DA850_USER_LED0,/ t3 \$ G9 D; n' w; s. @; X
.name = "user_led0",7 r8 J9 @% O1 R3 V) u% Y
.default_trigger = "default-on",* ]. f2 _8 U' Y; g
},
; W2 z* ]7 K; B8 p+ v {6 ]; c8 e* a4 z, ~
.active_low = 0,
9 W' x' H/ H' F- b .gpio = DA850_USER_LED1,
3 `2 E$ `0 ]1 _0 U k: H+ ^7 [! P .name = "user_led1",) q1 A5 I4 s/ E2 B2 j
.default_trigger = "default-on",4 n* [5 P _& ^2 ]9 w$ R; I& u! j
},$ ~" M3 i* k% z) ^
{) k( u. ^4 Y/ L' I8 p+ D2 r" {5 q
.active_low = 0,; {0 ]3 P% P# y8 d
.gpio = DA850_USER_LED2,, w% r- P! r6 V z4 N3 G/ T- [
.name = "user_led2",9 N* p0 i$ [# B
.default_trigger = "default-on",, n' y0 v, i3 U7 F; |8 u. {5 P% o0 \
}," o* k7 c/ Z; y- {
{% P( h* l! m t( K; B
.active_low = 0,) m2 Q) U: H' z: q+ `8 `5 W
.gpio = DA850_USER_LED3,
) E5 E; }% ]7 h; O6 P5 y .name = "user_led3",
% O0 G+ x9 A* {7 C C$ D! A+ t .default_trigger = "default-on",
; ~0 a0 c; ]1 u% c },
- A( N6 y3 o9 i- i1 [! @1 l' h$ a};
( m% w/ V8 [* ?. p" [4 u
' |$ K* K! _' b' d3 ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 D, q: F) |8 [: X6 i5 N. E$ e .leds = da850_evm_tl_leds,: F$ e' r/ P& ~3 v8 j9 s# {) [" ?# T
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, G' J4 {' [ t1 O5 R
};
. Y& V( @$ o. k& i3 ~6 @# b" y2 {. Z: \4 b
static void led_dev_release(struct device *dev)
0 B% X% ~ U% v) n( \{
% V% F5 a0 X, z! S; d; j};7 {: u) F) q7 m6 X+ A; \2 S- q
# M3 a% {4 C$ d" g- ?
static struct platform_device da850_evm_tl_leds_device = {
* [1 L, c2 ^& T& o& v+ j .name = "leds-gpio",
. y- z* N* y9 z9 L .id = 1,' I# F6 L: ]# m) I8 A- A
.dev = {5 c5 \* c: {4 i: `* [. k' V
.platform_data = &da850_evm_tl_leds_pdata,) F3 r. u3 y" x' N2 x& I
.release = led_dev_release,
% _2 g, m: V% a# v9 Y% c( ~- |. A" f }1 c5 S; p1 Y# ^
};
: [3 E) J( w& t4 y6 x6 L3 w. r! I$ \: `( h3 Q
static int __init led_platform_init(void)' N; Y5 |! m. T- ]# J
{( E. B9 v2 _) |) y1 E
int ret;
5 x; o e( ~: z+ {2 O& U6 G! U9 ^#if 0
) L8 F3 [6 e1 L7 n; D( \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* X! w2 ?0 V0 F2 [8 B! _ if (ret)% }, ^# s+ e+ }% ?& ?, J7 ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 W( p& V1 E4 X0 ]0 p4 w "%d\n", ret);
8 I1 t P3 B- ~ E' p' d. j#endif
2 Y. } c# G; F ret = platform_device_register(&da850_evm_tl_leds_device);
8 E: [$ i$ ?0 _7 P1 v) f7 T" H if (ret)
, w7 {( x3 m+ G7 z: E6 P& P pr_warning("Could not register som GPIO expander LEDS");
- ^# j" J! P9 g S/ I5 z' x# s4 } else
6 R! [, i' x5 s) S3 N. |0 [ printk(KERN_INFO "LED register sucessful!\n");
0 S$ E1 o; J* }& i1 S
5 _6 _ G' ^6 c1 j' c* O$ Z0 {8 N return ret;2 j! j& v' s0 B3 Y! F3 Y/ z9 A Y
}6 I9 s+ T- r/ g8 J* S4 K6 Z' y
7 P1 p- l8 a/ K2 |; d6 P* b$ E" u8 p
static void __exit led_platform_exit(void)
! g" W/ l0 k$ F+ w{
$ i% e; U4 t3 X& A platform_device_unregister(&da850_evm_tl_leds_device);
2 r1 B6 k) |+ B" x* L1 S& n$ d
4 F! d% ~/ q; @, F4 g' f/ ?! C printk(KERN_INFO "LED unregister!\n");0 J( C: r5 n# [( ~( D' e) G0 p
}
% }; L: T5 M# q/ z) W$ F- V9 l' D8 n T7 e) c7 R$ I
module_init(led_platform_init);: ]" V3 p$ q" S. a7 r% e
module_exit(led_platform_exit);
! G( u! ]0 h, n) P# _8 T* K
3 R) Q: A4 Q& g7 n$ J$ YMODULE_DESCRIPTION("Led platform driver");
9 k; c9 B+ o1 v" QMODULE_AUTHOR("Tronlong");) R& e8 L% _' `' R0 `0 a
MODULE_LICENSE("GPL");! C1 L& t/ U3 i! e, Q9 C4 h
6 A2 [6 r# c: Y2 m
|
|