|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 E' { Z* }$ ]$ m, a#include <linux/init.h>( p# w$ P' T0 Y* |
#include <linux/module.h>
) }8 M( \$ c$ j3 K- r6 j7 T) E( ^#include <linux/kernel.h># g7 w) q* b' U8 K6 p
#include <linux/types.h># z, C. K( i$ S' E& g* f1 D j. W
#include <linux/gpio.h>4 z+ F3 a3 `0 _# o# }# x' L7 r
#include <linux/leds.h>
- ]1 T! a+ d9 {# ~3 s#include <linux/platform_device.h>
9 t7 f W! ], _: Q2 H' k1 e* ~
( L4 p' q, o/ C( M$ J#include <asm/mach-types.h>
0 Y. {' U9 T8 L3 l" i1 l% b6 q e+ d#include <asm/mach/arch.h>
4 `' C0 x) |6 M4 G- h- P- `#include <mach/da8xx.h>9 E8 i4 q: v; b: ?5 |
#include <mach/mux.h>
- m2 g9 A X, p! |& l D- y% b/ Y1 y8 V2 S' s/ ^
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
N6 Q% m( _! v6 S% z# ]#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! |0 ]& ^" Y7 p* Z+ P
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. N6 i$ H0 r+ q& J#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 x! V, F0 |1 u6 S# V- G7 a* u% i6 d( F! J$ y" C- k' U7 y/ I z
/* assign the tl som board LED-GPIOs*/0 C) L" p8 k4 v
static const short da850_evm_tl_user_led_pins[] = {, `: J$ J/ w1 R4 d7 G
/* These pins are definition at <mach/mux.h> file */
" v9 g- p+ o2 l( D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," |3 F2 r$ V3 A* q: K- |2 \
-1
$ j. Z" x5 r A4 w& C# j};
+ g: \: _% w T3 L" _, n* }! g/ [$ t$ c! [# `6 g
static struct gpio_led da850_evm_tl_leds[] = {
0 X8 a- p; ^3 x7 i* Y/ z& w {/ W% Y& O2 q- j, _
.active_low = 0,. y: p& p. b0 h5 u7 y& `8 I9 N
.gpio = DA850_USER_LED0,
6 U' v7 C4 |1 Q, ?$ H .name = "user_led0",
/ [/ G4 e2 D H .default_trigger = "default-on",. }; x3 d3 s5 b6 P7 q" V( c
},
7 ~" n4 p) F6 u0 J0 L {# N" E! E; i* v- O
.active_low = 0,
4 L/ D) m( L' k9 _* P* U+ D* u .gpio = DA850_USER_LED1,
' v; }5 f/ N# `; T7 U1 H( b .name = "user_led1",
0 h8 n! O) ~2 R/ u f1 [ .default_trigger = "default-on",; H! V" ~6 g4 o. q: ~
},' I/ E9 h" l6 e) }
{
4 ?( _7 e! o R .active_low = 0,, G: g- i+ A5 ]
.gpio = DA850_USER_LED2,
; W9 u# O0 u/ M4 S6 H+ S .name = "user_led2",
( {5 t6 x7 b& f/ Q+ e; o .default_trigger = "default-on",$ j/ w# `! z9 ]) e, Z- ^
},' j! O; \4 ~$ x0 Z) I- K) P( ~
{- Z! K- M0 a9 B \. i, e! w% k
.active_low = 0,
_2 z0 L1 Q# ?+ G( q* y$ H .gpio = DA850_USER_LED3,
; m6 V0 E. }: Y .name = "user_led3",4 _$ c1 k9 c0 P* A2 ]
.default_trigger = "default-on",! u4 i- N/ b L; A* U; y
},
4 t. g2 |) T4 V4 q" A) z# A" o6 M};* O/ D/ o% N( ]- h! ?; E$ p& B
. `6 S! M+ s0 e* Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. g( m( t+ y5 b, e* ~& `/ b8 J. f C& X
.leds = da850_evm_tl_leds,
% {" }) J! s, Q8 ^9 ~5 ? L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! H7 {9 O6 D4 l0 L8 p% O' G" j
};
9 a9 ~& K( {7 H& r
1 R- j% f* |% M# v1 lstatic void led_dev_release(struct device *dev)
* p' f% q& }3 \{4 x; T/ L8 W( Y: ?5 x3 @
}; w( m' M& G0 p4 W3 M, X( ~' c
) N+ c" z6 ]1 }7 U. Zstatic struct platform_device da850_evm_tl_leds_device = {
) d \+ c; D6 N6 I2 v .name = "leds-gpio",5 P) ^. c- @% _5 m
.id = 1,
# A7 P- r5 c2 v z) x/ |2 p .dev = {
1 F$ j' Y/ T; b- ~ .platform_data = &da850_evm_tl_leds_pdata,
) d+ p! }& |8 n& M+ T# ] .release = led_dev_release,
& \7 s4 q" U( f( R) x/ D0 F: u& s }& d; \: r4 s7 k4 c( J7 C- f
};
) r1 G+ V4 V3 Z! u6 n$ F( \) n; J" _9 \# P$ n* |
static int __init led_platform_init(void). R+ p9 u7 D+ h/ b$ z2 b1 s7 k9 x
{
, u4 g* s& L2 L/ H; Q int ret;" R+ f- x9 M: ]. _$ E- q3 t4 a
#if 0# c' p0 ^0 k1 Y9 z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ N* U5 U! L0 r* {2 A1 v. X9 f if (ret)! y% N! J; u, d$ x: A! ~" l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 \8 @5 a" g3 I/ a2 J" ]$ b4 J# T "%d\n", ret);
$ } T7 S: r% m, b$ a8 R#endif8 d8 \$ P% p6 d3 K; U2 n$ P) n
ret = platform_device_register(&da850_evm_tl_leds_device);+ c5 E% Q) b2 z( Z
if (ret)3 m7 m8 i; H6 X3 D2 c6 U3 n3 m
pr_warning("Could not register som GPIO expander LEDS");7 C; L4 Z4 V4 H* M6 W$ t
else
; S/ D( e& O) a0 u printk(KERN_INFO "LED register sucessful!\n");& R6 a4 w4 h( a0 g! W r
# Q- y8 J9 Y F% B1 w3 t2 i
return ret;
7 [! m$ H& ^# x% i _}
2 ?! z) _2 O1 A( P% ^4 j* e) b, ?9 b2 q! Y: p) c, p: U n7 e/ r
static void __exit led_platform_exit(void)1 p8 v0 I# B2 V) `% f* L! m7 v
{
# ~& {8 H- l$ D& z( V. ^+ s platform_device_unregister(&da850_evm_tl_leds_device);
. p$ k1 V* ?. B9 O l5 m! c* L5 N! s! j
printk(KERN_INFO "LED unregister!\n");
5 A' U8 R2 z$ i, \2 y}
. J, Z7 T* M$ m+ I' O' Y1 Z+ D6 L' B3 D2 l7 ^# B' P6 e$ Q4 T
module_init(led_platform_init);
! o+ v. X8 |% Rmodule_exit(led_platform_exit);8 H5 e1 F4 ^5 o: P
% Y& k k) w- e, a7 }MODULE_DESCRIPTION("Led platform driver");
2 l8 | Q6 G, S) _# `MODULE_AUTHOR("Tronlong");
! S1 D0 \6 S6 @, P' J- \/ VMODULE_LICENSE("GPL");" c3 a/ S+ k; _, ~' ^9 w( ^
* g# s" {2 [& P
|
|