|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 R: L3 F# f$ a8 \#include <linux/init.h># i% L( W+ I8 U- O, G; S
#include <linux/module.h>, t$ B$ L# b2 E
#include <linux/kernel.h>
9 F' Q \2 w3 P#include <linux/types.h>
; [% `4 l6 D% v, b: n#include <linux/gpio.h>
; Y1 a# P( `- V- r3 O% X#include <linux/leds.h>6 h4 b' e7 s& J+ Z( O }3 O
#include <linux/platform_device.h>
4 }$ _$ Z6 E* C4 n; O' s' t0 }8 M/ t8 H8 O/ K
#include <asm/mach-types.h>* S6 F- p) z1 { p5 c5 P( e
#include <asm/mach/arch.h>. A6 H8 `: z' L* H! p( K% `
#include <mach/da8xx.h># C- G9 w$ f- X, x" |. X
#include <mach/mux.h>3 T: _+ i) }* v% u8 w+ b9 h3 m8 J
: g5 F- x3 |1 R4 n' X" J" ]9 n& X L#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- W8 z. e1 H2 _% [7 {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 N% T1 f# V: I. q3 v' Z2 j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) z+ W/ Y8 K) {) L9 { {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 A0 }, Y2 i3 l6 `) I: k- L
8 i, \/ z$ }5 c5 n2 z
/* assign the tl som board LED-GPIOs*/7 q" r0 ~) N3 p. f; Y p6 L Y. W K: ^
static const short da850_evm_tl_user_led_pins[] = {
3 K9 R* [( U+ s5 j$ z/ q /* These pins are definition at <mach/mux.h> file */. O. T( u$ b% t+ X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 x+ l1 P9 D9 _% H' b& C S
-1/ x; \$ @8 j, @# |7 @0 [, e
};' }7 S6 f# F$ q
! Y7 N9 x& ?3 o% U" L/ F2 ?7 k8 y
static struct gpio_led da850_evm_tl_leds[] = {+ |: L6 q' a( @
{
: u( c8 e) w# r; {$ x .active_low = 0,
V( i, q! f* Z. T8 z, o+ D' s! [7 M .gpio = DA850_USER_LED0,& J5 n/ V# q3 C) K# F& Z) \
.name = "user_led0",! g9 c6 O% A8 i5 D2 ^ v& ?
.default_trigger = "default-on"," z8 b5 M- a' W' n
},3 s3 z3 |4 D# I5 r3 c4 R2 h
{9 L- S+ `! R3 @1 o4 e3 X
.active_low = 0,
: @- Z' t, @) c6 l. P+ Y& l3 g .gpio = DA850_USER_LED1,
$ C1 [9 u7 s0 h+ Z& v" } .name = "user_led1",% a j* Q/ s& F4 m
.default_trigger = "default-on",
# L6 y9 C5 _# G1 H1 b/ o; R0 p9 J },
, \; `+ ?5 W0 ]' i {+ Y9 w3 T; S x) C& a
.active_low = 0,: i0 y* l4 h% A7 b/ c, T
.gpio = DA850_USER_LED2,1 S6 t: I& Y; T* }! \/ M% N
.name = "user_led2",+ D+ S1 g! S6 Q: M
.default_trigger = "default-on",+ p0 s- v9 T+ e
},. k8 n. c" F# N/ t" Q z
{8 S9 y, |% m: ~5 F
.active_low = 0,
* a' E; Y; Y4 s" d3 b. `* u .gpio = DA850_USER_LED3,
- y8 ]8 R/ y5 u, P .name = "user_led3",0 I+ k% j' K- k9 ^8 v
.default_trigger = "default-on",
: O9 \0 X% O9 ^; o; f( e },! c& i# t9 W4 n0 |
};- r9 |9 Y y) e
! s, b; @ w# f5 B6 Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; E3 f6 F7 e* D! k- t# I .leds = da850_evm_tl_leds,
5 ?5 L r' d6 i/ V .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, f4 a6 l# O: {9 b! a R5 e4 F, T
};5 A6 }) t; v3 Z1 F3 F
5 [, W2 P' e5 L& T! w# w* u% P
static void led_dev_release(struct device *dev)
( g8 w5 ]; u9 K& D2 ?{7 i [8 C; j$ k( G
};
: s' h8 W0 E& E8 T. F$ s2 A F2 V9 P5 B' d P2 p
static struct platform_device da850_evm_tl_leds_device = {, G( t) \7 Z4 X, M; L
.name = "leds-gpio",2 B8 n1 H; T2 k' a: ? o% D: q
.id = 1,$ H5 K( Z( |3 M. [3 J( m t
.dev = {* S5 R# { T! ~2 V$ {
.platform_data = &da850_evm_tl_leds_pdata,
+ R. V Q7 t& b) z1 s .release = led_dev_release,
. h! ^8 }4 c/ ^$ ^! j% W }
1 t$ d6 C; T+ @% u};
( @* V- X, A1 v! V8 `8 P N3 f( l+ L: J
static int __init led_platform_init(void), u, v$ F! a, ^4 q% y
{. z7 s9 T7 M+ p+ I W
int ret;
( i% m! k* \9 u2 Z1 N#if 0$ f3 e" v9 @; I: c
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- D1 P8 {: ~1 V
if (ret)
) u. c; J, w9 z+ j( P# z1 h pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" K. S0 F' C: s/ G
"%d\n", ret);
/ z8 ]* G; L- P6 r! [) V#endif
5 G3 Z7 F- z. g1 O! A ret = platform_device_register(&da850_evm_tl_leds_device);1 v# Y" b0 y' H+ K# j( ]
if (ret)4 T+ N1 ~" r, W
pr_warning("Could not register som GPIO expander LEDS");
" ~4 J# h0 ~% z) ~ else' }# g1 A0 l' U
printk(KERN_INFO "LED register sucessful!\n");
% M$ y4 I( P" B8 F4 s! c- A: |& s! o% K9 [0 g' B- }
return ret;
7 w/ C0 c( f4 e4 }8 x7 T c1 q+ e ^" t}" p/ b7 t* d) l
7 D$ T `& L# Z' l9 Ustatic void __exit led_platform_exit(void)0 O* c) @$ n( A2 r4 R
{
9 E R) {6 H p, L3 n9 p1 W platform_device_unregister(&da850_evm_tl_leds_device); X8 _. q4 D, a6 e) o* i
* x8 A6 e+ {: ^0 y* z
printk(KERN_INFO "LED unregister!\n");) ?& e9 `9 s; E4 u6 g
}
: y+ `8 e9 f# P" b R- `3 |
. `6 r, n+ L t% ~' h5 s' zmodule_init(led_platform_init);
+ S0 o6 o- \1 r% Z" I+ n! E5 Cmodule_exit(led_platform_exit);- i2 O8 q9 h# q' [4 u
. N: u6 j) `6 g$ {7 ]$ ~, Z. YMODULE_DESCRIPTION("Led platform driver");& ~ R( S8 S) R. e7 Z" t9 V6 n
MODULE_AUTHOR("Tronlong");2 Q) i5 @1 A x2 A. \
MODULE_LICENSE("GPL");
3 u6 V1 B, B0 @3 ]! y8 k
Y o3 D( R: j+ O& t |
|