|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ o# p5 d& Q9 X( S$ G+ {
#include <linux/init.h>
3 K- o8 S% }" U B7 T) B#include <linux/module.h>: k7 I; l U. k/ p. E% T
#include <linux/kernel.h>
# G" X& J. V0 t5 }+ t" |#include <linux/types.h>
0 P9 D; g- c0 N% l" @1 u5 L#include <linux/gpio.h>) v% f8 _, }. S4 c
#include <linux/leds.h>! I5 g! ?% U0 x5 S: B3 N0 M3 Y
#include <linux/platform_device.h>
1 L1 t& J/ b" i" l2 r8 a7 r: v6 O$ X8 u- O
#include <asm/mach-types.h>: g3 g2 t8 ^' G6 r0 ~$ @( r
#include <asm/mach/arch.h>
6 `" A5 I U$ Q. u( c$ h2 K#include <mach/da8xx.h> C! D V- w9 O" |" ?
#include <mach/mux.h>
7 J" _8 Z* I& N5 @; r* u4 z5 c3 L4 V& G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 q( Z7 z$ N' G* [#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ p( h3 u |' I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 D& @- Z% a; V#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 S9 d+ [% P$ L: O/ `1 j
) [; L8 B4 @. J6 h6 N1 ]/* assign the tl som board LED-GPIOs*/& B- l! b! b8 v% U( _# N n; |
static const short da850_evm_tl_user_led_pins[] = {, h* Q( j T1 d) {( R" ]' O
/* These pins are definition at <mach/mux.h> file */ ~. W4 w4 B6 y0 h4 x& S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 @" b* \0 E: _* X -1
/ \: X) _) ?/ `};/ ?6 J. F1 m/ x. H, b, G0 G/ m
7 B& v2 n2 v2 |& P( A
static struct gpio_led da850_evm_tl_leds[] = {
- G- u7 t: X) h2 T. c {+ T S9 L1 u3 v
.active_low = 0,8 M w- B! W5 x, M1 m i9 z+ s6 i7 R
.gpio = DA850_USER_LED0,( T) t* e6 s! P" G& Q
.name = "user_led0",( z; W# Y; F0 B$ W; l. b* l- W
.default_trigger = "default-on",: t( F% `+ m+ A/ B
},
6 `- U3 W c# K _, Z D4 ?7 O% ^ {) S2 W$ W% h5 w. S
.active_low = 0,
5 i; c. p$ l p2 p# t+ ?3 J .gpio = DA850_USER_LED1,- a* D6 ~* W7 q* @: L/ Z
.name = "user_led1",
5 r0 v1 ?2 H+ V5 w1 E* ?) R, H .default_trigger = "default-on",
8 {$ e" B& r) z0 ~9 ?4 t7 n },4 p: T3 I* ~8 O$ t# A r0 R& v$ W
{
( j/ _/ a8 f8 S .active_low = 0,, _; T- P" p1 s; {8 I1 C
.gpio = DA850_USER_LED2,
: Z+ V9 K/ t9 { .name = "user_led2",1 X3 j: s! T, C. ]. Z
.default_trigger = "default-on",+ K( n& ]# Q) l; h
},
- U/ `8 ` M+ @/ g {
$ b! L+ {) \9 M+ f d, m .active_low = 0,
. ^2 @9 t# S2 L2 K .gpio = DA850_USER_LED3,+ X" Q t! Y) [
.name = "user_led3",. [4 W( N7 d% c
.default_trigger = "default-on",4 w* ?0 r* { \/ d; D
},
% F" k5 J( S# Y};8 m7 }: t- M8 b O( I, R+ E
0 ]5 s0 Y9 P; B9 ?# q/ H' Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 }) m. Y7 q2 @4 Q! t4 }4 u .leds = da850_evm_tl_leds,1 Z; F0 C H8 B" u. Q/ `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- a. ^4 t7 w1 P};" V( W7 U- r2 |+ i) i) T
3 u+ U! T6 H* |static void led_dev_release(struct device *dev)0 ^' l R# Y5 d8 D
{
- W+ L' L4 W1 d r# t};
# l! W% y G% A. `, V5 v+ q) m
/ S+ P3 J2 T+ b; j4 zstatic struct platform_device da850_evm_tl_leds_device = {: O% B9 j' `# n6 a
.name = "leds-gpio",
3 L/ }: P) Q( a .id = 1,
3 U3 U3 L( a3 d8 x4 w4 E# z0 X .dev = {
* O/ B; i2 y3 ~ .platform_data = &da850_evm_tl_leds_pdata,1 V. F9 } m1 g4 p5 b, W
.release = led_dev_release,
% j6 v( V6 ~ {8 E: ] }
. ~0 O% D* K- R( ?};
$ e8 ]- _( b- t7 ?6 R) n; R1 r& k* n% h! w; `4 T
static int __init led_platform_init(void)8 m( r: P" [: p$ a3 G( Y
{
8 r, {$ Q8 g( } C4 Z0 |" {/ m% ] int ret;" J' z7 X6 u. T6 f+ \* c
#if 0! f# m9 g6 m1 t4 k9 S+ ~+ t5 N
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 g1 {# G% B6 w7 ~3 R( g
if (ret)- l1 A5 t. h, y, ^$ K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; j6 N' Q( b; _ x
"%d\n", ret);# H) W; w& R5 i( O
#endif
5 `! G2 ^8 j8 i* ?7 n3 o" O ret = platform_device_register(&da850_evm_tl_leds_device);
5 O: w8 F) ~: O1 J% Y6 u if (ret); Q7 J/ R- ^1 Y
pr_warning("Could not register som GPIO expander LEDS");
- z' X* _( o4 S( R0 Z4 k \/ a else
; R A% s* R( f6 \6 e printk(KERN_INFO "LED register sucessful!\n");" X# p, P. }) x* [; s# P
* s; Q0 G+ D5 F4 X' |; T return ret;2 `4 ]/ Y& s- k' c- o; p
}
7 ?; C0 C. t. ?' n5 b; I' X+ V* i' }& W- [9 d6 @, f# K
static void __exit led_platform_exit(void), y* G' ?5 u2 N! k" C
{3 o( {! b! m* x8 M2 }( @/ L
platform_device_unregister(&da850_evm_tl_leds_device);. Z! w) N, R) ?3 m+ K u! E
L9 ~- B0 \" \0 o6 B4 y# E; \. j printk(KERN_INFO "LED unregister!\n");0 r, k" K6 X I* `3 C$ L/ ^" m
}( G' }& S! D+ q0 Z
5 x. j. p3 \# I$ h3 Kmodule_init(led_platform_init);1 S4 i; R3 u, e' T5 w" E o
module_exit(led_platform_exit);6 K5 Y, `3 ?# _" B/ H( n3 r
4 j- e7 L8 r4 f
MODULE_DESCRIPTION("Led platform driver");6 ~$ ]( N2 Y b$ n) m; u
MODULE_AUTHOR("Tronlong");
; f: P5 J; p1 f7 s& cMODULE_LICENSE("GPL");8 b# |- C- W: [4 O$ l
$ v" d1 z& T/ H1 a
|
|