|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. X( T5 c# x" s8 ]#include <linux/init.h>
$ O y3 z4 Z5 L6 C#include <linux/module.h>
! U, U y/ c: I0 G( G) ~. B#include <linux/kernel.h>6 L* j% I3 z6 t; H, j0 P
#include <linux/types.h>- E I8 M9 W/ \. a. J
#include <linux/gpio.h> i" t; n- }! L( ~- W
#include <linux/leds.h>, j }7 M$ t+ c: y$ c
#include <linux/platform_device.h>! G2 E# F7 A# ]; H- ?$ \
6 @% ?. e- ]5 o/ n! H0 a
#include <asm/mach-types.h>
4 A; \3 n, x/ p. Y7 _#include <asm/mach/arch.h>4 t/ z! A2 X G+ K% b
#include <mach/da8xx.h>5 Y3 k9 ?- [ x: ?/ w0 i% E4 P
#include <mach/mux.h>
% S+ \* a7 n1 K* Y$ ^2 W9 {8 _! T9 \ Q* F6 B, s& W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
z: E. Y9 ~0 d) P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ `8 Q, r1 @5 G- p0 E" X+ c
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ J! |$ m, o8 v#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 ], N2 Y1 i6 {! n+ J2 U+ y# C! s/ A3 ^& o" N7 r
/* assign the tl som board LED-GPIOs*/
& w* P: w! i: t4 T/ ~0 [- Mstatic const short da850_evm_tl_user_led_pins[] = {6 m7 H4 y3 F& P4 H
/* These pins are definition at <mach/mux.h> file */, L, e* ^' p# l1 k. N' Y% p) G) }! E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ m' K, B! |- f$ E' c -1
4 F* y- D: s) L5 j# R) x};. q1 ?* t- p" W4 C9 G% q% K
3 c& P) j* u* k- _2 fstatic struct gpio_led da850_evm_tl_leds[] = {" B, {, H1 ~4 m: B9 E7 Y$ t
{9 u) ]# |) K @. Y3 Q
.active_low = 0,
1 ]/ M& x; e8 R .gpio = DA850_USER_LED0,
' N+ j# e: F4 t3 O5 Q1 c# T9 D .name = "user_led0",9 p" m& L3 Z d1 Q6 P
.default_trigger = "default-on",
$ S1 T0 M5 N# c- D },* H8 s, R& r, a9 P' D% L! S
{8 T/ c/ J a$ S2 v
.active_low = 0,
2 b J& o$ O' ^; f' G5 r .gpio = DA850_USER_LED1,# Q6 p$ q5 c) ^
.name = "user_led1",+ B2 D/ ]' b1 [" H1 o3 m- b9 }
.default_trigger = "default-on",! X4 ^$ y# W) F5 d0 a. w
},# y J0 N) t6 f' x
{
/ L& C) s7 W* k .active_low = 0,( y- P# r% J' C. C8 u
.gpio = DA850_USER_LED2,
5 g/ s6 Q) L0 o2 o& H' W/ g5 w, t8 i .name = "user_led2",6 }% h, Q+ n+ i3 z, @
.default_trigger = "default-on",
0 l4 Y" [, N" [& c& ]$ u; ? },* o' ]' j+ B4 o5 j$ x" N. f0 H2 z
{) F9 h/ p' j' n9 @( T, ]
.active_low = 0,3 S/ C0 R/ i$ ^ O4 U
.gpio = DA850_USER_LED3,* X( U. h3 `5 F/ ~) X3 H+ ]
.name = "user_led3",
- j6 y1 U1 E2 J3 u( `+ ? .default_trigger = "default-on",
; H3 ] Q' a3 {' X- J7 I2 c% [ },
1 k! L2 ]$ X7 k3 M3 _};# x1 c7 H( W- q( t% R
+ P! u5 u& c3 P- {5 E( Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% K4 ~& v4 W( k8 D; B o. Y& u
.leds = da850_evm_tl_leds,3 F$ Y: A9 Y2 U7 w+ d
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 A# l# G' [( I, S6 i9 d* y- `) E
};9 C$ E7 y! @% U- Q
2 \6 o6 r' H4 y0 U1 J6 d, Y
static void led_dev_release(struct device *dev)" u3 h2 w* \/ h! ~+ p7 f E+ z. K
{" k. e) Y+ {8 f
};
: k/ j$ k# x T, ~0 {3 d& d6 {; K. X' h
static struct platform_device da850_evm_tl_leds_device = {5 O2 X! B) {1 }* f4 G. o. i0 K$ z- O, E
.name = "leds-gpio",! L$ H- q" n j3 b
.id = 1,/ W. W9 U1 Q; }3 P. c- y
.dev = {0 B$ z; _6 C5 {+ a
.platform_data = &da850_evm_tl_leds_pdata,
* ~6 C& l5 M* l2 s$ Y .release = led_dev_release,
6 r; ]& w& _! h$ m+ ?3 C }# o- Y3 [8 d5 H4 J2 |, \2 _& u
};) }1 N5 `& d% V0 l! ?$ [; }# s/ \7 M
* O# ?9 F' X% R1 X: |
static int __init led_platform_init(void)
. N7 [* H+ x- w# I- V+ S, i{5 W' _ o, ^0 b. B' F1 w
int ret;
, B" }7 T2 y2 X#if 0, J4 m! P0 s' Z: w5 A" H# g+ Y, @5 a
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ x+ x. j: \: i0 y
if (ret)1 J8 K: L: C* w% w' l, X9 J! o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 G+ T; k% t* S6 d4 h4 R "%d\n", ret);
9 y) I' y9 H9 Q6 E6 e#endif) v; q9 I: r7 u( ]
ret = platform_device_register(&da850_evm_tl_leds_device);
- W- J& h6 w6 {2 ] if (ret)
& ~* J1 _: t) r9 b pr_warning("Could not register som GPIO expander LEDS");
, C" M7 [1 j8 m/ m% \( g, _ else" ^2 \- G5 N ~+ e) E' j6 X$ R
printk(KERN_INFO "LED register sucessful!\n");& Z1 ~( ^7 g0 _' ]1 Y& Z
1 W5 ~7 e) b9 s return ret;
& Y) S: q9 X! e% J0 u5 s& {}% L6 i t3 X. U% s3 Q
! f9 x! y8 }! V6 U b6 D, tstatic void __exit led_platform_exit(void)# s; g3 B. t0 ~) L# R$ b, }
{
0 t- t- t, g& u; | platform_device_unregister(&da850_evm_tl_leds_device);
4 J* B4 y* _4 c& m* A; k) R& a3 X- `* w% w; N6 Q) L
printk(KERN_INFO "LED unregister!\n");: ?" b" e% ?0 A/ l, ]$ c2 b
}! A& K& r# A! m3 o* O
$ T) Y7 e2 ]- o; v9 @( f% Z
module_init(led_platform_init);
7 M1 p2 s l% ]% ^( h+ L0 e& v1 Xmodule_exit(led_platform_exit);' \& ~- _2 o5 X* G6 B
0 j" n4 O. v$ o! k* m7 R' R
MODULE_DESCRIPTION("Led platform driver");
& V/ I) V) f& R+ @6 qMODULE_AUTHOR("Tronlong");
# d) j0 X8 ^- _" W; HMODULE_LICENSE("GPL");
o0 {. U" O* Z3 a) [$ L, d& t( }# z% S
|
|