|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 b/ ^% Q* O; c5 T. e- w. P#include <linux/init.h>
3 q% z" b1 d7 g8 c( t) R7 \6 _#include <linux/module.h>' m. \3 k( k3 K# v; C
#include <linux/kernel.h>* J+ a' E E' s* r
#include <linux/types.h>
& }/ g* |8 _) F7 A, q#include <linux/gpio.h>
4 j( {+ S& X: h6 B* X E" h#include <linux/leds.h>, N" d! c. k& w/ ^" Z* X
#include <linux/platform_device.h>
' l* W% e* y3 |) `: ~! g# g" L' m5 |' [) s: P3 _8 j( `1 q, v
#include <asm/mach-types.h>
0 y" A+ L, P2 C; q' ]$ H#include <asm/mach/arch.h>- V, y' }$ X8 y3 X; E' t
#include <mach/da8xx.h>
' o* g1 X% W! l3 {( h#include <mach/mux.h>
* ?3 ?3 q' j2 I8 ]
7 V) c6 x( ~! \. e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* S2 ?! D. e- q- B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 ^& Q8 H! J6 o* I#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 r+ @/ ^5 }8 e& f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); q- h" @ n ~4 {* P- Q
$ ?$ p' Q" r/ z. Y$ c
/* assign the tl som board LED-GPIOs*/
" E1 D9 C' u* A+ A4 s$ `! qstatic const short da850_evm_tl_user_led_pins[] = {8 e) f. j& l) m
/* These pins are definition at <mach/mux.h> file */
- ~* a% r7 N7 W4 E, l/ [9 d+ p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, C1 [& B7 Z6 z1 X, K -1# _" R6 P! y' S) |
};
2 `: f% ~6 }! i/ ?! ^
% I1 X) v T1 k: D v& @: tstatic struct gpio_led da850_evm_tl_leds[] = {
$ l& d' Z) [% y/ h+ B C4 l* H3 ?* r+ [ {
& {$ ~& W2 g0 k3 @' T9 W, @ .active_low = 0,
1 i9 c6 r, m5 R0 D .gpio = DA850_USER_LED0,
/ }# P, }2 B I& O t( [" s7 V# u .name = "user_led0",
6 ]% m1 D+ G' m" C) w; f4 ` .default_trigger = "default-on",
' R m5 t9 L+ H) _! h1 J M' g( t: Z },* V6 L4 B: h7 M4 _, C+ w0 [
{% B6 P; C2 I0 [, J4 B$ q
.active_low = 0,2 B/ i3 U3 ]5 q- G8 r# g; F
.gpio = DA850_USER_LED1,% b! O* n& f4 T% o, K8 S6 y
.name = "user_led1",! J* g/ Z% m( V% {9 g% R& O
.default_trigger = "default-on",# N# y# \& @9 ^4 J' l
},* n# Z/ D- x! [* X5 e0 {8 {7 M; \
{
0 }( u9 W- W: b .active_low = 0,- M9 s# y8 _7 d8 P' q3 h
.gpio = DA850_USER_LED2,
$ q- I% l7 O2 s) [6 U/ i .name = "user_led2",* g" p7 d# @: Y5 h7 G+ t' p' w, J
.default_trigger = "default-on",
$ i( L2 }% ?9 `% w },7 ]& ^1 O6 ], r/ h8 H# H/ d
{
& d* h: [, h* z! U: y .active_low = 0,
" r( O1 d) `" p- h9 J .gpio = DA850_USER_LED3,' V& n% ?) A9 J& N* s7 t
.name = "user_led3",
U0 Q: `% M' n6 A2 N/ O0 {2 t/ U .default_trigger = "default-on",. b/ v8 ?6 x# |9 X8 U( t
},7 N/ }9 u0 V9 v
};* F' I1 }* ?: E. S6 M4 ]# L
2 Q$ N, b6 Z% U4 f. o' ^& {; O, d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. W8 c" E7 m+ A$ t( j4 I
.leds = da850_evm_tl_leds,' z" K1 Q, L: Z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 f' t: W7 n" ?& N) d: p
};7 a! G7 @% g: T. \7 v
! s0 E R9 J# R
static void led_dev_release(struct device *dev)8 ?1 B( n+ b+ w) ?+ }
{& N3 O+ f) v7 ?6 g
};
' ^6 D: w5 V9 F/ |# p$ L& N2 c, H
0 ]) U* p1 V; Fstatic struct platform_device da850_evm_tl_leds_device = {
0 Y" b4 M3 ?5 x- [( a& ]6 Y .name = "leds-gpio",
G+ n6 ?1 E& h/ F' h .id = 1,
) a5 ?' A% E/ |) q6 D8 V/ N# | .dev = {
& W! ?4 a1 s" q .platform_data = &da850_evm_tl_leds_pdata,
' b5 a0 E2 g; z5 T5 B$ ` j: ~& m ?: O .release = led_dev_release,5 a. `1 ~) E0 g- z- v# t
}- \! @3 i2 F! G2 m$ d# ~
};
; ^% \$ C1 T1 s) i. V p+ f: D2 {0 c/ D
static int __init led_platform_init(void); r& Q) C8 d! ]* y; O& \
{
' Y$ L: ]* J, {+ S. V0 M; x int ret; V" f7 q) {. `+ S
#if 0
7 J2 D; ^6 B0 y1 ?4 y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# B6 D8 ?( u; |9 p4 |& } if (ret)
# [! u2 j7 E. l: j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- Q K1 d7 j% l9 z4 R% S
"%d\n", ret);
2 D {9 b& P" y' F#endif; s& A& M/ i2 O. K6 k9 V
ret = platform_device_register(&da850_evm_tl_leds_device);
. I% M- }7 n1 C6 y if (ret)
; e4 I1 i9 k7 O7 T+ T0 e pr_warning("Could not register som GPIO expander LEDS");
. k1 ?- b! {6 z( X% Y5 _( X else
0 L: a' A3 i* h$ U printk(KERN_INFO "LED register sucessful!\n");& B1 T& X3 J2 @
0 g( p& h7 [' i. k" o: P: J return ret;7 R3 I' f" J0 N6 U
}: T( l# a( }6 z* h: L
1 v3 x4 @# O$ H7 |3 }static void __exit led_platform_exit(void). H* V5 @1 d& H. W7 D4 F0 z9 z
{
: b. G* S3 V) W5 C A. _2 D2 X& | platform_device_unregister(&da850_evm_tl_leds_device);
5 K; i3 ~" N/ `- Y* ?$ A: \4 q# {, \1 V* _2 N! ?0 \
printk(KERN_INFO "LED unregister!\n");/ b2 S) _* n6 v Z7 |' S
}
1 n, D, ~- o$ r& B" H
( `7 U/ ]; _4 J3 b# r; k3 nmodule_init(led_platform_init);
7 n, s0 M; G! |& [/ M- Z* g* C+ }module_exit(led_platform_exit);* Y: W# E' ?6 X: [$ c/ H
1 K7 n: v! R# L% ]; KMODULE_DESCRIPTION("Led platform driver");7 h( l$ ~' w. l G u1 o
MODULE_AUTHOR("Tronlong"); @6 {8 w- n) a) v
MODULE_LICENSE("GPL");
$ i/ X0 n- s" i) k& ~) E
+ X" r0 e) q& e& s |
|