|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, L! V6 ?* x2 c: f3 ~# q4 t: [
#include <linux/init.h>: q% c7 h b( n _$ m, E
#include <linux/module.h>
R; |, D3 g2 C; @5 l#include <linux/kernel.h>" x8 e" {+ _- ]
#include <linux/types.h>
, P$ I3 s7 ]) ]2 a# {9 P- w' X" r#include <linux/gpio.h>% F- r4 h- x* w4 Q5 \- I/ ]" `9 G
#include <linux/leds.h>+ w! T: [- q. R8 q# \
#include <linux/platform_device.h>
8 S1 }; A3 [# z* \ T; ? r* D# h1 I' _; ^. W" C
#include <asm/mach-types.h>, l5 J7 N+ p: t% M
#include <asm/mach/arch.h>
6 `* h4 |: r/ G" c5 L- }#include <mach/da8xx.h>' B% }, g2 T& D. ~ ?$ Z
#include <mach/mux.h>
$ C& V. z1 `$ \+ {2 z. f
" b4 T3 Y+ N# z! c( i#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); v$ Z) i' w$ p: ^. T3 a8 E+ I) y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 V2 B5 R% `4 |9 v- w, o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 H8 `: i8 S2 D" i! F% q# v7 r
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 ~' i* y; L! m0 {0 A& |8 r$ x. B$ d# m% y1 [
/* assign the tl som board LED-GPIOs*/ l! u( L0 v2 \' C' A
static const short da850_evm_tl_user_led_pins[] = {& a$ ^) g5 [3 P( V# ]
/* These pins are definition at <mach/mux.h> file */
( j# e+ f b% t* ~( n7 V' e3 W; G DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 ?0 O( C1 M- c# f1 z" V0 _+ _
-1
& a" b5 p7 f3 R" R& G};
* q5 A' M. F' @+ U5 _8 z) }1 f: i8 R8 U2 T) q( R
static struct gpio_led da850_evm_tl_leds[] = {
1 I3 s1 { ~- q0 G7 q Q" f {* x e' S! y2 L# H# W
.active_low = 0,
1 f/ r9 [# D2 |& j3 d, P .gpio = DA850_USER_LED0,- l6 O1 _2 Y7 Z X3 c
.name = "user_led0",
C4 R; q, Y* B( V .default_trigger = "default-on",: q1 `. Y4 @! F/ f5 L
},
3 y; S/ I% `* y' U! J5 w4 i {
% G5 E( M7 o* h) F: J# z7 F .active_low = 0,
) f" J. W: n( K. _5 B& ~" Y .gpio = DA850_USER_LED1,) U7 {- A, g2 |2 ~6 o/ Y/ j
.name = "user_led1",
0 B( J \% c% g0 N .default_trigger = "default-on",% z" Z1 H( d% Q+ y' b
},; { z% N+ Q- Z9 D- [
{3 Q9 ^/ E4 S. ~& l2 R
.active_low = 0,
6 w& o. y: g) L( ~ .gpio = DA850_USER_LED2,# K& B; E% u9 P7 U0 Y7 I
.name = "user_led2",3 \6 W! M# J% Q6 s# J4 r* u1 t
.default_trigger = "default-on",+ G# V7 {& q& x! A
},+ i) [) R& E4 \5 q. I( |
{
# a$ F0 ~- B% b- }7 y* { .active_low = 0,9 j0 S7 @1 z9 ^9 y
.gpio = DA850_USER_LED3,) j( O& D: I1 ~; L& h" w1 M8 O
.name = "user_led3",
* \( d0 T* l3 G0 p' @3 U1 C .default_trigger = "default-on",4 T' S4 t6 O: J7 C
},
8 I) s5 ]6 `- u" Z};% h1 `' K2 @3 ^# j
% g& t2 F) l! U1 m+ b, M9 g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: f E0 o/ i" ~) `5 y" H .leds = da850_evm_tl_leds,; z1 z h. f1 A+ V& o$ x& H& @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 l* O6 @9 w- _/ j6 H};
1 C/ N: S: d: s- _
% N4 c/ |# D$ R2 w7 N' i% qstatic void led_dev_release(struct device *dev)
! K3 S6 T% m6 ]% X( C$ D) Q5 e{9 S0 s/ D! X; f( A" X; m1 u
};
% j2 W% ^8 l" ^$ F0 u4 D+ U; l" }/ i/ F+ F8 U3 V0 g
static struct platform_device da850_evm_tl_leds_device = {0 X* U! @( i$ K0 f% s# l
.name = "leds-gpio",
6 [: Y& k4 K# p% k6 i% O .id = 1,
4 s' V3 ^( F1 j# ^3 {2 t6 W& W$ Q8 M .dev = {
/ F7 m/ \1 I* y& X5 k% O .platform_data = &da850_evm_tl_leds_pdata,
# V( V0 A7 u6 e .release = led_dev_release,
% q, @) W U! d& a }
% l& b1 k% f k' d# p' v};
, l. y8 B7 U. d$ J, J, ^* M( Q0 W! y: Z* J$ J% O
static int __init led_platform_init(void)
8 g' v* K1 W* p% ?2 B- C{# t( L2 i1 z& M Z7 J, \0 h
int ret;' m! x$ ^9 B$ s; y6 [8 k+ M0 B3 B
#if 05 [; f9 ?6 y7 ^
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 M, y" L V$ Y) L
if (ret)1 K! D2 F' c% L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 V7 m/ H6 D2 K& S: ~5 Q
"%d\n", ret);
- v0 P; o" @1 |; h#endif
+ x) w K: [3 @, V4 _- K ret = platform_device_register(&da850_evm_tl_leds_device);* p6 f/ c. `. k/ [3 x: w t$ r/ B
if (ret)
" d ~& O, k+ v3 R; Z( Q pr_warning("Could not register som GPIO expander LEDS");! N& a& v+ Z9 Y% z. W$ j
else
0 _$ I5 q5 M! h printk(KERN_INFO "LED register sucessful!\n"); Q ]3 R ^" i3 U
2 a3 D- R- w% A return ret;
. z: K3 Q3 I9 |: ^) ~9 Z}
% z0 K, W+ w0 Y8 [7 [6 c% k0 y. _4 y' \5 N7 W4 d# ~1 f( F$ w, h
static void __exit led_platform_exit(void)
0 D( S8 ~0 N: E{
4 g: t$ L# c7 h) A platform_device_unregister(&da850_evm_tl_leds_device);" Z6 [. z8 o/ U/ V
( y; @1 V1 n3 g2 y, M% g printk(KERN_INFO "LED unregister!\n");0 [! x# w7 T& n% T9 \: {: t2 _
}
8 e$ y( l2 i$ {7 E' o! ~- g
% b2 [2 c9 G5 t1 k( M4 Pmodule_init(led_platform_init);
, y! R$ R k* Q* k; nmodule_exit(led_platform_exit);+ V; }# V* S, d
- n! w; Y5 w" I& b
MODULE_DESCRIPTION("Led platform driver");$ b8 m/ L3 c% _
MODULE_AUTHOR("Tronlong");
# h7 X" q" ~5 t8 E. `MODULE_LICENSE("GPL");
0 ~$ d+ ]! ~9 r" v9 s- W' O7 U' p8 Q) y3 {5 ~2 o |5 {
|
|