|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- K5 s% ~4 Z" {: i* I
#include <linux/init.h>
, g# h! R+ [) \' O1 I#include <linux/module.h>
8 t4 X; R5 `" N2 P2 _! l#include <linux/kernel.h># _* N( k. o0 c6 z
#include <linux/types.h># R- e+ C) S" y* g2 D
#include <linux/gpio.h>7 s$ }5 b+ A- M- t
#include <linux/leds.h>
# o7 O# q5 [# d; h4 v: U#include <linux/platform_device.h>" z: s" y# W- i, a7 Q6 h3 V
, ?8 b: \; s3 v1 `% {+ T( u
#include <asm/mach-types.h>
5 Z7 F! H, }$ I#include <asm/mach/arch.h>- G {. W; Z7 \1 i+ t/ g$ _; a
#include <mach/da8xx.h>
% q, p% e5 m- b8 c) O& n0 ~#include <mach/mux.h>% `$ P! y) L: V7 m& i V6 I8 C+ J$ Q
9 ~; e( I* U! U! |( L#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ w! k% X+ W% y* h( Z. {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 c% p% q8 A9 R; @/ c J; d) B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" r6 g7 j) l& A6 E0 V- ~$ C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( ]; F9 g+ N# z1 S. U; R+ W: h: b
. @; E+ K1 @+ e9 E" F, }/* assign the tl som board LED-GPIOs*/
$ q5 q8 i4 Y, ^3 q5 Cstatic const short da850_evm_tl_user_led_pins[] = {* T8 {5 X, }, @# k$ H
/* These pins are definition at <mach/mux.h> file */, O7 ]8 I! }+ R8 H; D$ Q" W; z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 {& S- f' h7 z6 M! d
-1
n: ^, p b2 |4 C! _6 R};1 J2 v- Q( k# ]& c i
) o0 B+ Q1 W3 D+ \- c P1 S
static struct gpio_led da850_evm_tl_leds[] = {
) ] B+ J1 t8 ~3 A {2 U! @* L% \, f% I3 s: q
.active_low = 0,3 a. s/ m3 c2 J
.gpio = DA850_USER_LED0,
) v" V/ P7 N/ ^5 ]6 E6 b .name = "user_led0",. w X- O: |0 H
.default_trigger = "default-on",
; P+ O8 r3 F6 o9 {* c4 x4 U },( m9 f7 l# k3 A8 c0 Q
{
5 A; _2 \2 k! `6 s( l$ Z* T+ \ .active_low = 0,
: i. f2 s4 O: X+ f! R0 D .gpio = DA850_USER_LED1,
8 F# `& D. m, U4 f b+ a6 f .name = "user_led1",3 w2 T' M$ {' L9 B6 b
.default_trigger = "default-on",$ c% N; O4 I7 C
},
7 {+ O ^1 T# ]4 H# Z( L! w {
9 M; o! D) Y' z, s8 J) r .active_low = 0,
5 R; M6 i; M9 {7 }8 K! g9 V+ _9 K" O .gpio = DA850_USER_LED2,
8 V" S: [- X) } .name = "user_led2",& m/ `$ n* h% x. |( X5 s* {4 u: K
.default_trigger = "default-on",
5 M7 h6 [7 j, C" T },
$ M0 m% s8 R+ E9 X) [! Q {
0 J5 r+ ?# @! f7 | V .active_low = 0,
2 M$ H5 Q* K, r+ d4 u .gpio = DA850_USER_LED3,
* \$ R/ l1 R6 Z: r' r .name = "user_led3",3 L p0 U2 W1 a p2 p/ |" _+ c' ~
.default_trigger = "default-on",
6 B8 ^: d8 S6 [/ h: _3 k2 w },
6 g. U: Q5 |/ e! X; s};
: A% P7 o: l8 b) ~. C+ S1 g9 F5 o) C: b3 B" C6 b) j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' a; K4 O0 o: E
.leds = da850_evm_tl_leds,
' Q1 s9 G" K* x$ A* N2 {: l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) i* H$ D0 ]. ^8 @& R" \4 c};0 D" f2 ?$ k5 g, l( j
; K5 Q8 T* W9 c! ostatic void led_dev_release(struct device *dev)8 `# i8 N- _$ T/ A
{8 k& |- z! y/ H1 ?5 _$ l8 p7 o
};+ O+ e% h* x4 q
& E, L. `1 w0 L7 `) U1 F6 A( ?static struct platform_device da850_evm_tl_leds_device = {( t0 K5 }2 x( u9 J8 g/ G/ G
.name = "leds-gpio",
0 z, X L2 g* `( ~; ?" W* z2 z .id = 1,
& q& o7 P: X9 O: M6 o .dev = {
2 J& L) X9 h* ~8 e/ C- s .platform_data = &da850_evm_tl_leds_pdata,$ m: _7 ?' P+ m5 A& F2 c, p
.release = led_dev_release,' b4 Y) }5 G! q; l/ f
}
7 @# W, Z% U. ]7 w};
* e1 H& B. D, w. f" n( P( S
8 i) p j( s, Ostatic int __init led_platform_init(void)
8 I3 J; u# {# Y2 C) G0 ?9 ~{
$ n* m/ ^1 I6 u A9 _ int ret;6 g1 }6 O% p- j0 ?* Z3 l! ]! X
#if 02 h2 J+ R5 k6 K8 R4 }7 n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 N3 {* d& r3 E
if (ret)
' C+ j1 p. R. f pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% U& Q' B0 f7 B/ y "%d\n", ret);* a) R4 ~- O$ ~# U3 n7 h
#endif
" A4 n0 l p p3 h/ H ret = platform_device_register(&da850_evm_tl_leds_device);
8 z5 e) F$ @% Y3 e if (ret)
0 d3 P/ N3 L% w2 R# } pr_warning("Could not register som GPIO expander LEDS");
& N' k! v' E- D1 q5 X else
1 m3 _1 o& K# j$ C1 @% v printk(KERN_INFO "LED register sucessful!\n");( J9 R# \) w! D
* j" x$ x+ @6 {4 } return ret;/ w4 Q) K+ D3 i1 c
}
0 [) _$ {- t' |* s1 \3 K
$ @; @! K. `5 ]$ I" j. Zstatic void __exit led_platform_exit(void)) S$ ^. `( p i! }" s
{
) L7 U% X6 v2 q$ @4 F platform_device_unregister(&da850_evm_tl_leds_device);! q3 S0 Y% Y4 U: @+ e9 w1 Z
: r+ ]% a/ f5 I& {, u9 } printk(KERN_INFO "LED unregister!\n");$ r- ?# x) ~% e4 P% _6 m
}6 k, p: k% }1 _( D7 N/ g
, h, y' F! I; }1 n9 Z9 H8 u. _module_init(led_platform_init);5 M/ n7 d2 ^' ^" N. m3 g2 z
module_exit(led_platform_exit);6 N+ n- h; `7 s/ \3 O
& [. j) G" `' n1 X" JMODULE_DESCRIPTION("Led platform driver");
+ K5 C$ v1 [% n0 N/ SMODULE_AUTHOR("Tronlong");) }9 W% a' z9 U9 J, t, x% E4 b
MODULE_LICENSE("GPL");( n1 x, _4 I/ v$ B# F2 j5 p5 D
$ b- X8 _. t5 ?7 y5 K6 y
|
|