|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! S: i* h$ h! R1 G) o3 e
#include <linux/init.h>4 W9 F; r1 V$ H0 R
#include <linux/module.h>! ~, l h0 W I
#include <linux/kernel.h>
; R" N! R% M% y' l7 y, R6 G7 g#include <linux/types.h>
; T' }9 Z7 B& \, ^' U8 b) D#include <linux/gpio.h>
! s" S" P) k8 j5 h' R: M* I#include <linux/leds.h>
# z7 x9 S; f' a#include <linux/platform_device.h>
( t n2 o% ~* J( k$ C* `9 A1 f7 @3 t4 D, _: P! K' F/ |3 o
#include <asm/mach-types.h>& \& |) r, f) f9 x
#include <asm/mach/arch.h>- Z& {1 l2 n \; n
#include <mach/da8xx.h>/ M$ L2 d0 Y6 i8 Z$ |
#include <mach/mux.h>
% e, _: ]' Y9 W2 g8 @% L9 G
( o+ Q8 g8 e) v. R7 u#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 o2 h) k7 ?3 m- R: @& B9 ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! h" _) h4 x8 X
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 n2 R& A( C. V4 A7 t" O! h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 }9 _' A$ ?$ k! I0 _( y7 E. D8 Y+ f, m1 H
/* assign the tl som board LED-GPIOs*/
+ D( F$ |. r2 D- Lstatic const short da850_evm_tl_user_led_pins[] = {- G' q; g4 a% Q' F: `3 i3 F
/* These pins are definition at <mach/mux.h> file */# a0 g' @9 ?' H+ H2 a* a/ D0 _; `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; J$ n3 _2 r1 A- E, {0 w& _
-1- w8 `8 o: p3 v2 y5 p
};
* s8 D5 i" \7 z
{3 L2 U, N( J5 Dstatic struct gpio_led da850_evm_tl_leds[] = {: f# o2 n# w! Q+ t T9 k
{
~: T+ m( s& A4 x .active_low = 0,; U" b( T5 l% |) D" i# f% g
.gpio = DA850_USER_LED0," Q0 d* O5 O i& V& X
.name = "user_led0",: S" ?% A8 @; e- `: X0 C
.default_trigger = "default-on",
: O* r# R0 k% O# M! ^) |3 t },- \( a6 L' G: r
{/ w' `' A, A! r- t
.active_low = 0,! N: v2 f" g2 m: @- {! d) U, d
.gpio = DA850_USER_LED1,
0 g; c$ T/ ?- x; Q .name = "user_led1",
' E. j* c# h7 }' o" ~/ ? .default_trigger = "default-on",7 }: J* x# ]6 K; L+ M* a2 @
},, v& t0 B, b$ l0 o
{
/ f( o; o! P- L" J/ ] .active_low = 0,7 C: m+ J* u. `# u/ f
.gpio = DA850_USER_LED2,
2 H5 t9 n, l3 k+ v+ u .name = "user_led2",
% b0 _& x1 B4 g' P' F .default_trigger = "default-on",
/ r" J) {3 m+ x4 I6 h! R },
5 F) D0 p. _) |8 R {& j' S% K" H$ B
.active_low = 0,: n0 \) G; g2 D" v
.gpio = DA850_USER_LED3,; K5 n% i: d3 J* q
.name = "user_led3",
* v+ `$ @$ \+ G* H .default_trigger = "default-on",' _( h( h5 u& u! B3 C+ e X
}," J7 G) o! [/ L) P5 a; O% _6 g3 I
};3 n% o" v4 f1 W( m- f$ i) {3 F' |
5 Y/ r, y \! P/ \7 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ }% e& T5 _4 }6 k% m5 I
.leds = da850_evm_tl_leds,
2 j/ i# W5 \2 z- u% v .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* S" f1 G& \7 `6 O, u1 y
};
( J1 z2 x* i0 b" t M2 {
( ~$ p! P5 U" F2 q0 ostatic void led_dev_release(struct device *dev) H* e) l; i3 i4 X
{9 W" i8 W9 |6 I
};
! s' O) e! c+ I& @, d3 u
/ ^) d& i5 {/ _2 Cstatic struct platform_device da850_evm_tl_leds_device = {
7 u; \. T& c- w$ k .name = "leds-gpio",4 E) G' |, m& o5 H; |
.id = 1,
: ]' R" Y) P' R* i6 c .dev = {6 }1 ]0 M& H7 t Y* ]. c. H
.platform_data = &da850_evm_tl_leds_pdata,
% N5 Q5 D. D9 z+ z .release = led_dev_release,! ?' z- u# S) f6 L5 s
}
o! p3 r0 j- y8 L0 ^& j};
9 O9 J0 X9 d4 Q" g8 c+ W& X8 {' g8 K4 F, K2 @% n% H' }
static int __init led_platform_init(void)
9 k/ `. T r% Z! t7 f{& E6 p4 W9 r( Q* c( R- q. i+ F! T9 ]
int ret;2 C) F* A" u# I0 v( ]( l# |
#if 0; C9 i5 g0 t h3 X0 ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) I; R; z' K' i% m& V
if (ret)" g# F% H" u# D1 |) X; K6 C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! N! e1 a! Q# l* o* B$ y2 U "%d\n", ret);4 T) l% a' `5 [: k! \
#endif
7 I* l9 l7 s8 N: r ret = platform_device_register(&da850_evm_tl_leds_device);9 B' g1 d* l3 {
if (ret)* |6 Q- b- F8 F! E( v: x3 m
pr_warning("Could not register som GPIO expander LEDS");
% |9 l' `) ^7 i f: e2 f else
+ ?- a8 K$ d, X0 i& f2 X$ M printk(KERN_INFO "LED register sucessful!\n");
6 ?% [1 n0 D) A, j
( t8 D" ^. L$ A d8 S# E: H- J" S& p return ret;' b6 h' U) }6 q
}
p4 n2 y4 W; u3 ]
* A, [4 I% H2 e& l, N& Astatic void __exit led_platform_exit(void)- l/ [ X/ V" e0 m3 V/ e# D
{
2 T+ f5 N) F% ?- h3 s5 V platform_device_unregister(&da850_evm_tl_leds_device);. i& C L. l# d* p
# w2 a8 p5 r( i5 D7 K printk(KERN_INFO "LED unregister!\n");0 |7 C. z: m' l" O- D7 r' j
}
8 I2 D; Y2 h, y4 H& m2 E. Q2 G0 T; l" m3 r
module_init(led_platform_init);& L: ]" i0 u! y1 d+ ^: w- [6 ?3 L
module_exit(led_platform_exit);
5 n* d+ @ R& E" R2 O% N/ w9 k* y9 I# V2 s7 H6 I) | a
MODULE_DESCRIPTION("Led platform driver");
/ G- {2 r$ \1 x$ I9 V( EMODULE_AUTHOR("Tronlong");6 t1 D0 S8 W& T6 J
MODULE_LICENSE("GPL");
; c5 r# K1 A7 V1 B; [" V% G' X( a
& E1 H: N# Y( i7 V" Y8 T |
|