|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) T& Q: A# Z9 @" E& E
#include <linux/init.h>
/ h. A* b/ b/ r/ R1 k* U#include <linux/module.h>
8 I2 q7 G; ^( G, F#include <linux/kernel.h>
( m Q& j5 M* `9 B( B* u#include <linux/types.h>
+ w {% V4 F( \" A#include <linux/gpio.h>
, ]- t7 `' ` Y2 B# T#include <linux/leds.h>: I! @9 L) y- b
#include <linux/platform_device.h>
) _/ p. r& q/ g2 P0 E- n2 E, i- R3 W/ l8 Q$ e, g
#include <asm/mach-types.h>: l$ A( m. q7 o# S
#include <asm/mach/arch.h>
1 ~, X' |7 @; Y#include <mach/da8xx.h>
! Q# C; J( i+ ^& w' A#include <mach/mux.h>: C7 G! s$ e" L. H0 _
+ i j4 I7 U$ G, W }2 a- N4 W5 h5 _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 \4 G7 S4 l5 Z. t/ F+ P
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 s# p- ]5 ]0 L2 T8 p1 ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), }/ X/ O. f4 z9 k
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 b& l; G/ _4 d
+ I+ x* W7 I1 ?; O6 T5 P4 l# k/* assign the tl som board LED-GPIOs*/
+ `+ Y! o, T8 [( h4 V: sstatic const short da850_evm_tl_user_led_pins[] = {
( I: Z+ g9 f3 x /* These pins are definition at <mach/mux.h> file */& P+ Z; T! G# U2 n8 m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ s# Y& f' g' ~4 q- N
-1
: X3 l/ x3 g! f0 c5 @5 c4 o};
7 u9 }8 n3 G! r! M8 s; Q2 f
0 Q @: i# l9 ^' o+ u) ustatic struct gpio_led da850_evm_tl_leds[] = {9 |+ ]; j$ r* ^& S+ y- M" R
{
2 \ B/ Z# \0 U% X2 Z: c& m .active_low = 0,
t$ `) Y9 X5 S* P: i* D .gpio = DA850_USER_LED0,
* n& _3 M l+ `0 p .name = "user_led0",
0 _( ?) i! }: C% A& e L& l* G .default_trigger = "default-on",
% s6 k$ C& P4 P },
; K6 p2 A5 J7 q3 d/ P9 I5 \! ? {$ [6 s( K5 ?3 r" n
.active_low = 0,
p2 y! R8 @5 T4 A U) l. \ .gpio = DA850_USER_LED1,
& B% G" L+ G0 i3 M7 ] .name = "user_led1",
! _" w: b3 w$ w" A" {* l* ]$ o Q .default_trigger = "default-on",
2 [' a' N8 B- O+ T8 j% h+ ^ },1 |5 ~5 c: [, H, _% G$ w, [& l
{
( P E* L9 I+ Y+ X .active_low = 0,
4 ~: c) q; C- I% z .gpio = DA850_USER_LED2,& y2 Z2 \/ w q, |8 O
.name = "user_led2",
& _" h- T) S* U7 H3 f .default_trigger = "default-on",
, l, L6 e& _4 b% d9 B" i },7 z0 ], {5 q1 q* F
{
- C4 W9 X! N% ?& Q" E5 D .active_low = 0,
" N4 }" g' x6 z- U" Z .gpio = DA850_USER_LED3,
! w, p3 z$ {) T2 C+ H2 l- `, K1 q .name = "user_led3", c( n" Y- b; T9 l$ M/ U" E& @
.default_trigger = "default-on",7 O, u9 S- ]8 A2 }% D
},
- z( n. c6 s; \4 W" ^};
/ C( j7 G" a/ D- {
2 {. ~$ S5 W4 T' Z: istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 P) U/ B; a- B) x
.leds = da850_evm_tl_leds,
% M6 v/ l0 h1 a# q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# E7 Q! z* f% Q# v* A};& i9 W9 V" K4 h6 P3 e, b
: h9 x! E; i2 e" b; s7 g: q: t, ?static void led_dev_release(struct device *dev)
5 d; X1 a* o+ `{" C0 K6 q# d( w; I- u9 K
};" [" H- i/ {& b" M4 T2 ^
6 H3 t2 p4 D; d/ O( T( Kstatic struct platform_device da850_evm_tl_leds_device = {# g/ ^9 C. ^- F. }" s4 b
.name = "leds-gpio",
7 f5 z! Y2 W$ q+ _* m G# X+ F4 Z .id = 1,) ~5 Y' X/ j" E+ U/ e; X
.dev = {
8 T& i' q6 n* q$ }( F2 _ .platform_data = &da850_evm_tl_leds_pdata,9 |+ U) v9 f' R5 [/ W) H. u
.release = led_dev_release,; W O$ S6 |, @
}
2 w; M) ~# A' ]" M};7 l: W% u# t! w c
' ]/ w1 L9 p8 L& O/ N# E }0 Y6 L7 ~static int __init led_platform_init(void)8 C2 ]5 g- F% ^& Z) b
{
9 e; T+ E+ q d! e int ret;
`7 P- S. J2 D! g& A9 G+ @1 w#if 0* Z& T( z+ I8 ?! d
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 X, Y; m% e! N( t* h: H if (ret)
- l5 E) N6 l* N5 h pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 `5 |# x& n5 G
"%d\n", ret);! S' U$ f- x" D4 |% T t( B
#endif, N2 K5 c- j, V/ S
ret = platform_device_register(&da850_evm_tl_leds_device);
3 M$ `: e, I& v; w1 k+ O6 J if (ret); @2 u: d5 A" P7 s. D# }
pr_warning("Could not register som GPIO expander LEDS");
~8 T, z9 k, x8 @' Z5 @! v else0 }7 w& ?0 k9 b$ T7 v5 I$ V& d
printk(KERN_INFO "LED register sucessful!\n");
( @. N/ e$ r: e& u, t( f! s( ~. S) A$ q- @3 @/ ^ z) U) F& R
return ret;
0 {9 y1 q7 _5 q2 D& x" z}- F }& _6 l6 y
2 T! P, Y% l5 E, h& \. r. z
static void __exit led_platform_exit(void)
2 P5 Z8 ~* g; w( E Q1 v, O{
- [% `- k0 R9 e% O% w/ h/ ? platform_device_unregister(&da850_evm_tl_leds_device);3 x6 j) U8 ?3 |! E4 k& T
5 f+ K, f8 C% Q+ u5 x- u
printk(KERN_INFO "LED unregister!\n");0 T; ~7 L: J9 h5 K, Y; y& k( y( V
}! U1 n+ @ s7 s1 U7 E4 q- v7 z
$ A* _4 X! w: X* y) v
module_init(led_platform_init);/ |! s; g b) R }* c
module_exit(led_platform_exit);/ O& }! n, `$ q4 [
" O- N# ~% P$ F/ L- p- `2 b2 yMODULE_DESCRIPTION("Led platform driver");* a, [! L$ N5 x9 P0 z6 W& k
MODULE_AUTHOR("Tronlong");; C, t. g- |9 ^5 v% C6 r
MODULE_LICENSE("GPL");
6 ^; W4 Q5 L- m) S# O# m8 x& m0 |$ L3 b3 [3 ]( _1 y& m
|
|