|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: p$ s0 |9 r7 Z
#include <linux/init.h>
Z) O" X6 H! R8 x#include <linux/module.h> c/ h- e, d; G
#include <linux/kernel.h>
, H7 W$ Q+ |. s#include <linux/types.h>/ t; D _! I: w9 E' Q% Q
#include <linux/gpio.h>: n( e( y8 n4 F! L
#include <linux/leds.h>7 n* M/ P" a. ?: b" a& Y% @' {3 v4 x, g- N
#include <linux/platform_device.h>2 j; @3 u8 Q& f
# ~+ I( P0 d4 T, g/ u: \2 r- y
#include <asm/mach-types.h>* D$ ^. [* L' \. t) L: ^1 }
#include <asm/mach/arch.h>
: H6 p5 V- u$ ~' T: Y( _#include <mach/da8xx.h>
5 i' u7 f! _# I6 t#include <mach/mux.h>3 s* u* x& B5 i" v& I" k+ z
( L5 U, |+ M1 y% N& O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 r" i$ l. e3 R#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" i' C4 M* H y0 f d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 a" C. X9 O. v! l9 E6 z) ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% a$ e3 `% e. c2 ?! J6 l/ V3 E
3 m- {* I( g0 x/* assign the tl som board LED-GPIOs*/
# w# O' n) y }" _( ]* Sstatic const short da850_evm_tl_user_led_pins[] = {) U/ J3 n( q" G) z# V) g
/* These pins are definition at <mach/mux.h> file */
+ E/ ^ D- o9 _/ t! j DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# j) ^+ Y* V% z1 b( H
-1
5 Z' k; V# C0 P9 I3 _};) H6 ]( x, \- h% h+ M$ b7 c8 R
5 D5 g9 M& ]( v, ?. ~static struct gpio_led da850_evm_tl_leds[] = {
& c# O4 S7 x. ~& [+ L {
* X5 ?) Z2 @" J. ?- w2 w9 L .active_low = 0,& g- p7 I: C! O3 j5 u# o _4 w
.gpio = DA850_USER_LED0,/ u0 ]4 k8 R1 J) A: k+ K
.name = "user_led0",! O3 V, x N) {: z9 g" t; o4 p3 o
.default_trigger = "default-on",$ I9 T8 m% P0 S- D9 `4 R
},
0 I' F6 Q! W3 x; p {
1 ` V- N6 D% O* c E .active_low = 0," h4 G, ^# k$ \+ A/ J# ^1 v9 |
.gpio = DA850_USER_LED1,
9 K0 q7 V) I9 d) A# u6 G+ \ .name = "user_led1",! e: O" a2 P$ e" {
.default_trigger = "default-on",! v! T! Z" {+ Q. D/ k6 j
},
9 q4 e; P1 p/ L+ ?5 I! [ {
% A m& y4 ^, W! M6 [! t4 B .active_low = 0,* V9 ^1 N7 l, d6 b$ q% z7 r
.gpio = DA850_USER_LED2,
5 s6 n- E5 o& ?9 L' n. g .name = "user_led2",) @8 Z! }) x1 y" i. ~0 K
.default_trigger = "default-on",
; ?! E. c7 H. x$ l$ c3 q6 E: P8 `$ D E }," b. A; o: ]2 ^2 ~' a0 j; s0 V
{
0 _' V; B9 g- q; R .active_low = 0,
8 x% h# |1 m* s$ f$ f: J3 x B3 z8 j .gpio = DA850_USER_LED3,
! M9 b/ c1 }9 ?9 Q( E! e$ y .name = "user_led3",0 g" M% _; _1 V- ` S, `2 k( f
.default_trigger = "default-on",% u' i( O5 D" d; w+ B& F
},
; `: |, c7 r; y" x9 `# _/ k};8 v' U; U" q8 Q, @% L) w) e) J
2 K2 V1 v8 ~' e, P- `
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 Q# F* v/ M3 _& X .leds = da850_evm_tl_leds,# c% u7 Y$ @* |7 x8 {+ _
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 r' _5 k8 b1 `" c2 T7 B
};
# R* X- |2 O" i0 L) _6 c
1 G m) _# z5 m* O" Z- Ostatic void led_dev_release(struct device *dev)
z) N. D0 f4 O) B{1 D5 L$ f. n* x, Z
};
# s' n9 R8 _% V" d; I9 m4 d0 l. N/ j; K' x) |1 ]9 L, U
static struct platform_device da850_evm_tl_leds_device = {8 V5 s y0 E& ^$ d$ l; ^) g
.name = "leds-gpio",
) \+ X* l( ^ F( c/ I8 I .id = 1,# ^- t% }- T5 a* e0 y: _$ v$ [# P
.dev = {
5 _% }, X+ ~1 v/ x .platform_data = &da850_evm_tl_leds_pdata,6 n+ Z* S) |2 k6 [7 g0 ]% F
.release = led_dev_release, e# T3 m7 i9 d4 N/ i
}3 y/ @% R# S- W" K
};: u M- W3 Y; E( G
1 b- b' s3 o& S) K. }static int __init led_platform_init(void)0 s' j/ L7 `! V9 u7 j A4 E5 O
{7 Y! ?8 U. b2 y2 j
int ret;5 x2 u! E4 Y8 Q; T4 ^% j
#if 03 U3 q# M2 t+ Z# R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" g# q: Q( b: L& p; G
if (ret)
+ q1 C( r3 x1 N6 \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 w$ m; Q+ z, m( N, y4 W; R "%d\n", ret);& S1 F& Y: A# i# B1 R) E$ t6 g: Z) O
#endif' ^: r5 p$ X7 R$ f$ [, a
ret = platform_device_register(&da850_evm_tl_leds_device);6 z, j$ J$ w7 w
if (ret)
, m7 \$ [( U% A pr_warning("Could not register som GPIO expander LEDS");
" t& ?7 i& c% i7 L2 k5 h- e else
- s* X, |; ^% M* p printk(KERN_INFO "LED register sucessful!\n");
8 W& j: W6 o# n- S$ m( z' G5 d) p" z0 N3 L6 m
return ret;
) i% p8 o) f7 l* G2 a" G; ^}
) `! ~; s# I% l+ q, A& I1 H
% x; R T. g- ^& wstatic void __exit led_platform_exit(void)* Z. a# k0 O9 @/ f& w( ~$ K
{" I7 z; L! T" v+ h, N/ \
platform_device_unregister(&da850_evm_tl_leds_device);. j) E' A* x; u1 g/ y( N1 h9 e
% x; w+ |- K% J printk(KERN_INFO "LED unregister!\n"); L; h- ^" k/ o1 h1 V5 g
}9 J. H$ Y& M# V* |
( W- e4 b' H, d/ I% h
module_init(led_platform_init);
( [/ S0 x& \/ z) i) c* Omodule_exit(led_platform_exit);
8 K5 I+ n" G; B0 W+ r' K
- h5 \/ {: l( a# O K3 J: y2 G, zMODULE_DESCRIPTION("Led platform driver");
) M: z7 Y: b9 V, d0 }% A# PMODULE_AUTHOR("Tronlong");
$ E0 Y2 @- X% `7 A/ ~% ]3 {MODULE_LICENSE("GPL");
0 f$ F% |# @( b! i; J" W# p6 x& ^/ J; G6 k5 }. `
|
|