|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 H8 m: O, I) W: ?2 J
#include <linux/init.h>- |. X0 @, k1 z& k) l( I
#include <linux/module.h>$ ]9 P; p) P" |/ \& z
#include <linux/kernel.h>" A2 C) f5 q" [9 G s* I
#include <linux/types.h>7 n* o) I I; n! Q( Y, Y
#include <linux/gpio.h>; N5 R' Z& F3 y( `. ]
#include <linux/leds.h>4 B- [8 s4 z: ]' E) V
#include <linux/platform_device.h>6 U; X) r( a* O" ^
2 J4 {- L" E( x, {) V#include <asm/mach-types.h>
, I% h. U1 X; b' C. T#include <asm/mach/arch.h>" Q7 x# R% z' d1 I( X5 w3 l; n
#include <mach/da8xx.h>
9 S! z. L8 z6 @5 N9 u1 ?#include <mach/mux.h>8 _! ^% c( w3 b. e. X
7 K6 F% _. ?2 k' ~* T1 A- Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, V( x- t5 G& z) q3 g1 w: }6 e4 i6 {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) }" D x7 c4 _7 P) |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# z" Q% A5 j: \' N( ?6 [3 I; D2 h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" D M# T* [/ z9 g4 V# C: A
6 p- P+ N9 V) g f- |% q3 U/* assign the tl som board LED-GPIOs*/( {) o% {, N: m. c1 [" }& F
static const short da850_evm_tl_user_led_pins[] = {) a$ F# p% C5 `3 I0 ~" w
/* These pins are definition at <mach/mux.h> file */0 s. ]/ w5 H0 T
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 P; r: d* Z/ O2 {5 j# W* i
-19 k! E! J& X, A
};0 G4 H, ]7 D- a- Y4 ]
6 ?8 X: k; {/ Q/ e" Z
static struct gpio_led da850_evm_tl_leds[] = {
- [) N9 M; L3 ~+ _% B8 O {
+ T5 r8 P/ Z- d( @! N7 k9 Y .active_low = 0,4 p( f, L2 A t8 x ~5 C0 T
.gpio = DA850_USER_LED0,% h* _) i+ O' a0 I( {( u
.name = "user_led0",: j# b e# c4 T: w8 L8 H% B
.default_trigger = "default-on",
) p! T' T3 K( Y8 C+ J. [ },$ L9 }5 A( V! y; e: A; \
{3 ^, S7 E: T; J+ h+ E
.active_low = 0,! e& y2 g) V* s8 k& K
.gpio = DA850_USER_LED1,6 F' F% z, I' ~- ~
.name = "user_led1",; q, e- Y/ Q% E
.default_trigger = "default-on",
, o1 e# Y6 |! L4 X },
0 b5 p8 p, @, u! G- j {
4 s" F+ `: B# |9 W. c .active_low = 0,
7 ]% ]" H7 n7 j o9 E .gpio = DA850_USER_LED2,
y" @/ c; c; M! i+ m, k8 |7 N) g( T! b .name = "user_led2",0 _6 g* B5 ` m& @
.default_trigger = "default-on",0 c7 V5 f* Y* D
},* A6 ~7 q, ?4 a* s7 F
{
* K! q1 B7 X: W$ u) Z: t$ W! v .active_low = 0,
" a, ]3 ~8 T2 S .gpio = DA850_USER_LED3,
5 M- L" p: L: N6 Q .name = "user_led3",, S1 {7 a6 x) W6 m5 }7 @% [
.default_trigger = "default-on",. z* d6 F$ |$ {4 W
},/ K# F7 x' ]" @( _5 b
};
- y5 ~& a2 O6 E j
3 |2 N" S+ G# k9 S& ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, p- m. Y& f5 t: R. ^- U
.leds = da850_evm_tl_leds,
5 \& W+ r' m1 h .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- O& G; g7 }0 E: o I2 p3 Z0 B8 H
};
/ {1 y, x) k% g2 S/ t
* n0 G* U0 D. Y2 U) P3 Dstatic void led_dev_release(struct device *dev)
( i6 b+ x" f) i7 T `$ J{
* t8 X7 L; ^: o* g};9 P- X( q' T- M0 O
. p1 z5 V& ]0 v9 ^& x2 d6 t
static struct platform_device da850_evm_tl_leds_device = {0 p5 e0 Q% c g6 }) [* ^
.name = "leds-gpio",8 Z8 U& Y/ ]$ l' H5 W
.id = 1,
, k. C- _' I& ]* Q .dev = {! a. g( k; R7 ~
.platform_data = &da850_evm_tl_leds_pdata,! b: m4 r# P5 ^! _2 G
.release = led_dev_release,
" N" }- i6 D5 p/ P9 H, a }
) B8 z, h% ~) N* Z};) E1 f! |0 Z0 j- _, s
" `1 ^2 c4 G7 A0 W8 M$ [
static int __init led_platform_init(void)
' H8 z) ?) N) T8 A" b{: _7 Q. c3 |5 B
int ret;( O) e* O* P% W! M X9 m
#if 0
8 C; ?7 Z- z4 ^2 _9 N ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% ~- ?6 W7 {" t6 H( d if (ret)
+ J, Z9 F) p3 \' W1 K& { pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* l* G" y M& ^( c7 }- F
"%d\n", ret);- q2 c0 z! Z t' t6 j/ n3 t
#endif
& @. s( S$ ~5 ?- S; L+ j6 b# @ ret = platform_device_register(&da850_evm_tl_leds_device);# M! ?# @) \ ^& \: ]; D7 B4 T6 \
if (ret)
4 V& C2 e2 Q9 p: U( y- w pr_warning("Could not register som GPIO expander LEDS");
' J$ s, W$ Y$ D3 ^ else
2 O; f2 m7 q' l7 @9 @ printk(KERN_INFO "LED register sucessful!\n");
" z8 g9 `0 W% V8 } q D
9 v. _4 v' B% Q' S9 t* h2 m2 x return ret;/ m, H& q$ k8 Z5 Z0 V8 A
}# H( m0 B2 V. O1 O& O$ @2 l% ?* o
6 o+ y0 P# }( W- p! Z# d# Q
static void __exit led_platform_exit(void)1 h& y* Q2 C6 _& r) N# } ?
{1 E3 K$ t9 H& n2 j; q
platform_device_unregister(&da850_evm_tl_leds_device);# U8 J, [' [! v
1 Z1 ~+ a* l9 j: ^# I- f; [: T printk(KERN_INFO "LED unregister!\n");
" H, T! _. r. ~& y2 I6 s}
- o7 e$ M( T3 c6 B% F
5 v; M8 O' g/ H$ r1 J& Omodule_init(led_platform_init);
% M0 O. ]2 Y5 ^module_exit(led_platform_exit);, G3 h9 A/ G2 s5 `& ` V; @& F
C# I8 S' d' \) t
MODULE_DESCRIPTION("Led platform driver");% e7 U* G! w! |6 W U! C! R
MODULE_AUTHOR("Tronlong");0 m6 W3 Z& N, B8 D! U
MODULE_LICENSE("GPL");6 ~4 I( M7 c9 Z, O* c6 O' q
- p: i3 @' C& f- W8 }% b% { |
|