|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ F& I7 t6 ]8 x9 i6 v! p) ]5 ?! L1 H
#include <linux/init.h>
3 F; z% d; e8 ], r" a5 B+ U/ n#include <linux/module.h>) r. v" S Z1 D7 x2 U; r
#include <linux/kernel.h>8 X# R2 e+ R/ w0 F. C3 N5 q U$ D
#include <linux/types.h>
" P! E8 Z6 x2 o#include <linux/gpio.h>4 _- T) L0 w+ Q0 `+ V5 w
#include <linux/leds.h>& D6 W P1 A2 n8 E2 K
#include <linux/platform_device.h>
* c* a: q0 g3 e0 }; f/ S
k) F4 A5 _5 f#include <asm/mach-types.h>. o( i# C3 g' y, ~1 s
#include <asm/mach/arch.h>' G9 w7 T v/ R9 _ O# v
#include <mach/da8xx.h>
; Z. L; o8 ?5 w8 m# P' V/ P#include <mach/mux.h>! X% ]2 {" v' d9 D
6 _, p# v2 V. \& C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 w" i: B7 }. Q# o+ n$ U! j6 H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; K9 w' a! X$ y Q6 Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) ^, H( p- r1 Q8 g#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 M) o7 X e' \0 Q) F& T) n# h9 J5 }+ ]
/* assign the tl som board LED-GPIOs*/9 M% W3 h1 |; a: G' @% E
static const short da850_evm_tl_user_led_pins[] = {
- F' |+ b- f5 a4 |# K( Z /* These pins are definition at <mach/mux.h> file */3 u! s4 M8 @& M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 v2 K# o+ ^; P9 k -1
9 @# e" a9 ]9 V/ {! |};8 G) V& U1 f) p* P8 ^
9 m1 D) H$ r C2 U. `4 G6 k% N+ mstatic struct gpio_led da850_evm_tl_leds[] = {
* l3 G( t* p2 X9 X! V( J6 ^ T {
6 i- W) E) }/ w& q .active_low = 0,
; \5 f/ f; Q- {/ b- x2 k. S .gpio = DA850_USER_LED0,6 X% y+ _$ }3 _; `
.name = "user_led0",
Q5 [" ~% D$ v5 |2 Z/ C .default_trigger = "default-on",4 r8 u: I1 X z# E" B: v4 ~ x# L
},
3 \. w- u) K4 N) M- T- l7 b3 y {
' e9 A$ ^ q; i7 q" \ .active_low = 0,
u+ i0 V# i) i/ b# [0 a .gpio = DA850_USER_LED1,
' R, u$ v# Z% x3 _+ [8 W$ f .name = "user_led1",' B- d& U3 \; M8 K4 k8 r/ K
.default_trigger = "default-on",$ R3 D$ U. k$ U/ l# T
},2 m% q, _8 A2 j! F$ \6 H
{
/ Z- C" ~" N1 q+ J! A .active_low = 0,7 N O4 V0 s, p# t+ l# K( l8 y# L
.gpio = DA850_USER_LED2,7 I% z) Q$ [! N- B! ~
.name = "user_led2",
& T+ N$ T4 y( l' o .default_trigger = "default-on",& t6 Y6 s3 c8 ~% _$ x' l" S% a! p
},
a9 Y4 a/ _, c3 N( E" { b {
3 G' b5 R; W1 F, m* u! C+ `, O5 }7 J .active_low = 0,
: I- P) T& B: ?0 J .gpio = DA850_USER_LED3,
5 j5 h7 i' P# j/ s8 D9 p .name = "user_led3",
' X2 \! y7 g, M; z. s .default_trigger = "default-on",
* F, T( H; W5 x$ S" w },
. h9 A1 ]+ C9 D' g8 S6 X4 s};
+ G: ^6 G0 ^- _. r$ x& r% G! u1 D j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 e! ]0 f i6 U5 {$ Q6 z8 A! b .leds = da850_evm_tl_leds,
; B0 O7 F' j7 V7 [$ ?5 [ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 v! e# [. n" Q4 A};
3 E& t: } d$ d+ i7 F* ?/ X9 r1 I0 b4 _
static void led_dev_release(struct device *dev)' T( ^: B' t7 J) A" C
{
1 F6 f- V5 p# _};
1 y4 s+ A S$ c- I3 B4 x! Y
8 E1 R* q Q: h+ O5 Lstatic struct platform_device da850_evm_tl_leds_device = {* `- S. f! x( k0 ~( @$ K
.name = "leds-gpio",& G9 w6 ]3 W2 \) g) j* Q
.id = 1,
. a3 i ^ r3 c1 w; W4 N% K .dev = {% l6 {9 u; q8 t" c7 E) R- N# P
.platform_data = &da850_evm_tl_leds_pdata,
: @' Z6 {+ y" o4 b .release = led_dev_release,+ @0 v4 I9 ?/ P" u% q8 _
}3 u8 ~1 D2 p, |) G R# w4 e: f* X, y
};6 ^- i! e4 p' ^, C* N1 Y' ?2 J0 J
6 F+ H/ {- N; s) V9 s- j
static int __init led_platform_init(void)
8 ?/ o4 ?8 H6 K, a0 v& m{9 Y) D. H. E8 R5 R6 M
int ret;
; E, G) J' ~6 b) |+ \+ U#if 0
+ a/ R( G" M3 j4 l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ F C( T# {: x: e/ P7 Q0 O
if (ret) V" ^; g# w5 O8 ` `7 K3 ]
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( S) ~2 A# f: D6 I6 m! J* E "%d\n", ret);" x" D8 C. G# k% i0 x v: c
#endif
% H5 O, ~" n. Y! Y7 [6 r! i ret = platform_device_register(&da850_evm_tl_leds_device);
( n+ w/ Z. p/ u/ G/ o/ x if (ret)
: r( B, j3 w' G k5 p7 T pr_warning("Could not register som GPIO expander LEDS");
# G' P' q7 o- c5 l' I. ? else
^5 ?8 T5 N$ h7 K printk(KERN_INFO "LED register sucessful!\n");% J! R1 q3 P0 z) d( M3 p
8 G$ y; u$ V; [4 ?9 I! Y return ret;
. B7 D/ H! }. J; Q& m% \}9 n; |3 i& r$ L: Z
$ w$ `- U; M D8 nstatic void __exit led_platform_exit(void)
& Y; v+ d4 L$ A f* q; f9 U{
3 d9 }* E8 u2 i' j% Z platform_device_unregister(&da850_evm_tl_leds_device);/ ?- l& F; M0 e( l* F1 A! t1 R- l
& J8 d y( x" n! ` s
printk(KERN_INFO "LED unregister!\n");
y# u3 I2 B1 W4 C}
( {3 Q) e! B2 w' Q2 L
6 }4 b- |+ p+ J) p+ Fmodule_init(led_platform_init);; e! @5 [: E K, u
module_exit(led_platform_exit);
4 ?8 z' P: E/ H
+ c( F2 O# H) I. e6 MMODULE_DESCRIPTION("Led platform driver");6 K$ r; `0 Z+ W( C8 U/ K" y
MODULE_AUTHOR("Tronlong");1 w3 G" l3 f8 F, {6 S
MODULE_LICENSE("GPL");
; W& O: v0 @! K( ~
& k2 o6 U( N1 \, d. o; x5 }2 O |
|