|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 f, m9 \# K3 N! a- A#include <linux/init.h>
* F4 B9 F6 h2 y, f q- h#include <linux/module.h>
. H8 W, c4 ~" T#include <linux/kernel.h>
" x P# D. m+ l4 J; E/ C, G#include <linux/types.h>
/ T6 P) w: M; R8 q& I3 n#include <linux/gpio.h>
* l, b9 [& _* G" r1 [$ _2 o#include <linux/leds.h>
1 `" O3 p% M2 O) ^0 \1 R5 @. p. b#include <linux/platform_device.h>
5 R, Q+ r; T' Y5 G, @: U/ V
, L0 T5 S' Y2 y1 {& c4 I#include <asm/mach-types.h>9 {. T2 J0 R' V7 e( V1 O
#include <asm/mach/arch.h>
9 m# \$ f! x2 C! p; I#include <mach/da8xx.h> ^9 G2 q/ `5 _0 s) \- U
#include <mach/mux.h>
8 n# M2 n+ O# C. Y% ]
: k3 R6 S9 Y, K, ^! I6 M#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 Z. r) U3 L# \* G5 ~" @0 |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 t8 H7 K6 I# V% X8 q5 b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 X3 o4 V2 F2 ^ H4 m4 z+ O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% `+ G: i( S K+ f
: \+ l+ m( c: s& f+ l' `1 }
/* assign the tl som board LED-GPIOs*/6 A0 A9 e/ c- U
static const short da850_evm_tl_user_led_pins[] = {
$ l- ?3 M4 |5 o( S6 t, e/ X /* These pins are definition at <mach/mux.h> file */, N7 d1 D9 `3 Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% ~ S3 d @/ x5 e: p -1
9 E: g# @' ~) \$ L};
- j& j! D# Y3 b4 X
/ `3 K" l4 S& \4 G( M# qstatic struct gpio_led da850_evm_tl_leds[] = {
% y. ^, d" l* T! ^ {4 O7 I. D4 X6 v1 g4 Z7 x: B
.active_low = 0,# ?2 R) a# Z) a/ F. M3 G1 t
.gpio = DA850_USER_LED0,
' b6 _( B+ O) U' Q% w6 M .name = "user_led0",* \$ e8 N; \. B; d, X$ A
.default_trigger = "default-on",
8 v6 f# s- r# T+ d- g' J& F },
# a- }9 o4 K0 Z' a1 a {
y7 W+ _; l0 f .active_low = 0,
5 r2 U3 E& f8 j1 [' Y7 |+ Q& M .gpio = DA850_USER_LED1,
/ E8 I3 o5 e) T0 J- ?2 o/ H$ w .name = "user_led1",
, z! u1 N5 Y- C, H/ \, V .default_trigger = "default-on",
x8 b/ l0 |+ a E7 ^) n; B/ R },
6 B- A9 v- @4 e( z6 @5 D {
2 H( M8 H) d/ b9 B7 H .active_low = 0,
, t; m: X$ t% F/ q .gpio = DA850_USER_LED2,. T& w' a2 b4 X" ?
.name = "user_led2",
. O k$ ?% V/ A& A* b( {" e .default_trigger = "default-on",
2 u5 z: y+ ~7 Y' e a4 q1 ?. h },
8 m8 T7 v; e% y3 z+ T {: H; @" u% w6 w, G7 q Z- l
.active_low = 0,
' A" D; Q/ r8 D& G8 @ .gpio = DA850_USER_LED3,, X' f5 l5 h$ e& @
.name = "user_led3",. f1 l5 U2 P- o; N" Z
.default_trigger = "default-on",
0 a7 D0 f& l$ T2 b1 o/ R: ~ },
! C$ M7 G2 a: Z% {};
! B, t9 ~4 Z A3 K- F' I, n# c. W$ G; M+ l; b2 s, q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* w; j2 N* _( `: l& x3 y1 O' c
.leds = da850_evm_tl_leds,/ H8 d0 e2 Y, m! G3 R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ O2 Q3 [7 {4 D2 D
};
7 U4 o9 R1 X" Y( n; }
9 T6 X% E2 b# Q- v6 ~( Tstatic void led_dev_release(struct device *dev)% a$ D0 _& B/ G! ^9 |
{* Z/ s/ B0 E- }$ F' y
};
; K6 c* A, ^- u: u0 l# H- @: e. D6 K) A1 V3 v) [
static struct platform_device da850_evm_tl_leds_device = {
" Z4 \) c0 e# @ .name = "leds-gpio",0 l3 z8 ?7 @5 [# J y+ Y8 r, O( p
.id = 1,8 A/ \# J, n5 o8 \( s- o
.dev = {1 R2 {/ u2 G/ V8 h. u, f
.platform_data = &da850_evm_tl_leds_pdata,# ]# q( F- }( [
.release = led_dev_release,; E* @: ]3 k" J( [8 P
}
4 w$ i: d* F3 l+ `, o% j};
X! Y- I& @ o/ r) [0 ]
0 p5 Q# f! t( [, c, ~static int __init led_platform_init(void)$ Y$ r% Z4 m4 D
{
6 s" S- X; W6 N. m0 _( @ int ret;
, r5 b$ T3 ?' J; ]$ R/ |) }2 M7 R" a#if 0
# r4 r, a! ?& K& E0 F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 b: v1 o$ _1 s* W2 V3 O: z
if (ret)
8 t; Y8 T- a( n* E3 b- X6 x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- C$ ~- k+ u: s+ T1 S' D* k3 z# L1 S
"%d\n", ret);5 i b! Z" O: j, C% s6 {# K* B
#endif& v( l/ b: Y3 }
ret = platform_device_register(&da850_evm_tl_leds_device);
9 P5 ^/ e+ _1 k2 z6 s) \% a2 T5 @ if (ret)2 o2 d/ h- w* V# ~) Z/ s
pr_warning("Could not register som GPIO expander LEDS");
) Y+ ]: i4 O* A) p: h2 `# T5 g, d& v else1 i6 r& f% ^1 O6 G3 p+ A( b
printk(KERN_INFO "LED register sucessful!\n");
3 X! O; C$ K" K# j) v1 H' Q$ g
9 z% W# Z( f( d d return ret;
* [8 U; w5 a! \1 K8 Y}
1 ?/ k) H f1 x: d% G% u+ ]5 r$ x6 P; ^4 r
static void __exit led_platform_exit(void)
. \! _% M7 v5 u- W{& e1 b3 W. Y3 d* B/ \% l
platform_device_unregister(&da850_evm_tl_leds_device);8 H8 q8 K7 T7 P3 m& Z5 m5 F5 t
& g1 x/ b; K' n8 b3 h4 i" ] printk(KERN_INFO "LED unregister!\n");5 {$ L& _5 g9 |% [
}' u$ t# ^5 n% A. i$ k$ W# I0 n. p
+ \7 ~3 B" z. h' _ ^module_init(led_platform_init);, h s3 I& ?2 Q+ ]
module_exit(led_platform_exit);3 F9 S/ M; j* r H5 Q- ]
' \. J% R# ~: Y1 ^( u" t
MODULE_DESCRIPTION("Led platform driver");1 s: _" I" `1 \1 o% E% q
MODULE_AUTHOR("Tronlong");4 V) q- u; d0 t) q. R4 U
MODULE_LICENSE("GPL");
* v9 D$ D1 Q3 {0 J. \: k3 X' o) R3 W" t n6 a/ G4 z
|
|