|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 L! c/ b p4 ^# O4 a0 G% a
#include <linux/init.h>
' W) X5 k+ N1 Y* v c#include <linux/module.h>
4 z9 q8 v1 j" F7 ?$ C4 Y3 H% z#include <linux/kernel.h>3 g$ G7 Q& ]( F
#include <linux/types.h>
6 b5 b8 |$ d5 t#include <linux/gpio.h>/ M. i s$ D5 n B4 u U
#include <linux/leds.h>
7 S. R x; u; P; Y2 n#include <linux/platform_device.h>
5 m! }: z( t1 @, }8 d2 Q. ~* W
2 B w; ?& U3 J#include <asm/mach-types.h>1 {4 n- r" R( L9 G5 l
#include <asm/mach/arch.h>8 k2 \4 y: p* X8 h# n5 a
#include <mach/da8xx.h>1 D. c4 Y1 J$ ~) K! P: E
#include <mach/mux.h>, ~: b5 I( n# B' J" j4 ?3 f* @
1 m p% [% t, P Q* a& P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# p( l) [* T! S' @$ x, y7 h z' i#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 I5 Q% v2 k3 h#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 z- J( Z, O) Z4 K
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- p& d! p" k! j
1 c# V# m5 Z- c/* assign the tl som board LED-GPIOs*/6 u) L3 ~& d7 r' H
static const short da850_evm_tl_user_led_pins[] = {
) B! T7 a- ~+ c+ B. x /* These pins are definition at <mach/mux.h> file */3 _" R6 Y! g4 u* ? Q# M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ P) G" B I/ ], V -1" |) w9 s3 K5 ^2 w1 ?" ]
};5 E% Q/ j- F* C4 v4 _
5 R6 w( n! x/ s3 @- s6 Z) B% Wstatic struct gpio_led da850_evm_tl_leds[] = {; e K" j6 d2 Y1 z( W
{
0 g$ @: F" o1 h: w9 {' R7 K .active_low = 0,
& J8 Q4 a) N8 ~! e# D# X' S .gpio = DA850_USER_LED0,. F/ M0 w" [, x0 `; l9 z4 W
.name = "user_led0",
1 T1 l' F( K9 o7 P4 l3 R6 l .default_trigger = "default-on",: S: ~7 |2 Q2 t- k
},
# }; t" `' m) B: [8 Z# v; S* i {$ l5 c8 p4 K3 _8 G* U3 [% k
.active_low = 0,
$ ^# B x2 f! z4 d2 r .gpio = DA850_USER_LED1,
* B3 P+ Q+ b5 ^ .name = "user_led1",
5 n: Z) m! x6 w3 \% G" L5 z .default_trigger = "default-on",' J1 k: `- x6 h' C
},9 [9 s' O2 B2 A2 v
{. ` Q8 T i( Q4 q8 q9 ?5 _
.active_low = 0, D" l/ S0 `; z7 j3 ~
.gpio = DA850_USER_LED2," y G# P6 N, t p' z
.name = "user_led2",
I" Q1 {6 Q. o; z4 L .default_trigger = "default-on",
8 h! x* ^3 \$ ^4 ?+ Z },! }& l, v' x. M
{! _0 v* |+ w' j5 x, }5 }8 F
.active_low = 0,
9 v9 s. i) e9 c1 J .gpio = DA850_USER_LED3,
+ J7 T! u3 r5 s6 }1 k .name = "user_led3",
1 Y* h/ d, I. k3 d .default_trigger = "default-on",
, d% B+ [, n N- r1 P7 D) n6 u6 Z },
& h5 O- C& ~8 v8 ^3 {; ^};" ^5 a7 p* b" t7 v1 A+ J( | r
/ A1 q6 h7 O1 `( U2 z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( e6 W( t8 k$ Z3 a I
.leds = da850_evm_tl_leds,; ~$ d9 ?8 L7 `8 }/ Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- m F+ [: o s4 y1 q/ ^) [9 G% c};
' h5 E5 P, v# n- w# e7 l+ b8 J6 |) Y: U
static void led_dev_release(struct device *dev)
0 s: i, U! _5 y, B+ a: p. w{4 p0 c! }8 B0 E$ a
};, n) u! R# O( l
0 ~ {% x+ B2 }static struct platform_device da850_evm_tl_leds_device = {
) i$ R8 s5 e1 d7 ]; z .name = "leds-gpio", m: U& |4 I" V3 L* C) V) }
.id = 1,
5 z' w' K g' ^3 C- s .dev = {
. e% {$ C$ P' ]5 v {/ q7 F6 _: s; l .platform_data = &da850_evm_tl_leds_pdata,; I7 Q. l% C5 e8 ^
.release = led_dev_release,
) S+ P, k: V# \# i/ I/ @( C } o; i# Z9 b* e; L J z. i6 g4 @ M
};+ T5 a4 T7 c; u; G
! q& w9 t1 a9 e u4 x' L0 Mstatic int __init led_platform_init(void)
7 y& W& }1 m5 @; t/ M{
, \- r ~6 ` @9 ^" }- ^0 R int ret;4 D3 N+ w0 ~0 a9 C x3 l% |: Y
#if 0
1 W; e& f. L- A y( W. j' X! j ? ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# C0 V- j* g w) w* N7 A
if (ret)
- F3 j Y7 r) [2 C pr_warning("da850_evm_tl_leds_init : User LED mux failed :": H! Q9 q) |- q( ?# U
"%d\n", ret);
& D7 t$ s0 e# y9 S#endif
' }& j, Y! f* s/ C o% y ret = platform_device_register(&da850_evm_tl_leds_device);! s5 v, P: f! A0 A$ E
if (ret): Z; l! A- Q, L/ u: C ?" |
pr_warning("Could not register som GPIO expander LEDS");# r/ Y$ E+ ?+ P2 b2 S/ q
else! X/ x2 V# I3 R0 B, z7 _
printk(KERN_INFO "LED register sucessful!\n");
' X2 P9 @8 V9 ^$ p) V0 l! O" F9 k0 V, L1 c# Z" y& k& r
return ret;
6 m# e" ~2 L7 }2 o% w& f}
( X6 ]9 B4 L+ z! Q3 T4 B3 h$ g0 s* z2 Y% a$ Q. ?0 ?* p) t
static void __exit led_platform_exit(void)
/ o# v( S0 D) @' O" W+ R! [' h$ W{
- e' ?0 ?2 \: n* F* w: y9 C platform_device_unregister(&da850_evm_tl_leds_device);
. C- p2 L, E) k" e6 B* g( }: ?' f4 M
3 ^# J o: D5 X, _& ^+ r printk(KERN_INFO "LED unregister!\n");
$ E' v; M8 G, {; W2 }}( d8 @1 e1 o T& p' _
# [0 L" J( a0 a* f# h3 Xmodule_init(led_platform_init);# o8 D5 r8 \+ t$ p. o
module_exit(led_platform_exit);, l1 U% I( x( ^2 m& }) ~* W/ x4 H+ A
% P% N3 n7 p; V) H" x" X4 e! v* [0 Y
MODULE_DESCRIPTION("Led platform driver");
! |. x! U" V- E9 j S" Z0 QMODULE_AUTHOR("Tronlong");
1 q0 h" H4 p% G4 U' uMODULE_LICENSE("GPL");( s9 }$ \0 S" I
6 l" B2 a9 D7 `, F2 A |
|