|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 q1 c" X# s) L4 X9 j5 R, U
#include <linux/init.h>4 i- ]! R+ Y$ w3 a g
#include <linux/module.h># n8 \0 h. z; b5 D; p- b) p0 Y% |
#include <linux/kernel.h>
; s" a3 i, r1 W4 j; h#include <linux/types.h>
" D0 I: D B: x#include <linux/gpio.h>2 z2 J5 Z) A* P4 @; g
#include <linux/leds.h>1 g# J2 V6 P: r2 {
#include <linux/platform_device.h>' m+ b7 U9 ]0 a5 l) U9 U* V( d
1 c- E' B+ x [: `4 n: t; f4 l# R& z# H
#include <asm/mach-types.h>
t( Q5 o! U1 P, {8 e4 |2 ^# n#include <asm/mach/arch.h>
, U7 v$ a1 }. ]#include <mach/da8xx.h>" x3 u% q$ N9 u! j
#include <mach/mux.h>
: f$ h6 g# u& I+ {; C
1 x4 E* d% S0 W2 C#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* R0 p" _. @* ]4 M
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. e" g% \' d* M" q$ y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). O" X, j% z% M- s% T- j/ q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# S0 o, o9 l$ O% W o
3 c& y9 a9 }5 O/ l! p
/* assign the tl som board LED-GPIOs*/6 I+ O5 M+ ^5 A7 q
static const short da850_evm_tl_user_led_pins[] = {* \8 R. [) r! V- \
/* These pins are definition at <mach/mux.h> file */
8 \* y4 b4 H* d' q& D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ ?$ i1 [# e1 W8 {
-1
U6 Z9 R4 G; F! z G};
; G/ t8 p) @ F; `% o# E! H, W0 W3 U( I( |7 g# Y
static struct gpio_led da850_evm_tl_leds[] = {. J& F* `; E! s% n
{
$ `% \/ U3 l4 d .active_low = 0,( [/ H# y6 H3 }. M2 B7 ^. Y( i" S
.gpio = DA850_USER_LED0,. C' x- z3 H `! @( V, E
.name = "user_led0",. o, D- a$ b8 u# a0 w# b5 C* [9 [
.default_trigger = "default-on",5 ?2 h6 X+ E# }, y( T& E$ I
},
/ M! _- Q% U9 k5 d) ~3 Q0 L6 Q7 W) r {/ @( ?# b4 N! B8 q. S/ c# U. v. L7 F/ ]* G
.active_low = 0,. m I+ ^6 L6 a, I& |. m
.gpio = DA850_USER_LED1,
' b# i1 {! m8 j5 y6 _( p .name = "user_led1",! D4 ~3 k0 O% r# A% L
.default_trigger = "default-on",
0 E. M2 c' s1 p6 w) d },
" L- T+ j2 D. [; G2 b( X* w+ u1 S {& Q/ C% L D9 j2 T
.active_low = 0,9 n0 D! o* ?! c& e% ]
.gpio = DA850_USER_LED2,
' V" v$ k% N: b. e .name = "user_led2", E, e) h6 K* Y
.default_trigger = "default-on",4 G, e2 u O; _. ]; E! _* e
},5 X6 u6 c( a) t, X3 K0 g" @
{) \. I6 z; ~3 E/ t" C
.active_low = 0,: @" c$ U! _$ O/ `' {& _
.gpio = DA850_USER_LED3,2 ] l5 Z2 @; X3 g+ J8 b
.name = "user_led3",
2 @" V0 Q5 P9 N5 [4 @2 \ T2 F+ _ .default_trigger = "default-on",
: W# \/ ~$ i1 C$ c, D5 } }, B7 Z8 ]4 B" g5 ], x$ y4 ?
};4 ^6 f$ U. S; |6 ?
* I: @2 x: G( z% g/ \* u+ Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% \. Z; w- Y/ u- R2 @$ [- b
.leds = da850_evm_tl_leds,
: X7 N* o% s `9 k# Y2 n {( \2 q. R, C .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: d. P5 L+ _$ ^, M7 i9 [( x
};' G! h! K7 E% ^- n) W
1 e4 A# s8 J0 k Y( i+ j& Xstatic void led_dev_release(struct device *dev)6 u G$ U- J+ e% A& Q
{
& y" I) l* N& J% J};' Y+ O) z- B$ C3 q% W# j
3 n/ ^" ]6 L# t+ \$ J4 \3 A
static struct platform_device da850_evm_tl_leds_device = {4 z; U5 V$ _* D) _* F- D3 ~& O3 R
.name = "leds-gpio",5 @0 Y2 v- F# S+ u. s; ^, S
.id = 1,
0 p, U8 I! S2 n6 c: W9 y .dev = {
, a3 O, ~) ]% \ .platform_data = &da850_evm_tl_leds_pdata,- J4 e" J* K' Y: z, G* m& _6 L
.release = led_dev_release,
/ s5 t, W5 H' v1 s! {; l' p }9 o# [* e, b% O. [5 ]( F) o
};. Q. Y+ v" l- f; y4 F
8 |- J" [" t# ?, @3 f1 h0 nstatic int __init led_platform_init(void)3 T j$ g Z, x) B! M: }
{7 O: h! A: K% b0 b9 }
int ret;
9 e% J! w8 S4 R4 f7 i8 W* L#if 0
6 t4 S6 c J8 l% _2 n6 b8 X R ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' V& |7 J+ D) S |% B0 Y if (ret)$ X2 ^* v9 v% d6 V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* }7 s" t# Q1 V1 {
"%d\n", ret);
3 P1 o4 |4 f$ O5 C) O#endif
" S4 E$ x3 X8 w0 y5 j y) r+ I ret = platform_device_register(&da850_evm_tl_leds_device);6 q2 S' G- m8 z' _! M. q
if (ret)
8 B+ ^% h+ R# A7 G$ a2 l: ^3 K pr_warning("Could not register som GPIO expander LEDS");
) }; F% D, N! n/ q( t% A% C else
5 w" n: j3 P, z4 R3 V printk(KERN_INFO "LED register sucessful!\n");* ?8 B" k( A! C$ q) |0 j' g
J* ~1 L2 B! d) j" c
return ret;
# [$ I' d8 D/ Q0 u3 q4 h}+ u& `+ n* M% K
9 _* _! e" z5 E4 W) k% H2 xstatic void __exit led_platform_exit(void)
* P' R2 n$ N. z: t( k5 @{
% m, Z% Z2 {& Z3 Z+ r platform_device_unregister(&da850_evm_tl_leds_device);1 E" u' f; c+ L j
" w9 B* q' |; O9 T/ d/ D
printk(KERN_INFO "LED unregister!\n");
B; r# N8 }% }# c6 K! V}
% l# {" p# i# i$ {, I( O* m0 z7 g# H
module_init(led_platform_init);
' _& q# G5 z! U4 R; N Umodule_exit(led_platform_exit);
8 Y) l% W8 d' H
# X; p7 @& x2 R1 k: \: y* M" tMODULE_DESCRIPTION("Led platform driver");
% U* E, ?7 p2 |; Q, m% [MODULE_AUTHOR("Tronlong");
4 r1 {6 y/ l. e7 J2 I- wMODULE_LICENSE("GPL");
, f7 s/ A' d8 C8 Z1 M I" S( E+ |2 F8 k- r5 [$ F8 H
|
|