|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 N+ h$ k( Y5 _8 k; t
#include <linux/init.h>
" ?6 k$ s& ~! C# u6 `- }" A8 u0 k#include <linux/module.h>
3 j a, @" t. _, {/ o6 v#include <linux/kernel.h>- [: L9 _9 Y8 N y8 N
#include <linux/types.h>
% ]1 p5 S/ N2 e0 u0 _4 Y#include <linux/gpio.h>$ e7 C3 ^7 j0 K# _& ^
#include <linux/leds.h>" Y2 o* P- i0 V. F: K2 O. U4 `
#include <linux/platform_device.h>) i' i7 a! a* \8 D9 h4 p4 h, g
) D3 z$ m! @% d7 M#include <asm/mach-types.h>
3 K' [( m% ]; y. M- z#include <asm/mach/arch.h> |3 k' O# _' G: C
#include <mach/da8xx.h>
. l0 ^1 Z8 G" x! s) M#include <mach/mux.h>
6 C. d6 b/ ~2 H- _( P( e5 @* W
% v) D; f9 ]; G5 |4 U! w ?/ E#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 x' `% g8 [ P9 `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 I. Z' L$ V2 Z$ O$ y8 ^0 @7 F
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% `* T/ n( J- ] E0 A: X: ^; {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: ]7 j9 x- M6 |3 ^/ e1 p) u! b# Q) k6 K0 E6 _2 Z
/* assign the tl som board LED-GPIOs*/7 k- G( v- V0 K6 r1 W, J
static const short da850_evm_tl_user_led_pins[] = { u6 G% `# p+ ~' I! Q3 @: m2 f* J
/* These pins are definition at <mach/mux.h> file */2 M3 l- O p+ ~. N- n/ W$ t7 _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, U/ E- U7 X9 I* R8 q( U4 z
-1+ R8 h. I- t( h8 Y- k
};& m; s5 ?# f4 a/ L# f* K
/ D; k0 A; s7 }! p" p5 r8 Sstatic struct gpio_led da850_evm_tl_leds[] = {) Y) x3 n1 g2 |/ c! j; L
{+ z, Y9 M% E7 a- o' O$ f+ U
.active_low = 0,
, G- y7 G8 g$ r6 r" T7 u .gpio = DA850_USER_LED0," ^9 _2 E3 i; v9 T# J
.name = "user_led0", i8 `0 h) c+ T" @( I v& @
.default_trigger = "default-on",
- }+ j9 a5 P% B+ ~1 {2 `+ B b }, b# ?2 K2 D# L' \9 z4 s4 D1 |
{
4 t. o0 A' g' L .active_low = 0,
2 G# z; Y/ B* g0 | .gpio = DA850_USER_LED1,
/ W/ I0 c5 r" }9 i/ b .name = "user_led1",4 ~5 Z9 }3 p7 N$ L5 J. T) p1 Y
.default_trigger = "default-on",$ H! z. M- n' d/ ^3 Y3 F
},+ s2 n0 s5 l9 n; N' y ^- M/ P% ?
{4 g% J/ a" [9 g/ a2 q8 N) u9 s
.active_low = 0,
1 i" G1 Y- P& j6 P& l* i .gpio = DA850_USER_LED2,' ?) G2 {: \5 r$ I* t P/ R7 [
.name = "user_led2",! n& J! \, p" ~, l8 S a! \6 A
.default_trigger = "default-on",
; e/ U: E, i8 e( f },; z1 M7 X0 p. E# u2 t: Y
{# t8 o1 }9 [7 v& h) |$ \9 z; b
.active_low = 0,5 c ?' {# n& v5 i6 I
.gpio = DA850_USER_LED3,
2 ?5 h- b9 B- X* t$ ~0 P# V+ V% Q .name = "user_led3",& z! W7 u8 U! y4 g: x5 G' Y
.default_trigger = "default-on",$ o: ~1 |* G( ~8 T& H& p
},5 P6 i$ x4 u: `5 a! e. e- z
};& Y# M; ?" {0 O) r, `! I
. A6 f; G- t+ H1 h( ]( h; O7 i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# @9 c1 X0 D9 H" G1 x4 P .leds = da850_evm_tl_leds,
$ I/ i6 Z* _# C) i; A/ G. L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 B. I) q4 [7 A7 ^% T% E
};. [2 \8 V" }8 R+ F) _# s
9 `3 [* i Q: ?7 g$ ?
static void led_dev_release(struct device *dev)
. F2 C" B8 E: ~0 ^{
# m& \) j1 r6 Q1 J};& U0 B+ _: Y2 K) E6 h
3 K' ` l1 ^: W; W8 G4 O( _static struct platform_device da850_evm_tl_leds_device = {
/ \1 n& k9 J/ b5 d6 s s9 O .name = "leds-gpio",, i: W& f, ~5 F- }( A* Q5 |- W8 L( c
.id = 1,
3 l+ `' K& Q5 H: A# I- I7 {' x .dev = {
! a) E: ]3 V' f4 D% P0 s" X+ K) R .platform_data = &da850_evm_tl_leds_pdata,
6 i! j; X: q- d" q% U' [0 a& A .release = led_dev_release,
$ n5 U% H7 @9 ] }
% q b( b: a A! ^% I! t};
! `3 [9 S" q& e( ?: v9 o5 {7 `2 d0 b# v& J; Q
static int __init led_platform_init(void)- I2 | K0 f! x
{7 `1 X( w) S$ l# @4 ~ K. z
int ret;
) F2 ]( L% j9 L3 t+ u0 ]. W#if 0
5 P6 u& b: B/ ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 F. [5 }2 v3 h6 Q3 F3 P if (ret)
! N; e, w0 y9 } K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" u% x W7 f% F, e "%d\n", ret);
% F1 C! T- I+ F$ Q1 M: t#endif$ N& t8 |( l4 v; m7 X& ~
ret = platform_device_register(&da850_evm_tl_leds_device);
) ^$ e* {/ N5 I. J, i+ Y/ E if (ret). s5 u$ n! \ x3 u2 k
pr_warning("Could not register som GPIO expander LEDS");
/ W" F6 Q% a2 i" b6 S+ }; W9 t else3 q2 ~5 {# d( H8 I, x
printk(KERN_INFO "LED register sucessful!\n");
4 w5 _% T/ Z* v, O
! Z. g3 M7 |2 i- r return ret;+ G+ h1 k% k @% [2 ~- i
}8 V- P! s. w" o
3 K* z" V3 ?5 Fstatic void __exit led_platform_exit(void)
$ F- l C! a9 ?. d5 x{
9 Q Q$ ~+ ~) ^( u9 B4 ]0 N# Z platform_device_unregister(&da850_evm_tl_leds_device);
5 ^5 H1 |7 p( L# u$ ?& ^
5 P+ Z2 S3 f3 w# `2 B& L% |' X printk(KERN_INFO "LED unregister!\n");
* x; ^) n* r( H}
( }5 c. p, S2 t* k& t v
4 J) U/ v! R* q- L# _0 mmodule_init(led_platform_init);
- ]: S) d7 u- E" _+ pmodule_exit(led_platform_exit);* r" T- A( @* L( p9 E
1 W/ q7 ?- i J( V; `( b+ p
MODULE_DESCRIPTION("Led platform driver");
3 q7 e) `% s0 b; {MODULE_AUTHOR("Tronlong");
; d3 _; l9 W6 O I$ X5 D! vMODULE_LICENSE("GPL");
/ T4 ]' S! P2 F6 p% u, u# [# q, y
- r: s7 c: V" Q4 |1 t: D |
|