|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' C# h5 t& ~0 {: y1 ~#include <linux/init.h>
1 Y3 x' t: [8 K2 o! l#include <linux/module.h>
& \' _ m2 Y7 X' m# E/ I#include <linux/kernel.h>5 D0 Q- N) _1 C
#include <linux/types.h>
$ p* t @, q0 V( C2 C y#include <linux/gpio.h>
4 E. t2 s; W# p( ~$ o#include <linux/leds.h>
5 C' f2 A+ v+ [$ U#include <linux/platform_device.h>' f: q2 I6 w1 l6 R
8 w8 H+ B. H* d4 a( l1 ?7 V V
#include <asm/mach-types.h>
{$ n5 z! p, V5 W0 D#include <asm/mach/arch.h>3 a5 \% A8 x0 r8 j C! O: \6 r
#include <mach/da8xx.h>. j/ A% X1 m4 {, ]- z$ }
#include <mach/mux.h>
/ T& a n( h" K+ u" Y* F- k$ d8 |2 l5 v
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% l# l1 Y/ R$ A( F! ?+ P( x
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% o- W/ l9 ^+ ]1 Q6 T. F7 h+ a#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% c9 f9 S2 j" C! ^
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 {3 d) a! ?( Q+ {5 F9 k
, C5 E* B) B- W/ j7 {( N/* assign the tl som board LED-GPIOs*/1 d2 k" Z7 {( ^
static const short da850_evm_tl_user_led_pins[] = {6 u6 j* g1 T2 E0 B) p u1 r3 I
/* These pins are definition at <mach/mux.h> file */7 F" ]0 k/ V6 O. F& l
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. ^- ?! h6 R8 ^# r8 l
-1# N9 O7 y! u& X$ ^, y9 M4 ?: y/ F
};
) q% u+ O* g* t n4 t
! A% p: r5 T) bstatic struct gpio_led da850_evm_tl_leds[] = {7 n6 j; p+ ^4 p2 H$ Y/ X3 f
{9 S3 |# v( d' J h7 P3 Z3 n
.active_low = 0,
- P) E! Q5 B9 \9 B- P: _ .gpio = DA850_USER_LED0,% m) Z5 X1 F5 H4 {6 b# P- t
.name = "user_led0",
7 z1 J* q; w( t3 B6 N .default_trigger = "default-on", U. f" w% j2 p+ N
},- [8 P6 x7 C5 }( M1 Q% A
{
$ |4 X% k3 r3 z* |# c& N0 p A .active_low = 0,7 X# N# L. ~2 \) [1 C
.gpio = DA850_USER_LED1,4 z! G, g g, L& _
.name = "user_led1",3 o( Y9 n% y2 G: l) s* e
.default_trigger = "default-on",# X/ H) D. g- U/ I2 R. \
},' _, d* l9 X$ _: u4 n
{
; d, N/ Z- n z' v$ H .active_low = 0,
, O! A& d# x- f/ I7 t .gpio = DA850_USER_LED2,' u& ^- E- o$ m9 e
.name = "user_led2",
* m$ c# q+ P/ y3 f/ t1 N .default_trigger = "default-on",2 f% A: E; F; [7 W+ A. i2 I2 e# v
},
_/ F* P" P) n+ E4 T% Y' m4 v" b {
5 @. v E" B2 d% a. _! f( Q; o .active_low = 0,, ]8 \& d# z- o! |
.gpio = DA850_USER_LED3,
; J4 r9 [6 g: C' @ .name = "user_led3",
" a8 `1 W5 R0 p2 ^' X% X .default_trigger = "default-on",
( x1 v6 a* b- a3 E },/ W2 p* g+ |7 N% F" y
};
0 D8 K( _4 S5 I n- t1 ]
- n1 B4 q. l6 B. Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ d7 V2 w( f0 l0 R2 D
.leds = da850_evm_tl_leds,% H% p- z" S8 V% D, y/ Y8 \
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ I. Y/ L) g/ d8 s& J3 V8 x/ i
};
; U' e& I2 S+ t' d$ f( C" d
4 p) ~# I) w" I/ P$ y7 C% j' dstatic void led_dev_release(struct device *dev)
& g6 m, \9 X p8 x+ I- d{: s: X9 p$ s& j- y- V- O' O% _9 W
};+ ?& s8 c: E9 ^4 z
2 A" a9 @) g5 R0 \1 {( L
static struct platform_device da850_evm_tl_leds_device = {$ r T) f) D& U" x
.name = "leds-gpio",
9 D' N w- }; ~ .id = 1,7 R% J' G& V: R0 t
.dev = {
& A: C% ?+ j A& v .platform_data = &da850_evm_tl_leds_pdata,% E) K) G5 k! Q4 f# a% {0 l( Z s6 G
.release = led_dev_release,
6 d1 b( s$ U5 T4 f3 K `* G2 J4 G }
, O0 l* ]7 r: P* S) K4 }( }& ~( t: r};) i" l) \0 A1 X. X. E
% M+ q' C! H2 i& e" Y" T1 B" \static int __init led_platform_init(void)6 ~1 J- \0 r. V; i; g
{6 r8 K8 }% U/ p; _9 ^
int ret;/ S( f; _4 W% i; \
#if 0& j5 j- l& u6 h. \+ F* h( {
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& R( l+ [# F' }1 H4 Z if (ret)
( x7 Z- }) m, s pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ q/ C/ H- n6 [5 x
"%d\n", ret);
+ R7 M) j; t+ s+ R#endif9 t) R( A2 B6 w, ?, {, d. ~
ret = platform_device_register(&da850_evm_tl_leds_device);
! R" r8 o! d# G5 z [ if (ret)$ u4 Q, W- S" P: k
pr_warning("Could not register som GPIO expander LEDS");! M$ l9 k3 | W; H6 a! f
else
+ | @( I5 K+ r$ f6 }. L printk(KERN_INFO "LED register sucessful!\n");
) D% g b& C# ]( ]8 E
# I( V7 h4 C% b3 z+ Y* _) o: ~ return ret;' Q, C% b# z) M# u/ E
}
5 G& R( E4 r; v3 }" P; Q5 C/ o" n
$ C w/ ^2 W7 w4 fstatic void __exit led_platform_exit(void), b: d0 C3 U1 E! q/ m$ G* o6 k1 o( l
{
! Z" s+ D0 K% d3 v5 V) ~/ C platform_device_unregister(&da850_evm_tl_leds_device);& I. w7 {. N ^. W9 h- F
$ b3 v) o1 m. j0 W- N
printk(KERN_INFO "LED unregister!\n");1 s% A1 S" ~- z# d! { b
}
$ h" D7 u( o/ ~" p6 g. i/ o4 S O
module_init(led_platform_init);
. m4 V }1 t" c9 `+ Emodule_exit(led_platform_exit);
+ k& I! ]* ^$ ]- I& V6 F7 I+ z) D! s# F; P' V# u- J" z7 Q$ D) u
MODULE_DESCRIPTION("Led platform driver");/ d; S. o/ O9 e* J) i4 M; a* l
MODULE_AUTHOR("Tronlong");
8 q A) |. {2 j! ^+ |MODULE_LICENSE("GPL");9 k5 n4 m* X! D( o6 r
0 y: n6 `+ j/ N |
|