|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% i3 S4 G( T- l6 h1 p- A. S#include <linux/init.h>
; X6 b# O. y" ~+ o7 N" j2 C0 G! |2 c#include <linux/module.h>
3 C% t1 ?* P6 h, V: m) O#include <linux/kernel.h>
! `. j1 \9 }. K# O- _' F& ], j& O#include <linux/types.h>) W6 c. L" [& y6 m0 H' ?6 o
#include <linux/gpio.h>! s/ R% e7 W0 ]3 {/ v
#include <linux/leds.h>1 O' O4 o5 V8 D @6 O: D$ ?
#include <linux/platform_device.h>
* ^/ d1 k7 Y [0 X8 W# Q0 s6 [$ h6 E }! }$ V! ]
#include <asm/mach-types.h>+ o7 Q* z5 P6 l. x2 w
#include <asm/mach/arch.h>
$ P* j! ^% @+ M3 d4 l D6 R#include <mach/da8xx.h>
h$ ?6 l/ [0 Q7 w#include <mach/mux.h>
4 P+ `5 ?9 t" |2 P/ W9 i$ u+ T* W' ?/ f
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& i! v( s& g0 r3 A3 r4 d# z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- [4 a9 p7 ]+ M6 v z3 N# w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* {9 m/ I {3 y5 D; \#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ Y h1 M3 w. \7 F3 T7 m+ p7 S7 Y7 G5 Q1 N% x
/* assign the tl som board LED-GPIOs*/1 |1 G$ ?6 Q5 D% r/ l6 R* B
static const short da850_evm_tl_user_led_pins[] = {" [, M3 N( [5 ?
/* These pins are definition at <mach/mux.h> file */' A" g# h1 y% Y& _5 U, n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# Z9 i$ ?; ?# U, h -1+ ~- e. `$ {* [, w% o
};
7 V" I1 S: g& z+ }8 z) g6 ?, K/ y3 z9 g$ X9 p. x% S1 ?( R
static struct gpio_led da850_evm_tl_leds[] = {% {3 J& b3 h1 l
{
% e z: x, u6 B3 V: ]6 G .active_low = 0,
$ `6 D! S5 t* C1 l$ P# x9 Q7 g5 I .gpio = DA850_USER_LED0,
( H U' i8 u5 V .name = "user_led0",
m% O. B& k" x; B6 U4 h; H .default_trigger = "default-on",
& k) q* O' M& O4 J) @& O },1 K1 d" K8 U+ i8 v# T8 O+ Y% B
{# g8 K, A- {3 O+ l9 N4 @
.active_low = 0,* {& x& ?9 a5 ]9 ~$ T+ @2 q/ {
.gpio = DA850_USER_LED1,9 q8 e8 c& r3 D- j; Q" q6 A2 U
.name = "user_led1",3 I% H. {' M- D+ C) M8 ?, Q) d
.default_trigger = "default-on",% O; W: _9 b. Q: p" Z9 W- W6 j
},) f6 x" D) u1 f
{
- t+ {1 E( e/ w6 t4 }/ u .active_low = 0,( g' g. v* q* Z5 ^5 [7 z# V
.gpio = DA850_USER_LED2,
$ {- N6 @9 s3 t9 }( r% }$ O, }/ i .name = "user_led2",) }: I9 O* O! L p7 t5 p/ _; H: X
.default_trigger = "default-on",* x; u4 `" } ?) @ Z3 w
},& M0 m- y% W/ o0 F- J; P4 S2 d5 b
{, W; W. D1 _6 ^
.active_low = 0,
2 E3 y5 s3 U, H/ X .gpio = DA850_USER_LED3,. f/ N7 m8 u5 Z4 @
.name = "user_led3",. [. c7 s3 V1 w: G
.default_trigger = "default-on",+ X- h9 H, t8 q' X6 L$ P
},' `: C! g' Z5 \: L# v- T+ C
};8 w, s, {" A; s9 Q8 G
( L, [$ H! s8 Z, U% f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 I8 q) ^2 {, q) ~4 M2 v .leds = da850_evm_tl_leds,, H+ l3 L* `5 X! Z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 D& _# o3 L% E7 _' W! N" R
};) ?# b; f" [$ j5 H+ C- ]: E5 i
3 n/ C4 {1 O( z q- b2 c
static void led_dev_release(struct device *dev)) R) k4 u' T; J1 K, x5 ^
{
2 c& @8 ` g! C& i3 i+ u};
: _; f' {/ k9 Y# L$ h6 x* G/ @
/ R- F& G/ T" mstatic struct platform_device da850_evm_tl_leds_device = {4 T+ N$ J; T; x; T
.name = "leds-gpio",) q+ w4 H$ E+ u7 {6 y) t
.id = 1,
# n8 f1 s, D% R0 J& }& A .dev = {
2 C7 a2 Y6 \* V3 h0 H* J8 z) R. v .platform_data = &da850_evm_tl_leds_pdata,/ ^' Y4 P2 B* [0 W# i) q
.release = led_dev_release,
' c( d8 x# f1 V }
: P% l( }% v" y};- d8 q$ Q2 S; N( |; Q
4 \9 l: [5 h! x8 a) a6 `" {' \ Cstatic int __init led_platform_init(void)
Q$ N, `7 j" t: p' d) s{( ?5 q7 y0 y; |; ]
int ret;4 q% Y1 p0 ]" P$ l
#if 0" r2 V6 f& C! ]* {
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 b1 a( J l/ ?" d- E) A6 k$ P+ L if (ret)4 C9 e w. n) N8 V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 | g9 t' C7 I- W4 q6 t* U
"%d\n", ret);
3 P" J1 [* z! J3 A#endif
2 o6 C: \: b% c0 N: ^# Y ret = platform_device_register(&da850_evm_tl_leds_device);
# i8 C" G3 [ Z, X- y if (ret)
+ w4 h, t0 q; F# o pr_warning("Could not register som GPIO expander LEDS");
8 z, L& D- X& P# ?( j5 n" E! a else) E6 r2 ?! y9 p1 I$ Q, F
printk(KERN_INFO "LED register sucessful!\n");
" t9 o5 L5 q0 J: D/ I2 {# S' x8 ^+ L" T
return ret;! h+ I4 g* [% H
}
' f( W e1 a- F* G5 f) O( K; y& a/ i5 {4 g2 V
static void __exit led_platform_exit(void)
( p" l! w- ^* K! v+ D5 a+ f{
2 ]4 r8 N4 \, N5 z; ?: Q platform_device_unregister(&da850_evm_tl_leds_device);* t. J9 q7 ]! J) _
5 w! @/ o/ z* c* z# d K printk(KERN_INFO "LED unregister!\n");
; q: g/ k' }9 G$ g5 a; }" U1 D} b+ K4 X. z# U+ L! t. }- W- L
9 B7 L! M `, M8 ?8 mmodule_init(led_platform_init);, e e/ j( i) ?2 V& Q4 m5 W" Y4 ^
module_exit(led_platform_exit);
1 }0 o; Y- ]/ k5 [- V. }7 Q$ U: t8 G! C n' \; g+ H
MODULE_DESCRIPTION("Led platform driver");2 e( f3 H3 U; [1 f0 c
MODULE_AUTHOR("Tronlong");
. J% m$ r5 g2 _% p, x4 a; FMODULE_LICENSE("GPL");* U- @3 K+ }1 R1 c f* Y
; I% z; f; E$ f! y! ^7 o: H
|
|