|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 p' b7 O, [' k+ M7 L- V
#include <linux/init.h>* l5 W ^: q+ {$ Z/ o
#include <linux/module.h>/ m7 `! J/ s7 O4 g) ^! V
#include <linux/kernel.h>
% U; ?$ }+ w0 b% O! \3 G5 ?4 h#include <linux/types.h>
1 w- t0 B+ B& `, R6 _# `#include <linux/gpio.h>6 J( b3 g0 ]) z4 |* x2 o: b
#include <linux/leds.h>
l3 O6 _) F- d$ u8 V# {% H. V#include <linux/platform_device.h>
0 t9 H, O9 ~6 Q+ s/ S0 G9 g" O
! i0 F9 C! j" I- B#include <asm/mach-types.h>* c5 J" \' |7 o" o7 V A: e- d( E
#include <asm/mach/arch.h>" V* Z. d+ z3 l/ H
#include <mach/da8xx.h>
) ^$ N; Y) v9 Y% q5 @4 w% M#include <mach/mux.h>
* k7 ]) F% N0 z1 P! u3 q0 i4 @, k5 {; \% B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
?1 A# ]/ \0 U j2 m& n/ Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; B8 E- p( V; P x6 g#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 t7 p7 _$ G/ ?8 o5 z4 ?#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- L7 t* x% w2 A, V/ D4 W5 K: i$ \5 t; M& j% _- D2 ]: K
/* assign the tl som board LED-GPIOs*/
4 o* }1 }5 Y: P: n9 g! e. ~; Gstatic const short da850_evm_tl_user_led_pins[] = {/ A' J3 f7 z/ J/ m/ e: I
/* These pins are definition at <mach/mux.h> file */; V" I. z- z% u0 G2 l, p
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! | T/ ]* n+ ^8 F3 D+ \, ^& \0 N -1& s/ e' y! q' c) j
};
' d$ J& _1 U' N& T$ N! b) V+ h- Q0 E2 C
static struct gpio_led da850_evm_tl_leds[] = {
# @" {* { q& O* B# M. m { e* s& N: G& b) x7 p4 l
.active_low = 0,
$ l; f# v3 ?# t; V% ^ .gpio = DA850_USER_LED0,
: N8 i4 P; i: U .name = "user_led0",3 L" X% {% d7 Y, Y; q& y, V# f
.default_trigger = "default-on",
; t7 t8 @2 G& _; B4 R/ { },% T& ]6 h" C% i7 @
{
- |# z7 E3 ?& G7 \! ]' H, u& K .active_low = 0,- u6 J/ c0 s- Q4 b6 L' y6 v
.gpio = DA850_USER_LED1,
% t4 O P- O+ d5 C .name = "user_led1",% E! t) {/ ?+ `3 y# M, r% o7 U
.default_trigger = "default-on",
: F. W* ~" e9 r( e( T. r },
' z, J% I, i$ n+ P: t, C4 {3 p {% f6 m6 S% y* u5 g5 r
.active_low = 0,' P5 Q: I2 o5 Y
.gpio = DA850_USER_LED2,6 h4 a. a+ G! L! D, H
.name = "user_led2",
/ ~5 w8 A- I! \/ L4 n7 ~1 j1 }! R .default_trigger = "default-on",' |- X. c! D/ r1 A
},
3 y8 S* A U- N. P {
2 h+ l" Y2 O/ Q$ g8 o$ _# ^ .active_low = 0,
1 @8 G7 W! E) ?3 ~0 ]/ H1 b .gpio = DA850_USER_LED3,; n) }) a+ Q1 X) M
.name = "user_led3",% z3 Y W7 K3 m/ r
.default_trigger = "default-on",5 \! G+ A% d' ]! t
},
: G3 P* i' G2 Z- T% d" G};
- {. V# H. U D0 }: G
5 W! @/ C) Z3 u/ q& G2 rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 c; Y/ J- N/ c: F4 _ .leds = da850_evm_tl_leds,. c) _; Z4 u1 D8 f( |; p' V8 j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# P' o+ {1 W4 X( U7 M# l};. O* W) z/ O1 h& U3 k0 I. `- J
& C/ L' ?( f) ?) n
static void led_dev_release(struct device *dev)! s* N, E% A' c$ o: E; {' X) y
{, f; X, y0 r+ o7 }
};2 K$ A$ B7 @2 C1 e- C1 @$ }
& F) e) Q2 y: T. o( \% p
static struct platform_device da850_evm_tl_leds_device = {1 q, C8 ^3 g: i( G; ]" @' E& `/ K
.name = "leds-gpio",: n& D. D( K: c6 {
.id = 1,
$ j7 ?. h, n0 j2 ?& Y .dev = {
" G" B+ ?- k. q/ ^0 W! h .platform_data = &da850_evm_tl_leds_pdata,
- m- l) Z8 r X% A1 A4 F& \9 C .release = led_dev_release,3 _. X+ L3 Y+ g; O
}
! Y% T8 o$ B% V! A/ w1 j};
% Z" N* p( I0 e# O6 O
0 y2 `& p* c' `( [0 E7 Dstatic int __init led_platform_init(void)) @* M8 Y# P% Z% U# `. Q, Z
{ k x# w5 ]. W! _( q* u* |
int ret;2 j9 `" [3 i8 I9 K' V
#if 0
9 s" s5 \; S, A' d9 I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( Y+ Z3 A+ b% t1 l* ?$ I
if (ret)
% ?0 e( b! o' `: ~3 c6 Y$ b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( V6 r6 l' |0 g: @
"%d\n", ret);
* C% `% o( s7 w- i, M#endif
3 A- V9 D9 e6 H" G$ w8 } ret = platform_device_register(&da850_evm_tl_leds_device);
* ]+ I; S! D# p. Q! Z& q$ i if (ret)& |, J7 |; T9 I) M# V3 f
pr_warning("Could not register som GPIO expander LEDS");. j b7 U9 k( n0 w+ f6 j* ]7 p
else
9 x; h& L. \9 X9 g printk(KERN_INFO "LED register sucessful!\n");
- n0 q8 }& O( ^! p0 [2 U& y" C8 T& N; I) e- t
return ret; [3 J1 K$ R. a2 T
}6 A0 q3 ?5 N; i8 l( z
k4 P1 V4 k; M# i9 K! Hstatic void __exit led_platform_exit(void)# u( z9 _# [& Q5 m
{
7 o: p6 O' P7 e* D platform_device_unregister(&da850_evm_tl_leds_device); w6 B8 P4 @9 ?* e3 j
3 B- I3 |" o8 I2 L printk(KERN_INFO "LED unregister!\n");
+ O; W: o+ n% R) m# s! n}
+ s5 M3 f8 g8 w6 c* C
* m, y1 S3 W9 D8 \* Fmodule_init(led_platform_init);7 |+ g# z8 G- L; S/ V
module_exit(led_platform_exit);+ n, `6 o% u/ a e: H/ E
" \0 U2 h7 w$ o( h: M4 w
MODULE_DESCRIPTION("Led platform driver");1 h6 `$ t- Q- ^5 Y
MODULE_AUTHOR("Tronlong");; X8 i# y. j9 q3 n' J- M
MODULE_LICENSE("GPL");- Y$ s7 v% h1 H! ^4 G& X
5 L$ p( H* y) }: N
|
|