|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' n% i9 \& K/ l
#include <linux/init.h>
/ J; {" X( a1 g- J2 d; I#include <linux/module.h>( \2 q v6 j8 F
#include <linux/kernel.h>
, G% n- P3 M8 L! e: Q: k0 _#include <linux/types.h>9 w5 o# @# E; c a4 ?
#include <linux/gpio.h>$ F) S0 z% V6 k% L! p' I. v/ _! E
#include <linux/leds.h>
/ K% P$ m3 f$ U' b+ g#include <linux/platform_device.h>, X: ~5 }! \/ `7 V- l" T: {
9 } i2 J: `. a; ^' R2 Q3 d
#include <asm/mach-types.h>4 {% w& @! ~4 s
#include <asm/mach/arch.h>3 Q! k3 e5 S, X! q! N) B$ S
#include <mach/da8xx.h>
0 X# k; W$ b& M- L#include <mach/mux.h>
; `% l* l% H9 n& m
+ s% \. V& W( x1 G2 [& k7 ^#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% W5 G/ Y+ V/ a; K' X1 |/ a/ f
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) U0 U7 v3 X6 x( j8 [#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) U: @3 L0 V0 c) b* I& V& M
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); d7 E* J6 { W; O. Y4 b" I2 z
" Y) e+ E$ d7 d! C' K
/* assign the tl som board LED-GPIOs*/
+ s0 X3 M. c; jstatic const short da850_evm_tl_user_led_pins[] = {
8 w' [9 z) @1 H9 ^$ e /* These pins are definition at <mach/mux.h> file */
2 U8 m8 y6 n" k/ t, o- z7 q: \; t DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" u8 C4 ]! I% s) q/ _" f% `. { -1
7 a: @# u) P) C z};5 f i; P* P2 }7 n4 j8 A! e
3 ` [$ X. l9 k: ]' u) q2 d5 Hstatic struct gpio_led da850_evm_tl_leds[] = {+ h0 \# q @. ]& m6 {( R% A
{+ p3 L8 t% X0 o2 d% _" G5 M" P
.active_low = 0,
( t/ W0 ?% C, s' ~$ f .gpio = DA850_USER_LED0,
" p7 T; |9 v8 U1 D$ G .name = "user_led0",
6 G$ h2 X8 W5 \9 f .default_trigger = "default-on",7 J8 E6 t& P5 h E
},
. F# q" f3 c/ b9 W; |8 V {
Q7 e& `" G! R7 k8 V% n9 ` .active_low = 0," S X" u e4 ~
.gpio = DA850_USER_LED1,
, a% x8 f" _ ^% | .name = "user_led1",
% B' F. b, @! \4 ?/ _ .default_trigger = "default-on", a2 N. g6 b, Z* v$ o0 j! J
},
6 w R/ }" N4 Z* J% c4 F {
# s, y5 x# p. B: G' r& Y5 Z .active_low = 0,
+ Q* P/ R9 P% X9 V$ _ .gpio = DA850_USER_LED2,) R& K L r* ]) A; [5 l
.name = "user_led2",' M _- H1 `% }2 V
.default_trigger = "default-on",
- {+ @+ _6 L' S4 } },! T5 c" [& @8 \/ Q1 l+ y
{ ~5 [" S, b- u4 ^- `# y
.active_low = 0,+ y: L& [0 ^ k5 L: D1 W
.gpio = DA850_USER_LED3,
$ P& B7 \' t5 P+ f; k& L .name = "user_led3",( e6 T1 q' T% d0 `: g/ H5 T
.default_trigger = "default-on",0 ]0 U* z, A) C! |
},
2 r$ E8 }) l$ I( z};- q7 m. J# t+ n' P
" h* B4 L7 O+ a# C) W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% Y: Q+ V8 U& w
.leds = da850_evm_tl_leds,
+ K3 B( R8 |" e* F6 u/ H .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 _/ Y" H6 O* r2 m% Q};
6 p8 ~6 \" V! [1 R/ n; v8 ?* |
|7 o7 z* X# `4 ~static void led_dev_release(struct device *dev)5 @7 l- |2 B/ o; U6 y6 m) N
{' ]) F$ G u2 V1 l+ w5 S
};
4 n ~- z6 H) \9 C: r- K0 J$ @- a( Q$ y& P4 L8 O6 P2 V& ^, _: m
static struct platform_device da850_evm_tl_leds_device = {
% z4 b# c7 {) @" N, N' s6 x( b .name = "leds-gpio",6 k* U) q' o% _ P/ H7 t
.id = 1,2 F. e3 M# P% d" c# E
.dev = {0 @6 b( v# V* R4 j
.platform_data = &da850_evm_tl_leds_pdata,6 F& L* Z9 E, a0 _
.release = led_dev_release,5 \+ Q7 _/ E) J
}
) g- p4 @2 ?# z. N% Q4 h};/ L6 p7 l8 s% w; Y$ U
4 h: R( m. H g* l# k
static int __init led_platform_init(void): E0 n9 Q9 D7 _% @2 ~0 H
{
% \! ^; V4 i/ T2 R+ X int ret;
, \7 D3 P3 j+ H' F# C#if 0% A" @ I% @: Z0 S
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' `( e H$ F- ?" N if (ret)
5 e+ s& K8 ]( ?" P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 {; p0 A" B8 }/ H" U
"%d\n", ret);
( a4 b5 z# u! M" Q A' r# v9 j, l#endif
" B ^; w n. f7 H ret = platform_device_register(&da850_evm_tl_leds_device);
1 {8 f. R+ E, l2 a' J5 s7 N if (ret)! M* ], z0 q4 }3 X: A( D7 t& s
pr_warning("Could not register som GPIO expander LEDS");
) Q! p4 _( O( g0 e$ E { else& u _% o: W# ]( A" M1 |: _7 o6 t
printk(KERN_INFO "LED register sucessful!\n");% [4 G( A7 W: }( t- `2 @8 r. w
( \4 L t! V! Q" D! W
return ret;
' m5 ~4 o% \& n4 N2 l}
- d( t, H2 \1 m; U E1 d/ ?% J. V' B, U1 ~
static void __exit led_platform_exit(void)
2 [* ~2 d$ b3 S& B{; O3 p) P7 p5 u( N
platform_device_unregister(&da850_evm_tl_leds_device);1 H" l( J+ a$ Z
4 w4 z" y& ^7 I& {# g3 S
printk(KERN_INFO "LED unregister!\n");
! ]" b1 a: `3 D1 i+ O- _" ?, q4 @: L4 y}3 W/ M7 T6 S% M1 N8 Q
4 i" a: `3 Z& m9 J& P: ?/ zmodule_init(led_platform_init);
9 Z H" b! V& s0 Y& Qmodule_exit(led_platform_exit);
5 ]& F- t; v W
4 z" W; R* Z9 A: BMODULE_DESCRIPTION("Led platform driver"); P* f' m* v2 q/ x% Z. i- z% ~
MODULE_AUTHOR("Tronlong");
5 X) C% `8 i% ^( K* uMODULE_LICENSE("GPL");
5 D, f6 k" [! W
0 g6 m5 g+ C% \$ D8 y1 S |
|