|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* z1 e1 X8 d3 L. P0 M, r+ x#include <linux/init.h>& R- T/ L$ Q/ B
#include <linux/module.h>$ ]( i, N% k0 |& x- i
#include <linux/kernel.h>* U' Z/ N0 m* ?- m6 u h
#include <linux/types.h>
* I) ?# k$ A8 z7 Y6 w#include <linux/gpio.h>
; X7 z5 {2 U) j4 }) ~+ z* |8 ]#include <linux/leds.h>
, T, D8 b; R* h; t7 S#include <linux/platform_device.h>
4 h1 H4 _; i3 `7 ^9 { V5 u: q' q r u: F4 G) O
#include <asm/mach-types.h>3 u8 w6 a b+ `) d: ~9 ~
#include <asm/mach/arch.h>1 N# a5 x* A% D/ `9 o; P) q
#include <mach/da8xx.h>
. L# \# |$ A7 O4 J#include <mach/mux.h>
7 {$ \+ @3 x* ^+ E6 z
+ L1 ]# N% ~) H0 N! v5 T: Z* p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: d9 v0 W3 W! c#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 h: @& a# V) c0 J) d
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 Y" ~: K% Z5 l8 @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ }7 s8 M- n) e* A* X5 R9 _1 q3 @& s B6 y4 N- g
/* assign the tl som board LED-GPIOs*/
9 k7 n2 L$ T/ W& kstatic const short da850_evm_tl_user_led_pins[] = {: x3 J2 q% M, y; {* o/ c
/* These pins are definition at <mach/mux.h> file */7 `% O6 o! R$ d5 }6 O$ M: j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
S( f& w+ s# O. r% K -17 [8 b' Y+ r+ \0 Y! e9 `
};
) v Y/ f2 V; q' e8 j' b. ]4 m* F- ^$ r- g! n% e/ X
static struct gpio_led da850_evm_tl_leds[] = {! N) M5 w" c* H1 H [" b" ?* v/ n
{
; h# s7 n# v/ Q2 H4 o; l2 n% A .active_low = 0,
3 Y( \5 \+ ^: { .gpio = DA850_USER_LED0,# c/ s- O/ S4 t, s/ K1 q5 ?
.name = "user_led0",# }, L) \9 R9 d) Z' P- p
.default_trigger = "default-on",
1 c# P O& w3 p0 O: j7 Q, S },
% W' t w0 Z' |/ R9 ` {8 V. o; v$ N8 I3 L
.active_low = 0,
# {- c/ }! o* ~2 q3 z O8 u .gpio = DA850_USER_LED1,$ a [9 g( G5 }" s8 q
.name = "user_led1",6 |! a5 m( z/ m% w
.default_trigger = "default-on",
7 f- L1 W. j% H },
. Y! Y4 x. M: Y# M {( _1 s; h7 s; c0 l
.active_low = 0,
) q$ \% P; r; u% v" | .gpio = DA850_USER_LED2,6 `6 u& x1 C7 M+ z* W# g( P
.name = "user_led2",
5 p$ d C, z: ~3 A& E, |9 ] .default_trigger = "default-on",; w4 M* D: ~2 o s* Q
},
4 a" B+ z' p2 p& ~; _ {
1 d: B! K7 i! [' T2 ` .active_low = 0,
# j' s* {1 I' M .gpio = DA850_USER_LED3,
; E! t+ h# G8 s Z1 d+ P .name = "user_led3",
$ b8 I5 ^: t, l$ M8 e1 N9 b .default_trigger = "default-on",1 {& s) E5 G" \% K) ?' a1 ?6 H: s
},
; V" @2 ]# H* J5 n4 l8 V# J5 F5 T4 I};! I; k7 p0 q! t7 U# V# S
% ?7 ?6 n1 Q8 O2 q2 O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! F* }6 d o1 m- P. y4 O/ J
.leds = da850_evm_tl_leds,
7 N4 x, i; G) j .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 B5 w2 ?) d. L0 |# B1 N$ W};$ d0 c+ ?# a% O
# F; k1 p. }2 G# R# g: {& z! Ystatic void led_dev_release(struct device *dev)& B7 z9 }; b3 i3 H% g' m
{$ i9 c% x8 T7 j* e( C" F* h4 \6 `
};
8 j" Q( M- U0 c9 _! C
3 ~ W& V" D; R3 u7 I: ystatic struct platform_device da850_evm_tl_leds_device = {
9 d8 V) M5 \: I$ G& _ .name = "leds-gpio",
5 R/ ^! V5 R" a* B+ P .id = 1,0 W& V1 }, z7 r! P% ^1 d. Q( v3 L
.dev = {! R. ]6 e& r* @8 [( q, `! ]
.platform_data = &da850_evm_tl_leds_pdata,, Q) }) l+ M' v8 Q8 S
.release = led_dev_release,
* a" ]* y% b# U; `" { }
' n- `" | {% i' t- V: L};
) N0 ~) f) Q3 E/ n
2 a0 D5 k o( h: K6 vstatic int __init led_platform_init(void)
. ], v/ \# |. `" b) @5 P8 v1 C. i{8 F3 E0 T6 W R/ x$ G6 R/ ?) j0 P
int ret;
5 M2 o) r! M0 r& A#if 0
# T' U+ S8 w. X+ f. G2 ]; ?5 b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: ?1 M, ` T6 A( c$ ~ if (ret)* _4 X1 ]0 X3 t1 H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( P! l" I) Z: N! v% g6 r1 c( [+ P* A! M& @ "%d\n", ret);, Q8 O E( e& {. x$ v
#endif! R! R. ~0 ?5 S0 @3 |$ n- Q
ret = platform_device_register(&da850_evm_tl_leds_device);! g3 {" }# \, E, O
if (ret)% a1 ]0 c+ p: q
pr_warning("Could not register som GPIO expander LEDS");
7 {' \& |; J- U3 s Q else
1 G7 A n3 ]9 V, {- q3 N& U6 ^ printk(KERN_INFO "LED register sucessful!\n");
- l- V3 f" M, p0 ^5 d K/ x+ J$ B4 D5 [7 d$ t# J+ e1 p6 }0 s
return ret;
: M9 r' S. B; D5 b}
9 o& a* R# M! T9 @ b
! _. t$ ]1 ~6 D0 {1 x: Qstatic void __exit led_platform_exit(void)8 y2 s9 D5 I' n/ d! G" ?
{, r/ J8 e1 `5 y- ]4 f
platform_device_unregister(&da850_evm_tl_leds_device);' [ @$ q& |9 E, D- D
7 F f' I# j! U- S+ c; s
printk(KERN_INFO "LED unregister!\n");1 \9 ^0 \% g5 K4 Y: x' v, i
}
, X0 S& _+ J5 V( E
5 A9 s3 l. @" S$ Pmodule_init(led_platform_init);
" z' x3 A0 H1 A0 B$ O7 Gmodule_exit(led_platform_exit); t7 O+ C0 C+ ~* x/ i
2 c" j" a! f: a' e; F L8 A3 S3 CMODULE_DESCRIPTION("Led platform driver");& f9 q3 F; I! [) W
MODULE_AUTHOR("Tronlong");
+ m3 W- x1 ]/ J/ W4 q. f1 } wMODULE_LICENSE("GPL");) g4 [/ d* u: i4 v
' S: S( P! H& r
|
|