|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; a3 Z; ~' b0 K% p9 I2 q
#include <linux/init.h>
0 o6 a% T9 t) j. E% h#include <linux/module.h>2 G* X+ Q3 x8 K- S4 F% `$ @
#include <linux/kernel.h>
# Z/ r ]) N! K2 q#include <linux/types.h>
5 D( K# o0 O# C9 i. @#include <linux/gpio.h>
' v6 ]" X3 j! v5 _" |& ]#include <linux/leds.h>0 V) O7 W8 @9 C; E/ y
#include <linux/platform_device.h>4 P* k& s( x" ~$ o$ n+ O4 U
6 p! f# ~; M Q1 d: E+ ]
#include <asm/mach-types.h>' ?8 o/ U' V8 Y. v; [8 ^1 B
#include <asm/mach/arch.h>
( X/ {: r3 g4 p* K#include <mach/da8xx.h>5 U% n* ^2 P4 f. U. a3 n
#include <mach/mux.h>6 |) Y: ^: F# U1 M6 X# F
, \# \# C2 F, U0 L- r% w& y m
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
[; P4 S+ P. C, {( z5 \. R: P5 b#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& C5 s# X1 ]/ M# L; } J, H, [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, j& P8 v; i2 o#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 {, L$ c5 K" B
- Z- v9 b7 t% }9 D9 _/* assign the tl som board LED-GPIOs*/
, M% C( ]& r2 V' Z1 f4 gstatic const short da850_evm_tl_user_led_pins[] = {
" K7 x( v& z5 H, J. U; c! T+ P( z0 L /* These pins are definition at <mach/mux.h> file */# r4 z; M2 H( {( P( u4 c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ d' V4 C* A4 N. P -1' @3 I Z4 B! O* j9 }
};
& ^0 F5 g0 G1 Z( T6 W3 r- d! E$ E2 K" a: h/ \! l5 f( o0 R
static struct gpio_led da850_evm_tl_leds[] = {- D9 H* F, M, T3 b
{
3 U$ S t: M1 G) @ .active_low = 0,
7 Q; i! |) K1 U7 d1 `# [$ U+ ` .gpio = DA850_USER_LED0,4 t0 j2 X5 h! Y& @
.name = "user_led0",$ }0 e, U) \: D8 H
.default_trigger = "default-on",% F& M+ s4 T; C: S6 h) E
},' ?; W4 G3 v6 a9 O' D3 @
{/ y# x# } B" U! ?3 O# w( r$ L- J
.active_low = 0,
: e, J$ J! v& e .gpio = DA850_USER_LED1,$ v" @, D; w; {& X1 l8 M2 D8 L
.name = "user_led1",3 a: D4 Y. u; D5 V5 P
.default_trigger = "default-on",
/ d0 n* y& x% v! v. F },
4 C8 l; W8 e6 Z* f5 t9 d, w1 M {( l" j$ v( e# Y. G
.active_low = 0,
% O. Z/ I9 I& r5 n/ f .gpio = DA850_USER_LED2,
, ]$ r+ [# S3 z .name = "user_led2",: a4 F1 C& K" o6 }2 B
.default_trigger = "default-on",
: s% T$ c/ z% w2 I7 L },
& Y# E: o$ B d1 u( O2 t {
; U" M! l: L9 o( C# l! f .active_low = 0,- }7 u. g; @: d0 `
.gpio = DA850_USER_LED3,
+ M! I' W' U4 t/ z4 v .name = "user_led3",: }+ D/ ]) Y$ a3 M/ v
.default_trigger = "default-on",9 F% z U6 G+ ~, I7 N
},* ^; G, V, H6 _
};
( O9 `/ y4 `3 p+ V6 x/ _/ n! {' d5 e2 ?) G7 c0 K% Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- e8 ~- k8 c9 Q' f+ v .leds = da850_evm_tl_leds,( l( ?8 u/ v# c5 \' H: J# z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- G/ Q# \2 P: B9 n, }3 C: D5 D" d
};- } e! `6 p1 j
& J1 R. a3 D' l3 T+ x9 z, {5 H- e
static void led_dev_release(struct device *dev)
. h, X/ B3 ?/ v4 o( j1 D$ J; n" K: |{+ `* ]' K$ @& _/ e3 z2 j
};
) D( F6 B8 Q/ t
0 ~" A' s9 c, t5 [# Nstatic struct platform_device da850_evm_tl_leds_device = {; l; \: N; k- v U/ |# Z0 {
.name = "leds-gpio",
: `+ ^) Q* I$ X# d& n5 I .id = 1,
: U, [, n- @# z6 n h+ e2 N .dev = {% ~! P( i# ]- O4 J
.platform_data = &da850_evm_tl_leds_pdata,
$ w; N1 s V! u) N" n7 a$ A* \/ _; j .release = led_dev_release,
( {3 z& C9 |: W: @' r( z6 L }
' ~5 C* p @4 s6 j" M' l};
# s' {. `9 L- Q m/ ?5 a7 t3 W: o, S- }) ]
static int __init led_platform_init(void)
' U" |- X0 [* S1 m; F% t{1 j, p, T }0 I% a' D. {- U
int ret;
! o9 g* {- t7 E" f/ u#if 0( q9 x( H+ X3 B* I! K9 X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 w- X" U0 y3 `' N+ f, w% g if (ret)+ ^7 j* |3 u* l/ G& o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 q1 N9 d+ C" a2 f7 B4 B O( W
"%d\n", ret);
0 J) l' v- U* K0 b#endif1 V" L Y7 B0 q) q& \
ret = platform_device_register(&da850_evm_tl_leds_device);' n3 q8 I1 \. g% x! V% q
if (ret)
( D+ u4 P4 A3 V/ d! j& `/ S5 H pr_warning("Could not register som GPIO expander LEDS");
+ r" w! f" e9 f+ x else
+ c# ~' |$ H/ E+ Z printk(KERN_INFO "LED register sucessful!\n");, k' e7 H5 c+ o" b- h8 D
; y1 Q: R$ p, T! t0 ?
return ret;7 g' {$ \5 F$ |) J! Z; \7 I
}% _! Y0 h1 v u
. Q! T; y/ I, d. H! n8 n6 }2 T
static void __exit led_platform_exit(void)2 G7 O5 X; w+ X3 o$ S
{5 X) Y) T; B2 P7 x& O6 h
platform_device_unregister(&da850_evm_tl_leds_device);8 [7 S3 ~7 V6 o$ g; W$ c( _
1 ~' S; m/ O$ F printk(KERN_INFO "LED unregister!\n");
. M) C& I3 \3 [$ U j}$ l6 B B S2 n1 L6 E m2 C
1 U6 ~( O: H+ T9 cmodule_init(led_platform_init);; @3 g1 }$ `" c7 N8 u* T% b$ `
module_exit(led_platform_exit);
0 N( ?8 ~8 O8 X& K$ |' R* `" L0 N0 |6 o8 ^ }4 e7 _
MODULE_DESCRIPTION("Led platform driver");, e L: l& U- n+ L# p
MODULE_AUTHOR("Tronlong");* O3 a$ S2 j9 D1 ^* ]+ _, f k
MODULE_LICENSE("GPL");. Y3 f Z9 b/ M% L$ S
/ a# v9 L c4 w; v* P' I* \2 z
|
|