|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 H' x& y* E/ ~# W1 _' E#include <linux/init.h>" d4 m9 j. q4 L! E! Z) {0 j
#include <linux/module.h>
' p" ^5 P2 w6 H% K#include <linux/kernel.h>
- w( G! C1 R3 e7 g( H S#include <linux/types.h>! o+ K' W/ P3 B5 I- ` z5 A
#include <linux/gpio.h>0 B" X ~, J E D0 a+ o& J! G
#include <linux/leds.h>
- p- C" b2 V- U6 j4 i) W#include <linux/platform_device.h> `2 U# Q0 r( M4 i
" p$ L% Z( x( u$ b9 S0 x K9 {0 F
#include <asm/mach-types.h>+ r. N0 p: e% Q: V. I
#include <asm/mach/arch.h> G$ y% T6 c2 ~ f7 X$ b3 |$ t
#include <mach/da8xx.h>$ x8 ~5 b! Z, D
#include <mach/mux.h>
- M ?8 P# H* l* _, E/ B, r5 z. R5 S7 s2 Y' C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 g/ j' H- K. N Q$ K! K* t' ^# Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) N* k" s3 T8 z( O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 ?& y6 }5 G& F9 A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 W! n4 m; A2 Q% l! R
5 N/ h2 Z0 ~- i, H, g( a4 }" j$ z/ p/* assign the tl som board LED-GPIOs*/6 s8 U% z" j3 Z) A: S) D
static const short da850_evm_tl_user_led_pins[] = {1 Z+ e$ L$ @( M
/* These pins are definition at <mach/mux.h> file */) b4 p) N$ S [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* s+ f8 ^8 V. T6 ^. T: S
-1+ [3 x* l. B. S# k6 N( n5 e0 [
};: t9 G% ^, k- f) f
% I" R: L: @8 E3 ~/ b$ C8 U0 ^
static struct gpio_led da850_evm_tl_leds[] = {
' w4 y6 C0 q( k: X7 K# ?: d: F! Z {
+ t! U1 c. d. g) H6 ~+ x .active_low = 0,& p* y- b! E) u
.gpio = DA850_USER_LED0, z) H; C& l2 T. Q# N3 _6 ]$ f
.name = "user_led0",
4 {5 s* ~3 U0 B .default_trigger = "default-on"," ^/ l# h5 z& R+ Q# w
}," i6 y0 O0 i% W6 m& }
{ l1 C. O) R! T3 ]+ r( W; _
.active_low = 0,
; `: p, x2 r# |: W+ N .gpio = DA850_USER_LED1,: ^- {6 R* c( X
.name = "user_led1",
8 W7 w& y& K0 x) M, r .default_trigger = "default-on",
9 }% T& r3 N' M1 u' d- Q },
; T+ U' V1 ]" ]) R) ]; T9 @, J {
/ K- o& T1 l6 y% n. F- i- y& y8 r+ h .active_low = 0,0 H' ?& S( P& T, ]
.gpio = DA850_USER_LED2,4 |4 v4 l" i+ P" h2 m X
.name = "user_led2",
, o' \- p# a- T G* e" c .default_trigger = "default-on",
3 H7 o7 ~$ I7 ~' u: N, {2 c },! w/ L! ^- I4 ~5 V
{* y- W6 r9 `3 f% O
.active_low = 0,1 k6 j* q3 H ~0 J4 p2 b$ \
.gpio = DA850_USER_LED3,
) f$ j8 z* E' O% `8 t1 ^ .name = "user_led3",2 S3 P# F3 e# _% M
.default_trigger = "default-on",9 J; o: Z' [; p# M1 Y
},) m2 {9 Y1 v+ L; f* n' U2 q
};* ~! D7 E, b8 @7 H
- L% J" @6 k" w6 u5 [
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 U/ a, t- Z5 r6 T0 ^ Z: K. C! z .leds = da850_evm_tl_leds,3 E& g$ v. F6 m- Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* y7 X- Q# j( n. c6 \};. e* u8 Q: x* e+ \; M2 m7 y5 }5 H& ]
: c( k) A2 |$ O( V M8 U+ A: Lstatic void led_dev_release(struct device *dev)
. z( o4 M. b# l{
; u4 C8 f! S% z V/ V6 o};
* R$ K; t0 d0 {7 r
A$ B' e T; Y* P: Kstatic struct platform_device da850_evm_tl_leds_device = {6 C; j& X: o) v( R9 l# C. V
.name = "leds-gpio",
& v6 l' k/ B6 W8 v4 E4 } .id = 1,
. m l* j1 U8 w6 ^/ O .dev = {0 K! P. D- D, ~8 q
.platform_data = &da850_evm_tl_leds_pdata,
/ W) W' y5 ?$ k6 Y2 l2 p, w .release = led_dev_release, R' K. S4 G; U2 u& w3 k
}1 N k) {4 S3 I0 N& D
};
4 q8 q) y1 x8 ]/ S! g
1 D. j8 y" r6 y# i- H, R" ]static int __init led_platform_init(void)( D* L9 S0 d( U/ [, J; m7 n
{
& r5 C2 Q x! N9 E int ret;
' t3 k+ d. Y9 L" y- P: p0 X( a5 `3 R" A#if 08 T8 r) L# l' _8 ?* _; _ \6 ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 a' L8 n/ C9 ]/ G2 J, o- M$ o if (ret)3 c T7 t' ` A1 o( H) k
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 r( ^ L: J9 L
"%d\n", ret);
% Y( o, H& n$ Y1 t#endif
4 e& w/ J9 R% d9 h* T ret = platform_device_register(&da850_evm_tl_leds_device);
; f+ ]. P0 N# s# W) H5 t2 z4 H if (ret)7 z) N- D/ A( b5 a4 g; i
pr_warning("Could not register som GPIO expander LEDS");
# D5 b5 i% h' L3 B1 I, o else
9 |: }' L5 B: b( [1 A6 z+ i6 ]; ] printk(KERN_INFO "LED register sucessful!\n");6 Q3 d7 i' L7 z: L# l! r3 [9 C
8 ?4 q a) N, j, m( ~, _9 I3 B return ret;
' C% d4 n0 j* Z1 f) _}/ Z, }# m- z) E) d. K6 w5 x
" O5 z+ ?$ K# Q" G% ^( X/ {static void __exit led_platform_exit(void); G4 A+ E' B7 f( i; m# @
{9 ~% k2 A7 ?% i4 g2 A3 W% \) k
platform_device_unregister(&da850_evm_tl_leds_device);
t. i' r" P5 A8 p+ s% R' n7 m2 u# ^/ a. U5 Q2 G
printk(KERN_INFO "LED unregister!\n");/ `' T: v! ^ P& i! k% A
}
. @2 U9 V" [! k$ I0 x9 H' S6 a8 J/ O6 r
module_init(led_platform_init);# i, v i4 k7 q' N1 L% s5 j
module_exit(led_platform_exit);
% B2 y% n( O' Y8 e9 F; C r
5 x7 R# T' z3 P) J3 U% k: `, d) kMODULE_DESCRIPTION("Led platform driver");1 c& G+ b& P+ ^
MODULE_AUTHOR("Tronlong");$ Z; _/ _5 G. b
MODULE_LICENSE("GPL");
" D+ J3 N% F9 A/ T
) c# R& l y! @; @" @ |
|