|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! b+ E/ D; I. K; p1 b0 K7 h
#include <linux/init.h>
" X5 }; F, C6 S/ S- V#include <linux/module.h>
' [- \7 r" X" M3 W% {) V#include <linux/kernel.h>: p6 l; e9 q0 p& w
#include <linux/types.h>. h' M" `, g7 w% B2 N4 g5 S
#include <linux/gpio.h>
# r$ }% E2 t6 U$ j: P8 Q#include <linux/leds.h>& u5 X9 H) H% [: ?8 q8 y$ N: T
#include <linux/platform_device.h>
- A- M; y t/ j+ j/ m
; K, d3 g; b/ Z% b#include <asm/mach-types.h>
$ ]1 F0 W" ]1 f4 k#include <asm/mach/arch.h>
) O$ G3 G/ V5 k+ l#include <mach/da8xx.h>! v7 V; k0 B2 ~! E( m/ F
#include <mach/mux.h>2 N% E7 A: v5 O( M, r
5 K% n6 x! P" X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ ? l! j0 u5 W& y1 e+ f$ M
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& ^ H: _& e3 x4 W
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 j0 E+ |# t ~/ |#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 h4 p6 [8 Z7 F; u& F2 A0 M
+ W# S1 V. P6 u) z/* assign the tl som board LED-GPIOs*/$ K2 A; P9 r) R
static const short da850_evm_tl_user_led_pins[] = {
; @7 F8 o$ F' v /* These pins are definition at <mach/mux.h> file */! L3 ?$ C4 y9 O
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 w7 W7 q+ b# {
-10 ?8 G% q* V3 C1 Y2 f
};
7 @9 w; B3 d5 f$ A0 Y
Z" S% [0 H- q2 T* dstatic struct gpio_led da850_evm_tl_leds[] = {
! U6 x" h4 w* w3 L {4 Q! c5 r1 `( s: z
.active_low = 0,
- _% g+ i# g; S .gpio = DA850_USER_LED0,
4 L1 r Z6 w- G" m .name = "user_led0",
+ y9 e: k8 C& ?' d+ g .default_trigger = "default-on",- g5 ]! u u J& |% m- P
},1 [% t l+ [, x6 ^( d. G- `" L
{
) y$ U1 c0 _* A; h, d .active_low = 0,
* d [( M( c% v( U; h% a- n .gpio = DA850_USER_LED1,
' y- W# t8 F- D. k! ?# Q( H7 k .name = "user_led1",
0 K f6 p1 Q, Z% a# C4 N% \' k3 k .default_trigger = "default-on",& C4 A, \5 X3 J! n8 e P/ w
},4 \$ p: H' h: ?) X4 S) h
{* }1 @: }3 T' L4 }5 G% ]/ s$ F' x( v
.active_low = 0,
; @- g% ~3 p1 y6 r m5 E9 k .gpio = DA850_USER_LED2,
9 Z+ I3 W* w A$ x. J1 C* ` .name = "user_led2",5 b5 G( |+ u, g( E
.default_trigger = "default-on",
7 v q! d7 m" I! ?6 F3 }; V },
# {. `4 l7 e5 ~' M5 g7 s" | {% p, n3 G( Y# E1 D0 O- b' M
.active_low = 0,
: n- T1 F# ?0 J+ x; ^) Y .gpio = DA850_USER_LED3,( M" T. _8 o. @; W
.name = "user_led3",
2 G7 v0 u6 c2 \5 ` .default_trigger = "default-on",
/ E% ]: i5 [* l- k. s) `. M' t },
4 `" q% B* N. ~+ b! u8 B};
. {6 C9 `, d- m. R0 [4 B. B/ B4 e/ |. @2 j) ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 t% E& T$ b1 ` E3 }9 W
.leds = da850_evm_tl_leds,
9 j9 z7 c" |+ y1 u4 i0 \- h$ E; ] .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& R. m- G" O& E' T
};( `" \# ]0 G5 ~( ^$ `
: z$ t% ~6 A0 a* J- G5 C! [% m
static void led_dev_release(struct device *dev)1 I: A1 u1 `% J! R( ~
{
/ I1 C. Y( s k5 \};
$ N& H: f) i } O' g! a0 N W2 f' R
static struct platform_device da850_evm_tl_leds_device = {4 e" B7 }* ~0 U" M. Z
.name = "leds-gpio",: X0 p8 Z; t+ z7 |' a2 x; F" a
.id = 1,
7 X/ V. n+ L! k- t8 D$ }+ n+ G .dev = {
6 ~- J3 w; C0 ^( c: S2 K4 }' M .platform_data = &da850_evm_tl_leds_pdata,
, }7 H; a6 S/ ]& A) c0 K O, y g .release = led_dev_release,
1 P" R& C3 `) N; `, a# p- T' c& } }
: k3 W9 a# T* @" j1 h};
( @- L2 Y; N2 W# U P) l4 S7 ~- `7 D" I9 \, n
static int __init led_platform_init(void)3 r; N: M; A. e! y) m6 S* S9 C; u
{
; h6 S% i( o2 h' q int ret;
" l9 ?+ W2 F: R n8 ]#if 0
' P, x/ n/ w; x: P ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
A y# o, B. b# \; B if (ret)
1 B7 f, g2 k. q1 d1 m9 l$ g' } pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 ^+ D3 o" b* R6 Y "%d\n", ret);
+ \% Y) i; R0 h#endif; Y! Y- A) ?, W4 s4 b; }7 n' U
ret = platform_device_register(&da850_evm_tl_leds_device);: t; g2 B1 n0 ~
if (ret). c g& C0 Y+ i4 Q" @
pr_warning("Could not register som GPIO expander LEDS");
) q2 I) j. ^. v( k5 W else
7 Z7 P# t- w5 B/ y printk(KERN_INFO "LED register sucessful!\n");
7 t# E+ K$ E) \) n9 ~7 n$ z. x1 [9 h+ }% z; t( o% Z/ |& W5 f8 G
return ret;
0 e9 a5 j, _2 U/ A- v, r}) f; `! T* S, z0 r6 \0 [: t
7 P2 E$ X* r: Z/ Tstatic void __exit led_platform_exit(void)3 n1 }) O x0 i/ C( s8 ~% N
{1 R% `5 W% \$ E5 ~. q; P
platform_device_unregister(&da850_evm_tl_leds_device);
) Q# @5 O2 X" t3 _/ m- j2 `; [6 o- h6 E
printk(KERN_INFO "LED unregister!\n");3 n1 T6 T% K) p4 @
}
* y8 |5 u' `! f. K- N L7 e5 G, g* b& P2 V @
module_init(led_platform_init);2 ?. X R# C, w1 v. j$ k
module_exit(led_platform_exit);7 n! T; c- Y% O6 w
+ J) J2 ~7 q6 k( @$ j
MODULE_DESCRIPTION("Led platform driver"); E+ e( Q% d6 [1 H$ n; U7 [ N
MODULE_AUTHOR("Tronlong");
6 D) b% G& x* F: G, lMODULE_LICENSE("GPL");
f2 s; X& t- ^7 P6 p6 t1 |" d E4 v- e7 A0 h
|
|