|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! n/ u4 S p( T+ n% Z# S" T7 K M#include <linux/init.h>
$ Q) v2 T3 S1 e- k( y' h4 M/ n$ j#include <linux/module.h>
( x7 u+ y. d9 {# n8 x#include <linux/kernel.h>
) I- R- M# f: V+ W#include <linux/types.h>4 `, f) h4 h; ~- R2 r! A$ C
#include <linux/gpio.h>
1 N* N: ^$ I( d! y) ~#include <linux/leds.h>
2 b* `, W' h2 k7 E5 ~#include <linux/platform_device.h>; d$ b$ V* {* H( n5 _" j
+ c4 x% X# o& O, }7 R
#include <asm/mach-types.h>; x5 Z& r% J8 @9 _8 Y
#include <asm/mach/arch.h>8 {. k) K. k" @( _+ B3 E2 ^
#include <mach/da8xx.h>1 U5 e: [6 G# I- [
#include <mach/mux.h>
3 Z# v9 s% k& N8 x' S% l: S# P/ y' `* P; I
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 J1 l. p v* W
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' i7 L' D! ?5 s& x: e9 u
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( v9 o: F% O! b- Y A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); q2 [2 I1 z, p @' }# L
$ t/ m" I/ m: O! A1 G! l/* assign the tl som board LED-GPIOs*/$ ~8 W7 F7 l/ B6 O& F5 _/ R) m
static const short da850_evm_tl_user_led_pins[] = {
2 l+ w3 S; T1 }" u /* These pins are definition at <mach/mux.h> file */! l- _$ U/ P7 C) J' o( |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 O/ Z8 B8 s4 q0 j% f# w8 c
-1. x* k9 c$ S. j1 z" Q
};4 T4 [8 I4 Z9 N G
" \6 r2 G8 D7 I0 ?* O. {# Istatic struct gpio_led da850_evm_tl_leds[] = {
3 Q1 G) d( x- _ {
: k, c1 N& S9 p7 W$ r. y2 i .active_low = 0,. o; m! F6 z" G5 I3 M- M
.gpio = DA850_USER_LED0,* M: |7 |; L* V. u( u6 ~
.name = "user_led0",
, E. Q. ~! [4 L5 e3 N .default_trigger = "default-on",
0 P( c/ j/ D$ @& ? },
# r, o: t* R; x, J2 a- M {& v* z& c# w4 Q3 U; ^- S, {
.active_low = 0,4 A7 _8 N7 j' J! R+ w
.gpio = DA850_USER_LED1,6 U S6 O( p8 _2 z' {& x, n
.name = "user_led1",
. s4 g& V+ l0 X" m4 G X+ s .default_trigger = "default-on",
0 I9 n! G# p; _2 V; \2 A% y },
1 ~/ |+ [4 J! I4 z% i: A. Y0 b {) S3 l/ Q, D$ e5 b& k
.active_low = 0,
# M: y& {7 U) }- @2 {. k6 Y% a .gpio = DA850_USER_LED2,
' e7 e( M2 K( h- ]8 ]* { .name = "user_led2",4 a2 m Q# |7 k* l. h0 r% ~5 X
.default_trigger = "default-on",
1 Q; ~9 z$ O/ h& M8 y },$ G* F& E2 D! l0 e4 g
{
& T& s. x+ U3 f0 ]' @5 S+ K .active_low = 0,
# I. G& u/ e# C .gpio = DA850_USER_LED3,& K8 u% _6 }* X: `9 U6 B
.name = "user_led3",
4 W* R% V" f* }+ ^7 j) S .default_trigger = "default-on",
. ?8 X# W; ]" Z },7 R1 F: b* T( W" ~$ c1 {
};# v6 E( W* Z4 X7 n( a
) |( L5 \0 @2 n8 g O; B' R. M; Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ z' h4 X: B% x. I1 t
.leds = da850_evm_tl_leds,
7 j0 b2 `: h7 ?1 x- | .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! w& X0 r$ D- n" Y+ R9 [& ~3 A};
R- M% L* m4 P% S, l# W% P6 _ @2 q, k% c, s. y: E0 n5 [7 j" \+ F
static void led_dev_release(struct device *dev)
$ o8 t9 r) b9 X8 k c Q{ j, B+ I. l1 \( ^% Q- @
};
$ E; c8 I; e, E2 D& W+ x
* D& n" ~$ k3 h+ c$ Mstatic struct platform_device da850_evm_tl_leds_device = {6 R+ r& E$ O$ A c
.name = "leds-gpio",
+ h |0 H$ Z% C7 s" p+ P% T0 Q6 l .id = 1, J) ]8 E; G" }
.dev = {% T. p0 p: S* c" ?& A
.platform_data = &da850_evm_tl_leds_pdata,
. q9 C( y9 s+ h; r6 j .release = led_dev_release,
1 W; M4 g' G% B% P( `, Z: ` }1 W# u' S c8 M1 R/ X% X$ ]
};
0 g1 U* P6 W1 C: `* B3 q w) `
: S; [3 j% s# _: s9 |' _static int __init led_platform_init(void)
: {9 E. I5 z' I6 E$ X& p{+ j0 M# K1 l: B; }' J. X% M0 \
int ret;: W* A! ]. ]7 [ {
#if 0
: Y- c" X% \- p2 f+ M6 N& K ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! X" K5 z' {7 e& F1 l% M
if (ret)* y' ^8 X$ |% I' H. C1 }5 Q! M
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 r8 T8 b8 i( D' L. D# l
"%d\n", ret);
4 E7 b7 B, m5 m D4 H, ^3 P#endif
0 K) t3 ]7 T1 Z, T E/ ` ret = platform_device_register(&da850_evm_tl_leds_device);
( q2 G K3 o4 v( k if (ret)
" k+ X3 S- v$ G! c: Q pr_warning("Could not register som GPIO expander LEDS");: z1 N9 E( U) ]
else. h: C# X6 H) O( d) O5 V/ O
printk(KERN_INFO "LED register sucessful!\n");
; L4 p, f" i* g8 x
" ?$ c1 J% ]; T1 l1 h ^ return ret;& ~, L7 b* G* ~0 I" m7 }2 Q
}
, e" `7 k8 v; Q! q! q/ C9 f) e: C' Y- l
static void __exit led_platform_exit(void). Q/ Z; B, i# S+ e
{+ w; {+ I' }+ p
platform_device_unregister(&da850_evm_tl_leds_device);
0 T5 g+ A% ^9 W; x! y, N% H' ^* H3 G! }% v
printk(KERN_INFO "LED unregister!\n");9 ^+ K4 _, D% n' W5 m% G) S
}
! H( _- Q5 W: D. |6 O/ g% X+ J) ?7 r( d, L# t
module_init(led_platform_init);# y) X6 D }+ _/ w' b9 D" I
module_exit(led_platform_exit);
: H+ \; w% u$ l' K- i+ i O
. m+ L( I& a- ?- l; a% ]( eMODULE_DESCRIPTION("Led platform driver");
9 y& G; _ e& K, B* OMODULE_AUTHOR("Tronlong");( z# h9 g+ Z; b; g
MODULE_LICENSE("GPL");5 {7 s g. K% f, G
- x' D) L. A& ^/ l _% n) k- `
|
|