|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* {3 f2 ?% f! H9 I' C#include <linux/init.h>: F& N+ j& b% [
#include <linux/module.h>
6 b- W3 \+ m0 S% @! M#include <linux/kernel.h>
: b/ a! U6 O/ S8 h! U( w3 y* I/ [#include <linux/types.h>
7 u% Z& k4 d: p" N#include <linux/gpio.h>% E3 @) m& b" E9 W$ m
#include <linux/leds.h>. r; o5 O6 K6 v* B
#include <linux/platform_device.h>& \' d; L6 X9 k1 T
K6 H& {* j6 V; u8 n4 d: T+ O#include <asm/mach-types.h>
7 u( T! j% u6 c6 G. l' u2 O0 g#include <asm/mach/arch.h>
, }* q7 R w" ^( p& f#include <mach/da8xx.h>$ A4 w, |- {# s9 m! z) |: r/ I
#include <mach/mux.h>
. y) r( [4 f: V* @7 F9 }3 G+ y$ x. ]0 C' ]1 s( `! s; g) |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& s6 B2 g% ?' }; ]#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# w1 h% G1 i8 X/ q/ g$ g. z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 T8 x) t2 O! r8 I3 X+ f& Q% Y) P#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 M' K/ m8 ^# C6 [+ ]; Q& D: i$ ?5 @0 |7 Z5 e
/* assign the tl som board LED-GPIOs*/
2 O0 k1 h$ J; istatic const short da850_evm_tl_user_led_pins[] = {
! q W6 l$ X: n% P. ] /* These pins are definition at <mach/mux.h> file */
6 N2 U. N h$ u6 X9 ~5 O DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* N" h7 d# K# L/ X& n8 g, p" a
-1
8 V! v/ a8 e) _5 s' ?: W};1 z' @, B' o' i- ~% @9 y% S3 |% k
. M' g" `& B- k s. K; q
static struct gpio_led da850_evm_tl_leds[] = {
9 |) {- I" N8 F2 A- _! h/ Y {
( K& a3 d" E0 I, Q+ v- u .active_low = 0,
( t! A" ]4 {& L% Q* ~0 y .gpio = DA850_USER_LED0,' Y7 g" E2 D& M1 L: h+ E8 C
.name = "user_led0",
. h1 I; d7 h( } .default_trigger = "default-on",7 c8 U/ l* p/ |7 u
},9 ?* @- Z; @" y O) m0 a
{
0 {: ~2 a9 ?& K! g' M2 |9 s: n .active_low = 0,
4 n7 J( j/ ?, Q: \$ R1 a w .gpio = DA850_USER_LED1,4 L( ?1 W9 A: f7 r& S
.name = "user_led1",
) w6 @5 Y5 I# s .default_trigger = "default-on",
0 ~$ @* E$ Y9 S: H' `$ ~# N- y },
7 h' ?3 W0 \% I! q6 V. y' A {
* s! E6 Z! y1 T+ M .active_low = 0,
+ X( w, Q" o1 s( ^ .gpio = DA850_USER_LED2,
/ w/ R; m+ Z# Y" d# `3 i .name = "user_led2",
4 g. Z# s% L! i' h8 A, k .default_trigger = "default-on",
9 m. N1 Z7 V7 _! ~2 s },; P7 L* Z5 D7 t/ |% r% T( t
{. H$ P9 p4 o5 Q: R/ j4 `7 n- \
.active_low = 0,
; e7 t: S' t* ^, m .gpio = DA850_USER_LED3,
1 I5 h) X' ^# r2 z .name = "user_led3",/ n# s+ _( W1 t2 A: O2 ^
.default_trigger = "default-on",
: [( h! J, R: a: J },& n( a0 P& r' G
};
6 J3 \: B: i5 ~ w5 r2 r1 \5 V) w. c X) G+ R# e8 h
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( [6 c W x+ O$ i, G' g F
.leds = da850_evm_tl_leds,! @" c. ]) x8 v7 e6 A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 X% Z; Z! j0 _3 i" ~0 h# ]
};) p6 G, I. u- z
/ p3 j; I2 l* n$ k) Z
static void led_dev_release(struct device *dev)( E% V3 @; V) g" Y9 T
{7 z+ s) r+ D6 u
};( o: K7 a& S j) I$ X2 N2 g- [2 h
! }) j, D$ V, Pstatic struct platform_device da850_evm_tl_leds_device = {: w6 |" |0 o9 J& a2 w( c+ v
.name = "leds-gpio",
, W9 y. x' f/ \; Q8 { .id = 1,
% l9 @, p' C5 N .dev = {
5 }9 f' {+ d; ?9 s: A% B .platform_data = &da850_evm_tl_leds_pdata,. }# v' F2 C2 D$ V
.release = led_dev_release,
1 k3 z. u7 i" k7 F$ D8 f% w }
. C- W8 B5 X% v* }# |};
$ J- q; c6 E$ O0 D" c" F9 {
4 P1 b" `9 B# L+ d9 A# \" g" xstatic int __init led_platform_init(void)* u5 A4 c4 G, o7 A6 X6 J0 S
{
% Y4 S2 C4 g+ Z& C% Q, ^ int ret;
0 C1 b+ ]8 r( r0 D# E8 Z' [% p' D: b#if 0
# A' c' u/ m6 a: t' w ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% f1 w% Y* k7 F$ N7 e; {; U' B7 S if (ret)
5 t. v6 b* _1 C+ y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, p1 O3 k7 X+ E1 B9 z2 U/ V& L "%d\n", ret);$ c2 g2 s1 w0 t: D" I; u; r `) e
#endif; C! D+ |+ O& q! a' e+ D
ret = platform_device_register(&da850_evm_tl_leds_device);
0 g7 X3 O9 P- E8 f8 @. S5 J if (ret)
8 J' V# C; x/ y3 h9 p' R+ }$ y" Z pr_warning("Could not register som GPIO expander LEDS");6 @1 j, N. h" |* ]/ X" V3 W
else$ l! ?# p/ u9 Y
printk(KERN_INFO "LED register sucessful!\n");
) S7 S* S' Y) e: Z& ]6 `) f! ~) @" l
return ret;3 { \ P" c7 P8 L) d P
}
9 W& F; D/ S6 s: q& b1 F% V5 L' {. q0 Z; ~* W
static void __exit led_platform_exit(void)8 h$ P; P( L+ ~ {7 f
{
6 y9 S1 r2 j9 b) g6 p& L2 c- t platform_device_unregister(&da850_evm_tl_leds_device);
8 P8 O/ m% L6 y7 l2 Q0 ]+ m3 V% ^5 D/ _5 ]- {9 S
printk(KERN_INFO "LED unregister!\n");1 ?, Y" K# T( m$ Q7 Q# o
}
: H1 h; b. n) a7 O) r. x2 S, i& J- ~8 d
0 f# J' ?0 Z! zmodule_init(led_platform_init);
) l' g4 Q6 z# j7 y/ \module_exit(led_platform_exit);
* O) Y0 B- H/ j+ e% _4 Y0 ]. {" _2 c# \ \
MODULE_DESCRIPTION("Led platform driver");/ Y# K# B' z" A k
MODULE_AUTHOR("Tronlong");
* F+ }" t; j' wMODULE_LICENSE("GPL");. j/ w6 ~ _8 u4 w1 N
1 [' W" E' i9 _- S+ g/ u
|
|