|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* C0 H `7 b! @* S- N#include <linux/init.h>! t% C+ w# }- T
#include <linux/module.h>
3 m U0 b9 D+ ]% P+ j9 x5 w2 s#include <linux/kernel.h>
$ H" O1 B3 p7 ?3 I& z#include <linux/types.h>
G7 ^8 y9 k5 N1 f8 C- c% S#include <linux/gpio.h>
, q9 S- b' D% c#include <linux/leds.h>
6 E# ~1 a* K$ c% C& F/ w" j#include <linux/platform_device.h>* \& `; n6 U- k. Q$ c& C
+ E( y9 z* O$ _5 A% b1 Z' o#include <asm/mach-types.h>" Z. }! n, X$ q# O
#include <asm/mach/arch.h>
: P* _5 J1 B: E6 s0 K# J: X! F#include <mach/da8xx.h>
. @! y2 J1 c& ]3 }2 _: F#include <mach/mux.h>
" b5 ~+ P& c' d+ E }( {3 b3 `( p" i+ I5 G, @" W" O
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' f' @6 T+ T3 t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ b' `, I4 _- E' L9 B, j2 ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). @* I/ Q) p; F0 \2 ^
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ h" Y( J# q' A5 L0 Z, }% r }0 g( V1 ?- k p4 {* b% ~4 f8 r
/* assign the tl som board LED-GPIOs*/
# L# o$ m- Z; M5 a2 H+ ]; E( bstatic const short da850_evm_tl_user_led_pins[] = {5 O5 d1 Z! ^( X" q
/* These pins are definition at <mach/mux.h> file */0 n1 O* ?* v0 J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& E* Y% q! @ Z9 f+ m/ B' b W; |* e9 Y, T -1
$ r' P2 F/ p0 e) v. a5 `};9 c! h! Q+ I9 Q8 i1 l9 s4 r
1 s! b( M) {. p- M
static struct gpio_led da850_evm_tl_leds[] = {
( {! q) K, V# j/ n8 t9 p* l {: [, X! J4 h2 U
.active_low = 0,
, B$ u7 X; R" B( G% h .gpio = DA850_USER_LED0,
# e# U) p+ l/ j .name = "user_led0",. {7 X5 ]- R: l
.default_trigger = "default-on",
- _; a+ y0 Z, T+ H4 \ },
+ p4 Q1 G3 |. o; h4 q9 J6 ?+ H1 q {
7 V9 ^# [* O3 }8 P/ m+ \8 F9 O .active_low = 0,5 a3 z8 w1 f% P# n! Q
.gpio = DA850_USER_LED1,
0 F% B5 j( s" _! h" ^. @ .name = "user_led1",* t) M( ?- F% q/ d; C& e
.default_trigger = "default-on",$ j2 g5 Y: T& a! L$ \. Z
},+ ^1 ?5 k; Q% A* z5 S
{1 {* r1 ]4 t. |& V
.active_low = 0,5 T" C' e; P* y6 d% o
.gpio = DA850_USER_LED2,3 n1 C3 d3 w# V7 C, I( H
.name = "user_led2",2 }" v, c/ }3 J% U2 i
.default_trigger = "default-on",/ R% m. A, n7 k
},
9 a- L$ o5 Z+ L1 Q- O {2 S3 j$ _) v+ Q
.active_low = 0,
! y, C. u2 N0 p( r# m( N p3 W .gpio = DA850_USER_LED3,: t& D1 l: h. t$ i$ Q7 m4 G
.name = "user_led3",' P$ C* Z8 r7 o C: Q# F. c, {
.default_trigger = "default-on",, d2 \8 T, R7 I5 ?( u) A# }
},3 t- Q* }& F) q* l, ]
};
: q: F# \: D& P7 o( {* l2 r& V7 a$ b
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) z% A& L0 c, f. `: E; C .leds = da850_evm_tl_leds,: n! k% f$ c( F3 g7 J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 X! p+ N0 u5 r/ ~: G$ H. H
};
6 n( Y2 S; p6 K! z7 y. ~6 W
4 E9 F& q/ N/ D( r/ _; i- Ostatic void led_dev_release(struct device *dev)
* i' |) o6 y9 q# s4 n{
" ~2 n' l) l/ l' e! u}; K7 G( b) i+ O2 o4 `3 `3 T
1 v R. r* ]( l# i3 A8 @5 a; ^static struct platform_device da850_evm_tl_leds_device = {+ S! T* u( k$ ~5 w3 D b
.name = "leds-gpio",
. H5 x% `$ w$ J+ i# B- o3 j .id = 1,
7 r2 t5 I! R. G2 i .dev = {' [$ V# n2 \6 O+ i9 V! Q/ f2 d: p3 m* Q
.platform_data = &da850_evm_tl_leds_pdata,# p: w" x' X: i
.release = led_dev_release,$ ]: a, G5 i4 H
}
- `( d4 y9 ~4 t};
/ x( i7 {0 t6 z5 w1 a: r' w) V
; y$ L4 Q3 T( d' Y1 ]. e$ dstatic int __init led_platform_init(void)) X. [2 S8 S9 x' W$ _
{. ?% G4 u9 z" M% T$ q8 d4 V
int ret;
( b4 C$ Z; x3 `#if 0
% I- P; v" `6 i; V3 u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: v; {8 J8 R) L5 B# _
if (ret)
3 Y: @2 u8 {9 U1 N pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 W; U' \- H d* m( c
"%d\n", ret);
' c4 V) `2 Y3 X# G" |* P; d#endif
6 s S; C# F/ p R ret = platform_device_register(&da850_evm_tl_leds_device);
9 P* l& h9 @2 ] if (ret)
3 r, T% Q2 [- ? pr_warning("Could not register som GPIO expander LEDS");
1 l; a+ B; B3 W8 K7 m2 ^( e else
$ e* `# _% v. t% l( r printk(KERN_INFO "LED register sucessful!\n");+ N! S+ r( } s$ C
. n7 x. C8 H; @3 [
return ret;
: m8 W9 b! C2 _4 C4 k}
6 J4 R4 Z6 ]0 N3 O5 n9 L8 b
/ L& Y+ S: o: X0 e! Mstatic void __exit led_platform_exit(void)
8 |0 A8 N( L3 x7 u4 z% O{% @5 n# L& k, }" w, D9 \
platform_device_unregister(&da850_evm_tl_leds_device);
; [! \ o1 M; a
}5 m, y$ C6 D4 p printk(KERN_INFO "LED unregister!\n");* }- W. A" K0 S5 J- J1 I3 X
}
9 p7 t2 c2 E, s8 n" ~- [
# `! q. s, a3 [ ~module_init(led_platform_init);
u3 U& v+ U% O) x) z ]' Amodule_exit(led_platform_exit);& b! G) l0 a! m' h
4 L0 }: ?: `* T7 k8 x
MODULE_DESCRIPTION("Led platform driver");6 [1 Y" b# c( H
MODULE_AUTHOR("Tronlong");
. M4 ~5 g" @1 c Q$ KMODULE_LICENSE("GPL");$ M" [0 ^5 Q2 f0 L5 }- x7 N% _
4 P' l6 k' |5 c& V0 b$ q |
|