|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* i4 D7 w* z# ^2 k#include <linux/init.h>( `& B6 d& a. }1 Q. X# g0 y" w/ y
#include <linux/module.h>; u6 q2 @# [3 E. S7 K( ~+ S
#include <linux/kernel.h>2 f$ v8 H6 b5 J. j/ D) a
#include <linux/types.h>
9 G9 X0 L. R8 W9 ]#include <linux/gpio.h>
" f6 F$ I: j6 n% c H#include <linux/leds.h>+ Z& h8 u7 I6 N/ u q/ j4 G
#include <linux/platform_device.h>
9 C. Z2 X' o# I8 z% _2 C( F% [$ ~; K1 n. i6 F5 \( Y+ @! o* h$ p
#include <asm/mach-types.h>
1 K; h, f% B' |#include <asm/mach/arch.h>
6 P" X! S3 h& T#include <mach/da8xx.h>
& N- g, r! I3 R/ L9 {; n* [: @2 d#include <mach/mux.h>% d. P0 b' p5 }0 h! N: Q
" }5 _# n: h- D6 R) j1 _& `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. d6 M4 g9 d# L8 G; `9 e* x ]% c#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& U4 L- d# g+ c( h; C5 D4 x6 l4 S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' W3 ], m! C+ f9 p#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 }7 O/ W H/ r$ g
. h# i8 @; R; q# k, q( I* V0 \& f/* assign the tl som board LED-GPIOs*/
" t$ c- s. |. Y( q0 _4 i3 ?6 }6 f5 Tstatic const short da850_evm_tl_user_led_pins[] = {+ l0 i6 U! T2 m1 P
/* These pins are definition at <mach/mux.h> file */) X1 [" o) o5 K- K6 S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 O" B: ^+ p' e: _% ~/ v9 @+ b" i) c) d -1
& s+ J$ V+ Q( Z8 Z# A- O};
) j2 p( P, O% { D7 n* i. G0 b8 n r x
static struct gpio_led da850_evm_tl_leds[] = {% L. A8 w3 t+ f; U' D9 B1 _
{
% t9 {% Y1 k a" ]- O .active_low = 0,7 j3 N1 ?, W! ]1 G" U- N% ~
.gpio = DA850_USER_LED0,
\4 B% g" E3 Y( }4 N5 u .name = "user_led0",* S8 f+ x* l3 k8 N, H4 r
.default_trigger = "default-on",
' o' p2 I# U' c* B; f9 U },
% B, M0 M' m' u6 \' x: Z) W! u* Z {, m3 k, C8 G' [ J9 ~( R% m. W
.active_low = 0,; ~+ o. {0 B3 [; {2 f
.gpio = DA850_USER_LED1,% R& x, i+ P% m1 @
.name = "user_led1",
9 f# I$ M s. E) _# [ .default_trigger = "default-on"," J, ~& H: W( H2 k) o
},5 ?/ X9 K9 `& d }3 v
{2 p K4 N% P. t- _/ |
.active_low = 0,
: Q3 q$ H# J3 V# a/ i: e8 c4 X0 ?5 [ .gpio = DA850_USER_LED2,
. _& h# z+ t* `3 n# _; @- j2 j3 s0 C .name = "user_led2",
. T0 r8 j o" P: y6 ^ .default_trigger = "default-on",
3 }' E/ K3 @5 F4 S/ U: ~. G( t* Y },+ | ^. q! ?5 ~, F' {
{
# u3 u3 O, H+ e x+ W5 S .active_low = 0,' B$ K; X- ~0 {) x+ r# V$ z! E
.gpio = DA850_USER_LED3,
& T. M: [$ n$ `$ {4 e4 ~9 N+ X .name = "user_led3",
1 ] Y* x; L, I) S. s .default_trigger = "default-on",) V7 @* ]/ l+ H! }3 L. w
},
. j& S& Q! w3 S! t$ j7 V7 I) Q2 B};4 M- N: y E& B% E' u
- Z# V7 y/ x( A# _# sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ h; N* {% ?% F- \" Z3 H. Y3 H! C
.leds = da850_evm_tl_leds,6 s1 W) o7 I9 ?& x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 x E# C3 E. \, E# `
};; N* T. s# o7 p# x# R X% e, m
7 ~% L5 ]9 }& j) ~' D8 I' H* h
static void led_dev_release(struct device *dev). [3 ?$ h( V; {
{, A1 ~, A9 t8 {2 W, R' b( M
};
: z1 A' S; z6 s) N8 U- L6 j
% H* Q( r: g, S: R* ^" O( Qstatic struct platform_device da850_evm_tl_leds_device = {# n" t$ W+ H, i! C5 i- N
.name = "leds-gpio",/ Z( ?6 a' ]0 g/ F. W8 L( p" E9 J
.id = 1,
4 V" r, T6 X8 T# ] .dev = {
& ^. t, B$ C2 t/ A B e .platform_data = &da850_evm_tl_leds_pdata,
5 b8 }9 ^# F6 L/ ^# X0 u .release = led_dev_release,
8 S( f5 f; D8 C9 m }
# `" C1 f: w" X1 X, d- u: S. t( _; h' J};8 D- ]: C9 b! N+ W( M& j2 s9 q7 g
- p9 s1 I* Y8 r* j/ m& o+ u8 g
static int __init led_platform_init(void)
! r+ ?0 M9 a: i" H9 j{
7 P* L- s$ k9 {, u1 D4 K! h int ret;% t5 h+ Y1 \: _) \( `9 W* ]- L
#if 0+ ~& S5 u& y6 E: O- e/ v
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ X6 j& E. X- i b( Z5 d if (ret)
d0 F$ |, {% z0 Y% ^' J$ M pr_warning("da850_evm_tl_leds_init : User LED mux failed :": H5 |, X; E# p; p2 |3 b) P
"%d\n", ret);5 [' j% Y- @) K$ o0 e, S
#endif
' D( ~" J6 D8 ?. A4 ? ret = platform_device_register(&da850_evm_tl_leds_device);
& R2 V- m6 b3 s- j if (ret)
4 q2 Y- |- i9 h( `% M& N: o pr_warning("Could not register som GPIO expander LEDS");' h/ c: O6 c; Z1 e2 ?
else z3 z3 ] J6 d* {8 j4 ^- m0 T" A
printk(KERN_INFO "LED register sucessful!\n");$ Z9 E3 P/ J; j* ]9 F8 Y4 i* J$ c
1 x% q' b4 i- V1 j, x
return ret;
; A% G0 x" Z- [. c}) s- @8 |! R }" N
4 v: \' ?9 W( _: m; [static void __exit led_platform_exit(void)
. b$ k! J3 H/ D9 ]{
' \9 r! E$ o3 [8 ~ platform_device_unregister(&da850_evm_tl_leds_device);- h/ t/ f i+ O( p( ]4 x
* V) t6 X. u6 V( w) K# v, o- ?" v printk(KERN_INFO "LED unregister!\n");$ i/ E! R% T( w2 x2 [0 d$ E g
}6 B$ r) e$ _, |/ i
- f2 ~' U5 i6 d* ] ]$ Y6 C! R
module_init(led_platform_init);
- p. a6 B4 O: J4 j5 y* Pmodule_exit(led_platform_exit);4 l& s- V" ~; _
+ P' u7 V5 S! R7 H
MODULE_DESCRIPTION("Led platform driver");8 C* o9 V4 f9 U4 v. h) U
MODULE_AUTHOR("Tronlong");- i9 @' D1 A- \# @7 H+ h
MODULE_LICENSE("GPL");
/ w% r; ]" ?. {" p$ T' }' J+ m+ g: d- R- X9 e! e1 d$ k2 p4 N
|
|