|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 j7 T# y$ m! E x
#include <linux/init.h>
1 l, O& Y: V* J3 Z) Y( S#include <linux/module.h>
$ P7 b; P4 A% }2 C" \1 f#include <linux/kernel.h>0 W' s. O5 x+ Z A6 _: E# Z
#include <linux/types.h># l( A+ {4 z% }2 x/ B4 F
#include <linux/gpio.h>
( \: Q9 a9 Y' J4 ~& p% P#include <linux/leds.h> P2 m7 [ J$ ~4 g
#include <linux/platform_device.h>
# _! A8 J! v1 G) W
- C. z, J k3 O: U1 j#include <asm/mach-types.h>& n$ O, k0 j# D) `
#include <asm/mach/arch.h>
' n: }# O' u6 ?: o8 w#include <mach/da8xx.h>, K9 H/ w% }: N
#include <mach/mux.h>
- F2 L7 P; j! O- z) e, h1 N- Z" ~" D& l6 m9 A0 ~$ M+ k3 D8 A8 A( Q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): ?9 Y* i) O1 w9 O# v; J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 c% ]' c6 G9 l( r& q* N
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 ?2 i, \! O" J* S( h3 Z* k" _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" T( c l5 c$ @+ r% s) k! P2 J
0 J2 `: u& k8 f: V( \- D/* assign the tl som board LED-GPIOs*/
( J% {9 b9 c& C+ }6 jstatic const short da850_evm_tl_user_led_pins[] = {
3 B3 y0 C; w7 ]7 e$ e0 B /* These pins are definition at <mach/mux.h> file */
0 e/ e& J$ t9 P# { DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. c4 I+ h4 v! v# C/ j
-1
4 n0 I# h1 n: t};% p8 F* T* ~+ i4 z- C+ r
& g$ @: b% ?4 q2 n0 ?. |3 e9 c
static struct gpio_led da850_evm_tl_leds[] = {' l' Z4 p5 n, ^; w2 Z- b
{
+ L$ H& a! B% C8 J .active_low = 0,# g/ s, G) H# w0 b) A" e, i" C1 @, N
.gpio = DA850_USER_LED0,! }3 M+ r# {& p' v6 u" o* w
.name = "user_led0",; F: V0 j4 }) d/ T4 L/ g6 M
.default_trigger = "default-on",! h$ ~ r# O1 g
},
. M5 Z2 b5 J7 @- M {/ _/ [' {, e6 p6 [+ M
.active_low = 0,3 N/ x9 v8 x0 K7 C1 J. w# s: Z
.gpio = DA850_USER_LED1,
3 k! m+ ~* H" q6 B; ?5 p .name = "user_led1",0 A9 o/ J1 C- X3 @) p) ?6 ?
.default_trigger = "default-on",
1 w: u. g( i3 Q8 c# q },, u4 v0 o& r2 F V. Z- R% [& D3 p
{' x- Z5 E- t( j# H
.active_low = 0, x4 E& U5 n( X O* l
.gpio = DA850_USER_LED2,9 j7 } b2 ^# ^6 f% B/ x. |
.name = "user_led2",( {8 r/ a6 k) j, _
.default_trigger = "default-on",
9 f" S6 a$ x. h9 Y; x" D },( y- L) \& f# \" O# v& t) S6 V$ I
{5 b( s4 e- V7 k- G3 w1 C- f: s
.active_low = 0,
0 b& j' u# h2 D, }- t2 [ .gpio = DA850_USER_LED3,, A: F4 q, q" E: ?
.name = "user_led3",
' c; ~6 |% z8 c) v% a' \$ Y4 R .default_trigger = "default-on",
& ?: V; n" D6 p2 y. f },
* r0 e' X$ s$ V! D};
; o6 ?4 \9 m7 e( k4 h; z9 B: O+ t
/ Z- h/ K1 ?& I0 o* {$ h/ E- r5 ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 }3 `0 x( [. D @9 Q% p& G .leds = da850_evm_tl_leds,
# A- z6 q, n$ S! t* G: E7 w7 [ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ Y9 \9 O7 }: {$ T+ E) { I};
1 O% O! [ |+ ~0 w# B* A; f9 |! p4 v) ? S
static void led_dev_release(struct device *dev)6 t) W1 z( [4 A5 o0 q3 u
{
) D7 B; T7 n4 U0 j! e3 D};
& j+ x- ]8 v( b; ~; q
- \' b2 Y% v7 `. S5 W) hstatic struct platform_device da850_evm_tl_leds_device = { i: \' ]3 [9 U+ P/ R& f! L9 T1 K
.name = "leds-gpio",
- }0 P7 T/ y* Z; E; B .id = 1,
0 I5 k) H( O1 ~ .dev = {
7 H! e+ S( y: o4 C$ _ .platform_data = &da850_evm_tl_leds_pdata,
6 J) w1 I3 ?. ^0 F& u& t/ } X' z .release = led_dev_release,
- j6 F6 V# |8 z) H r8 w$ U/ f }& q0 S, U$ ^4 a0 i
};
7 T+ g8 i h' `/ p
* z; F$ o( x, ~0 ~static int __init led_platform_init(void)
% ^3 z% q c# X{
4 ]( q% y9 {: j& @. F( z+ Y' I int ret;# }0 |. z9 K0 P& l y1 o
#if 0
2 s, e" u' y# Z+ [ z" w' b" x0 |$ ] ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% s# b8 Z, A# v. \& v
if (ret)4 ~4 F: Y7 [7 K+ w8 t2 [
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ P+ @$ z& R: a& b. w7 t! t& J
"%d\n", ret);6 P) {4 K- A, a# {9 ]
#endif+ k9 g0 O, f# r7 ]1 W+ u) H
ret = platform_device_register(&da850_evm_tl_leds_device);
. }! c2 N6 G% |3 M; n h if (ret). V, K6 N% z- c( @! z
pr_warning("Could not register som GPIO expander LEDS");
' w; R- D8 f/ S else0 U' d+ e0 @- _, q
printk(KERN_INFO "LED register sucessful!\n");
) S; k8 y. ]; V! }4 k/ h6 C
7 h# q! X2 O- S2 m( f( J return ret;
& [% c0 m+ N7 |- Z}
7 x& I }' |' w$ Y# l* S& u# u" i# u: b& y9 u' h% `2 ?
static void __exit led_platform_exit(void)* V* W/ D& ^1 E( B
{
, I# I6 g, Z2 x) d4 v) X platform_device_unregister(&da850_evm_tl_leds_device);( ?. m, U; M! ?
! C0 Q8 Q4 q* y4 t
printk(KERN_INFO "LED unregister!\n");
% s; _! G/ x# Q4 C' w}
* R0 B4 u) C- ^$ t5 q. r9 w3 ^6 @
5 L/ h5 Y& X% {3 `module_init(led_platform_init);
6 v! g* l" A) ~: gmodule_exit(led_platform_exit);
0 T3 \; l+ c, H1 b4 @/ D3 B" T& v5 e0 F. R
MODULE_DESCRIPTION("Led platform driver");2 j5 }$ e) H" x/ B, U
MODULE_AUTHOR("Tronlong");
. S: z0 m- C; }, l) i* c2 S, |0 iMODULE_LICENSE("GPL");3 t* b4 L; o6 T5 K* R& R4 t4 K; Z
) \ B0 S, I8 l- z& H! n8 j
|
|