|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 D9 l3 w- H3 v' s5 J#include <linux/init.h>
3 E: w8 ^+ {- s$ B0 g1 Q#include <linux/module.h># [' l" F6 h; d2 s/ T
#include <linux/kernel.h>) s+ a# Q& {7 d; i, z* n/ `
#include <linux/types.h>
* L0 }. [* @' h3 d# u* n! c* w#include <linux/gpio.h>% X: _4 K# |+ Z3 w+ }
#include <linux/leds.h>
6 h5 ^& m4 l% B#include <linux/platform_device.h>
4 G3 f1 \, f( o8 D) Q7 R4 v3 h$ s+ j0 z( G/ Z/ n
#include <asm/mach-types.h>9 Q9 B& t& O. |. l9 s% N7 t- V
#include <asm/mach/arch.h>/ A: i1 k" |- ?7 g
#include <mach/da8xx.h>
3 g9 N9 P2 ]4 s4 P6 t/ @0 W#include <mach/mux.h>
. o8 j' V9 \2 k
* E5 f5 o/ S+ |* X#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ |3 {! w+ @; Q$ s" Y1 m3 e#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# y5 _, b) p: K$ V! Z2 I$ v/ E#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 _3 R2 D0 z+ ~#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" s, ]; w7 ?" y7 I" V J& Z6 P9 r% N$ J/ f
/* assign the tl som board LED-GPIOs*/9 F o% S) t3 ~+ [7 X$ W2 z
static const short da850_evm_tl_user_led_pins[] = {. U! M) }& s! U( U: U; r2 v
/* These pins are definition at <mach/mux.h> file */
" l1 ]/ g3 z3 a. e6 K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 j, ~% n1 S( B2 r$ W* l0 V( d7 I
-1) D v: H V' M1 F9 l. n" K. s/ u
};$ ^5 B; Y- Q# H* D' n$ m
: g- ]7 ?, I; ^+ c& z" dstatic struct gpio_led da850_evm_tl_leds[] = {
* m: Z, m( S' h k! l- {# h- k; A {* t/ ?( ~% D F0 ]. ?2 A$ a$ m
.active_low = 0,( |) P# \; h- ?: [7 s$ a1 S4 x
.gpio = DA850_USER_LED0,
7 X r/ I0 F8 W* G .name = "user_led0",* P6 i3 T" w! ]# c7 d2 C3 F
.default_trigger = "default-on",- J# e& n: Y" W! U/ n" h
},; S8 [7 X1 T, i/ x' z
{9 D! H) G+ a! I/ \7 t! `5 L4 w+ l+ E+ b
.active_low = 0,
% b& d% `# B! r+ n9 E .gpio = DA850_USER_LED1,
0 g* G* }; Y8 ~" {' N .name = "user_led1",
# S' U) J3 w) T- W) z .default_trigger = "default-on",
( G3 b+ [0 b: R/ s2 k },& \ @ b: N9 z
{& m) y- I# {# B3 P( q. I) G3 s
.active_low = 0,
3 S- k `. e1 |, W U ?5 L, l .gpio = DA850_USER_LED2,
- r6 G& t/ E6 z n8 K2 |4 z9 i4 f .name = "user_led2",7 W$ b' s- {- m t/ l$ E6 Y
.default_trigger = "default-on",
* B- t9 L, l5 H0 `4 o; Q# i },
) o: U) D# ]. k! s! s* d {
2 n; N3 k6 i. r7 f) i8 `% L .active_low = 0,
* ^. p$ u7 N2 f+ \ @$ A4 t- K5 ? .gpio = DA850_USER_LED3,
# k2 _. F/ C. @, c .name = "user_led3",
$ C3 J8 H1 \( Q0 u& q) c* Y0 } .default_trigger = "default-on",, U& W: o) ^2 d% `
},- U9 I/ j8 q# }9 y0 d5 N6 K+ I
};, g" L8 b4 k3 L" P5 n% O" z7 {* E
/ T3 [- ?/ ^' G: v+ A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ u7 P* Y5 W$ w. k% W .leds = da850_evm_tl_leds,; R/ k9 z2 j. G9 a
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 _1 N1 O/ P/ \7 I
};
5 A; s6 D2 z- h; l7 M% H6 H3 ^( ~ Q8 M' t4 ^* J# u% R
static void led_dev_release(struct device *dev)
- Q; q& r( l* E: T5 e" L0 M/ _{
; x' ~5 p; |$ D- t g n, A};
3 w* Y9 ~" p+ c1 `: Y1 M
% x% u9 y) K% \; qstatic struct platform_device da850_evm_tl_leds_device = {
( X6 T$ u1 P% B .name = "leds-gpio",
* F7 c7 v/ |2 L; e7 i .id = 1,
! A/ H+ x4 z6 r0 ` .dev = {
4 V1 [- [& s5 O* | .platform_data = &da850_evm_tl_leds_pdata,+ r9 n$ y, \2 L) v1 @, M; o- l( u2 r: Y
.release = led_dev_release,
; }# J1 X* q- p: j$ } }! g3 _# O" w6 X C2 U# `4 X
};
6 ~) S) E N. T# X. \% t# T" N+ Z N) F/ _) a; ^8 y( \; q
static int __init led_platform_init(void)
0 V0 I3 N+ U9 f( {) K{: {( R% O0 C( A+ W1 X+ ~$ ~
int ret;) P5 x, x% a, y
#if 0. V; f8 t, p1 c1 H
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) N9 h. r# F4 D/ w4 a if (ret). [( ?3 A, Y' u2 P( q7 G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; l' s8 b: ?4 F$ V) z7 j: x "%d\n", ret);
* Q/ C: o( S# r W u$ [; `; V#endif F' I3 b* G, F- O5 J
ret = platform_device_register(&da850_evm_tl_leds_device);
" E" c4 W4 F- t6 g# G: ^! H if (ret)& o" P* ^" N+ t9 ]: Z I
pr_warning("Could not register som GPIO expander LEDS");+ U0 Z/ m3 H& y* o) ^! S& }' y
else
/ ^$ A {7 t/ w% F2 d/ ^& D2 U printk(KERN_INFO "LED register sucessful!\n");" q* o$ v$ f& ]/ \ `
3 \6 r. S0 |; G$ c& F! x return ret;5 C; u8 c% c. X. m1 D0 Y
}/ Y' z1 R$ l" b1 P9 e
2 j8 B" W, C. h' R
static void __exit led_platform_exit(void)( w6 T/ F2 [4 g& T% V
{! L" ^! E. f. w) c
platform_device_unregister(&da850_evm_tl_leds_device);, d G- v _4 s) X0 a* ^
' o9 j9 ^2 d+ \ printk(KERN_INFO "LED unregister!\n");
4 i; Y8 v) t' `. f9 F- H7 u5 N6 A}+ U4 |0 w8 U) s" A& q# O7 N9 \
1 }7 [4 Y7 R/ T0 X& r, amodule_init(led_platform_init);
0 q `! y, ~. T, _& mmodule_exit(led_platform_exit);2 [; [- I! j$ C+ d9 {
, ^% H# H# x/ |+ Y. OMODULE_DESCRIPTION("Led platform driver");5 m; e0 v \/ o/ G, E" ^5 x$ @0 t
MODULE_AUTHOR("Tronlong");7 r; d$ A( o3 ~
MODULE_LICENSE("GPL");
# j' w" W1 [, G, A+ q7 D: a2 o+ c5 g9 [+ I, u" y6 F' a5 R
|
|