|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 F6 l! y1 y- C. X0 N#include <linux/init.h>, H8 B5 W' U' }
#include <linux/module.h>1 J' Z& ?7 H+ |4 N6 {0 [
#include <linux/kernel.h>5 f7 N; j. D% T! M s+ N. `
#include <linux/types.h>
% q" q: g! i+ X7 `( m7 p3 }#include <linux/gpio.h>
9 I- ]/ U9 m# _" N; |, d#include <linux/leds.h>
6 H- E2 L9 s3 q#include <linux/platform_device.h>
# N2 r6 O. @! B1 r( d
) A- A/ H+ R7 M$ k, y#include <asm/mach-types.h>" ?+ `9 c/ m/ b! D
#include <asm/mach/arch.h>+ J- Q. u5 i4 v1 E3 b
#include <mach/da8xx.h>
/ Q. {% N( `! v4 R/ m#include <mach/mux.h>
* v d7 ^8 o8 |0 g! E0 T( n
& L( U4 I3 v+ N' R0 B#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" V+ l$ B6 t6 o9 t1 D4 @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 J/ z! E8 w4 E
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 U! x& D1 Q9 R% H#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ e/ x9 I$ {% s8 B6 [2 D! A1 ?5 H F! d" X7 D. d' t/ B2 F
/* assign the tl som board LED-GPIOs*/
$ z" j! l+ L% Fstatic const short da850_evm_tl_user_led_pins[] = {9 q9 e' U( w" h
/* These pins are definition at <mach/mux.h> file */- w I0 q# A. L# ]
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 c3 t( j' K- ]5 g s4 A. N7 e. u* \
-1
9 k3 o" p- h+ i8 Z" ^9 k};
7 B* R1 S# c. ?+ [8 X
. g) @' j% J, E# c6 E4 P: B6 G' \static struct gpio_led da850_evm_tl_leds[] = {
8 P( a! T8 u' H' u s {
5 t: R% X& V/ a, \$ W; {9 F6 b .active_low = 0,* K5 l3 H' a% k4 _* }2 C+ { K9 ?+ |
.gpio = DA850_USER_LED0,
9 W2 |6 J; \* T .name = "user_led0",; w: J, K) e& b8 B |
.default_trigger = "default-on",& a" ~$ Q5 y$ S& _/ R6 P
},
* @" e, M5 E: f5 w: H {% k; a. H- q( p! l; ~
.active_low = 0,
) ]1 f' |/ Z. r+ u8 R .gpio = DA850_USER_LED1,6 N* B u9 d' b' ?- d8 H
.name = "user_led1",1 ^. b, }3 x) [. ^: Q6 C
.default_trigger = "default-on",
6 Q' I% _' p" S E },3 G. ^9 s6 K7 l1 ?" N3 L# O" a
{
1 Z! |7 Y9 J& O l0 h .active_low = 0,
" d3 W8 L% T; Y/ ~# G .gpio = DA850_USER_LED2,
# T9 Z$ G3 v w+ s9 c4 T4 C1 Z .name = "user_led2",# A) q9 x& D6 [3 h
.default_trigger = "default-on",0 [8 j! N' }8 b. w& i
},, I: g6 n: p! q2 [0 y: v) l+ N
{
$ c( W' d" \, y, A5 [ .active_low = 0,9 j/ ?3 ?; l# j* Y: h/ ]' r, s
.gpio = DA850_USER_LED3,
* }6 O: n4 I, E0 t l/ f6 W4 K+ w# L .name = "user_led3",
1 `9 D# J9 O7 _2 X' Z u- L .default_trigger = "default-on",% e) n7 }$ n) Z7 E# ?2 v6 B1 R
},# n. e8 b* ]8 a
};+ n( C8 K7 N2 _
5 X8 e d7 O* }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, |& w- w! ?6 X0 s5 y6 r5 h
.leds = da850_evm_tl_leds,& ]. O9 i2 |) u/ k
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& M: K3 C4 j$ t. |
};+ ?8 i$ K3 j2 }% d7 ]/ A! O4 c
0 Y9 n% q7 l. lstatic void led_dev_release(struct device *dev)
+ B3 m$ `" v3 x- S{; p/ o, m$ S0 j! k& y/ e# v; g
};: O9 l: W9 `( T' m
$ F1 R0 g. C4 i1 s' k+ h" k
static struct platform_device da850_evm_tl_leds_device = {
( D! w' C @' h" x .name = "leds-gpio",
$ z* `2 z* x3 F .id = 1,
# k6 I7 O, l/ u6 K! I) [( R3 S .dev = { @+ W0 F$ `6 o5 L- W
.platform_data = &da850_evm_tl_leds_pdata,
8 @! }7 @0 {) ]/ X8 S .release = led_dev_release,! Y# ~- [( @0 A3 O: E: B" j2 E1 l
}$ _ m+ ^0 S% M# e1 w* U: X
};
2 \* N+ o' ^) ~$ Z$ p0 s8 h
8 E# X3 J( j f8 E H$ n3 p0 istatic int __init led_platform_init(void)
B3 S- y( o2 `7 ?* H0 I{4 _) c+ h, K M: O
int ret;1 f! H3 _4 D5 T) B
#if 02 _# ~5 z( t+ B/ y* o
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ j" W+ U: {5 _' |2 j5 [* Z
if (ret)/ D6 @5 z: N& N0 |. X" H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 A2 i( T0 b, p' o- z "%d\n", ret);
& B" W& Q7 D9 h( \#endif1 d2 F( ]" R- F1 \
ret = platform_device_register(&da850_evm_tl_leds_device);
1 j+ v- _- r9 _: V% j6 N, \$ i( n if (ret)
6 j! q/ J ` C5 J pr_warning("Could not register som GPIO expander LEDS");
) |5 R6 G! O$ I" H; j$ s% J6 E else
. G3 W( i% |! V, V8 Y, [* y printk(KERN_INFO "LED register sucessful!\n");
( S5 c2 T" F: ~+ B/ E
0 E. ?+ S" T# ]( L, t( [& K/ y' `- U8 L& H return ret;
3 d% k% S- Z L! F& \1 b( R' [}8 k; n" B% ]- {! r
4 Q8 q9 H7 X% _ N9 f0 q0 g' |: u
static void __exit led_platform_exit(void)
& L5 l% b) P$ Y% f) x, j; i3 d{# r/ o5 g6 f. j/ e; j* Z
platform_device_unregister(&da850_evm_tl_leds_device);
3 @0 ]) S/ o; W/ j" l( t$ o7 w( z! Z+ x. t- l- }" ]* q( k$ S
printk(KERN_INFO "LED unregister!\n");
% k. |0 }+ X- x* }: z' @} G+ j; m1 I2 n$ B, {
2 }1 H" |' {) z
module_init(led_platform_init);% W. e3 p1 F! t2 i, C" p: c% D; X
module_exit(led_platform_exit);. u8 Y/ x' j( i+ z. m2 R
0 s3 Q+ t2 C6 r8 w2 {' C. D
MODULE_DESCRIPTION("Led platform driver");
[- h7 S1 T0 jMODULE_AUTHOR("Tronlong");
2 {1 O4 q. D! }$ OMODULE_LICENSE("GPL");! P2 @% g! ?8 x% d z5 R f5 K
7 ~5 [9 b( A G |
|