|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( D* b2 X9 p5 a9 _5 |#include <linux/init.h>
" f" T5 T) B/ l6 X; Y8 K# `#include <linux/module.h>
: s) @8 e3 F" o* G# Y#include <linux/kernel.h>3 [, b+ m4 G; S+ P/ J
#include <linux/types.h>3 t0 H1 v8 }% J* u0 f) @
#include <linux/gpio.h>& r+ Z; [3 E3 A9 k0 v/ l$ N- j' y" q) I
#include <linux/leds.h>
o1 t J4 H u6 [* k#include <linux/platform_device.h>
$ a% s$ E A' w* Q4 A: |
; S1 W1 N; U. J; P7 ?8 k" X& p#include <asm/mach-types.h>: R( G6 O! ]1 C6 p! `$ e
#include <asm/mach/arch.h>
: u3 k0 y( g3 }#include <mach/da8xx.h>
. p6 H) ~4 x; P3 n2 n# O#include <mach/mux.h>( l+ r! r5 g( `; |0 m0 O; D& y3 M0 w, ]$ N
2 J* Y$ ?9 w1 p
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ R2 L' S5 u- V2 j2 H/ E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 a/ M0 `0 Y( U8 m3 }: b/ `( ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( t& ?3 _* B) L# \5 V# w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 G/ K# @! _5 n* M B6 {
/ g+ i/ i& p% ~- [1 J, c; h0 W/* assign the tl som board LED-GPIOs*/
7 Q. c6 Z0 ~: T+ tstatic const short da850_evm_tl_user_led_pins[] = {& b5 d' Q/ v0 } ?
/* These pins are definition at <mach/mux.h> file */% n; Z6 G+ V7 P/ G& _2 \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ h) b8 C% }4 P3 y, q7 K+ m% j
-1) `. i$ S, a& R n
};
( p T2 a- l7 [1 ~& o- B# t# T/ f. Z* [) T' }/ z+ ^# L2 I* l
static struct gpio_led da850_evm_tl_leds[] = {6 e7 ]. @# ?& ]2 `6 [( H
{/ ^: C3 x5 T( z' g# y6 Z
.active_low = 0,6 a; @, F! _3 Y
.gpio = DA850_USER_LED0,9 b G9 _0 s1 v. g
.name = "user_led0",5 Y' }- k" `8 C) G4 _
.default_trigger = "default-on",# d- U a( P- q' h/ U
},
* C/ `. `6 u; ], H {
2 W) x: L; A |) E5 B7 h .active_low = 0,# G. a8 S) r6 w, k9 q2 _
.gpio = DA850_USER_LED1,) ^+ _: f- i( i8 y7 b2 V
.name = "user_led1",
+ |4 L4 p) u! e# i8 V .default_trigger = "default-on",
/ F% C9 U4 ]1 M, _' M# L },
) I. n6 l$ C% t: F) V6 ]0 F {- S0 [& o. S' n$ l: J
.active_low = 0,' m( D) u# M' i& q7 K6 }* O
.gpio = DA850_USER_LED2,: N+ H8 S- s2 M& {1 j
.name = "user_led2",
1 E+ ^1 l6 e( `$ y .default_trigger = "default-on",1 ?7 d, K+ R; ? H
},; a# W% j. a5 ~) B e
{, K$ b) E4 T# g3 a
.active_low = 0,
. ]" t$ h* T3 g1 Q. @6 g+ ~& u .gpio = DA850_USER_LED3,: }: B, a6 o7 s- v" I( R4 u
.name = "user_led3",
" D6 T, ]) f( X6 D: F/ o/ w .default_trigger = "default-on",0 s0 `: X% i: Y2 M1 U
},' c' H% m4 z+ g1 N/ f3 h: C
};
, l2 l: H5 n' m1 l
6 ~8 y9 ~1 s" T7 I3 }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 F! e: G7 Z2 M; ]3 C5 h7 i .leds = da850_evm_tl_leds,: D1 X7 I) `3 O
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. E% l+ A) M1 f5 y, B" O* M, W, E};5 ~% ^" E% [. T$ Y
. }$ T6 K, ~* h: ^% v) ~
static void led_dev_release(struct device *dev)
. n% O- [. W3 }) ?3 k{- I+ e' v4 r$ n9 p0 V' ~9 T
};
% {! `, }# n! a2 \; @: T9 o0 f. w( S
static struct platform_device da850_evm_tl_leds_device = {
3 E2 x; t9 t% a! j7 T; N( z. b2 U: } .name = "leds-gpio",
) }5 t; N& P6 x6 c) B0 } .id = 1,! X% J% F+ v; @5 k- \, U
.dev = {
9 h* u, A5 [/ D5 {4 q7 H( v% ` .platform_data = &da850_evm_tl_leds_pdata,
) }5 u" t5 p0 t( C# i .release = led_dev_release,
8 s/ j3 U- l2 [: \ } Y, G: Q# q' }+ B9 j4 b2 b
};
# Y) }3 M2 P$ y: _2 P1 B4 W+ l; p5 w
static int __init led_platform_init(void)2 B+ h# A, W& d$ z# q# ]
{+ v3 H! _# e& f3 v, p
int ret;
* u" ?8 B) e/ v' h4 Z4 ]6 O#if 0
+ p3 u& U$ J0 c ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
W# f# {+ G* R7 J if (ret)
8 d- Q: q3 G, l6 J; [5 \" p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ M2 G. B4 T E. z( @ "%d\n", ret);) |8 F* ]; b2 T: e2 _2 ~" P1 n
#endif
+ }+ }: @' i8 E x/ C5 { ret = platform_device_register(&da850_evm_tl_leds_device);
7 R! w+ d# U5 x1 }/ p: a& n0 ? if (ret): g! {9 \( N( D7 f: U' E% S
pr_warning("Could not register som GPIO expander LEDS");
, j' q& N6 f0 b' D7 E else' @* {% q5 j E" ? Z3 L' ^
printk(KERN_INFO "LED register sucessful!\n");
! P& I# d! ~5 f" {8 d! w3 U! S, \+ u* m9 a! E
return ret;
! c; E/ X# T! o) R: f1 ?+ @}
' p$ g' F' s6 Y6 q1 Y) h b7 R' [
static void __exit led_platform_exit(void)
% u7 m7 u7 Z' ~+ ^- l{
6 a! h" d# j% v5 q, M platform_device_unregister(&da850_evm_tl_leds_device);
, h: i2 N# ?6 P1 l& Z& m) D1 v) w( `6 x, q7 p* Y
printk(KERN_INFO "LED unregister!\n");
+ ~% _2 Z' o( g/ E1 {( t# Q}
; l( {) a* `& Y7 A; G# O
/ N5 X. d$ C/ F) X$ Umodule_init(led_platform_init);- E/ n5 m$ S9 c+ X3 m7 W
module_exit(led_platform_exit);+ c" Y* X9 }! a7 ]
& i/ R' j. w* ~8 W4 J' {
MODULE_DESCRIPTION("Led platform driver");# m; H& }# U9 F0 r
MODULE_AUTHOR("Tronlong");
: W6 s1 C* i' i0 C _+ Z- [MODULE_LICENSE("GPL");3 o) z; g d1 k6 w# ~3 ]2 F5 ]
/ k5 Z4 a4 e2 Y" h- H
|
|