|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' ^' N; |8 {* D: j9 M#include <linux/init.h>
6 \$ W4 k. t6 Q P& |/ C \#include <linux/module.h>* h4 D# {, T! N8 }' f; g
#include <linux/kernel.h>! c+ ~, T9 e9 G
#include <linux/types.h>
% G9 q p7 N. |2 g& |% q# T" p2 X#include <linux/gpio.h>
. K3 U: z! t8 p2 U9 ^#include <linux/leds.h>. D" T! _1 |2 l9 Z
#include <linux/platform_device.h>! Z; \0 q" y" z: L4 ?9 l: l
7 k" m p5 |/ J a/ f! ]
#include <asm/mach-types.h>9 _( x% _& U' r! {$ z8 d
#include <asm/mach/arch.h>
) q. `' O) c8 T4 o0 T' |( o#include <mach/da8xx.h>4 C1 @, ^7 n, R
#include <mach/mux.h>
# K# O. v# {( a$ U
. O4 ]+ X# Q! T9 E#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 B/ Y c0 Y% @0 @! \2 }# K
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( C) X7 \) z+ W/ W& Q6 M5 m% W( x
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); q- c/ ?1 L: Z; h! h% a! [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! o( x* D T+ S2 [# D
% f" w( T' @% }9 ^. P/* assign the tl som board LED-GPIOs*/9 b9 t/ E5 @1 u" |% i
static const short da850_evm_tl_user_led_pins[] = {! ?0 A1 I) X5 j! t4 g
/* These pins are definition at <mach/mux.h> file *// p0 f3 G1 e% e! V O
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, p1 l. j; J, g, _, @) C
-1
9 X% o: s4 y l2 V9 E1 u! _};' H5 {4 K9 F# w
6 `$ s; V) H% k
static struct gpio_led da850_evm_tl_leds[] = {
! _2 e1 T7 m5 S8 t% }4 h) Q8 v8 _6 w {; ?" Y. E, k5 q
.active_low = 0,
9 D& S1 v9 i3 l) S .gpio = DA850_USER_LED0,! D" ~( K9 q3 a* [
.name = "user_led0",7 n/ r& K- j( E- D$ d: ~4 \
.default_trigger = "default-on",
! @0 a+ V E7 z) e, Y! N% n },
2 L+ P5 s' A5 Q! C/ H: s {8 R( T$ \0 g7 ?# g8 X {
.active_low = 0,; h9 i. |/ d7 _" M1 @8 B) ~
.gpio = DA850_USER_LED1,! M& M; l" b. F. b2 s
.name = "user_led1",
/ G; o" y+ p+ |! G1 x4 u+ n .default_trigger = "default-on",
: O# L9 @2 B! Q },0 c' m' l: g8 g, D
{
& C0 A$ t+ x& ^# ?7 p# a .active_low = 0,
! L( Z1 H2 W* n .gpio = DA850_USER_LED2,
5 k$ n) j( A- W: o$ D .name = "user_led2",% U, T, |( l7 J% B* u5 U
.default_trigger = "default-on",' g! G3 t2 w3 r' }0 ^" h) \& z5 N
},) \; k2 ]- g* S; a% J% l
{4 Y0 k$ l: c7 ~1 Z
.active_low = 0,/ E+ ^+ Z3 M8 L9 x* M' [0 k
.gpio = DA850_USER_LED3,
' x" g4 {3 L. A( J* J7 y0 _! I .name = "user_led3",/ n) o' W% c" |: Q" d+ U: h
.default_trigger = "default-on",/ m, P. r" ?. w# f) y1 z r8 E
},
6 v% Y2 n0 ^5 q5 ^4 Q7 t};
- j* `9 O- p( d; ]
; l, J# Z$ `) I# D: q. J' @) bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 O: U" D; [+ d% w. M8 R; R
.leds = da850_evm_tl_leds,
' ]1 T$ h" N X$ L1 [5 M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! n* E3 ^! n+ E! v+ T" l
};& J, n9 C2 P5 ?( J4 K9 ]
4 }) S2 Q* X6 pstatic void led_dev_release(struct device *dev)
* X6 u/ g2 h# ~& N: `& A& J{
/ @" h7 ?% I! J: Y. B};; f! A* [0 p4 S0 w
7 c4 B. s6 ^9 z8 \6 k! c. V
static struct platform_device da850_evm_tl_leds_device = {
3 X; U/ }1 m7 y9 Q: r" i .name = "leds-gpio",2 A& x2 Y7 A" z2 L2 x/ K1 r! Y
.id = 1,
4 E8 L: G* S( _3 l' W: d* Q( V .dev = {
# Z+ Q* O& b t! j' ~7 Y" f' z4 e+ y .platform_data = &da850_evm_tl_leds_pdata,
6 B: \ N2 s) f+ G) ]! s' H .release = led_dev_release,
( g) O1 `, s: @6 v2 U; a }2 ~0 t4 N& U) P/ C% ]$ N0 J
};2 o4 }$ G \5 L& S. ^( G
- c. b8 p+ V* g/ C2 {1 I" astatic int __init led_platform_init(void)# P' d- D3 e7 f9 L1 T; c, U
{0 _3 m7 N V& G; D c
int ret;
9 Z# F6 E6 ~! G6 _ N6 v#if 0
; u4 Q/ e) j: a: m" B4 Z8 a1 _ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& v# _5 u+ p" D. D) S
if (ret)* a0 d1 b" r& }$ s. Y" t* Y2 X5 S
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 E2 U$ p. ^9 ~9 U4 z I
"%d\n", ret);7 s; z% y* M9 s2 f
#endif
% R* [/ ?" K) W2 a ret = platform_device_register(&da850_evm_tl_leds_device);
5 X$ G* \7 y5 A' y if (ret)! s" y1 C0 Y* g2 |
pr_warning("Could not register som GPIO expander LEDS");" l9 o$ H1 o% l
else) E; c" K6 }4 z/ i& f; X
printk(KERN_INFO "LED register sucessful!\n");5 E( o6 P# O# o# C0 \6 y. W) K" ?9 I
$ E f: S7 S# P return ret;
) D: @8 A x1 @* G/ H! u0 ]" L}
( W+ u5 ~' n, c6 o0 {7 M4 l) C& |$ G' ~& P0 ~. E y& G* |! V$ u' P$ [8 Z
static void __exit led_platform_exit(void)4 F- U+ e% M3 y- `( f* C/ h
{
# m3 A$ v, D/ t: e- I. v- r; ~6 z platform_device_unregister(&da850_evm_tl_leds_device);( _) j6 ^- d% G' G* f/ p& l
8 m, ]+ O0 e5 f8 s printk(KERN_INFO "LED unregister!\n");
& `4 _9 `2 j1 N( t: g7 c}
, c' Z& @7 }1 ~5 ~; E/ f
4 z4 H4 c- `' C* H) fmodule_init(led_platform_init);7 { @+ r2 z! K! [+ E
module_exit(led_platform_exit);
8 t# j- @/ I: W9 {% H
! M9 Y4 F0 \5 b, I: iMODULE_DESCRIPTION("Led platform driver");
7 k, D+ s# q7 n3 S; y G1 qMODULE_AUTHOR("Tronlong");
8 h+ J0 ]' v$ h( \% _MODULE_LICENSE("GPL");9 R. C2 L6 |7 o: ^$ b
: x: H( k' _/ y" }) ]+ m0 r7 [
|
|