|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: n: f8 ?9 s5 N' c
#include <linux/init.h>1 i* f7 ~% c6 I7 _5 @- e1 {3 H9 g s
#include <linux/module.h># P: {, y. I- D' R4 g6 X
#include <linux/kernel.h>7 H& k" ~2 m- }
#include <linux/types.h># R# @! b: s5 S9 K+ ]2 p4 [* Q; i8 I
#include <linux/gpio.h>/ [- h& h* D1 w; Y$ \3 b
#include <linux/leds.h>! M: o- b; D7 F0 Z9 `' A8 U& H" p
#include <linux/platform_device.h>
6 z' x+ `/ }6 x3 A' ^3 {8 d, Q9 [
* U8 X0 z |" B1 `+ z4 o8 N#include <asm/mach-types.h>
7 I& e* q% K+ q5 D4 p#include <asm/mach/arch.h>2 ?& E: R6 u$ q$ k3 R/ ?
#include <mach/da8xx.h>
# B/ {; D' M# h) k0 ]; V+ g#include <mach/mux.h>
% a' _* s K7 m& t+ ^
, C- J* _% V0 h3 _2 H#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). r U5 s' C, B( h
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), W% d2 n; c9 D' M- n
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ X+ E0 Y+ F& v2 o1 @, E5 S/ \
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). i8 O0 _: A9 U! [
- g4 I2 Y, B0 r$ _" ^2 ^
/* assign the tl som board LED-GPIOs*/
( X) z. S/ z4 c5 o: W' Gstatic const short da850_evm_tl_user_led_pins[] = {
$ {8 C" }6 O `# X /* These pins are definition at <mach/mux.h> file */8 A. R: a& {" N* V& e' ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. U2 B# q: Q( Q" B4 W, \
-1/ ~1 z& a5 e' H+ ]2 K4 r
};
; P8 z0 y, T6 Y& B) w& e5 o, C
" w7 Z+ d8 j3 |4 P' Tstatic struct gpio_led da850_evm_tl_leds[] = {
8 Q& k$ j6 A @" D% g {4 u3 V6 H+ H5 l
.active_low = 0,
" k: q, v, g/ G2 Y .gpio = DA850_USER_LED0,5 m9 a7 J; q) p& F
.name = "user_led0",
) }- k; L$ F5 f. V* U$ t .default_trigger = "default-on",
, ~( O k- G7 o1 { },
" y& c$ R9 j1 l1 R1 I {* W0 `! W$ L9 ]; A5 q X$ N
.active_low = 0,
3 N. \0 g1 Q4 J4 G& x5 T+ l# Y .gpio = DA850_USER_LED1,
, j* w, f l' s& _! P- d .name = "user_led1",
' o) m) B1 m5 f( Q# Z: k% ^ .default_trigger = "default-on",( B Y& J. r9 j# b1 B) z! d
},
: [: L# x. L7 }6 G {
' ^) ^- n8 e f* C. D! a .active_low = 0,
5 u6 \' X) l7 o5 u .gpio = DA850_USER_LED2,
" V9 K4 Z& r# Z3 }! ^ .name = "user_led2",
[1 z8 a) ~+ N .default_trigger = "default-on",/ g9 p3 ~) z4 Q/ F9 H# c
},
4 D% ^/ \4 J' D' _. k2 k; ^6 y {
( A5 F9 `5 Z0 X, _" E7 R8 w/ ^ .active_low = 0,, f; M: p" u" ^1 q
.gpio = DA850_USER_LED3,0 W! P; I2 O7 U4 R- P( p7 [: c
.name = "user_led3",. a/ ~: X# V s6 l8 O
.default_trigger = "default-on",
. c. ^: b9 b" H9 O. }% { },
7 D7 p( T$ [. O/ q9 [};; X6 z O) _# z4 h
" m7 E$ D* F8 s' z+ y O: o" Tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) S0 z2 t& W/ K+ D' i$ e .leds = da850_evm_tl_leds,; Q6 ?" ~: a# a8 w5 Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- G, A5 B. Q% U% v
};
0 z0 H' ]; |% W8 }# C, I1 a x! Z& o# q/ j8 w" r( z! ` E
static void led_dev_release(struct device *dev)7 f$ h) q5 g8 o% D* S5 A; N* t, f- J
{( Z1 q5 o/ `5 _, w' @5 u
};9 N6 K9 t3 m6 w* d/ z+ `8 t
$ Q6 P# ]5 A. V% n/ \
static struct platform_device da850_evm_tl_leds_device = {6 e) | D9 L4 ?" V3 |+ G6 J
.name = "leds-gpio",* `% r" P- N! U
.id = 1,8 l5 a( T. H1 S0 t' \5 p1 d8 D
.dev = {; w; T1 |: i; ^# O% J$ l& l
.platform_data = &da850_evm_tl_leds_pdata,* e" B3 C# q7 ]/ r0 e+ D
.release = led_dev_release,
2 z. q. K3 x; e3 E0 N }
6 E- R, D2 T+ T};
$ y7 c- f8 S* E6 \ L, E. Q4 ^% a2 n9 C6 N! v. d
static int __init led_platform_init(void)& P5 V" b6 ~& W9 Z5 C
{; H: K0 f, E2 `3 m: P
int ret;
' e! L0 s+ n+ }; D% \1 Z#if 0
% P: i$ f! K+ J6 S0 i ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 v* F5 Q1 R% \, L5 N8 Z1 l if (ret)
! y' Y+ g5 a# v, R+ I2 j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' c4 F& g$ R. k
"%d\n", ret);
) f3 t0 a) B7 |) o" w#endif
/ V. h% z" ~+ a/ S3 [ ret = platform_device_register(&da850_evm_tl_leds_device);7 M- }1 d% j& x# Z
if (ret)
) Z! I3 W/ K% f! |, j4 A9 q8 [ pr_warning("Could not register som GPIO expander LEDS");1 ^- m6 ]* v% J$ {2 n0 O7 y6 X8 b
else* w1 \7 l$ c0 Q. B: d
printk(KERN_INFO "LED register sucessful!\n");7 W7 g% C9 ]/ T7 z ^$ C# f& n4 m s
( f2 f& ^9 f# v* Q% E% K1 U
return ret;8 b# c: C% H2 B) U2 s5 s3 V1 r
}
# k9 X6 h( u8 Y+ p& q- W
9 U; W$ y, d+ k$ U. \static void __exit led_platform_exit(void)
4 c: F \1 h& c" y9 v& Q9 o! j1 m{+ j+ z# T8 R) {7 ^& \3 j4 X
platform_device_unregister(&da850_evm_tl_leds_device);
" ^* e0 V5 p/ X( e: N9 E$ B/ z$ p5 _
printk(KERN_INFO "LED unregister!\n");
( L, L/ c2 {4 c" j9 T1 J# \, I& V}
/ f, c: z. Q% ~4 y4 s* p2 F" b. ?8 C, H7 Y! I" D
module_init(led_platform_init);( {! @2 V1 f* {
module_exit(led_platform_exit);
+ Y5 l$ o6 B! p% Q
5 ^8 s$ A9 ]" u3 CMODULE_DESCRIPTION("Led platform driver");
. E3 V' N1 L/ d3 Z8 }MODULE_AUTHOR("Tronlong");
2 ^. V, H) d: W C" d% O( b+ VMODULE_LICENSE("GPL");% j I5 A1 }7 ^2 l. _ E' y& C0 a6 k
5 u( l; R3 D5 `2 t" b
|
|