|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 u1 ~/ i( a! m% _9 @9 \5 U#include <linux/init.h>
) v3 Q/ [6 ^- z6 o. u#include <linux/module.h>
, {( f( u# O' }: N7 B#include <linux/kernel.h>0 v u, g/ |- K" a$ F4 a
#include <linux/types.h>
, ~6 p5 Q) K! I9 m, @/ q; o#include <linux/gpio.h>
7 \+ ]( K. e+ M6 l#include <linux/leds.h>- @ H. T) t. z M/ C
#include <linux/platform_device.h>) [ j; m) t0 u4 V* z2 p- B
. Q4 J8 s- _, y6 W3 q, E#include <asm/mach-types.h>
) b1 D1 H: F8 W8 l/ ?- ~#include <asm/mach/arch.h>
+ p, D% Q8 x3 X% B#include <mach/da8xx.h>
# o8 A* q, y ]9 K. B4 e#include <mach/mux.h>/ {! s/ Q6 u4 s, K# c$ B
9 K) R$ W! N& m* ], Y3 b% ^7 |#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& V6 [8 @4 c# h5 [% E. `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 C6 [5 Q: Z W1 \* }! x k$ F$ P#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) s" i- S8 L8 g#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( h% A/ h& L/ R8 n+ H* W7 o- F) w$ i4 A( j1 Y$ M7 C8 y4 g
/* assign the tl som board LED-GPIOs*/* t( C% D( ]1 y$ s
static const short da850_evm_tl_user_led_pins[] = {
- ?+ a$ c1 S+ Q: E& o! i /* These pins are definition at <mach/mux.h> file */- \9 y ?" U1 r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," p" V8 N1 ~0 A
-1! X0 j4 ^+ c# b) |
};
! R. C- Z2 U0 L4 R/ u
) O& T/ e( y% |% e. Q2 Ustatic struct gpio_led da850_evm_tl_leds[] = {
' l& u# A& s/ f6 T. u: j! s {( c4 L. T' _; p: `5 m2 [' L
.active_low = 0,9 n' E1 a* g P) _
.gpio = DA850_USER_LED0,
! q" }2 f& t+ { Q3 f: d .name = "user_led0",- I: K3 {5 H. L' B4 j1 M& m8 e
.default_trigger = "default-on",
$ N1 f R" P5 T9 Q },. R# J8 D' A/ [% t; o4 O
{
R+ ^) }: a. A1 t .active_low = 0,: D" j2 t, w- b
.gpio = DA850_USER_LED1,; _3 S0 b: g4 u. Z2 C) u5 i
.name = "user_led1",; J6 f- f$ h5 W& h' E
.default_trigger = "default-on",
6 K& h5 n9 J8 g1 d2 v },$ {& D! ^9 l4 p
{2 v2 g6 \( N" W# m$ q' C
.active_low = 0,
+ M% W; N/ m8 U9 D3 H) G% _ .gpio = DA850_USER_LED2,1 K, [% k: ?8 t5 {: e. {0 ]
.name = "user_led2",
' ^9 I9 l$ K3 R .default_trigger = "default-on",7 S8 L: Y H! f" A3 r
},! F3 m* c" f* U7 j% _
{
6 i) n( R) M" [3 V) |' O% W, T .active_low = 0,0 E, ~( O% O9 @$ `& z, @( U$ y X
.gpio = DA850_USER_LED3,
" P7 h" g7 w, Y .name = "user_led3",
6 ]8 L+ x6 Q0 C2 c" v .default_trigger = "default-on",# }% |+ t% q: u- U: \6 q
},
, m. P+ z$ N( K' {0 w};
& G- K5 M; x0 m X6 I& p
: l% }) r. E: T+ t7 v* H7 K" c$ B3 hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 `' O- A; e! A$ B; @8 Y v
.leds = da850_evm_tl_leds,% k4 x B3 z/ _( O. {
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ \8 S4 h* w) n% i! X2 h7 v};
" e. b; f4 f$ @* j+ L6 t4 L
) z( P' l: P6 @( w' estatic void led_dev_release(struct device *dev)6 L4 {( t$ O* G- Z- v( I
{6 @# P. ~$ K5 {
};
6 d8 M& M2 P- ?- ^6 ^2 k6 q* O& G
- I$ _# n4 P) V' G: Qstatic struct platform_device da850_evm_tl_leds_device = { d& d a3 K- `3 o) j* t5 M6 P
.name = "leds-gpio",: T9 R5 E# C( x- k+ k
.id = 1,7 ]3 P8 b# h' o& _- G9 n/ I
.dev = {2 l0 o4 L- c+ d: t
.platform_data = &da850_evm_tl_leds_pdata,. z# M" o+ G$ ]- [: {! d( m3 x
.release = led_dev_release,
8 d; O8 g2 N" d9 H! p9 {/ x# b }
s" O1 z. W8 A" `+ u8 O7 Q; b# u! U3 _};
) t; P7 o6 |6 K/ b
2 P2 V) H3 j' @; T* ]2 \& D( istatic int __init led_platform_init(void)
' I1 X) D# K0 O' Z! ]$ V6 {: a{$ L* ?0 l. _3 e
int ret;
3 |. D5 W% v% o& W5 _1 ]0 q#if 0& Z: C7 }: Q3 n/ H- n2 O; I/ j$ e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ C5 ` q7 u) @) x0 ?9 ~
if (ret)! h6 J& \* {8 M! K/ Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; N w) a- p2 c0 ~! ?/ m. t, i) [% f; U "%d\n", ret);
/ f( @ c, k& h1 g#endif
. T) X& H: J0 y ret = platform_device_register(&da850_evm_tl_leds_device);
) g7 r( K$ R9 t if (ret)
3 J, j; D7 ]6 t# |3 W& S- Z pr_warning("Could not register som GPIO expander LEDS");9 D5 j' `/ K, {5 D9 [
else
% [ z# B9 Y E9 i( y) ` printk(KERN_INFO "LED register sucessful!\n");' l( A5 C1 M( k! P5 x
% A4 |$ A% a g# c$ l$ z return ret;
, @4 [! l& F( T- y$ \2 c}
; `- N. G* a- ~ v0 z& g* g4 c: X a( o5 u
static void __exit led_platform_exit(void)2 S, X1 x: ]& d( I
{
0 M9 f) ^4 P J8 f( N platform_device_unregister(&da850_evm_tl_leds_device);' }7 U- F0 p, q
! c6 R; n; X& o1 }: L. e1 S9 \
printk(KERN_INFO "LED unregister!\n");
N4 I- g5 k M2 ?}9 i6 ?( P) ], T# q7 { y" Q0 V
) |5 q8 p. F% U% J/ A/ F9 Z4 W$ l0 i% Dmodule_init(led_platform_init);; m$ H9 {$ T7 Y4 Y8 h
module_exit(led_platform_exit);, P/ _+ {! I+ q4 k" O9 v9 E; G5 n
J* V7 q% @' U$ V
MODULE_DESCRIPTION("Led platform driver");
# ~# p K ^# A- |) A- QMODULE_AUTHOR("Tronlong");+ U7 p/ L6 E) `) a: z& _; X
MODULE_LICENSE("GPL");
8 h v) q3 p# K% P+ U" |0 M$ e+ I- n
|
|