|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 @4 G/ A) ^" R7 ~2 [( |0 p: f
#include <linux/init.h>2 f: g- x3 c" N' Y3 _
#include <linux/module.h>
. U: ^/ ~3 a: A+ X#include <linux/kernel.h>
! r" |) h7 `* O& M#include <linux/types.h>
. e8 [ [6 q. T1 Q6 K/ M! ]# u#include <linux/gpio.h>
4 S' B! w" m0 d+ q: b#include <linux/leds.h>
' F* f2 |- j4 X! s#include <linux/platform_device.h>
2 J. @- g; T6 \0 @2 f* K% \" Y* j9 c7 P9 p& [ C5 F
#include <asm/mach-types.h>2 J1 d6 L9 e& q6 Y* ^' I4 }- ^
#include <asm/mach/arch.h>
3 p7 R% I& B: f3 Q+ E! u. X# ~2 |- j#include <mach/da8xx.h>
/ ~* R& }) Z6 i, N% Z#include <mach/mux.h> `' N6 r! ^4 P7 C. f
+ ~$ e5 [! i# X4 T1 u" @ Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), A/ \1 b" [' {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% R% V. }* B( w) N/ V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' Q$ {- B5 T& T) i# }3 |% X5 I
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 `) E' R0 t9 h7 Q0 M! f
. W ~7 A: p' o3 e. \/* assign the tl som board LED-GPIOs*/
& D7 ?. B6 _3 S$ {' jstatic const short da850_evm_tl_user_led_pins[] = {
; y! J0 O/ s6 ?0 R l /* These pins are definition at <mach/mux.h> file */; ~) B" O1 O( f; Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 [& s/ X* ~# }0 C
-1
# X. X0 U7 z" ?. _( c; h3 X- R};
2 j L; I6 n, [; l
1 C( P0 N: I; h2 d `: f( Astatic struct gpio_led da850_evm_tl_leds[] = {
6 E4 v5 i/ c/ C7 x; t1 p {
: U# ?; \5 K/ i7 ?# `0 E+ c0 T .active_low = 0,
2 p4 N" L4 S8 D- Z1 v' x .gpio = DA850_USER_LED0,
Y7 ^3 ^% i8 [3 s0 t .name = "user_led0",5 \6 h; N2 y5 H+ O
.default_trigger = "default-on",
I) b1 @. y+ D },4 V2 e, d6 o! s9 f& k
{
% t% ^& [# P8 X: q. z5 r0 ^* p .active_low = 0,
8 q# I6 e, g; s* H .gpio = DA850_USER_LED1,( S& F3 \ j1 L/ W) _
.name = "user_led1",, e5 Z! \1 V1 l: S% ^7 l
.default_trigger = "default-on"," S/ B* t* D f1 [9 V/ H0 }7 g# O
},/ s4 ]' {8 t. _: j
{
1 M( V, t6 u5 @3 t .active_low = 0,/ C2 i* k# J) |# K
.gpio = DA850_USER_LED2,
. n# h% _- s* ~4 n( w% b/ w* d .name = "user_led2"," V" W" y4 l! ]3 ]
.default_trigger = "default-on",
/ M2 J2 E- y" @2 J: B4 l% v },0 D g% B# E/ ?5 v% Z3 ?
{8 ^% U6 D# Q5 }7 e
.active_low = 0,8 w* _, d9 j2 h& ~2 |
.gpio = DA850_USER_LED3,
( F5 J4 u6 @2 ~8 t) n. T2 i7 f .name = "user_led3",
/ F5 k" K' P3 l0 ? .default_trigger = "default-on",4 ~4 Z1 ~ ?4 p; N. q
},
% I! x% F1 H, q1 ^5 m. V};- B9 q$ Z+ i+ e6 P: V! r; d
' o" W& i, G- ?: Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! ~$ D# {+ m5 f3 d5 I .leds = da850_evm_tl_leds,
0 g/ A: t+ C: m8 _/ a% W. K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 L) P2 U! y5 Z% o5 \& ?4 a};
a; Z6 Y( f: }" x# W9 N6 @6 }/ \" `+ X: m" C- k# r1 n* H" L, m
static void led_dev_release(struct device *dev), B/ M" j0 y2 ]3 `
{( w) K/ X) [( X" v
};9 @2 c, Q8 o3 {7 ^; T9 b2 C+ F
7 I) e v3 d0 r* p! D
static struct platform_device da850_evm_tl_leds_device = {1 a H( P5 D2 q5 [% X0 m
.name = "leds-gpio",5 F4 F% J' V7 R" ?( N
.id = 1,
' j1 O+ |5 ~( w1 h .dev = {
5 H8 V6 ]2 J: o: H* B$ H .platform_data = &da850_evm_tl_leds_pdata, c% h- e e0 E% Q: a
.release = led_dev_release,
2 B: H) y2 m# c% i3 A+ B }
1 ?8 G' n2 m% l5 ^7 U, I+ @! r};
# \. \7 s- S6 b) Z& m$ }1 l6 M0 W9 v# Z4 {8 E* u
static int __init led_platform_init(void)
, y8 ~% z l. v5 ^' N{
, P8 \( ]4 s6 d- H& }8 _, L int ret;
6 \/ j0 t# Y$ A4 m' I) B#if 0
5 i) T2 F4 e8 A0 Z& {% r3 S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- S; u, ]' N4 l N; T# M
if (ret)' L8 P: a4 C9 F4 }
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 n, R' d( x1 r! i; E& U5 m2 V. m "%d\n", ret);
3 t0 L1 f, W3 q+ P& V. r5 j#endif
0 O7 q$ d1 J' W/ v- ~ a ret = platform_device_register(&da850_evm_tl_leds_device);
9 ] I+ i/ l) G1 n if (ret)9 ]7 P4 _8 H; O2 i
pr_warning("Could not register som GPIO expander LEDS");/ y1 _7 y5 _: z4 N$ I* K
else1 |& o4 q O% O& i6 n
printk(KERN_INFO "LED register sucessful!\n");( t6 U! X: ?' w& b1 o
* K0 x/ Z5 g3 m+ R1 e$ k
return ret;/ L; @8 K8 C% g; v5 `5 E
}
8 H+ q$ x4 Y( u/ \6 ?) e2 R. V: h% V) \& `8 ?
static void __exit led_platform_exit(void)
2 Y. s! B& j( Z. m{# M* p4 w5 i+ Z
platform_device_unregister(&da850_evm_tl_leds_device);
% ?6 O& i$ \5 |9 r- f
0 ? X9 s$ I) r$ N+ v6 ~ printk(KERN_INFO "LED unregister!\n");
. }) d, p: F( P- g}* |: d. k+ U) D( }' P/ }
" h* B0 K6 Q" G7 v, amodule_init(led_platform_init);
8 ^) P' I; T; E; l% V3 pmodule_exit(led_platform_exit);# L" I3 s: Z4 S, D2 }
: ]1 X' F4 e, V' i6 V+ ]. u
MODULE_DESCRIPTION("Led platform driver");( f8 f. c' w4 \8 {0 ^
MODULE_AUTHOR("Tronlong");; E4 }1 i5 I7 H3 x. Q
MODULE_LICENSE("GPL"); i& `2 G* W0 m2 ~! N: j
% f9 X, v9 ]2 Q& }8 q |
|