|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; t, L" V3 J+ b6 R: t/ A; P
#include <linux/init.h>
5 z* v" Q& s R& F1 b2 m% E( c#include <linux/module.h>
7 X. _+ k. \: z' S. D) ?#include <linux/kernel.h>$ |) ?7 }3 [+ V
#include <linux/types.h>3 F b u. g0 I, q) W2 y0 F
#include <linux/gpio.h>4 S# B; D1 V: O# W5 D& f! i2 C
#include <linux/leds.h>5 Z0 I2 ~+ O* ?' W7 K; e. H# e
#include <linux/platform_device.h>0 b T% ^& U! K) c4 s
; Y. k4 k! _% w8 @8 ], h& `5 \#include <asm/mach-types.h>, m, i! v) I5 o+ I, J# C
#include <asm/mach/arch.h>2 g* S" f/ {# _( _ y
#include <mach/da8xx.h>
8 M1 E/ d, p" U* h* h& H( ^+ i: C3 I8 ?#include <mach/mux.h>
7 B. s# j7 J n. [
4 G/ _" i% N: v5 w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). Y( N- r& x9 _! g( h# k x
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). X b- B% v% G6 E
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 P7 \- l1 v- \/ Z+ ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): C a% v/ d( T$ {4 A& \
" f! R1 r/ d9 o+ J* D- |/* assign the tl som board LED-GPIOs*/( a- ]' }0 o6 {9 G+ I1 v
static const short da850_evm_tl_user_led_pins[] = {9 e: Y% j9 U) L+ T1 T$ Q
/* These pins are definition at <mach/mux.h> file */) s N/ O( g5 U3 ?: d$ c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 Y3 Q C, {# u -1
! E; e* _: ~! D; M% k6 ]};
- K/ K5 C5 @) G* K' \0 e1 |- O. I9 r) `: K+ {! a& r# _
static struct gpio_led da850_evm_tl_leds[] = {4 ?( k$ [" T9 e% a% ^1 F' i1 H6 x4 t& c
{0 [+ j2 a. N; o- {7 B
.active_low = 0,. | p% ^2 q8 Q2 J
.gpio = DA850_USER_LED0,
, C( a4 e, X+ {+ t3 V) E$ X .name = "user_led0",
1 W8 H% [& r! ^! y, X& e0 e .default_trigger = "default-on",6 m3 K' \6 z- [ _) H
},
\2 j8 ^ F. \& _8 R6 x; r {
) @9 l& X% S/ J% T9 H1 t .active_low = 0,
+ p! e9 b/ R/ d6 I, s) U .gpio = DA850_USER_LED1,+ v0 c8 z) V3 S" b* x9 E4 }
.name = "user_led1",
& d! i" ?& U+ {2 Q6 Q" s% ?- @ .default_trigger = "default-on",. D' a1 w+ q7 e! X7 ~
},9 P) W R7 T7 n0 J* d! u) P5 x
{8 r/ T) \3 Q' }" F
.active_low = 0,( H K3 `0 ~5 L, z0 S+ |% y
.gpio = DA850_USER_LED2,
/ _" A; Z- I+ Q$ r' B .name = "user_led2",' a8 k! \) z7 {8 `; y4 }$ @% p& X
.default_trigger = "default-on",
9 B! [1 b$ \0 I9 c },
+ r. l. m3 r5 ^0 c% o3 T ~- v {
! i* u' l# N! ]. n .active_low = 0," c& D) J7 s* [
.gpio = DA850_USER_LED3,
$ h2 N( t! L( L6 ^% R5 M .name = "user_led3",
8 d6 g; G4 F/ y .default_trigger = "default-on",1 s. Z3 t5 |5 x) f, S8 o6 j1 I
},0 ?- k& o7 L9 m- ]. n9 O P5 G
};
+ _# F: K, Q5 U) ~: G+ x& s1 j5 `
% {5 F4 @( u" }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, M8 f5 y# [9 S! T" r .leds = da850_evm_tl_leds,% s9 S6 N: d" J( R: o+ Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 W7 N8 R) D- E; ?};; j& J" ^ i X$ }" R x
# }3 L. K! ]3 C. H& g/ kstatic void led_dev_release(struct device *dev)
( R! |3 @8 J9 \4 M/ u1 u8 a# {{! g- \/ |2 Y/ E& s1 C$ D
};
9 I: n: ~; \# t5 }& i6 a0 W$ n+ | W( j8 Z% O8 R
static struct platform_device da850_evm_tl_leds_device = {
- D2 K" x4 [% K* ~ .name = "leds-gpio",
4 G4 {# |% _) q/ w6 X' j; d( l" }7 k .id = 1,
3 P& {, d0 D# s9 Y, f: A! Q .dev = {8 a9 w9 ]" l. ^5 c
.platform_data = &da850_evm_tl_leds_pdata,& ~5 R4 G0 P1 r0 S) _
.release = led_dev_release,* Z6 K1 r9 h, @, S% x) u
}9 h- n, n6 n a7 x' z
};5 u! Y+ h0 c4 _% k0 b# N4 b5 e. i
3 _6 T( l, X; _' l7 Istatic int __init led_platform_init(void)8 ~) p4 o: t$ U* o# q+ ^& {' I! w
{
! `& a; }7 F6 b9 V- N5 T int ret;3 W- F- B% `( {1 Z
#if 0
% N: D7 J/ Y ^& C8 F/ p3 U' H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& W A+ Q! o8 ?% [- {, N: U if (ret)" p+ w j1 w6 O4 [* Q! c
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* r% [8 S) }- n4 f; i1 X' l# M; O: e8 F "%d\n", ret);) e$ y% c; W. O1 b. G
#endif2 w; I0 F) w1 E( m- H
ret = platform_device_register(&da850_evm_tl_leds_device);
3 j+ V8 N4 R; L) d if (ret)
K% ^! t( Q, l+ `% F+ y pr_warning("Could not register som GPIO expander LEDS");
w: E3 S+ G5 ~ q% D else
* |3 K! v8 l l1 r! R printk(KERN_INFO "LED register sucessful!\n");; ~& n& F. ]% ^) W5 P' N5 V
! F5 s0 H0 O4 U6 n
return ret;# K* l# x+ V: ]
}
5 I: V( O. _% u+ q' ^5 M4 d" Z5 B, \8 ?4 a( ~- U" y* E6 \
static void __exit led_platform_exit(void): Y" ]) v4 l8 I: V. ~; r( Q
{8 x, }1 @. a+ W
platform_device_unregister(&da850_evm_tl_leds_device);$ f! h% u; \6 U' a- f
) \" }) t# C7 u8 ^/ e printk(KERN_INFO "LED unregister!\n");
# \7 g p; q. t q- K- ]2 i2 y}7 z2 g Z) v' U; D; k3 a
5 N Y) F- _& H3 d+ |( v7 h
module_init(led_platform_init);# Q f% R+ h$ k+ S$ N) P/ a5 Z
module_exit(led_platform_exit);; Z3 r w8 C$ ~
: D% m& b4 ?6 r/ DMODULE_DESCRIPTION("Led platform driver");
9 Z1 p. O6 A% p9 mMODULE_AUTHOR("Tronlong");
& J; l' p2 U! g' {* KMODULE_LICENSE("GPL");
; u4 }- ^5 s& I5 H# I+ d
8 e9 h/ k+ s1 b5 S5 T- o8 Y |
|