|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 R( X% W8 X$ e! _' h
#include <linux/init.h>% _* Q# C- b; v. D7 g/ u: r
#include <linux/module.h>
& V* t0 }, S j6 }3 y! m#include <linux/kernel.h>% S5 M% J% F' v( |
#include <linux/types.h>
" ?& ^) P' k9 A- O% Z/ Q; E#include <linux/gpio.h>
+ m( b" `" z& ~3 Z; |#include <linux/leds.h>
' v: U2 C: R$ A. s#include <linux/platform_device.h>, x, L$ ?* u0 a) O$ g2 L
) M8 \1 |. z: w9 }#include <asm/mach-types.h>) M4 T6 S/ l& C* Q# A6 ~
#include <asm/mach/arch.h>- O$ O0 l: L2 S2 B1 `5 k
#include <mach/da8xx.h>; j: E& p. l! N
#include <mach/mux.h>' n% Q7 K2 |" I- r) {6 [
+ H" s* K4 \( @. W6 p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( }8 w6 ?" f5 a0 r+ M q0 h" O7 ?7 D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" E* m* e' n7 P
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 ^8 `0 q. d& s; ?. L. @! E% j
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 |6 g5 j2 w( ]- O, k- O* R! t! M+ M5 Q" e6 H* b6 W1 k
/* assign the tl som board LED-GPIOs*/ F3 D: H, q( L4 d' [ ?- r- t
static const short da850_evm_tl_user_led_pins[] = {
% d$ e5 @3 q4 p/ J /* These pins are definition at <mach/mux.h> file */
0 U" J5 C8 W5 Q- p) n+ M h1 T" J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 w6 N$ E5 v3 w! G8 L" x -1
% c {" y q4 ^4 J$ s& D5 v5 R, H% p};/ N# a$ s; x# d. a: [' W' [
. B7 Q' y: y4 i' y+ A+ kstatic struct gpio_led da850_evm_tl_leds[] = {. } |2 U E" _4 N( N" i$ _
{
* F# l9 T! b ~$ p, H+ y m# q9 W .active_low = 0,4 n: W# o8 Q* i: W! d1 h! d
.gpio = DA850_USER_LED0,
U% r: ^! ?# w9 V4 Y/ E' F .name = "user_led0",
% h J4 D) S4 e; a8 r. H$ Z6 I .default_trigger = "default-on",' d6 ^4 y1 B0 f0 `
},
5 a+ q& i7 _3 j- M( L7 F' s/ B9 {* C {4 Q6 [5 |3 s5 n. W
.active_low = 0,- s/ ^) t, E' X" f; X2 I2 y
.gpio = DA850_USER_LED1,. @9 g, v' W D7 E6 ~
.name = "user_led1",
% O+ O3 h" {& Q% g. x! _ .default_trigger = "default-on",. V$ M* v: Y0 u$ H# B2 a
},
: r! n: ]; |5 J. ~ {6 x, Z0 c- U7 V% @/ T/ l
.active_low = 0,- N1 x0 Q/ J, R; ? ?% D! l
.gpio = DA850_USER_LED2,5 G' I$ j# E$ n1 n7 x; h5 o. d
.name = "user_led2"," u% H8 @8 H) u8 k
.default_trigger = "default-on",
! {: j0 j9 D/ G: n/ f& r },
$ q/ K8 [' c a0 f, U9 u' \0 [9 O! g {6 c$ r# \6 I4 }# @7 _
.active_low = 0,
' @- e- F) p8 b3 L* F- W .gpio = DA850_USER_LED3, Q2 n: W; E. ?) v
.name = "user_led3",
: G& m# }: t, c9 ?; p. N8 T4 _, A .default_trigger = "default-on",
1 ]* C- h N6 e& ]$ a3 J },
$ g8 y9 L/ \9 _7 M4 f4 w};3 B) O0 v5 q1 d9 ]
8 q% D$ ]8 \" {. N2 B! Q S, xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 ^5 g* f. f3 \* V/ x. g .leds = da850_evm_tl_leds,
& U0 V `" r% g* x/ r" H: k) u! c, l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( s. d" c {- P};- S+ D1 T% J1 }+ e; s/ Y, E
( _" I" ~; s9 N/ w) z" r3 I. nstatic void led_dev_release(struct device *dev)
. G" A8 @% n4 w! s. [5 J{2 |& C! `- }% o- m
};/ [# r0 i0 e8 U
8 C4 v9 x8 e; f: x2 B: j6 f
static struct platform_device da850_evm_tl_leds_device = {
a* s1 _% @- s2 d; B. G9 X .name = "leds-gpio",8 b e0 k, g' V
.id = 1,9 v/ n+ p" J# ~2 u* A2 R
.dev = {
' d; e9 O5 S u' ] .platform_data = &da850_evm_tl_leds_pdata," u4 h+ k) j! e/ @( p
.release = led_dev_release,; B6 ?7 G! K3 P0 w% o0 w
}
! P* Y+ b6 X( m+ d};
4 D* i2 r% I" }) C' d0 {9 t# d
9 ]9 F3 r4 K, l% ]& g2 Hstatic int __init led_platform_init(void)
$ Q) U% G& k/ [! a4 \{
/ T9 E7 P7 B, t: {8 O6 J( H int ret;
# d- c* k; X7 U6 n) S6 I#if 0
" L" x( B9 A2 u8 T$ _8 f7 e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ c6 C8 Z9 I) \0 a) e% L) m
if (ret)8 R& |: F: A5 e# r; H; i
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ @7 s& n5 W3 b- X: a( t. c8 w
"%d\n", ret);$ M& t+ V$ E9 |0 {
#endif
0 f2 n l* N- h0 w# n3 S. u ret = platform_device_register(&da850_evm_tl_leds_device);
# g7 ?+ M% K4 ?6 b; c. [7 M" x+ g: \ if (ret)0 y# _: t% I' F# U; W. Y
pr_warning("Could not register som GPIO expander LEDS");
: f' _( @& p5 o8 T3 k( a- c else
6 R' }$ C. y/ m3 R printk(KERN_INFO "LED register sucessful!\n");
3 Z; z- L' ]5 C# i& }8 A. Z! {: i
U" _( }9 `: |8 }# j( x return ret;+ Q+ O7 D( l! S; L& V% J+ O
}
7 T9 ^' {9 R1 K. F
/ n, n/ U7 N1 A2 q5 tstatic void __exit led_platform_exit(void)
% J, o3 V9 |: r' s& `{3 S3 d5 z% ~- T, y, l
platform_device_unregister(&da850_evm_tl_leds_device);: e- u$ u; g! n4 R
7 }$ X `; {, ` printk(KERN_INFO "LED unregister!\n");; Y% Y; W0 A; _- N. j
}$ L" g& t$ @# T. m: V) i$ Z+ T' ?
& g6 q( Q* ~6 Z% m8 K& K- O) Z
module_init(led_platform_init);" G$ F8 u* u* {( b; s
module_exit(led_platform_exit);* }' C* r1 s4 h) Q( Y3 W8 I) h
& \" H, s$ e; O, p, WMODULE_DESCRIPTION("Led platform driver");
. e$ t8 _: }4 ?, C" |MODULE_AUTHOR("Tronlong");
8 g4 o3 u+ Z. b7 ~: a: FMODULE_LICENSE("GPL");) h+ ]- F3 e# k, g& V
9 ^0 H; x* j- w T! B |
|