|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 o! l( J8 R i( L#include <linux/init.h>1 u0 G7 P# q& i
#include <linux/module.h># k: f9 `! e6 J( d
#include <linux/kernel.h>
. K2 ^8 d" B5 c6 `$ ?4 b#include <linux/types.h>8 ^% ~' |( }4 ]& S2 B( l" B4 @$ I
#include <linux/gpio.h>
0 d9 W" T/ ]" A" U! G#include <linux/leds.h>
# ?/ S" R6 u e# G9 |% w' U#include <linux/platform_device.h>* D. h: e3 ~7 H% i- T4 H, ^, y
) c' ]( Z6 ^) I, R8 Z; y#include <asm/mach-types.h>
. w$ h7 s9 A! B5 e% m8 Q#include <asm/mach/arch.h>
) @2 Q+ k& s. A+ n#include <mach/da8xx.h>
4 J% Z, U2 L" x. c+ l! L#include <mach/mux.h>
- V# A) n5 p; z8 [
( w0 z4 @, w G#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ ~+ w4 a! w! B3 X& z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
G4 [ k1 @% Q2 K5 h- I+ n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ s- m# Y/ T. n; O5 K, s+ u#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) {( |. E1 Z/ W1 e h5 E
( A) ~* m% p1 o8 u/* assign the tl som board LED-GPIOs*/
! n( Y' q+ C' I8 B% @static const short da850_evm_tl_user_led_pins[] = {9 P# T8 Z0 ?) R) z2 u6 j( `: d- N5 M% s
/* These pins are definition at <mach/mux.h> file */
9 C4 K2 R% T$ B! R, Z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# y8 j+ r$ [* I O. t' t- P -11 A* p+ a+ {7 w |3 W
};
3 w* H* J* D3 @+ a Q( N
% |* C0 M# a4 ^7 Bstatic struct gpio_led da850_evm_tl_leds[] = {
2 \9 T4 c+ o4 a. o {
9 h+ \/ k7 I2 v, i- j$ |7 | .active_low = 0,
9 ?5 ]: C0 m a .gpio = DA850_USER_LED0,
" M5 c; j% b, H8 K" | .name = "user_led0",2 J3 S; w5 B1 Y- w9 Q- m4 k! `
.default_trigger = "default-on",
# o/ f B& n8 \ },
; y9 e( q2 l" H* S- h* J {
+ O+ F* x. |; I8 }1 }+ b( S .active_low = 0,& f* L8 ?$ i+ c5 L
.gpio = DA850_USER_LED1,7 L- ~) x* C1 O5 M5 W; _
.name = "user_led1",
% F! n" s9 @' ^$ Y1 A5 o; F1 t1 _ .default_trigger = "default-on",
4 d( T. l# v) ^6 k7 l },
6 `. F9 i7 k M% u {
5 n6 N& }3 F9 v! m$ D9 u6 h9 ^ .active_low = 0,
6 j; l4 P$ a2 r+ o$ \* A .gpio = DA850_USER_LED2,% h+ D* D( r5 |% {! Q$ J
.name = "user_led2",: ]$ h# e, J) T! } J* M! \
.default_trigger = "default-on",
1 `' ^# ~3 C' U) \- a2 u' y% T+ T },
# b. x' C/ p# c! _' ]( i2 i {" s8 _2 _; I9 l
.active_low = 0,7 k J, W Z% t+ X9 h4 x
.gpio = DA850_USER_LED3,
$ N" V$ ~3 ~- `0 Q .name = "user_led3",6 @3 Z$ ]6 B' a& k( Y/ y7 Q# i- u/ d2 A
.default_trigger = "default-on",
6 W q9 g% u% n8 U1 l; `1 ]: h }," o, v) r$ n1 N8 k$ c7 ^; \
};! S& I! d2 \! Z' G1 p
/ X0 c4 ~/ a: `( z: |! h) n# o/ ~/ xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ E, v. `- D& M' l/ S9 z3 r* T5 c
.leds = da850_evm_tl_leds,
7 |+ _# }; b8 t7 ^0 ^+ b- Q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 A; O' r7 r" K' E1 h0 ^
};
. v8 f+ W3 b* w- ]: I
- v$ }+ j- G- e/ s3 v. Fstatic void led_dev_release(struct device *dev)3 @1 m' T( h( P, \7 A. r
{% s. L2 G' h8 ?- w+ L9 b
};0 A T( s. t2 @6 T" q3 x
8 Z, q5 E. u) c0 E% C6 i Q0 t
static struct platform_device da850_evm_tl_leds_device = {3 n7 }2 n7 j' [, b. D
.name = "leds-gpio",6 b* `9 y$ K! a }* Y
.id = 1,
: N- z8 C! U2 x' B9 U% |. V .dev = {7 K0 p/ D& s4 I+ L3 N2 l
.platform_data = &da850_evm_tl_leds_pdata,
' t3 o- U% s1 _: W+ d" n5 c, z .release = led_dev_release,9 W# N/ | G2 n
}
1 s+ m$ c4 g- n. U0 d* a- M' v};
, f8 s$ Q0 { L5 o, l: N/ O! G" A* p `- Z5 a
static int __init led_platform_init(void)2 {$ w2 s8 ]3 _3 O9 X7 k3 q( B
{7 [$ Q" z) H+ m: p
int ret;6 C$ h3 e" s# c0 l+ q- F( E
#if 0, }. S" W6 M! K+ Q! u! q$ R) |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# s; G6 @- M Y' p& Q$ e
if (ret)
. h: v' |$ w1 S: {5 |" z8 I4 ] pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 u8 y2 }( K! R- X3 b$ O3 A+ M4 | "%d\n", ret);" B* ]5 c7 R/ X D
#endif
5 i& F5 A! q2 ?0 ^7 R: K ret = platform_device_register(&da850_evm_tl_leds_device);
2 L# ]9 |% O' `( z, h# }( v, ^" c if (ret)
. a, z1 q0 B2 u$ K- i0 U f pr_warning("Could not register som GPIO expander LEDS");% l T) x% ~+ h( x" z
else
5 _, i! Q2 A1 E5 o8 H( ^ printk(KERN_INFO "LED register sucessful!\n");
# ` T: f7 M, y, v2 [6 F0 d/ B+ K. I) j9 j
return ret;9 |' l# ~9 u8 q% U
}/ c9 w: E0 D% o; u8 g' J! T
6 L* J- \3 k( x4 R8 W5 f
static void __exit led_platform_exit(void)
! x; V$ }' j8 _. A8 G{5 m. u9 R/ i. Y# T$ e4 n
platform_device_unregister(&da850_evm_tl_leds_device);4 b% u" D5 M6 V5 w
! u4 b; j: b3 o+ M* n printk(KERN_INFO "LED unregister!\n");9 b4 k) ~) V; W, Q- P
}
! M# B* H* Y* r R- ?8 E+ h3 L& M' v/ H* b% W- |
module_init(led_platform_init);9 O2 N( W) f% ?1 E: i
module_exit(led_platform_exit);
' ?: a. e% E9 H
1 K) o1 |, _ ]MODULE_DESCRIPTION("Led platform driver");, T* V. S& H& I& n
MODULE_AUTHOR("Tronlong");( \: e0 U/ S! O1 t
MODULE_LICENSE("GPL");
0 O/ I# t: Z# q$ T7 b
$ C* ]& s S& |0 {2 l% P* G8 g |
|