|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' ~; o; m5 `9 `#include <linux/init.h>
1 |9 c* J+ J) [' `; C( @) b#include <linux/module.h>. J" ?/ F- Y9 R" W/ U
#include <linux/kernel.h>/ [' b# x7 J2 P8 \2 a/ ]) j8 V
#include <linux/types.h>
" @9 Y" h4 N- E1 l#include <linux/gpio.h>
+ X& b6 S( R t#include <linux/leds.h>0 }9 D m% V* j, D, R7 Y# M1 i& S
#include <linux/platform_device.h>
2 j% {4 p0 h& j0 _& w
0 _$ Q/ z3 u; j, C! A, h# f# s#include <asm/mach-types.h>. e, b% s: I5 B- s: y
#include <asm/mach/arch.h>
: S/ \5 E5 e, P+ v& X$ _, |& f#include <mach/da8xx.h>
7 }0 H; K+ U3 p3 S: z9 y#include <mach/mux.h>8 f2 G) j3 Q( r8 u- h! ]/ P! ~+ \* ]
5 M1 M, {* L9 ]- ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 [' E( C! c, ^2 c- t1 J, h#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 E+ q# j) T( u9 t* N#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): R! K0 E2 N1 M3 |6 b
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" H; ?1 X' _3 u& g, B6 `& o
& @: C# Y4 H: X" M+ B* |/* assign the tl som board LED-GPIOs*/+ O9 T2 U, C9 b' k& d4 n9 f
static const short da850_evm_tl_user_led_pins[] = {
. l9 u9 C7 T5 M( @5 R$ V /* These pins are definition at <mach/mux.h> file */) d) N' c9 U1 v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 m, R6 h) E. K p1 z& l, d
-1" P6 {/ `% H3 g, A6 w k. Q- {% L
};
9 Z# d' v$ J' u! Y9 y6 }
4 h, z+ V7 W0 K" |static struct gpio_led da850_evm_tl_leds[] = {
8 r. I* B" A/ j6 _; m- o( u {% i$ G! I+ E2 S& A G6 a' t
.active_low = 0,; K) ?) W1 L4 Z: [7 @6 T* ~
.gpio = DA850_USER_LED0,; R( F* t( d+ c2 @; d0 }
.name = "user_led0",
! b) I5 k$ r. w- U7 O% v4 E: V .default_trigger = "default-on",+ p- d" v- f, m( z2 ?" u8 R
},+ q" P2 T* Z" u! H4 p' A2 z
{
% Q% S* W8 n8 V9 _4 x .active_low = 0,, \2 @& C+ Y/ Q2 k( T/ J
.gpio = DA850_USER_LED1,
# e S) M( a1 H a! J .name = "user_led1",
Q- ?9 C% D! C' ~% q" L7 Z .default_trigger = "default-on",
0 A' E( x! @6 j, M V6 W8 [$ K6 K },
. F8 Z) E7 A: C0 s {
C; b& T" |. j, W' ^ .active_low = 0,1 s, ~. T! h3 J8 C' ]. h
.gpio = DA850_USER_LED2,( F& B _; s, z# |% Q8 }4 B
.name = "user_led2",7 y" o- o, B: @
.default_trigger = "default-on",
4 B, k) ^8 B+ b h T! n- q# P },- _5 }# N( g ]! U5 g& {' b1 E
{) K1 b3 ?, B7 h( n U4 Q
.active_low = 0,4 m/ r) W7 F; `! o g4 d& n
.gpio = DA850_USER_LED3,3 }9 S1 N4 n- Z+ t9 F9 q
.name = "user_led3",1 G6 s: `$ F, J9 A* k+ I
.default_trigger = "default-on",/ H2 f4 [1 ~/ @- p2 j6 Z+ l3 q
},. F) K( u0 K1 b) ^9 S5 o3 Z0 m
};
0 k0 i1 E1 X" B; ]+ v& ^* S& `
- r) g/ r2 }6 n! H3 R/ Z( X/ C; _- ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# g( A2 ~8 }1 R" d6 n1 Q: K/ H! H0 H .leds = da850_evm_tl_leds,
_) `! y* q3 d: R' ? .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, r" u' j& t4 H j* P/ v2 O& F};
- Q @) d0 j" C+ n" h" `
& C4 Z' B2 Z$ F7 ~5 @! ?% Dstatic void led_dev_release(struct device *dev)+ j3 y& K$ T1 ?" K
{
" f8 w; `* x) H3 o+ R: x: X};9 f6 }/ ^+ A$ t; U7 x
6 I ^$ t9 j0 T) _static struct platform_device da850_evm_tl_leds_device = {
0 v1 [! B/ v4 a3 z1 i( o0 j .name = "leds-gpio",
2 ~; l& S. F! b6 O- I; B0 i6 q E .id = 1,+ s: B0 {9 P8 t: p: R, [/ x- g/ R
.dev = {
3 |3 U2 i/ x/ X0 W* v3 r9 c .platform_data = &da850_evm_tl_leds_pdata,
( e( Q# T$ ^3 W2 q1 y7 }6 e/ P+ s .release = led_dev_release,
: |6 L/ n& }# q }
3 X- g x4 l9 U5 Z1 ~. J, o};" X d6 y$ K8 i4 r: ?( h
: Q3 [. @# D' Z1 s5 b6 Vstatic int __init led_platform_init(void)
8 l# i1 T1 p0 j; ?5 O6 R; D0 A! t{
: C& l$ b' N9 D) g7 h int ret;
- c9 V; U# G3 `9 o. y' y#if 0
+ I% p$ H& V+ h+ R" Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( s3 C1 ~1 K8 {. j5 A
if (ret)
+ d/ {$ V) w* D1 N pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; B% M& {1 ~6 ?& D" o* B "%d\n", ret);
3 D1 A/ _2 X$ T5 |( u' e/ p#endif
9 W7 x. e* p. \1 W8 H) Z. H7 G ret = platform_device_register(&da850_evm_tl_leds_device);
7 t; d! H% p. z8 h) V: |+ w" a if (ret)0 a: p9 r+ H! \2 E6 _1 W4 c. f
pr_warning("Could not register som GPIO expander LEDS");9 A$ S+ F6 g3 _; B7 B0 k# {$ Y
else
* x. u0 n+ ]- Z0 p y printk(KERN_INFO "LED register sucessful!\n");
. H4 E- D2 w7 \1 A& g+ c) V1 f7 }/ \9 W# G0 G: j, K) @' ^; n
return ret;# Z; L6 b% K% R7 X5 e$ X4 a9 h
}
6 R, A+ Q# \5 f" o$ g% G- c5 W3 p3 Y2 {
static void __exit led_platform_exit(void)4 t. U- N' O4 X( w' a$ g
{
# ~% p/ p# F+ {1 n2 G8 O" L2 [ platform_device_unregister(&da850_evm_tl_leds_device);
& i2 ]' J9 C" s, U# N B
6 J, T) X6 Z8 U e3 Z1 o printk(KERN_INFO "LED unregister!\n");
, K, P) o$ ^. V* |/ d S}
* k; W: ?5 Z9 y5 H! f. |' j& d) J
module_init(led_platform_init);% v4 T0 [+ \. O. u; b* A, x
module_exit(led_platform_exit);7 U: |" O% `, U
5 z. p, g4 b* C
MODULE_DESCRIPTION("Led platform driver");
8 _1 }* F: E1 S, r" |" vMODULE_AUTHOR("Tronlong");6 S0 n( ~2 K+ T- Y) `; T
MODULE_LICENSE("GPL"); T: C/ ~- i8 t& L G) L6 I# G
% H1 ?# C' i# M7 \+ h
|
|