|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 b7 |3 d& z5 X( d, [- A. {: o#include <linux/init.h>% Y3 R! a. ~) ]1 L% ^
#include <linux/module.h>
8 I0 D$ r1 |* g( A/ G; v#include <linux/kernel.h>
6 R1 M8 s3 D+ K$ j3 o9 M#include <linux/types.h>/ E6 z+ M9 ]/ k& |$ }! N* n, W
#include <linux/gpio.h>5 }: C6 q: m( o* K+ a9 l3 Z% K
#include <linux/leds.h>* b2 {$ ~- F" ]0 h2 h
#include <linux/platform_device.h>
# i+ E* R8 N! x5 W% s; B) _5 c. Y( R: P4 O
#include <asm/mach-types.h>& P9 I3 y3 D. v8 o3 M9 N; F" m: k
#include <asm/mach/arch.h> t/ S. o- d9 B6 ?& f A& g
#include <mach/da8xx.h>1 O7 C' b0 _# E5 o; |
#include <mach/mux.h>/ N9 D& z9 t% W
) a) N" M. R# S; W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* Q1 W; U2 ~2 [" K
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ n8 e) @- i* e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ O) R+ e/ l( n( J5 l8 X9 X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* ^2 S& B+ n% y8 {3 d
2 i/ Z. `% h* i8 ]' z# a( u
/* assign the tl som board LED-GPIOs*/& g. o+ H& U- G2 r8 s, O
static const short da850_evm_tl_user_led_pins[] = {/ m* k' y( u; e) |/ e
/* These pins are definition at <mach/mux.h> file */
4 L ^, l* U7 A/ h: u1 v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; G+ s! ^- F2 ]8 z/ y8 H
-1
7 S4 @0 B1 }# Q" }: ?) S};
5 F& W& t; N, Z
/ X1 t) j) v5 n% Y. Bstatic struct gpio_led da850_evm_tl_leds[] = {6 R" e/ ?# L, n$ T' h; r! J
{
, k/ ]- e( n5 X- k/ T; | B .active_low = 0,( j% r! [0 N- Q: e* r9 c/ }
.gpio = DA850_USER_LED0,
* e/ H3 R" c' A .name = "user_led0",( ^" e7 @) Z4 Q, p/ r% [ y
.default_trigger = "default-on",9 A4 n7 o; J# @/ r# h; N# E
},8 T& ]$ O5 h. e$ G
{5 p. b9 ^- j% k1 R- f. _7 Y# k
.active_low = 0,2 V9 ?" G* a( n% x
.gpio = DA850_USER_LED1,: O6 c1 ?' U6 p$ i B
.name = "user_led1",
# _! ^- M' T, p' f8 S# O .default_trigger = "default-on",
- X- ~: l% f" N+ { },3 Q5 U& U. ]& K. @: c0 d8 f
{& h3 }( d e3 V
.active_low = 0,
" M$ ?6 A& q( ^# G+ J. Z' M. D .gpio = DA850_USER_LED2,) e- F W8 W& i4 t
.name = "user_led2",
4 \2 J9 z: [7 z2 Y .default_trigger = "default-on",
. i' T1 \# a6 N( @0 v },
) b% R# K1 m& l6 c( M {
8 j4 [$ ?( ~' @ .active_low = 0,! v# N- l4 `# X3 ^) m9 ]" ?. f
.gpio = DA850_USER_LED3,
$ K8 L* U8 h: H$ a1 |1 h .name = "user_led3",
/ k. z) `* G. c5 {- C .default_trigger = "default-on",: |' S9 I# t4 [9 J
},
$ e Z7 X7 t$ Q9 Q$ K( B! ]};! p: a0 `; C9 X
1 ~/ [) j1 I1 x K8 j1 _+ @7 k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 d: S6 x, J5 W( ~; I7 C3 Y .leds = da850_evm_tl_leds,: h7 A8 x: a6 o4 ]9 }* V
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 M% k' |5 m% k9 A! D+ D$ H' M
};& a2 ]: Z- L8 g- r8 s Q* S2 }8 ^
0 K# i8 p% S8 V4 [/ K: [# L8 S
static void led_dev_release(struct device *dev)
& s) U' E3 t3 J0 ^. n: K. Q; b{; N- [; U. w) i7 L; [; T n4 R# l
};
1 T% l; X: ~! _' c9 s
, {' I" U: J2 p; ^9 g, Estatic struct platform_device da850_evm_tl_leds_device = {
, _! K& e8 T# r, O .name = "leds-gpio",
, S* v* H; N& d+ { .id = 1,, v: G( \' c9 H% T( C7 l( h$ ]
.dev = {! {- p$ @ i( K( h5 G+ r8 q
.platform_data = &da850_evm_tl_leds_pdata,* P* T2 l0 m* l
.release = led_dev_release,7 G* E6 V" H2 K l$ W" B: X
}5 j5 L* Z' B" C' Q/ `( C
};
" U2 Z9 i6 k* ]; i: E0 b) y5 S1 z/ t$ Q
static int __init led_platform_init(void)
, X2 m9 `6 d2 A$ |; ?' y{
6 b; F. \# _4 p' p int ret;
5 s+ b ]5 p, C+ w: O# z5 d+ t6 V# x& q. r#if 0+ k4 C o4 b5 [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" M# E o1 R0 U
if (ret)
) J: a7 w2 d3 A( J7 S- F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( @2 V7 F, @+ L6 v2 [ "%d\n", ret);
: R. o* [/ X7 _0 M! R8 t#endif
6 b9 b0 K6 l4 X8 p" H( [ ret = platform_device_register(&da850_evm_tl_leds_device);1 Q8 l- Q8 F4 b7 F
if (ret)
( ]$ u! j; k1 m* O pr_warning("Could not register som GPIO expander LEDS");3 u- T6 `$ p( g8 E+ a7 E( i& X
else
9 o$ Q, x! s3 |* H! G2 O5 A% C printk(KERN_INFO "LED register sucessful!\n");) M/ t/ g0 ~" Y/ q) C% i9 p
8 t7 R* r* c, D; \- R return ret;0 E3 z$ U8 }. m
}
3 c( R _5 N# l! S, M1 X! p T* X6 O7 d% P+ w+ a
static void __exit led_platform_exit(void)
* ^) _. w+ `0 V7 @{
# V, l3 [: S4 I$ w) u n2 d5 m" I/ [& k platform_device_unregister(&da850_evm_tl_leds_device);4 ~5 x* W4 _' `7 [" h* u
5 }4 O: d Z1 b3 b+ v, E1 C# p printk(KERN_INFO "LED unregister!\n");
" x, N O! C$ p' V+ ]}
. Q; M7 \" w# Z1 B+ u- w/ _* Z3 w8 \+ z0 F/ V {, C' H
module_init(led_platform_init);
8 x, t: _; `) X; V4 S" o$ @$ amodule_exit(led_platform_exit);
9 z; r; O4 k. ^! g- E1 P8 o, }% N) S3 y
MODULE_DESCRIPTION("Led platform driver");
1 D6 l9 ?1 b3 z% F+ O2 DMODULE_AUTHOR("Tronlong");
8 t+ D1 p0 J5 f! y/ r" x- BMODULE_LICENSE("GPL");0 P- J0 H3 N6 T8 ]( S% O" S0 ?( f
& h, q! ]$ \% O; @" ~, o& s
|
|