|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 r3 O4 t/ c( [) e3 u#include <linux/init.h>8 `" a- L+ \+ N# G: _8 u2 F# R, ]2 W
#include <linux/module.h>" G# H) T3 [! i- |0 n
#include <linux/kernel.h>
' k9 u# Q6 ?. }/ H" A#include <linux/types.h>
_- I) b* q/ x9 D#include <linux/gpio.h>
% K8 G' g N* X7 v5 o7 }; z#include <linux/leds.h>: K& B' I1 |/ C5 I
#include <linux/platform_device.h>
$ H, M' g' A2 a* k( \
% k1 P4 ]$ |+ O#include <asm/mach-types.h>
. Z+ u0 @/ B: y; R: R#include <asm/mach/arch.h>
& i( o' {& {" D$ e( y, s#include <mach/da8xx.h>
7 Y) W& _) e5 Z0 [#include <mach/mux.h>
+ N2 f1 N$ B5 f9 [# C1 f4 Y. }* d0 E% r7 l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 R1 Z% m3 t( j7 y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- e" \3 I* s% D5 e6 p/ z0 j4 t#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 D4 |& b. p! H) y9 m#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 H3 n8 {- D3 x
( v$ V3 L( C2 Y9 e5 J+ e
/* assign the tl som board LED-GPIOs*/
7 _: {% N2 A% f2 T% kstatic const short da850_evm_tl_user_led_pins[] = {
* ?2 G. z1 X6 y9 t: { /* These pins are definition at <mach/mux.h> file */
5 ?: o1 \6 |0 ^( }( ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! m( N+ Q1 }5 Y -1
8 t# Y1 f! m$ D6 m9 c+ Z};. J4 n. ~9 \" W$ J
# Z5 V* R6 J5 ^* S! {- X
static struct gpio_led da850_evm_tl_leds[] = {+ Z0 e- \- M; g0 O
{2 V0 M: ] `: d/ x
.active_low = 0,
* M8 J- }! E" b4 D* c$ X6 M: I' C .gpio = DA850_USER_LED0,) s/ [$ ?$ U: I; a$ U5 b
.name = "user_led0",
+ q5 ]2 q- z% I3 B5 B5 ] .default_trigger = "default-on",
" W$ X+ r8 ^9 T },) F7 m) Z' }9 O4 l( u
{. T& c ~0 _ P: b; W
.active_low = 0,, y- f/ I6 m, r$ i o0 J* M1 u! Y) @
.gpio = DA850_USER_LED1,; K. ^2 }( b* y7 F( U% _
.name = "user_led1",
* L& Q. e1 Q3 R* l3 g .default_trigger = "default-on",
4 j3 X* ?9 q1 m# j C },
8 b* S" e2 I/ j7 E {+ L5 } i; y6 R# b G
.active_low = 0,
/ A f9 B* Y3 M5 ]8 a .gpio = DA850_USER_LED2,* z* ^ c7 j5 X: G
.name = "user_led2",
6 Q9 p u0 \/ M$ E1 _& U/ N .default_trigger = "default-on",; Z# p N1 [, _1 W$ G
},
/ z, b6 [- x- s6 E {8 ?( i( b, U5 l; w1 V! W+ u2 j
.active_low = 0,
H3 }. Y/ f) y6 y* q% @( C4 r .gpio = DA850_USER_LED3,$ t3 Z7 }5 e' x, |9 _
.name = "user_led3",6 m# o7 E5 H' `
.default_trigger = "default-on",
( E" {' c6 c# S) n2 q0 L },' h" k# w9 X- n# _7 e( P: D
};
; n/ \5 s, j8 X) g% I! F
% a7 B0 {& X3 Y2 G# Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( A" i' ^+ }! V6 R
.leds = da850_evm_tl_leds,
' A9 B3 @: F% g# W .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' j U7 O/ o& } l, i: I};
, b4 d, x" z/ }* ~- X
, ~: X4 h" g& N+ f5 V1 tstatic void led_dev_release(struct device *dev)
0 ~/ a3 c9 D U1 ]{4 f) A! P, d+ A
};
\' w0 }. g% |% t. B7 o" Y0 T4 x
static struct platform_device da850_evm_tl_leds_device = { B& {# T, I4 p4 p3 P$ y; v0 x( W6 M
.name = "leds-gpio",
: ^ {5 L, x5 ]6 n! P .id = 1,, ]5 U, q6 C& W" J) D4 z" U% T( R
.dev = {/ M( V8 Z' r' z2 X" H; Q
.platform_data = &da850_evm_tl_leds_pdata,+ _+ d- d- _4 U2 _: F) `
.release = led_dev_release,
. @# j/ s/ L# C" I i2 ~" | }4 M* r! n& Q: K5 j( p
};+ n- S: v5 _2 |
/ M& k3 m1 [0 h g4 Bstatic int __init led_platform_init(void)
* J( m3 q9 P: [6 i' c& A. S{
4 g9 U! i5 \3 D& \/ n int ret;
. E) z9 U0 |" `/ k7 D/ B#if 0) S7 f$ _% B, O0 G3 k+ G ?" K7 I
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 |( a* b$ v' ~: i! L; R2 n6 r$ {
if (ret)' k5 {. E2 F3 e5 J# t. ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! d5 J2 e" F- W! v! S. u
"%d\n", ret);
1 k8 Z6 {3 o$ w1 I8 r4 K2 V1 y#endif
7 r" p% E) Q2 Y* t% _ ret = platform_device_register(&da850_evm_tl_leds_device);7 H/ E) v! O& \2 c) e9 }
if (ret)- s& A; _ f8 ^5 Y. ~
pr_warning("Could not register som GPIO expander LEDS");
& q+ }/ h; L; {9 j) H2 D else
, d$ x: K! r+ g0 L" {% m printk(KERN_INFO "LED register sucessful!\n");
9 T) G! P8 |% W: T b$ S0 L; ?
; @+ c; }0 K& z: h+ C7 ^' | return ret;: S: n: E- p/ [
}# y& y- ?" N7 h" ^5 X9 _1 }" d' w
, v5 m8 ]( Y [$ w+ N' l) G. e1 f/ Mstatic void __exit led_platform_exit(void)
5 u) K) q% a2 }{
# k) j% [, N$ W( i4 _ platform_device_unregister(&da850_evm_tl_leds_device);
/ w3 P( y) b3 v) g
/ r% w% y0 E/ X2 F: _ printk(KERN_INFO "LED unregister!\n");9 v% E1 Z0 M) w0 S4 r+ P
}
* Q C( {% x! l( _- E) f( e+ T( _/ ^. `! H
module_init(led_platform_init);2 i% s' K0 [' G+ Z# x
module_exit(led_platform_exit);( v' S3 o/ r' @# ?+ @, s% n
9 e a3 ~" k# j! P+ f' i
MODULE_DESCRIPTION("Led platform driver");
3 o: Z5 x; R s4 r5 K# nMODULE_AUTHOR("Tronlong");. m6 W2 Z/ r; E, u3 z
MODULE_LICENSE("GPL");- c) p$ `% m( A6 m" E+ D, V
& v `9 z- Y1 g, |
|
|