|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 j$ a0 Z5 I3 \) q0 w
#include <linux/init.h>, Z7 I6 Z1 f9 S$ q0 y
#include <linux/module.h>
! Z! B) c% t( [) P1 s; d#include <linux/kernel.h>5 C2 C* R6 V/ j9 a) D: a" O/ w
#include <linux/types.h>" l: H5 \4 p. a! u8 d8 T* W# `$ G
#include <linux/gpio.h>+ y5 T G2 N8 D, @6 I( ?' F* N
#include <linux/leds.h>+ s$ o0 \ C* ]6 g$ X. ?+ H
#include <linux/platform_device.h>8 y9 d8 \2 J$ ]4 \/ k6 x
7 ?5 l3 F1 M- `* a" \7 Z1 j#include <asm/mach-types.h>0 Q6 P6 ~0 p9 R2 L Z
#include <asm/mach/arch.h>$ [$ J' I2 y0 ]0 j8 I; v6 F
#include <mach/da8xx.h>
, M) p8 w }5 a6 z. G+ Y. X8 @0 S, q#include <mach/mux.h>
0 |0 |/ U c& w$ c D. N+ }" x4 M. Q1 [( W, ?+ ?% c: v V
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 j# N" M! P. r0 A; T$ X: i
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' O/ b0 U" [. t; D+ k: H2 ?#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* N* j' j- @! x1 T
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 Z) t; L2 s; @
0 f; q$ z% z2 V- B/* assign the tl som board LED-GPIOs*/
0 j0 w9 l$ o9 I: Z9 B; V& Xstatic const short da850_evm_tl_user_led_pins[] = {
0 D) Z1 w. k; n4 C3 {% k /* These pins are definition at <mach/mux.h> file */) O6 l! d/ p$ A' }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ l/ E4 y" S; m% o5 { -12 U4 ?6 G# Z7 M, u6 C
};
& _' \8 t1 ]! H0 r- a
3 z2 p; N K8 ?7 c3 r: W Vstatic struct gpio_led da850_evm_tl_leds[] = {
4 f6 e; Y1 A2 f3 f {6 Z# Z, R& \/ ~$ G& m# L+ o
.active_low = 0,2 b3 L4 l X& H5 N
.gpio = DA850_USER_LED0,8 ?# U/ r% a6 n+ o+ V z
.name = "user_led0",5 x# c- j7 |" ^" E: H: h
.default_trigger = "default-on",
Y; L6 x# d% n1 j4 l: [( l },+ l1 C3 D# y! H# j: N7 Q9 N
{
$ L/ ^* J4 K. d .active_low = 0,: z: V: e) ?) Z
.gpio = DA850_USER_LED1,% w! E" c1 b4 @# H1 K
.name = "user_led1",
. g# {* E( _4 U .default_trigger = "default-on",
9 P( _/ I3 I& n0 Q+ z* A* i },! ~) H5 Y6 k3 C( b& v% z( z
{9 X. ~3 _' E: [( Z; A
.active_low = 0,
" S$ h H- f8 T; I3 U/ ?9 d .gpio = DA850_USER_LED2,
( v6 {& V4 h, u/ p .name = "user_led2",
& b" C) ~6 B: `; r6 [0 W1 V8 ]* C .default_trigger = "default-on",
8 G/ y3 W5 R- Q+ @! Y, `6 q }, R$ y! A% C: [3 V3 |! Z6 \4 X
{
' h7 @* X8 ~ j+ x8 V .active_low = 0,
' p9 p' C" U, G# ? s- X .gpio = DA850_USER_LED3,
2 \4 I/ ]7 {) h& y, T, A% T; p* S) q .name = "user_led3",
+ c$ d4 S! O& F4 v: K2 `6 J .default_trigger = "default-on",
P! X4 v0 P2 p9 I& O },! E7 ]( x1 d; V; e3 s% ^9 G
};) }' F! o3 l. {0 o
" R3 ~5 z/ P% M7 H8 ?# z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: l1 W+ ^% h% s. D- n
.leds = da850_evm_tl_leds,
4 m7 b& K' u h0 k: v9 B9 V: S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 F1 N& ~# D+ J
};1 c! g+ r: F" B- K( Q, q! L7 Y& M# \
9 o4 C) M2 Y$ u9 @
static void led_dev_release(struct device *dev)/ q5 o1 e5 v$ m2 ~( e! ]$ R0 a
{% c8 X6 W4 W. t. _( k
};! e0 ]. c% M& A' x0 P/ w
# N8 I1 \8 L& x3 [8 B
static struct platform_device da850_evm_tl_leds_device = {$ M/ A6 Q; T( F! e
.name = "leds-gpio",% ~6 `% E$ H+ o
.id = 1,
$ ] I( j! E( x4 ~( [. } .dev = {/ t- `6 f8 k0 W0 b9 w: o
.platform_data = &da850_evm_tl_leds_pdata,
: w3 I; a# R6 v/ D .release = led_dev_release,; u( `6 G8 H9 }; O
}, r, w' O' g) f1 `
};
4 a0 r* e& K( a: o, I) p. b% P0 I9 g/ _
static int __init led_platform_init(void)
; q' g+ o D* d5 v; a. |{
( t, G! d2 p( J+ A( Z. t$ i int ret;0 G' I1 A1 o$ o: |3 P
#if 0
2 \2 D' ~* M. N! p: q7 A8 x/ x ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 c3 ?& a( W) F# X2 i# @4 f if (ret)
) j- w' k9 [& Q6 l! w2 x2 R& f9 y& l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* P- R: S0 l9 Y/ p8 A# J8 X1 X
"%d\n", ret);
) d5 |8 I* `$ u" h#endif
% T; @; \/ O6 j! m! I( F ret = platform_device_register(&da850_evm_tl_leds_device);
* ~% \1 k2 i. F2 M, D) C if (ret)) Q: |. d o' z2 P+ l# @% H4 s
pr_warning("Could not register som GPIO expander LEDS");
- X" ?) @. k, \; B' t" r else
4 l! E7 k5 j/ ~ printk(KERN_INFO "LED register sucessful!\n");4 f9 C, A- c- k. w: d" T4 R3 [
4 N5 F& Z" c- ^* E4 v$ a+ x5 b8 K return ret;- P# g8 O) n! d- g
}6 Q5 E' _& Q" @, V
& }/ x9 H# {2 F: y5 L+ g3 U
static void __exit led_platform_exit(void)
5 p g# M1 f, L( w6 y{4 `- O) |/ ^6 b! C# e
platform_device_unregister(&da850_evm_tl_leds_device);
- F' U2 O2 o6 {* V, F
* B' ]4 p( g7 K7 H% A6 \- p6 T. G printk(KERN_INFO "LED unregister!\n");" ^5 L& O# M+ F
}
; z# O( R, m3 G8 G
. s2 r# c1 ]3 l5 d& B2 D V! _- dmodule_init(led_platform_init);$ Q' F1 N" N" r" D1 ?
module_exit(led_platform_exit);
0 L3 ?- [6 ^) O0 [2 ], L8 e6 @: c D) a' v" x5 G/ l
MODULE_DESCRIPTION("Led platform driver");
5 [" E; I9 V/ j q( v' Y" D3 ^3 Z; EMODULE_AUTHOR("Tronlong");
3 f8 V, o. E$ y- x7 w3 B4 b' TMODULE_LICENSE("GPL");
W7 U) t' L7 v+ c2 B1 t9 F a; a, D8 ^' o) e! a; F4 Z/ e) o2 @
|
|