|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 F) o" e6 j" l- [#include <linux/init.h>& n$ B, P) U5 y
#include <linux/module.h>- c! [7 r; x# q2 V. H
#include <linux/kernel.h>7 S* I8 V9 T) `( O4 {6 l
#include <linux/types.h>
8 V+ g2 k3 L" d! y6 z% b- {: A#include <linux/gpio.h>% M% _; g8 u" s5 {" p+ H9 m
#include <linux/leds.h>. u$ o# i% x6 F5 i. J2 J/ e0 G
#include <linux/platform_device.h>3 r8 h! B4 y" j8 m
4 K3 D" O* g6 O; J#include <asm/mach-types.h>
1 P% K3 |! R8 z8 o#include <asm/mach/arch.h>
) P( C d0 U- y$ B$ O( T4 ^4 Q#include <mach/da8xx.h>* L- \/ K+ y; E
#include <mach/mux.h>
& {& M( p8 y' P. A7 B% ]' M
3 b4 }8 T3 [* @( R8 }0 ~; o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); ]2 M" b- a9 m% c. N) L" e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" Q5 J( y( ]# o" n1 L& t
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 k1 _3 m/ ]! B. M/ T# }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, W+ b1 s( }1 n1 K4 X0 H( t
, Z( D' }! C+ s7 C) c$ }2 K/* assign the tl som board LED-GPIOs*/% [: v- [5 q: X7 F
static const short da850_evm_tl_user_led_pins[] = {9 H6 V$ w3 W2 G% m) b* a) Q: a
/* These pins are definition at <mach/mux.h> file */
% _; K5 H7 {3 e DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ d; m1 `% j$ N. H- Y1 q* e6 Z8 e -1
5 }) O& z; L$ {) G9 g2 A" o};& }/ m. d: n, E- L" J- ?5 `: Q
8 x0 Z4 o8 L* y2 o, l- D- y1 Y; J4 Cstatic struct gpio_led da850_evm_tl_leds[] = {- s) O0 b9 _3 [9 J$ ]# q6 w
{
" G2 f7 `5 q8 n; u) G$ [ .active_low = 0,
0 E5 y1 x$ k6 {8 Q% O! Y( v# _ .gpio = DA850_USER_LED0,+ i! l9 W: c9 K) j Q
.name = "user_led0",& h# S/ `, ?$ O$ D
.default_trigger = "default-on",5 j4 I/ ~: Z8 C
},
' j$ A# |2 f) Y. K% V {
4 B- X V7 e. a7 z# [; n# U .active_low = 0," D' M: ]: Q% N% b
.gpio = DA850_USER_LED1,+ Z) G5 @5 t( j1 C
.name = "user_led1",; ]3 `* ]1 P4 @) L; B0 K
.default_trigger = "default-on",! P3 D1 `3 E1 |. Y, y
}," Y: l* p' o1 P3 D0 I; R
{) A' g; C" u; M5 t' t; _. I5 }
.active_low = 0," s5 s( z) q8 `! ?: |
.gpio = DA850_USER_LED2,8 j* X7 B& z$ a# ~1 b
.name = "user_led2",% c# y- D7 h0 c$ a
.default_trigger = "default-on",
! a# M$ v/ N3 T) u },( @. m2 m0 F1 i0 ^9 D- T3 D5 [/ z. N9 j9 I
{
7 S: O* Q. y6 x$ Z$ R, x .active_low = 0,
" ]( o+ v( U$ l: z( w7 x .gpio = DA850_USER_LED3,
- @, U4 |$ T2 N! I .name = "user_led3",( H) I$ W; K5 i# V3 n; `. Z! g
.default_trigger = "default-on",2 n6 E# _; f' ^/ z
},
' W" S/ R- J6 u+ N4 m};
3 P& n/ G1 H) E5 i2 \7 b6 T- ~
- }9 T e) I b# S% F9 q/ ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 d* ~* A+ N# _6 f+ m6 ~; D& @3 [& ^6 o .leds = da850_evm_tl_leds,
+ e% Q3 N( ~# I1 d; U, X) w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' p# _3 }, e9 y* ^% D$ T+ @};) \7 t6 q5 ^" z
$ u' C, u2 y" t0 ~
static void led_dev_release(struct device *dev)
8 }, s% ?- d% v$ w{) _% U. c6 |( F- L N
};
0 O+ P' ]0 F7 U: A& X
: W% ?$ [+ z! P3 K5 K4 o8 ustatic struct platform_device da850_evm_tl_leds_device = {
3 d `) c6 r2 { .name = "leds-gpio",
, G/ X w' B4 n4 Z8 K .id = 1,
0 I2 E. A0 }) P9 i- m! s+ K! r .dev = {
0 _# |+ ^7 \7 @$ Z .platform_data = &da850_evm_tl_leds_pdata,
1 @$ N5 b* s2 ?* G; ^ .release = led_dev_release,( U$ l* V5 q. t& b4 w) [ M
}
$ Q' a8 B) y4 s& b* @ }};
/ G. b7 m& w5 y1 _: t& C9 S$ ^1 i; X: e1 f+ [0 b
static int __init led_platform_init(void)' F- `: Q( |. M: h& C
{; E: a( h: J3 G
int ret;: i1 ?3 S# Y1 r0 ~
#if 0
$ g6 B) E' Q8 u0 r4 [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 L% }+ v6 C/ p4 Q- \* g if (ret)5 E4 j) {' w9 ^: D6 S5 ?7 Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" ^# _* {6 l5 z( j
"%d\n", ret);( U! c! P0 v* b* M, `; ?
#endif8 {" O: u$ z0 X; ]% i: Q' ]
ret = platform_device_register(&da850_evm_tl_leds_device);
& r1 F9 c* Y7 E/ \8 s if (ret)
; h5 R# W% O( I/ p! A v, }4 L! k pr_warning("Could not register som GPIO expander LEDS");: x/ X) a# e- v! N
else2 q) M5 K0 j; A- i+ E; g/ J
printk(KERN_INFO "LED register sucessful!\n");7 E0 Y; [$ p; I |* g
a! N8 K. I- T, X8 U Z2 s
return ret;
9 I6 K! k0 T! Y. ~+ X}
4 L c" ?. h3 X5 n: {2 @) N% n) Y* x9 a9 q+ t8 q* R3 }1 i) B# L
static void __exit led_platform_exit(void)
1 W* x9 }7 w& H3 _) X+ K{" l0 s( o y9 t0 N
platform_device_unregister(&da850_evm_tl_leds_device);* _6 e1 h4 R$ m* k ?! Y$ H
, \5 \' _8 a l* R4 g6 S printk(KERN_INFO "LED unregister!\n");+ W. h- E8 c. V
}
. Y9 v5 W* k0 y, X4 _* R( |
1 {4 }, F9 y8 V7 N1 l3 H' Lmodule_init(led_platform_init);# W, _2 D2 y' J3 B0 X7 B6 x, b# t0 W
module_exit(led_platform_exit);4 d Y$ F/ B9 O# S& ^
* I$ [( i6 m2 ~' Q) R% V0 p) f" @MODULE_DESCRIPTION("Led platform driver");
: j7 K2 C* p+ \4 C% n$ v5 `" ~0 CMODULE_AUTHOR("Tronlong");6 \0 k6 m8 v9 O- w# [
MODULE_LICENSE("GPL");7 y7 K. ]6 Q; S/ g: A
+ g9 u7 } j1 }4 V0 F |
|