|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 n1 g5 ?: Q+ K a# M7 v2 C K0 d
#include <linux/init.h># a( s5 {% r/ O& B* O T7 @
#include <linux/module.h>
) M; U. Y7 O4 v( g& y' ?( T9 o#include <linux/kernel.h>! w# X. h; l, H. o2 k( ?
#include <linux/types.h>
8 H2 n% d, u& j( @5 p#include <linux/gpio.h>
( d8 s! G" O& [7 M3 h2 c#include <linux/leds.h>% o( D, x4 c8 c7 M% g) W5 T# P v' o
#include <linux/platform_device.h>
" Z4 _8 w8 y9 r, k6 U. ~8 h" X$ H/ t5 I3 V5 y" W; v0 G
#include <asm/mach-types.h>
) ]5 @" d, R6 S* S* o! }#include <asm/mach/arch.h> ]0 C, G5 x. J i0 b! t) E: a
#include <mach/da8xx.h>
4 L% \$ N5 K9 k' `: j7 U) G3 i5 S#include <mach/mux.h>( N7 Z! i" ?) ` R5 v
3 i% p; o) j6 y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
f. W6 S& n. U3 g( R0 M9 J: M#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" p9 M3 E! G, n V#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. a) A; }& h! N; y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; i; x+ W, J E+ w' {. g9 x! s q3 U* H% N( f/ u8 y% {9 M
/* assign the tl som board LED-GPIOs*/
/ W, u4 W% R* |- a" i7 ]static const short da850_evm_tl_user_led_pins[] = {
: l1 C) p/ ^3 ]: F5 ^& o; X5 `% v /* These pins are definition at <mach/mux.h> file */) T, ^: i' @& N% _+ v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ A5 r7 N; Z5 N& H, v
-1; e$ S+ U' ?( B7 G6 G5 d6 V
};0 n2 N$ S4 z6 Y4 h" Y
1 h2 k6 A& o" b9 O$ W, B' }# Dstatic struct gpio_led da850_evm_tl_leds[] = {3 l( n# x( | e' w& ]/ j
{
* P; i' D3 x# X( E .active_low = 0,
9 R9 r7 |( }% C: o# z .gpio = DA850_USER_LED0,
/ E6 m8 G& g X; k9 j .name = "user_led0",
, T, F" p# B; p: M' ?# e8 U! x% K .default_trigger = "default-on",8 u" H# y I$ v+ ^8 X% `, a _" H
},) a: ~' B+ H# k, O( z0 v
{
& M5 C: }( t# b3 G& i4 b$ q .active_low = 0,
! U, ?$ K& E6 l; s .gpio = DA850_USER_LED1,3 V- L" w0 l) ^8 t
.name = "user_led1",4 z- z% Z" ?, e- e- V
.default_trigger = "default-on",% F8 G# e3 e/ l1 ]: _' V6 v; x z
},% } Z3 \8 ^1 w! N# }
{7 a; ^1 M4 F) P# R9 f5 u! O: U7 d( V
.active_low = 0, y2 e x. B# o
.gpio = DA850_USER_LED2,9 d9 X" K4 ], {+ b
.name = "user_led2",
5 e) a* t/ Q& e7 { .default_trigger = "default-on",: H3 `# B2 b5 y) H c
},2 s# q+ a' ^. w" t/ u1 O1 E
{
' _' G) A( Q/ O' s .active_low = 0,
1 E) d ~/ z" t O .gpio = DA850_USER_LED3,9 i( g) d$ M9 Z* b/ t
.name = "user_led3",
0 V, k/ B' k5 K$ u' w- s+ @! l5 m1 G .default_trigger = "default-on",
) _7 D( }4 X" G; l7 v },7 v: l! \+ m/ v b& i; a1 R. `
};% t3 b0 E# m5 ^2 s& O+ U; y1 }
' l& A% P/ J# } f, j! vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; P5 A6 z; n# ?/ Q6 H: q! W
.leds = da850_evm_tl_leds,
/ b& a. U% E9 b( ] .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 R7 I: V' y' l: L, e; q3 Z
};( N3 D6 Q+ G: n6 w6 i i
; x# t7 c, S0 ?$ U% J. H
static void led_dev_release(struct device *dev)
) j g, a3 r' O! H{
* R3 F) Q& b* o$ I) X( ?};
6 p2 a. v& U/ \/ m. ]. G1 n( t6 c: H2 ~2 T0 I4 H! W4 e
static struct platform_device da850_evm_tl_leds_device = {
! R1 |4 A- Q1 B/ e .name = "leds-gpio",
/ |4 p8 K5 P0 b! ] .id = 1,+ j4 q) r1 m8 q# n. L: b
.dev = {
( p( N2 _- d* m# t6 g# ] .platform_data = &da850_evm_tl_leds_pdata,+ ]) `, }6 e% f `' x, W4 |
.release = led_dev_release,
7 ?. B" K5 R2 c2 \" j9 t# `9 y }- W' X$ S7 Y! j5 L, @
};1 r2 ^2 U Z) L# Y3 r) v' b: x
( M |% N. ]( U" B+ ]1 J% y% P- E6 wstatic int __init led_platform_init(void)# E3 U5 m: s" A- q. D
{- P6 ^# B% j, \
int ret;
$ A6 I3 m `$ }8 W" o- r2 K1 u/ q#if 0
6 y2 U# K) ?# m7 R; L! P2 T ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( {0 x$ h" U. @2 d$ I# k& E
if (ret)4 {# g0 l( D' Y x' q/ Q$ f/ ^( j
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( x5 p, ?# I. a
"%d\n", ret);
) J4 Q5 W7 F1 b! h5 @#endif. [* r c3 Q$ v% L" p* D9 C
ret = platform_device_register(&da850_evm_tl_leds_device);: X- T9 C ~2 I8 z8 s+ k# [; ~
if (ret)
0 M& S! C; @: I. c, ^# _! `' L pr_warning("Could not register som GPIO expander LEDS");
1 c! w2 v" N, h4 W8 K else
4 L/ b2 ]* V8 p: O printk(KERN_INFO "LED register sucessful!\n");0 c/ H& D, R7 g$ H! i' _6 d& L0 _
- j1 C z5 P8 `+ ^* \$ L
return ret;
3 }' i8 {; Z$ m" t$ Y5 K}
2 v, a% ^+ s+ P; g; _* z
! m; x8 I' W( kstatic void __exit led_platform_exit(void)
5 I' m* o$ b. ~" x{8 n, Z7 _8 S' k8 t. f. e
platform_device_unregister(&da850_evm_tl_leds_device);
/ x$ ?- N7 N$ i) ~' g5 l6 d. @
printk(KERN_INFO "LED unregister!\n");
5 m4 S5 R/ a# m# A( g# e" Z: `}9 f' S4 p: U" Z( j( m3 v
* j4 O$ o! `& X( D2 K1 r! ]- a& \3 |
module_init(led_platform_init);
' o* O) ~$ i& `module_exit(led_platform_exit);
5 K" e+ p: Y! K. o9 o
% w; j- p- v% R; [+ G! x- j: PMODULE_DESCRIPTION("Led platform driver");- ?! J* r' f8 M) [
MODULE_AUTHOR("Tronlong");
; w) d8 W% i( a1 |2 ^MODULE_LICENSE("GPL");
' L! L; t Z5 Z2 p7 I8 h- j- }! V6 P% Y' v5 l% s' [3 A1 U o
|
|