|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 t: @, d6 ^: J#include <linux/init.h>
6 q1 H0 X! E8 Q: F3 E ]8 U#include <linux/module.h>
" N; o+ h! j6 u% _#include <linux/kernel.h>' }0 H- j9 |4 s# M6 g, f! C* s; W6 b
#include <linux/types.h>0 M, l( i7 N' k5 s
#include <linux/gpio.h>4 G% O& [/ w" s, P1 {( d
#include <linux/leds.h>
; ~9 v4 j7 C8 w, h- Y#include <linux/platform_device.h>
% A. u( {; f( g5 L: M+ k* O& f- I) a9 n1 Y: z( l" C, ]: g
#include <asm/mach-types.h>
+ X4 H1 x, k, v/ j#include <asm/mach/arch.h>& X% W8 H& z" S/ `. H7 @3 H
#include <mach/da8xx.h>6 d! @3 W w; K# u5 \: J4 B
#include <mach/mux.h>
9 G' B, w, Q7 J/ u! F7 i3 x! B9 E7 K9 O1 j7 z- s( z2 P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ T4 g) i% S" Q4 F ]4 @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 r- Y" y$ L6 w& ]' T" y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 ?8 k! B2 e+ W4 P ?% z7 b4 [#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* v* v' l9 D7 T
& v' M, b" W" K4 \! W/* assign the tl som board LED-GPIOs*/# k( D0 {; }' J
static const short da850_evm_tl_user_led_pins[] = {
0 R6 W3 A2 z, M# r' O1 ? /* These pins are definition at <mach/mux.h> file */ D% k6 T% F2 ]' |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 t4 ~" v+ R5 e5 S! x0 h
-1
6 f% Y3 L+ \% f};
0 d6 z$ f9 M4 u x9 i7 a# ]7 e7 ?6 A( @" z+ }8 k& W; @1 Z: H
static struct gpio_led da850_evm_tl_leds[] = {
) ]9 w" L) f) W {2 q( a9 {1 h" m3 a2 O1 m. u
.active_low = 0,- U2 ^: j" g* c5 o. v7 T
.gpio = DA850_USER_LED0,# x/ F& s! [( [
.name = "user_led0",
$ ?5 q$ k# k. M" Q7 K .default_trigger = "default-on",6 o, |' P5 S) ^" Q' h- i' ^6 \
},
2 m4 u2 [" S& ^9 z6 n {
. Z3 j# w# e- m+ \1 V& b6 |4 V .active_low = 0,
9 D! x* [& O7 X+ r5 S0 j .gpio = DA850_USER_LED1,' X$ g: E8 q+ w7 v, f& A
.name = "user_led1",5 e! ]5 [* _+ c) L& m# g2 y
.default_trigger = "default-on",
: S) b1 c! H4 ~* y! S6 f' G: N, } },6 @, f8 p& e* s7 ~8 _
{
, n" d# |$ G" @7 N .active_low = 0,. {4 R8 C: b j/ T( ]- F& R" q
.gpio = DA850_USER_LED2,1 Z; Y) }% ] a3 n/ \$ l
.name = "user_led2",
0 i+ Q$ }1 t/ L; _7 { .default_trigger = "default-on",
+ [- Q) P$ g+ R" E% w },
* d0 Q2 M3 W6 v- j' A* N; W {
2 y1 d4 N' Z3 y- U .active_low = 0,
6 ? @3 a) X( d/ m6 _- M% q0 A .gpio = DA850_USER_LED3,
# ^+ x- m9 u( c. z8 t1 B& g1 _ .name = "user_led3",& x7 y& t7 B, P+ o" Q* m
.default_trigger = "default-on",
9 e& Q2 z% \5 ^( r. {. H },. k6 s. u. y3 V' S- i% P( u
};8 ?- e# u0 `2 g& ~4 x
5 k2 }+ @2 s0 l ^4 c N0 jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& Q+ ~$ g' Y/ J .leds = da850_evm_tl_leds,% h+ ~/ I7 e6 `; J$ b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 n/ J% t! O4 ?5 q1 C' r( s};- i- R8 \, U' K2 N4 Y
5 ]# b5 n4 a. ^- ystatic void led_dev_release(struct device *dev)
/ _2 ]( E" Y' y/ x, ^{
) [6 w) O' P4 s0 y; o};
5 |3 A4 m2 F/ Y( s/ @. b) {
& R1 k) S {9 [" p" @6 S0 zstatic struct platform_device da850_evm_tl_leds_device = {
. r, s g E7 V7 [ .name = "leds-gpio",
" j3 `) q5 n( s2 h' M! v .id = 1,
% c9 X" w! r( C .dev = {8 X* e, Q+ o/ }2 E$ ?# E" _
.platform_data = &da850_evm_tl_leds_pdata,
7 O; n4 D2 m4 d$ R .release = led_dev_release,2 ~& L- q( C2 I2 t
}
: O& z4 d0 z* ^, ~5 y};# z7 h. }9 {% k5 [2 O
5 W) W2 S! O! X& O* Vstatic int __init led_platform_init(void)
+ h1 J( J2 Y: {, x{
% i1 z5 P' a; p! y. Z int ret;- _2 Z) e( Y. p
#if 05 X' V$ F) ?0 s |& }6 v& Z, x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 [( J5 I# {9 I. O. u4 X if (ret)
+ t ?+ L' r E5 p+ D& h- C0 W6 i pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 G; }& a1 E+ ^2 H) e
"%d\n", ret);
0 C8 U1 q5 b% H7 r! V i; _8 W#endif
' H( E& ?/ _! z- L, ~8 j ret = platform_device_register(&da850_evm_tl_leds_device);; m* b& s' S* Q) l) n: s
if (ret)' v/ @4 Y6 I1 }* D' C" ]2 ^
pr_warning("Could not register som GPIO expander LEDS");
& q% Q5 [9 E1 W# g else5 v4 b& Y) m* c" c2 ~7 Y0 V5 B+ T
printk(KERN_INFO "LED register sucessful!\n");
7 \' N+ O1 r+ n+ f a; R
0 Z- @# J" E8 F6 i9 V6 o return ret;
R3 m" X( ?4 E2 a% L% g5 k/ S}8 ~* E2 N7 t, g4 @7 ?, G. ^# N
1 w5 `; l$ b& v, v% Gstatic void __exit led_platform_exit(void)# B) Y+ m" h' K3 P3 |6 R' q: B
{" Y* n8 O( d7 I7 V" J2 F
platform_device_unregister(&da850_evm_tl_leds_device);6 ^. b# A, E y0 p, K T
( E9 ?* s' }, o; g; u+ l4 Y
printk(KERN_INFO "LED unregister!\n");* R- g; B$ a/ k9 ?; I9 b# @
}& A+ P/ @6 B& H7 C; V' x
8 t4 U, r5 F. {$ b. }% n! a' S
module_init(led_platform_init);! V6 j+ s: x5 ^, {. x8 m: r9 ?
module_exit(led_platform_exit);
- V( v/ h0 V9 _' `% J/ {+ ^' @
: B, |" x8 |: d, ]2 D4 l+ @MODULE_DESCRIPTION("Led platform driver");
1 Q, C6 Q7 `7 z3 B# V o6 ]! JMODULE_AUTHOR("Tronlong");% F2 I% h1 W+ Y& r. o
MODULE_LICENSE("GPL");# B4 x1 v5 i8 S2 ?* q: n, b
) `1 V- @ v& R6 ~/ L
|
|