|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ Z1 J7 s8 u5 [: \
#include <linux/init.h>" ]! B% i& j2 H& y \ ^
#include <linux/module.h>! R% J: E" g- G( O& ~1 A% c% b( b: z
#include <linux/kernel.h>
* a0 g! V3 l# i) e& p" E#include <linux/types.h>
' G9 C# m/ i/ E+ P j7 K1 }#include <linux/gpio.h>, {6 s1 T" C; L# m; d+ e
#include <linux/leds.h>
3 f+ r* v7 u% W4 l#include <linux/platform_device.h>- n% ~8 N3 q9 M3 ]# R. } Z0 e
/ W: v& v# t4 i0 ]: c" y' s2 A#include <asm/mach-types.h>, b6 W4 t6 w! y: U' L I
#include <asm/mach/arch.h>" q' l' v3 h$ l3 v
#include <mach/da8xx.h>
! m" S3 e& P7 x#include <mach/mux.h>
& t" }' g2 A8 d& N! o# R
/ `3 F- r# Q0 |' ~+ F% q/ z( W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ g, r" b/ L: P2 s5 K# P1 {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; S7 Y7 X2 j( e1 b5 p# T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ q8 O a0 C/ C9 \# f6 m. g#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* [6 r7 W7 Z# n0 ]5 H; r
8 m; v2 |! ^ T2 P2 u9 y# o8 K6 H' w
/* assign the tl som board LED-GPIOs*/
! i0 k8 D9 S) [* ?. d) l4 istatic const short da850_evm_tl_user_led_pins[] = {" B# a1 G9 ] P$ V" ]' p
/* These pins are definition at <mach/mux.h> file */, D- C7 f0 z# z/ t) w
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* W8 K' `- Y) `; @
-1
. [% M; e% X/ {; u0 {4 g};
; a% Z1 q1 k9 t4 l8 _- J `3 B! d& Y& C4 C4 n0 m8 T
static struct gpio_led da850_evm_tl_leds[] = {
; z3 M U& v( O {
4 v& t( M6 }1 T7 x4 r& d .active_low = 0,
/ {( E3 i9 ?1 Q: i+ m( j5 Q' O .gpio = DA850_USER_LED0,
; u0 U/ b7 ^& P! n .name = "user_led0",% x6 e% B* a, T5 M
.default_trigger = "default-on",
k* ^# R6 x! ], \8 e },# }- X+ f* Y, k0 Y
{7 P& d" x* V) t, P3 | R4 e
.active_low = 0,
4 h S4 S k* ` p5 n: S .gpio = DA850_USER_LED1,1 h: I) Z0 H! {( O3 z* ?5 J# P' F- R
.name = "user_led1",7 I. i) ] l& \) ~" u
.default_trigger = "default-on",
* r% y$ b" `- s0 d% ? },& Z" Q! A2 d1 I4 y3 N
{0 t" N' C# B* f8 J/ Q
.active_low = 0,5 a* R+ a o, Y
.gpio = DA850_USER_LED2,$ x H" ]1 r' Y$ i+ F
.name = "user_led2",
# j- p) T5 [+ p6 d; Y# w: ^% L .default_trigger = "default-on",
/ ]% t7 k' z+ M7 _( [ },
& w* U* `; p5 W: @ {0 _; j$ k* Z" F, B4 s
.active_low = 0,
& W4 x( Z# m3 V# |' n" E .gpio = DA850_USER_LED3,
1 } @6 C" y5 c" I6 y .name = "user_led3",4 B3 g/ P# M. W* q( e* o* ]
.default_trigger = "default-on",
0 a# _! q; G; ^' r3 Q2 c% P },, d6 b- y) f0 b
};7 J$ W1 w4 M$ w) O4 z6 P
- {4 s4 v; g9 l) \; P1 N, E# ~
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, t5 p% R7 c+ I% I! W .leds = da850_evm_tl_leds,% |4 {$ | k$ i5 R. t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 Y# Q6 k1 s: u' U5 l [. n6 k};1 q5 U! P/ y( L
4 T( u6 {* u6 B) a, k
static void led_dev_release(struct device *dev): O5 b% r3 \$ j' V" b
{
; s; I+ z- j& U3 Z1 ~8 s/ o};: |, ~6 P$ ~* M0 X0 t f; L
2 p* D! G' c2 ^) s; N# J3 A; j: }5 N
static struct platform_device da850_evm_tl_leds_device = {
" [+ c- D! ?) u- g0 V .name = "leds-gpio",! r0 R* |4 ~, [7 l
.id = 1,- O, d. t& p5 t
.dev = {% E0 V. v& V6 Z) s: o
.platform_data = &da850_evm_tl_leds_pdata,
: W& A+ j% ^* U$ j# H .release = led_dev_release,( Z# \( X/ U5 N
}- x. T. z1 `5 T
};
8 r- D; E G0 Q2 ^4 ^$ |. j+ k' G, n" c4 s* `4 b0 @& [( v6 i& q
static int __init led_platform_init(void)1 ?( U t, S7 b% |" f7 y
{( z8 ?' d7 g8 z6 Y. i( d
int ret;
; Q) D+ E8 B5 k+ o2 ^#if 0
+ ]% K _+ X. C* A$ K4 S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 N8 R7 U/ [1 j' N8 I if (ret)" v4 O) @, T, L( Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' g' D2 ?1 o- |& Y* ^ "%d\n", ret);3 o2 q7 F `7 a4 C( G2 B1 k1 T! v
#endif4 j, q% b! L5 J! B
ret = platform_device_register(&da850_evm_tl_leds_device);. i7 Q, C- d8 l! t2 F- }
if (ret)/ x {4 r9 C; N% K. C8 I& i1 L
pr_warning("Could not register som GPIO expander LEDS");
: |3 `0 w! r* R4 C9 }% m else! e" ]2 x) ~% d; I4 Z# W! P, k! l3 `; x
printk(KERN_INFO "LED register sucessful!\n");
+ g" g' g* S. S3 d" f+ E# e6 W% T. C2 R3 P ]' M0 M
return ret;) d: J" X& k$ O) g% E
}% X( Y& r2 R Y- Z/ Y" x
8 q) a- `2 @1 C5 E# X, |3 Cstatic void __exit led_platform_exit(void)' `( A" [% M2 A* z/ J- ~1 y
{
) a8 b5 |! L1 ?1 x9 m3 b$ @ platform_device_unregister(&da850_evm_tl_leds_device);8 N- e; Z% n8 h, _! e1 G
' w4 j' H+ C6 C! }5 H printk(KERN_INFO "LED unregister!\n");2 u2 j* _3 `% m y* ?: t0 \ }! b
}* A( g1 S8 x$ |! V" H. ?7 M) ~9 a4 f
+ Z5 V+ \7 B* v9 g- Q; A4 q3 ?! X0 a
module_init(led_platform_init);
: W' o* ?( w7 ~; a0 S/ G; rmodule_exit(led_platform_exit);
( N" ~" M$ R! E
& V2 I8 @8 ]2 v ~" x4 v( ?7 {; pMODULE_DESCRIPTION("Led platform driver");
+ Z2 ^5 s* `$ P X7 ^MODULE_AUTHOR("Tronlong");
8 h# R3 }: M S* G* Y( m1 k& H* F) R1 \MODULE_LICENSE("GPL");
) r2 _+ D. I) V& P/ B
+ E! C: G' h: I G |
|