|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 j1 k, i7 j/ `1 N2 ~
#include <linux/init.h>) }, M1 D) J% G4 i3 {# M/ ~
#include <linux/module.h>7 n$ {% C x: I. I/ \' o8 P" l/ k
#include <linux/kernel.h>
+ k8 f0 r% G& t) T5 K#include <linux/types.h>
$ d5 ?$ f. S* z: @, V/ Z! K6 g$ l#include <linux/gpio.h> X; F$ ?! m* B- P5 Q! f* M6 { d; g
#include <linux/leds.h>3 h n/ t# w z' X2 s
#include <linux/platform_device.h>
4 H7 o4 x! [, s! K0 d: ^& B* T$ y
$ q$ V. Q2 U b% M. i3 l#include <asm/mach-types.h>
2 C9 ?2 C0 u7 P% g* `; w' s, |+ g#include <asm/mach/arch.h>, x. e% ?& Q+ J/ G2 \
#include <mach/da8xx.h>
9 v1 A9 w, q/ a O- }# s#include <mach/mux.h>: e- J( F9 g n9 w) S, v
9 S: Z' h. U; q6 z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 Y! e: I. J! n; q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" P$ C7 X; c0 ]6 M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% j% a0 c9 i. n* X$ Q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 W+ _ c7 w9 u* C4 v/ f" T2 f
2 N( A) z! g4 S4 x3 u+ g8 A/ h$ P3 X8 E
/* assign the tl som board LED-GPIOs*/' k- p X- F/ `+ i, U
static const short da850_evm_tl_user_led_pins[] = {# w, G0 C+ c$ a' _4 ?0 N
/* These pins are definition at <mach/mux.h> file */
8 l9 e ^* v2 y E5 c3 J0 i DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ h2 N2 k. u5 a% q; c
-1" z( J7 x) v7 Z5 o( U1 H
};
% T5 R" z; Z% d
: L5 u% F& D$ j% m' \& O3 o. f, U% Pstatic struct gpio_led da850_evm_tl_leds[] = {: M! [+ \; O$ Y- u/ x
{
Y9 s$ Q+ I# O2 U8 O$ E' u& o! | .active_low = 0,1 ^% U! f# i5 g) g" z
.gpio = DA850_USER_LED0,
7 k% b2 e7 n' y* |: C2 | .name = "user_led0",
7 Y# L( L3 x# O8 I6 {& L .default_trigger = "default-on",
. Z9 c. F; w7 r, {3 T/ C3 \& N( ~/ g },' j4 L( Y1 |1 G% U" d
{
6 l- Z5 k+ Y% v' W4 Q* U; y" s .active_low = 0," f* a5 N Z" r% i0 d
.gpio = DA850_USER_LED1,0 M1 ^9 Y3 u" p q4 I
.name = "user_led1",9 V. G* l& i. |+ w8 J
.default_trigger = "default-on"," \( L! S5 \6 A$ o4 g
},
# o5 l7 b; a" ~7 ? {
) E+ I0 `) N! l( h* P" u5 b# D) }: U .active_low = 0,$ `8 w# ^- [. C" ?' k
.gpio = DA850_USER_LED2,, {+ }- N- h$ U6 B
.name = "user_led2",
0 _' w, z1 `# E% u .default_trigger = "default-on",; v8 R! C9 d5 `7 M$ H
},
C, Y/ b+ k% F$ F# w6 t& Q3 L {8 `% F. o. v5 @# Q# {6 f! R9 M+ l
.active_low = 0,( H/ v/ U: y' l4 v
.gpio = DA850_USER_LED3,
6 X- _6 R9 C6 V! \$ B: C .name = "user_led3",
8 b( t# }( o* c) y% y7 _ .default_trigger = "default-on",+ S f# W7 J' n) ?7 I
},6 M Y0 x* Z8 e, m
};
/ G# p2 f. q" ]/ `& i, \6 ^( U2 x7 d! |& `5 u
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ d( X- P2 t, k! K3 Y2 o& d e
.leds = da850_evm_tl_leds,! L, x0 Z R: J! L6 [
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 \+ V+ j8 C" d* D/ g, g
};+ _' u8 F5 o: ^% t6 @' g
K/ A8 N6 U& G" @
static void led_dev_release(struct device *dev)
{* h& S, N: ^5 |{
- X0 @: u/ A; e+ h7 {: ]( d};
( U0 n O) Q9 m7 z {& @& j
3 l% b6 y3 r$ O S0 Z, ]static struct platform_device da850_evm_tl_leds_device = {
& p' o3 b; s5 F/ ^0 ~ .name = "leds-gpio",; Y' K2 J! C0 \9 w0 U/ J' T& I
.id = 1,
/ O7 E0 N8 A2 T: z- x8 c .dev = {
0 I; R- x0 K5 E& M7 y& _$ M .platform_data = &da850_evm_tl_leds_pdata,+ V E; e) t% H0 ^0 _5 ~
.release = led_dev_release,4 H; f: R8 p' E& j1 X
}
8 s% ~- Q4 F# I1 ]! r: W};
! R3 i( @- B' V4 l% J0 {
- v3 |* O+ M3 r% v& N m; O8 vstatic int __init led_platform_init(void)9 I' x0 o6 P& P
{
$ _) C) S: \/ A9 h5 l int ret;4 D" i: x" Z. ^3 W2 l" J
#if 0& t( {( ]. U8 |% m
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 j7 e( y" r; N
if (ret)) }( A2 C: V; Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 f2 W" U( b3 c) C" b p0 f6 M& Z "%d\n", ret);
; I+ _4 T) p$ {! x' `) e#endif; Q3 s4 J2 C; U. D6 j/ W
ret = platform_device_register(&da850_evm_tl_leds_device);
+ j$ |% E, J/ w( K$ z. k if (ret), d {* ^! S) H6 S9 ~2 c& E
pr_warning("Could not register som GPIO expander LEDS");
/ \- k* u# j- o7 x9 N else
* R% s! s: P, B) u/ A printk(KERN_INFO "LED register sucessful!\n");! L7 a" q1 K1 o
/ u ?& K y( u: Z6 s- u return ret;
, h. x: z# O& I& c4 k}
0 ]6 [7 z( g, W" l% q) x% W( ~+ |- P% v4 A( \
static void __exit led_platform_exit(void)! }$ \9 m) E9 u. x6 P: m1 z0 b
{6 Z& N0 }% [8 g
platform_device_unregister(&da850_evm_tl_leds_device);
- w* |+ d w+ Z$ b0 S: Z$ c2 _8 c
# p2 w/ ?3 u0 m( \+ O printk(KERN_INFO "LED unregister!\n");
: c, f! `; S: u# q! I' ^$ \}0 v: }& n* \. c
9 Z% ~; h4 h! T1 D, ~3 N) k2 [module_init(led_platform_init);4 O5 l" {; W" u; M
module_exit(led_platform_exit);& ~/ V" ^1 U3 u5 X6 q# q% L
- K* u* n, |/ K+ Z
MODULE_DESCRIPTION("Led platform driver");5 \' r! h* }' [1 h! f+ F# m
MODULE_AUTHOR("Tronlong");2 z% \* ]# o5 P: B4 l; b
MODULE_LICENSE("GPL");9 b/ V7 k' _$ Z# [* G* V
5 C/ I% n4 H4 C+ |$ u |
|