|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 Z( f( ]2 m$ I8 h
#include <linux/init.h>4 ^( L2 H: }8 D2 ]2 t( _% D' l2 A
#include <linux/module.h>. a [6 G5 Z3 ~0 C; M! C
#include <linux/kernel.h>
3 k8 z# M& W5 I2 C#include <linux/types.h>) o1 y8 n) P+ y8 g) @) b; ^1 p
#include <linux/gpio.h>7 F q& O, |7 V
#include <linux/leds.h>. i; i3 C; O3 s
#include <linux/platform_device.h>
) Q; q3 M8 `, G/ a8 B H1 C' Y. ]% T) c) n) A# e
#include <asm/mach-types.h>. M- f! p! R C6 `# U6 r, E5 G; ?
#include <asm/mach/arch.h>
- T6 T& y. K* y, \#include <mach/da8xx.h>
( t: K9 B0 @9 V7 ~6 i$ y#include <mach/mux.h>
* `+ e' r, ]5 v% E6 q
0 ~. p Y! f- H$ W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 Q( N1 b3 C& ^) N F/ F! C. a) c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 G* S8 j5 n- h6 A* k6 \
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 Z0 A# z; b- c
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. I' I' l) T# }: R; D, t% _' x
- N T6 Z7 O% }; T/* assign the tl som board LED-GPIOs*/
1 }' P7 J0 B/ U% {8 s/ xstatic const short da850_evm_tl_user_led_pins[] = {% l- {' b( y+ u
/* These pins are definition at <mach/mux.h> file */
" e% [0 i1 [. k DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; B) ]& k+ |$ r2 F" P% Y" x! g0 P
-1+ H D7 m) l8 s
};8 b5 H7 v1 \# Y! q. N0 [/ b1 n
3 m9 y* X9 Z: e X, z) ?. u) M
static struct gpio_led da850_evm_tl_leds[] = {
: o6 }5 _5 c% o/ K; W( z0 c# E/ @0 O {
{$ Z( N6 ~3 L6 [ .active_low = 0,
4 g! w0 s1 u( }2 @" U! R0 V; Z/ V .gpio = DA850_USER_LED0,8 B$ N) _" c- l- S# J+ x- Q
.name = "user_led0",* |4 ~4 P7 h" _9 h, I# t6 S5 z
.default_trigger = "default-on",
' g+ S3 A( J7 ^ ]- z9 z u3 Q },8 a6 k# o8 F8 X0 `
{
1 k* n: C5 ^) [# ^$ _ .active_low = 0,2 P$ Z: F+ a3 a$ f) }+ _ ^5 ^
.gpio = DA850_USER_LED1,
$ y8 f$ p% V: L0 Z( u .name = "user_led1",
0 Z; E- e, y' [* ^- k .default_trigger = "default-on",
+ Y# S4 s. K$ L },$ x( y% z d6 }. N& p7 k4 L
{
0 _/ F" J7 @3 U4 N o% I* b* W .active_low = 0," t8 |: V2 C! v: F
.gpio = DA850_USER_LED2,( O# Z1 s e2 a3 z
.name = "user_led2",' d/ |: d" C0 T
.default_trigger = "default-on",+ r* ?. t! @* j, F; f0 K
},
$ G! R" L; Z: W# R% m5 }: t! z {5 g. n; ?8 u# R4 [! [
.active_low = 0,
, e% R6 W/ t1 Z0 O8 R% m; o .gpio = DA850_USER_LED3,6 [5 Y% h( U- H9 @9 ^, R0 j- Z% O
.name = "user_led3",
' S' S+ }, g' Z .default_trigger = "default-on",5 q* B- A9 j3 L* ^7 w# M7 O" q
},
9 N+ ?% H" {/ s% W};" |: m0 F6 E3 U6 {" E9 E5 c% q1 ?
# U! Z; A3 P. mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! v9 m( [3 J' L+ U! U+ i5 a .leds = da850_evm_tl_leds,
. L8 q: {( r8 I+ Y6 x E. o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* r. e+ C2 |5 }# s) k; {7 u
};1 Y" A( ?+ c: `, ]1 c
. K2 n7 U' R E
static void led_dev_release(struct device *dev); Z0 h5 Y1 @3 A8 J8 C+ u
{; Y- Y( T+ D% M9 M) ?: V
};
$ E' _ [6 g" u& [9 _5 H3 _7 u4 B. L% N! d" k
static struct platform_device da850_evm_tl_leds_device = {
8 w+ `0 U- s+ ?: { .name = "leds-gpio",. H- m/ e- X0 ?' r
.id = 1,
1 s" Q3 v2 ]( G. E7 L) c% l4 N .dev = {
$ K- g: H( a% H5 T .platform_data = &da850_evm_tl_leds_pdata,# i' o0 f) k, b% Y
.release = led_dev_release, L A: X3 a3 A7 D( @
}! S1 M0 B4 B6 a6 t6 M2 L
};
8 C; ]# l/ ~" C# H& [) @: Q& |. N. Q9 v
static int __init led_platform_init(void)
; p- q0 t6 W0 A8 f3 z( G{
0 Q3 `! ~/ L6 v. E8 \' `2 N, R int ret;8 ?, W0 t( P6 ^3 i
#if 0
$ N$ q$ f/ a" r# \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# v/ d' ]1 ]' v( |1 X }- [
if (ret)+ r; ^8 h5 X7 k
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 _( k. U4 P! d+ Z$ o, F- [% K* ] "%d\n", ret);+ o% B5 P6 B; p5 `0 ~' N
#endif
( v" {0 @! y, D, A5 o2 G8 h) {( q ret = platform_device_register(&da850_evm_tl_leds_device);0 w) i }9 Z. w5 R& l
if (ret)
* ~3 R) f( X I, x, J( I) E; D" h pr_warning("Could not register som GPIO expander LEDS");, K8 ], W. e0 x
else" M6 `6 N1 I) S1 p. ?8 b
printk(KERN_INFO "LED register sucessful!\n");3 o+ \# J4 e7 S) l3 g4 i& X% T7 \
4 @& |$ U7 z' ?: Q return ret;
?3 y5 Z1 T9 w}/ V3 P, H p! N2 g5 }) I3 @: Y E0 Q
. [+ J9 X' D6 |! p7 U
static void __exit led_platform_exit(void)* J I! |% j a
{
' z# ~& }& t# l3 @( |. f Y platform_device_unregister(&da850_evm_tl_leds_device);
7 p/ i; N! r3 m7 u, p3 m9 g1 q% v! }- b: q, m4 i
printk(KERN_INFO "LED unregister!\n");
2 L5 a( i3 ?+ w3 z! v}
3 X9 c9 @5 j) r1 g+ r" |
3 x! z7 O. a+ ]/ L3 e4 Nmodule_init(led_platform_init);6 J9 g- L0 U; i. ~- W* ^' \9 z
module_exit(led_platform_exit);
/ Z' c, D# k8 D& k( v% P4 Q
/ A. z- _- Z: B/ B# p2 RMODULE_DESCRIPTION("Led platform driver");% l/ B. e- U2 F2 _
MODULE_AUTHOR("Tronlong");" n& U2 u0 Q- \4 W2 _! W3 ~
MODULE_LICENSE("GPL");
! Q; F* f' i7 M8 P4 S- R3 U2 n0 N% n d/ E% q2 |
|
|