|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 T. I+ {- S5 }#include <linux/init.h>
3 r6 N/ E- c; x#include <linux/module.h>2 B. \( t2 a- S) C- E0 A/ C
#include <linux/kernel.h>2 D) a; T% s( a' V
#include <linux/types.h>
! \: A5 g7 T8 T, c+ V) }4 Y/ H% t/ Q#include <linux/gpio.h>
6 ^& J( |" Y: M/ B8 c, G#include <linux/leds.h>7 R; {4 I7 s3 |8 W4 C/ T
#include <linux/platform_device.h>: Z& X5 N) v% q8 F! [8 X( S6 w! x6 f
) ^. d) K2 a8 k0 f& z! s# V T#include <asm/mach-types.h>7 K$ s5 m/ Y0 m) c7 D; L
#include <asm/mach/arch.h>8 x0 Z% z0 c5 n; n$ V2 G9 H% `% K
#include <mach/da8xx.h>
8 G3 [7 Y1 G( x, } B#include <mach/mux.h>
7 b" O) L2 D: q6 U( k" d3 `
) L) S0 }2 _6 a: @/ Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; ]( K0 }% O2 L0 J9 O6 I( E1 }& K$ m#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 I0 o$ V# \6 i6 X3 B8 z0 |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' z2 B9 U$ V, E) u; Q, ~#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) W/ l7 i; n7 Q7 U, a% w! s. R: Y, d F
/* assign the tl som board LED-GPIOs*/. t0 F! }! t0 V
static const short da850_evm_tl_user_led_pins[] = {
4 M7 {3 c6 L0 m /* These pins are definition at <mach/mux.h> file */+ }+ n( i" A5 L: ~- ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ H3 {" F( ?% H! w9 T$ }$ f. A
-1. W1 d9 `, ?5 I8 \; F0 W
};+ v# O |) K) U
`5 W, J } W2 r7 ?static struct gpio_led da850_evm_tl_leds[] = {( d1 k+ D8 p" g
{& R8 y0 r0 L0 I- j4 ]4 ^
.active_low = 0,
% P2 X9 Y, h- L- h7 p& \$ g .gpio = DA850_USER_LED0,
# f$ T1 d; r p .name = "user_led0",' I' B; V. M& `, K4 W1 J
.default_trigger = "default-on",
0 t4 \ w9 I8 p$ O3 t; k( _ }, J. u5 ~ Y9 W; o
{% G7 r% X- I4 s% T; z1 d* x& ?
.active_low = 0,: _# p4 u. n5 [2 E9 f5 v2 e
.gpio = DA850_USER_LED1,# H- `) Q: C0 c) T% W, T2 C; o
.name = "user_led1",
& v' u$ x; u" b- C .default_trigger = "default-on",0 h& z! n+ Z# H" W" R8 d! t7 k" h
},
* U3 q" s9 y* h {
; Q& R/ @! J+ O6 e, N% H3 V .active_low = 0,
4 y* H! D% k) q9 k/ a1 k .gpio = DA850_USER_LED2,
5 o! ^1 g* N! k& B3 L2 C9 d4 m .name = "user_led2",
% o/ o% l- ^, b+ f* \8 v .default_trigger = "default-on",- {5 Y [ \) Z" e8 W [, |
},# d6 o( W' W4 t
{
/ P' _- `- g5 h b! \4 P .active_low = 0,1 P5 l) N7 s5 ?9 t; C* Q2 z E$ A
.gpio = DA850_USER_LED3,) O) x; [5 J: Q# u* x$ A
.name = "user_led3",
2 r( C* c" ~5 y) Q- e .default_trigger = "default-on",
* N0 e$ l# {: G s; e) { },1 ~ p! C- ?- i$ s/ f, t) Q
};
& ~" G( t$ n0 T, p6 t& J. I2 ?4 b
' N( m1 I% v6 T, ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 j& {& B1 E6 }+ K" K .leds = da850_evm_tl_leds,5 B, Q6 q. A8 y- P) {. y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 F- M# }5 {, A" ]8 s, Z};* V6 i( x0 |5 Y1 e' y
( l5 b/ \: V% t# hstatic void led_dev_release(struct device *dev). R4 Q* ~) s4 h d' h* R- c
{! F% D/ z, T5 Y$ b) B
};) k1 G, n; N: E. u
% y3 Q% w8 ]: p3 L3 N! rstatic struct platform_device da850_evm_tl_leds_device = {# g( \' f( X. Y3 c- h0 G5 L' u4 }
.name = "leds-gpio"," X; I( @8 o: h4 H
.id = 1,
# G! T& Z7 v; `1 n' H* \ .dev = {
$ S$ ]5 z9 H* f# w! a9 G5 H1 q .platform_data = &da850_evm_tl_leds_pdata, X9 E0 z; i& S# F' E) L3 } t& j' U
.release = led_dev_release,) J& z d7 r4 g' x4 j
}
+ R* l" T, J) r8 J+ V9 F2 R};$ I& Y; V& D2 N! R
# J U. y! Y/ pstatic int __init led_platform_init(void)! M8 H! Y2 F) g6 Z
{
/ E0 Z& m2 W- E$ J. f/ E; _ int ret;
4 H( P1 \8 }# Q4 w l" x0 m9 V#if 0
3 P, P: U2 |5 @8 n& p% k) a8 _- o7 l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 I4 O; x$ y$ U& u- m* h6 J if (ret)
7 H# F8 m, S$ |" ] pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 U# W9 L, N5 U) d& Q) } "%d\n", ret);
! H5 k+ I; p/ h2 v6 w( a y) @#endif0 e/ Q# z1 c! U/ f8 `0 p; n
ret = platform_device_register(&da850_evm_tl_leds_device);2 B) O4 E/ ?$ K% D* x N
if (ret); K+ T' [4 C6 d3 }5 a% }
pr_warning("Could not register som GPIO expander LEDS");
3 m) b8 @# I) {! H' L. ? else- ?3 t! @$ w, R: {6 s" B) t
printk(KERN_INFO "LED register sucessful!\n");% @- w% k+ A% A0 Y& k/ g& D* @
) }/ h, j1 g) J
return ret;
. j6 F7 d, {3 G; w! z4 D- o}# h* z# s& s9 @+ G2 b2 E6 {
: m' b) A$ ~: S6 ~* ~; lstatic void __exit led_platform_exit(void)+ F1 O+ d& U9 }; A- L+ I
{
1 g3 {, C5 I- x' Z, P) O platform_device_unregister(&da850_evm_tl_leds_device);9 E( { o) `: I% ]) t6 ]
8 P3 G; p5 r! w) N( A! ?
printk(KERN_INFO "LED unregister!\n");
2 q. z' M+ m+ @1 v* s( E7 E}, O: d* O2 J$ u: P
- \' O4 P/ M" M" O
module_init(led_platform_init);% f6 X Q( _5 C, r2 P
module_exit(led_platform_exit);6 d! o& ^; f, T
+ p& w. S& @* |( P$ c* kMODULE_DESCRIPTION("Led platform driver");, F! I8 `4 N% p& P/ |
MODULE_AUTHOR("Tronlong");% K. ?9 i: R3 o% R
MODULE_LICENSE("GPL");& Z9 x I2 c: P0 e1 ~
3 O/ ^& A e) L/ Z0 y8 I' K2 T
|
|