|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- g o/ G$ Y$ O4 U4 y3 p5 \#include <linux/init.h>
* s& ]! f) O" d' O# `#include <linux/module.h>
% K. s; X4 f& |7 ?& F8 \; `& S#include <linux/kernel.h>
" l# S3 m2 b& ]" c# V' ^* D; }#include <linux/types.h>* \$ X# V! z& Z
#include <linux/gpio.h>
2 r7 L* q% @( R- r0 h#include <linux/leds.h>: @& K& Q' J( ]7 ?' y7 D% B& C
#include <linux/platform_device.h>. K4 N9 l3 F$ w& o) V' O9 K
: E0 C8 e$ n9 K' M#include <asm/mach-types.h>8 ?9 w5 h% R* L1 C# o% `/ {
#include <asm/mach/arch.h>
1 x' o; C- A5 C, c" U#include <mach/da8xx.h>8 _0 g* F$ [& ~+ ]
#include <mach/mux.h>2 Q6 l2 K; J$ W% X! u$ r; c
, h) ]9 t8 b9 f" h7 l' v! p' o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 @5 k. J; V8 G$ R8 H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): T+ q' t4 S: x* S; N p3 N
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
`0 g8 O: S) m/ G5 ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 ?: V2 c/ H" E, q; f1 m7 W3 I3 ~; w
/* assign the tl som board LED-GPIOs*/
& o! a$ ?8 C$ m" B. y% H0 [( bstatic const short da850_evm_tl_user_led_pins[] = {
% n# P5 W6 k) v: |9 m9 t2 d [5 V /* These pins are definition at <mach/mux.h> file */1 m/ i( q( c5 R" l+ `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' V& k! @& K! T
-1) R' _* {2 {, R3 g/ q. q. [
};7 o* [6 V& C; ?1 m1 k9 l
. A9 B4 \. [+ nstatic struct gpio_led da850_evm_tl_leds[] = {- ]6 I. y, {. h2 y" v& h. [
{
6 u5 H* ^1 d; `/ F# j .active_low = 0,
2 L+ W5 a3 A, I' g' U. J .gpio = DA850_USER_LED0,
2 a; }" O, s: a4 ?% r0 ] .name = "user_led0",- h7 W. g, m# e3 C6 X
.default_trigger = "default-on"," A9 I/ |; J) j% { T* c
},
" ]9 }7 z" P) o) t. c" p3 \ {
. J* }1 `' Q6 y' Y; j: ~ .active_low = 0,
- V# S; O4 g1 T$ Z* Q+ i: V5 l .gpio = DA850_USER_LED1,+ v% `% C8 N2 A9 z5 Y: S
.name = "user_led1",
/ I- V: t \( t3 u1 g3 M- D .default_trigger = "default-on",
3 y5 z2 C$ y; x: Q: r% O },
* I/ r" Q0 j% B {9 x V& W4 F1 ]1 U/ ]5 Q% v; L
.active_low = 0,
$ N, k, O6 h: t9 T4 @! X { .gpio = DA850_USER_LED2,1 ^8 |, G0 G( Y( V# u ?+ a
.name = "user_led2",
8 q9 J; f6 M9 e6 {: G x% {- Q' u .default_trigger = "default-on",, f5 c) o/ l" y1 v& Z4 s" U
},
& q/ A+ t9 F& ]! {' K- L( a {
: i; j* v/ T- {8 Q6 ]5 |! b .active_low = 0,
% |/ I, [( u% S .gpio = DA850_USER_LED3,# I' D1 b3 ~6 Y. x7 v5 Q `
.name = "user_led3",
' W) ?# j9 l% P" K .default_trigger = "default-on",
# |8 g+ `* x' c+ f# Q8 [) A, s6 G( x },! w) r" U" R8 b u5 T5 [( P
};
$ D- j: n1 z- i6 h. S
8 ?- H# ~9 ?9 z2 c$ B, astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ j' y3 D6 E; @4 F) b* S' Z .leds = da850_evm_tl_leds,
, n! h$ n l( s$ ?% c% [ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 _ e6 x2 A6 B* x" g: ] q};$ A0 c/ e. S' r; d' n
7 h2 Z- m# S tstatic void led_dev_release(struct device *dev), b! Y- N- |: D6 |' A! Y2 `
{, m) ]/ e0 `; g# J I4 D
};
) D* d6 g/ k S i- _9 R z
$ ^/ E5 H* J& p7 wstatic struct platform_device da850_evm_tl_leds_device = {5 a) w/ E5 E& ?1 P8 _; `
.name = "leds-gpio",6 G5 `6 e ~$ z/ x- `# ^- X2 _% _
.id = 1,
) u' ~: z# v0 x2 t* N5 D( ]5 i8 o: p .dev = {% ^: `2 q! a- x" } H! T1 {: }/ j
.platform_data = &da850_evm_tl_leds_pdata,6 T, }4 \7 [" Q7 a& I& F: q) d
.release = led_dev_release,1 ~3 c! g. W& J5 \3 N; x, x
}
" ~7 |0 R/ i0 }7 @- d};% w ~6 u$ f* g; v& p
1 r. p4 y% @5 i
static int __init led_platform_init(void)
, s [! t! \9 @) ^" ^{1 Y, T/ j5 a& S$ F+ N& a
int ret;
3 t/ D7 m! f4 Y4 @! ?3 X+ F#if 05 Z9 l/ S* x; g. O& T6 n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, [7 a. E0 B1 E9 K
if (ret)$ _" m1 ?8 l' b7 ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 B" p% [ `! I! [) f
"%d\n", ret);7 I4 s! t& g0 Q% [" @7 o. d
#endif$ c0 V" h) |: ^ z$ P2 R4 a
ret = platform_device_register(&da850_evm_tl_leds_device);4 _2 ?, O# R2 v$ m8 S
if (ret)
7 j$ _/ X8 J5 ~9 q5 m) n3 d: d pr_warning("Could not register som GPIO expander LEDS");6 y9 j5 _ M4 x+ T4 [+ V/ l
else U+ R+ N1 k2 ]/ N) U
printk(KERN_INFO "LED register sucessful!\n");1 v1 j5 |1 y2 R2 a( z r7 a
" c- F6 {) l7 Y' O C p return ret;0 s; ^. x% X0 v }7 R
}
+ Y% J8 P( S- ?3 x$ a6 q# J" ^) X2 R+ b4 \9 Y1 X
static void __exit led_platform_exit(void)
9 {# B5 i u. S1 X{7 h9 f) d6 ~$ p6 \7 D O
platform_device_unregister(&da850_evm_tl_leds_device);
5 t# h, N8 z; _2 ^. K# X1 t4 g. c2 |/ m9 y( |0 h5 ^) o
printk(KERN_INFO "LED unregister!\n");
b5 o, P2 Q1 s, Y' ^}5 f3 m. b3 k( f" D1 C8 M; p9 |- z
: L: p5 P0 R; e( J3 t# o5 N
module_init(led_platform_init);
; _! [# J( [5 Pmodule_exit(led_platform_exit);
% ^: J/ Y' O4 K* k `
) j% X6 E# k9 N6 _: U5 @MODULE_DESCRIPTION("Led platform driver");8 S) S- f, @# K3 J* [: a" C0 Q5 s
MODULE_AUTHOR("Tronlong");( P4 W8 v1 J3 J, b) Z" w
MODULE_LICENSE("GPL");
" c- W& I1 j* u, Y) D
+ m5 j( J/ b, C% B6 m/ p0 P* F |
|