|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 U9 A. v$ S7 E; s& Z
#include <linux/init.h>, L9 h& m8 i5 N6 f
#include <linux/module.h>$ W6 K' A. u4 m0 _$ n
#include <linux/kernel.h>9 q# X; q! a/ N; y
#include <linux/types.h>+ a3 C8 [$ l9 k N# [" X# j
#include <linux/gpio.h>
3 q! ]8 u" B- r9 L#include <linux/leds.h>" L( J+ p w( s
#include <linux/platform_device.h>3 A" d- Y0 K) A( S
0 s" X6 s& ?8 X$ O9 o
#include <asm/mach-types.h>
, j; K: J6 Q* d7 c#include <asm/mach/arch.h>& }! F& P' A7 {' Q8 ]! c- I% A
#include <mach/da8xx.h>" E: n& m+ z d; Z. B
#include <mach/mux.h>
; @3 C6 i9 S# i- q
3 T7 _8 V7 L2 K#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), B1 O6 ~! _% x" {+ J- n! _2 V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, N8 S5 |/ N, T* }#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ l8 Y! M, U/ p* A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! s1 T7 w4 p( R' b! |
! ^; Q7 N* |# }7 l9 |4 `4 h7 h; ~/* assign the tl som board LED-GPIOs*/$ E+ h4 r8 V9 k/ I
static const short da850_evm_tl_user_led_pins[] = {
% T% k: P+ E% `& s$ `" c /* These pins are definition at <mach/mux.h> file */% |" l, S7 P3 c+ y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 |+ Q: i0 p7 d* x" e) l1 Q -1
5 S& P# y. H$ }& x7 q/ w};
+ E/ D( E# v v5 j) {9 q3 K$ Q3 u7 w0 R% x6 x
static struct gpio_led da850_evm_tl_leds[] = {9 V5 c9 Y C& G
{, \1 r* j$ X* ^* \
.active_low = 0,
, y* i& }) h8 W+ S" P6 [4 r- | .gpio = DA850_USER_LED0,
3 y! N5 k2 y* z9 P .name = "user_led0",
* s c" r6 b% z1 W& `; w9 X .default_trigger = "default-on",
! Y" Q" f6 c( J },
' C! u. e$ C9 ]5 J {9 l4 ?3 k% ~9 C* ?! ^* O3 }
.active_low = 0,9 l/ r7 J* ^( j
.gpio = DA850_USER_LED1,4 m# [+ }9 X: k! t& v: A
.name = "user_led1",
) |/ _3 |9 r: w; v# s4 G" \ .default_trigger = "default-on",* @/ b1 h: l. S9 T2 ^9 T
}, z/ j+ t. x" }, U
{
4 P, ^. L$ u$ L3 J7 K% ~ .active_low = 0,2 d. P# g! s+ M# `- }* A; I
.gpio = DA850_USER_LED2,' g1 o& q. c Q: r/ X6 H
.name = "user_led2",
. O0 h4 T# I' N2 _+ `& Y .default_trigger = "default-on",
8 M$ s( E5 y' z* ~0 T; G },
: d$ t0 ~' [$ \5 c% U {
% d# @% H+ E# }+ T' Y .active_low = 0,, V# r/ n# W0 S/ { f9 f. D2 P
.gpio = DA850_USER_LED3,' q; a& b; n6 L& l4 P
.name = "user_led3",, P% ^% _$ D$ d' K) q2 I8 q, b
.default_trigger = "default-on",; p; e# I+ }. \* A9 L( F
},: G) P5 I. T0 Y$ d9 K6 F1 h
};7 S5 O2 N6 H. [% ^) v B
& b1 W+ \, t4 @9 C9 ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ k \6 J" Y# V# ? .leds = da850_evm_tl_leds,7 l8 J$ N# l; V- g1 B1 c
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; x& {1 @ g D8 i8 Z V
};
9 X. S" @, S8 p7 B2 D* i( x$ n2 J
+ C0 }; V# G* |static void led_dev_release(struct device *dev)
& u) @8 X& k3 q* ]6 u, a' f- N{
3 I3 N6 j3 f( s5 W; w3 T};
6 q" h" ~" F: x% d1 X
c" @$ t9 [: x% I ^static struct platform_device da850_evm_tl_leds_device = {( ~! X$ }1 Y- r$ \, m
.name = "leds-gpio",
1 f5 r# ?$ v- C. T; ^% i$ ]) R) F: C .id = 1,
0 | ~2 X" j6 G; Y7 H$ i, W .dev = {% t4 y& o0 e& K7 S2 |# D
.platform_data = &da850_evm_tl_leds_pdata,8 V* q* ^2 _, L
.release = led_dev_release,
( d: r+ p# i9 V) R* t& u }' q/ L( u( }0 u
};; B* i: m2 ?: w0 ?; E" e
) L3 S3 e. U* g" _* }
static int __init led_platform_init(void)
8 Z+ X/ _( Y k( K{" V+ W3 I7 k( t# L7 n
int ret;. @% r( @" v% k
#if 0% Q# t" R3 `% H( [3 a" d. g
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
H4 u4 G; D% z; `; o" y0 T8 q, S3 ?' B* C if (ret)0 M. X2 j, \/ u+ T& V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 R- d) _" p" B
"%d\n", ret);
% e, e r/ d i( f+ I5 D6 y#endif
2 m, _7 K1 w! c% M/ n! B* [ ret = platform_device_register(&da850_evm_tl_leds_device);; L; u1 f* E6 I! z# w$ h
if (ret)) F9 n& O3 \# x0 a ] m
pr_warning("Could not register som GPIO expander LEDS");4 I: B9 _' B8 r* T" O* _
else: ^0 e+ l# P8 x4 O+ @/ a
printk(KERN_INFO "LED register sucessful!\n");
- L# }' }6 z9 u$ |$ C; l% d3 h# X7 _
return ret;2 z, V S# ~" ~# l" O/ X4 g n
}5 F Q0 {- M4 V: s5 ^
4 ]$ q6 @ }3 u% L& l2 j
static void __exit led_platform_exit(void)
3 a+ E, ^! O1 z0 M& u0 l9 {{
4 B; \' P; ]1 e2 ~' J2 _ platform_device_unregister(&da850_evm_tl_leds_device);* M& V' A- @' L1 S
; m9 Z5 |: t# r
printk(KERN_INFO "LED unregister!\n");' |* ~7 N& e9 }3 S9 h" v* r/ h
}
! K9 R, i: s" p3 {0 w% k3 `8 c" x1 M9 y
module_init(led_platform_init);* O: k5 p9 t u/ B& F: d% i4 ~
module_exit(led_platform_exit);
# }1 s# }. O/ U |8 b" {6 e8 Z
$ o5 s7 T* P- O) NMODULE_DESCRIPTION("Led platform driver");
' F6 D3 t0 I5 q; Q& t" hMODULE_AUTHOR("Tronlong");0 r$ r; q4 [* A u% O5 Z$ T: F! P) H
MODULE_LICENSE("GPL");
7 ?. y' \$ Q, x( A3 I% l
6 r: `# @( o, c( C& f; y1 P |
|