|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# m5 E" `) X1 f#include <linux/init.h>8 H8 \4 a/ ~$ Q. N
#include <linux/module.h>% d' y8 ]. r; }# T' s" j7 |& v
#include <linux/kernel.h>
! Y1 d3 |1 B0 J3 Y6 P4 X# `0 v#include <linux/types.h>
$ J, T* S1 I. \$ \#include <linux/gpio.h>: L' l7 l* |, i
#include <linux/leds.h>
9 \# j" H8 B& V: m0 i& ^8 w#include <linux/platform_device.h>
. V: q& c( ~' h$ e
, l E! M8 N/ }$ P( r#include <asm/mach-types.h>
( s) j1 ?" U5 _; M$ ~5 P#include <asm/mach/arch.h>9 I2 A; J, h) _6 f) h
#include <mach/da8xx.h>9 U- L3 \( Q8 ^9 S* U& C: I
#include <mach/mux.h>2 I- f ~: P" c2 k2 ^& {/ Z; e
c5 {2 A1 \1 |( u# j t
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 v& ]1 r# x% b9 z7 O, e% G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& V* N9 p* ?/ m; o. W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& L/ q: }; |( y3 U7 F0 j#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" x$ J: C( y3 m, \* i
$ A) G$ Q" r9 ^) G
/* assign the tl som board LED-GPIOs*/( ^0 |5 J0 l3 ~8 [2 `3 ^
static const short da850_evm_tl_user_led_pins[] = {+ Q1 {& y; ]) ]* n
/* These pins are definition at <mach/mux.h> file */
$ o$ ?: s: y4 f. k9 ^0 J7 ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ `+ D- [2 R% `9 {, ]1 H! X
-1
: ]1 `' {8 C7 g6 m9 J$ k8 z/ ]4 m! X};# u# ?" V `) D6 |5 o0 i
1 z. b! l% R3 a0 B3 J$ j; J8 N; I+ V
static struct gpio_led da850_evm_tl_leds[] = {# n, Q4 \5 R! B+ Y( p
{
4 Z8 }0 f2 V, x' n0 _9 D% m2 H .active_low = 0,
4 M6 | k- P8 r+ t6 x" p .gpio = DA850_USER_LED0,
0 h9 S6 s3 x- R# A ^: H .name = "user_led0",
' j4 D& V! J0 R4 S! ^: M+ e .default_trigger = "default-on",
3 ]) t; l3 o" M' O- P3 b }," v1 J* D$ k2 ?9 U2 U
{) l( X( j) j" o3 l4 @6 O
.active_low = 0,
7 x' p4 H# O* x* \: @ .gpio = DA850_USER_LED1,
# g7 n+ p/ E9 G .name = "user_led1",+ E3 [, h L- Z: m: O/ r$ c6 c0 W a
.default_trigger = "default-on",
# I, u# D) R4 [2 P" @7 D5 n3 C },
5 X: U/ q6 b! J {
) ~' N6 Y }5 N+ _6 t; }0 w1 o6 ~ .active_low = 0,4 s' s, I9 y8 ^' r/ X, @
.gpio = DA850_USER_LED2,) c# | H3 X |! X
.name = "user_led2",& V! C- d2 p/ z
.default_trigger = "default-on",
0 O' F) ~6 _, X- X, _; i },
5 M: j }" a+ j {
$ [/ B \5 D6 A4 l b# h .active_low = 0,
- i. ~! p. f% A9 P& J .gpio = DA850_USER_LED3,
: U8 i4 {" o4 F+ v% ~" P: S T .name = "user_led3",
" O7 N, O; H0 o .default_trigger = "default-on",# U3 Z; s% A9 t+ `. N
},9 b- l/ j+ L9 A, ]: f0 j6 ]
};- ~6 X* \$ w5 ~4 h. X
; H5 k% x) [2 ^2 j8 U8 K8 ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 E' c0 {; o; L. C' g7 j
.leds = da850_evm_tl_leds,
' w1 c/ ]7 `& K8 ]8 O8 I7 H$ n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* O/ S% }9 n+ c& L5 J};
( a& ?& L$ R6 n, a/ s4 p1 Q& Y1 E' Z: U: }* s7 l2 A \. l* ?, w
static void led_dev_release(struct device *dev)
1 W. h1 y( F; j: ^6 ~* Q! @: b$ x4 H( y{
3 [* q# W, b. [/ T};
" M3 M# f. a( z0 ^. u
) v. Q* Z* T# b- astatic struct platform_device da850_evm_tl_leds_device = {1 v c9 h! M8 Z6 k/ n# A! ]
.name = "leds-gpio",
/ e; u# a' ~1 s .id = 1,& d0 v c, B0 c) F; a, Q
.dev = {: v" d- |0 {, Q( o* ^
.platform_data = &da850_evm_tl_leds_pdata,
+ Z7 g& N' [- ^9 r: q' k .release = led_dev_release,
& [7 `$ y$ x I2 w$ e }
$ P2 h' p0 k3 l( C D1 s};
) ]$ }: S, b/ C& h$ e1 ^6 w
9 h" {" [; }% ]" X1 T% astatic int __init led_platform_init(void)
# W+ U% e E7 }0 Y{% y6 J2 X3 p/ L% p3 _# r
int ret;
' L$ d9 f) f5 n( m4 ]- ?# n#if 0. |0 l& W0 w0 v( g' H% Q7 q5 X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 n/ B8 k1 O) N$ d5 C+ @/ c* t if (ret)2 S! \+ h( @( r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 z* g' S$ }" o& `: E "%d\n", ret);7 f1 f9 G; L, \0 M9 [0 e
#endif
6 a0 A) o5 r+ G, u ret = platform_device_register(&da850_evm_tl_leds_device);
; S3 i& S3 b% a if (ret)# S% {- W+ q7 i, H* L4 j: P' |6 l$ g
pr_warning("Could not register som GPIO expander LEDS");# b B$ D& I6 j9 Y: O
else9 B, e7 [& B1 E7 Z% E @- b. ?' v
printk(KERN_INFO "LED register sucessful!\n");; g2 a* G) V' E, _; \% l
+ V, B) P6 F/ G* }/ @
return ret;" C+ }( w8 A( O, w
}
8 G& B* A0 @! |% A& V/ D+ q! V! m4 o3 L+ j5 | Q& u9 F( T
static void __exit led_platform_exit(void)
; n, L5 p/ g+ A; C, v7 ]/ b{
( p0 b4 ?0 V6 X, W8 Q# X platform_device_unregister(&da850_evm_tl_leds_device);
! Z* T4 Q5 d7 B- g
: s- |: O& ^. D- r( b/ F printk(KERN_INFO "LED unregister!\n");4 t; E/ Q) L0 y ~& q( }9 u _
}. }8 i0 ]: y. n3 b* X6 u8 K7 z; V( N
/ } b* m: v9 y" P, I" [ ?
module_init(led_platform_init);
9 w7 \, s$ b, {8 Y- Q6 r2 umodule_exit(led_platform_exit);
* ?$ M, u8 g2 E5 \, u" v3 ~ ]0 z$ d; x
- `6 z- W7 i$ T8 V& AMODULE_DESCRIPTION("Led platform driver");
8 I% u& _/ B3 T1 I8 ~; j, z6 e9 _% vMODULE_AUTHOR("Tronlong");
$ m4 W/ }, R, G: ^MODULE_LICENSE("GPL");
! j% z+ m: n5 @8 H
0 l* g( ]( B7 ?5 T |
|