|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 F1 B4 l% {. C) j
#include <linux/init.h>
7 J- R- [7 k0 N#include <linux/module.h>2 Q3 M3 D% H0 L. g
#include <linux/kernel.h>/ g( N0 q) l2 R- @4 T. N$ D
#include <linux/types.h>
- E, m# C1 B& j! i8 d/ g* t#include <linux/gpio.h>
& @8 @7 Q) [9 t" X+ U#include <linux/leds.h>
/ A, i. D: o1 c9 g9 o#include <linux/platform_device.h>: B1 j4 T) e7 T, s8 X
6 F7 s) c0 r* [: g, _6 N- T#include <asm/mach-types.h>
/ u- G0 c' @1 L. ^$ c/ O#include <asm/mach/arch.h>; z* x5 K/ _+ n2 A/ l* j N
#include <mach/da8xx.h>
N* Y* j# m: S; Z4 k& h* n#include <mach/mux.h>
6 C( g+ D; c8 `# k; ?7 k2 X& u* `+ s6 E3 p6 f
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 L" t/ Z% J' I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! ?- `6 A" s5 d9 C* E" k/ j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 |$ [& T# T1 N3 e5 ?: n#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 b- X. T: G* i8 y' e" o" I. y |, H1 J
/* assign the tl som board LED-GPIOs*/' t" a9 t) ]' F1 `; m+ u
static const short da850_evm_tl_user_led_pins[] = {
. I' ~) @" n9 B; Y# e7 ] /* These pins are definition at <mach/mux.h> file */
: h5 l2 ?( K9 b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& X+ C) \) }1 _! k' Q% G
-1
. u+ e9 p$ }( x ~0 E};
( ~0 M" s( T5 k, f# p. a9 A2 F/ D! o
static struct gpio_led da850_evm_tl_leds[] = {
( j" Z e5 o' F& |5 V) }2 I {
1 ^- O J# ~, |9 _+ L' i: K' q .active_low = 0,
9 f0 \$ ?; D, X .gpio = DA850_USER_LED0,
0 A; i2 i6 ^3 N/ ~( I* E% ` .name = "user_led0",2 g% g+ p* L) w9 u( x
.default_trigger = "default-on",
$ R: c2 d' C2 R# L },
J8 [ y2 N+ Z( Y: D {0 f ^$ @) ~) Q% h4 J1 E6 M
.active_low = 0,
# ]; { P( o' L, Q6 N .gpio = DA850_USER_LED1,
' H! Y7 h( ]: e0 ^) O .name = "user_led1",& g/ o) l" i* r7 F# _- c
.default_trigger = "default-on",0 W4 s2 U ^% }' L2 b$ U! b
},
: J: V3 e; Y, F/ j {) [6 {; {: j" A* F8 |
.active_low = 0,
4 m V6 X" {( y .gpio = DA850_USER_LED2,
0 P0 T$ K; C( J9 H" ` .name = "user_led2",
m% T8 c1 o- p7 y3 h* i8 N .default_trigger = "default-on",$ I: g2 M- w. i. r% F! T
},8 }, h9 g A' o$ l, i, [" ^1 `7 N
{0 K6 H; e& K# K+ Y) n( ?5 z
.active_low = 0,
' m1 Y1 k, k) D8 f E .gpio = DA850_USER_LED3,
/ G4 l, b: _0 f% u. x .name = "user_led3",
: R* w+ V8 y: b! | .default_trigger = "default-on",9 w+ I( t, a* c# C+ J% J4 v
},
1 h% F4 F8 L4 `. Q: I};
+ ^% m* v; g8 Q4 S: ?& ?5 T3 |" ?, a9 `1 L9 n6 L$ S/ W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: m( t$ v$ B1 ] .leds = da850_evm_tl_leds,
& Q3 g1 u- B1 L3 J2 a0 Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ L5 h3 G# m# d7 K. u};9 }& a% _! y3 E# m% {9 c
1 K" q( n+ P Dstatic void led_dev_release(struct device *dev)
6 s$ W( @7 S/ T; R6 d. b0 p{
$ Y- a* s* v N7 W C% q9 b};% F, m: p: p# _( h
" t. v* Z1 U1 ~: U' V
static struct platform_device da850_evm_tl_leds_device = {
?' ]- ^8 c6 N! K6 O- P6 i .name = "leds-gpio",9 r% y1 i1 x. U
.id = 1,6 n/ O. X5 p( |" |- n; V* O
.dev = {
* c- ~7 C5 V+ V' ? .platform_data = &da850_evm_tl_leds_pdata,) ?8 [1 v5 T6 y0 f) W1 z, }6 ]
.release = led_dev_release,
# d( `( ?8 Q# |8 z+ y }0 M- N, I1 y' D- L/ n, O- i, N
};- W( }* o3 g+ A
& j3 c2 D6 h2 ^; ~) Vstatic int __init led_platform_init(void)
. K2 t! E& ?5 p& c7 L& Y{: `0 b! ?9 @, q1 a
int ret;) `* c% [8 w3 Y. A* L5 j
#if 0% Q2 j5 K/ U9 G A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! Z2 t/ L; |, \' J" } if (ret)$ `) P" `/ c. D7 r$ D
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' s7 o# x+ a; j" b+ L; m* p
"%d\n", ret);( q: ^# ~/ N3 A" R; m
#endif
3 p$ n) T q- G) M2 ?- k* S ret = platform_device_register(&da850_evm_tl_leds_device);
3 C; p4 A2 h8 B) W6 ` if (ret)
5 s. q3 J% g: z) i8 L+ E/ p pr_warning("Could not register som GPIO expander LEDS");
/ N; H/ x* J# s2 V7 _7 B else
. {) g1 U9 ~& w* L. o1 V- X, a8 C printk(KERN_INFO "LED register sucessful!\n");
( q. c$ L3 H% Q$ [: Z4 q6 k u$ v- e( _4 g: G' [
return ret;
$ _. K, L! I8 @1 ? I2 q0 e9 A}
u4 ^( O! R( \* s8 G2 O. S, V8 q4 k W% J. J; o/ U
static void __exit led_platform_exit(void)3 t; @2 Y1 j( ]- g1 k0 f- C! f! u- l
{. u% m: s( M# d$ m* E
platform_device_unregister(&da850_evm_tl_leds_device);
4 b5 T* b8 N, @3 w# Z9 g
! v! B9 o" \5 A2 e( B) w6 t/ c3 g printk(KERN_INFO "LED unregister!\n");
$ l, s2 c6 e& n) ]}0 E5 r z6 a3 j p: \
! n0 F, C' m( x4 g7 u8 lmodule_init(led_platform_init);5 Q4 M& O% N. X& F8 ]
module_exit(led_platform_exit);# `: q+ |* q2 \6 z ?" T# k
5 N5 I; l y5 G ], QMODULE_DESCRIPTION("Led platform driver");/ [! n2 j& B1 M" O% i
MODULE_AUTHOR("Tronlong");2 i/ L- [0 @1 F/ u
MODULE_LICENSE("GPL");
: W8 E+ V& \, P2 [# @4 w+ n# q( L- E) @* d
|
|