|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* M" }2 N8 n/ s& t$ G* v* a3 M
#include <linux/init.h>
' T3 C9 t; W& M1 ~% Q/ A3 b#include <linux/module.h>* O8 P9 A0 j: t0 ~
#include <linux/kernel.h>& ~. G3 s+ Z2 {. G7 P" r, s
#include <linux/types.h>
$ I6 D4 H: V3 D& R5 T#include <linux/gpio.h>
5 h. S2 M( ?8 n* Q+ H#include <linux/leds.h>
% X. h( n2 l6 l1 w#include <linux/platform_device.h>/ T; X i6 L/ Z3 n/ F
/ z3 M" R1 y7 Y. [/ p5 X! ~
#include <asm/mach-types.h>
" t: }7 ?- D8 o1 K; t#include <asm/mach/arch.h>1 G0 n5 j1 E# J( B [; E( H
#include <mach/da8xx.h>$ D" I$ q: G y4 M+ X; N4 \
#include <mach/mux.h>7 ]: F8 o" I. w0 _# E
' I) E- C( x5 i3 g6 e" @" z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 g7 _. _ ?. v0 v8 e) q$ o#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 O' l! m1 G- t" \' z# Y' Y: N#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: w- d- t1 R& O! R N# Z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& Z# p1 [5 S5 `% B
* n+ U! q- E( [$ g" e/* assign the tl som board LED-GPIOs*/
. X/ @: c# X2 B sstatic const short da850_evm_tl_user_led_pins[] = {
l) k0 S6 m2 f" h2 U/ L /* These pins are definition at <mach/mux.h> file */
. B/ e* I. f0 d6 [' X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 ?# B6 m7 `0 M
-1
8 {- v" X" c+ r- s$ t% T};
/ f* }3 j( r3 _3 n2 y
, s T% ]7 ^0 hstatic struct gpio_led da850_evm_tl_leds[] = {
7 W$ ~8 ?, b! G {
8 W6 P! L5 T0 L4 U* h5 Z .active_low = 0,% o. X# F" N: y3 y* y
.gpio = DA850_USER_LED0,
8 r( \9 c! t$ y; U .name = "user_led0",
I1 v* B$ H+ D, b% p8 _. E7 ~ .default_trigger = "default-on",
& ^# k* X' N' K: \ },
% w* [; s2 s( s# h {
' N! @( E' H- F1 f0 L( T) `. c .active_low = 0,6 P5 f6 h0 a, W7 n
.gpio = DA850_USER_LED1,/ U9 S: X% X- \. ~
.name = "user_led1",' n- a# D* Y; V" V
.default_trigger = "default-on",
9 F$ d! h% \, \ },
, V1 q+ }, f) ]9 C Y {
/ z+ j# t. t% v .active_low = 0,
# v: @) w0 o6 W4 o3 w( T j" Y+ P .gpio = DA850_USER_LED2,+ M& V5 W7 h3 U5 u6 `: x
.name = "user_led2",1 F4 _7 {* _+ r e \* i
.default_trigger = "default-on",
$ D; B/ [- a3 `2 `9 P },- x( b( V* K' F1 q, `
{ n% E$ _4 |& {/ _/ O/ t
.active_low = 0," t1 O- W1 Q I+ @, z5 A
.gpio = DA850_USER_LED3,
" Q& Q) o' G! T1 H .name = "user_led3",
I6 t' j( Y/ G .default_trigger = "default-on",6 @5 |2 P; W2 y; s
},
; C# G$ b+ }9 v! o};8 m) U% Q- o4 s. y9 b: X5 f# v
$ N$ \. ~4 T9 c4 w+ M
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; ~; P: Z. B1 H3 _. g* q
.leds = da850_evm_tl_leds,
' ^: }$ A0 e+ f- X4 A .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- @( D" u7 y/ @0 F
};* w, x0 O/ }; i0 T
5 Q f, @, U, f( h' \1 S- @0 ?& c
static void led_dev_release(struct device *dev)
( p0 `3 ? t$ V5 p) q- R{
- r: c2 E7 h, O% m; Z( y};2 q5 t. | S* N0 v! q: i
0 K( c8 }$ w3 N. A- C7 ]static struct platform_device da850_evm_tl_leds_device = {: @; P( T- P+ u; q
.name = "leds-gpio",1 G+ v' F3 m5 k
.id = 1,3 I; X8 r. d7 T) K5 g# X( F
.dev = {3 G. i8 S+ ^0 w* J2 o% D
.platform_data = &da850_evm_tl_leds_pdata,& y3 z+ M- F7 _" i' n; F
.release = led_dev_release,& ?* U4 w3 K# v; A' G! y
}; S) f3 a+ [4 J" j6 h2 h: }
};$ u1 r5 t' p4 c
7 c/ L% b9 b3 n. ~ a0 F+ Q
static int __init led_platform_init(void)
$ S+ f/ C C8 N{% d" r7 D3 @; Y0 N7 C) z
int ret;
+ H( z+ u, p( m4 K5 y) ^#if 0
: j4 C8 ~% k7 @4 j4 Z+ M+ f+ w ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 L; r: M/ U9 E+ h4 N1 ?$ y if (ret)
1 W7 O& [) _, ~5 ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! U9 P% L9 x4 b1 N1 Y8 R1 ]
"%d\n", ret);
; U# J, N2 {7 w+ q/ x#endif, h, l. X, C; i. V* q, N4 S
ret = platform_device_register(&da850_evm_tl_leds_device);, E$ d. g" V- K+ `
if (ret)% P% V5 n7 [) N
pr_warning("Could not register som GPIO expander LEDS");
% v: r4 ^ p1 r1 c# O else4 A# B" C# o2 |3 X; v! o l
printk(KERN_INFO "LED register sucessful!\n");1 _5 ~2 I3 b# `7 p/ L
4 k. P4 U1 z1 N return ret;8 C( N: H4 l# r5 n. E8 I. g
}
9 C+ Z' P5 C& y2 w; @0 P
1 B1 |) V5 T. g3 F7 G. n( M; Mstatic void __exit led_platform_exit(void)6 k' J, X0 d: D5 w' g1 x
{2 G" Z. `3 F# I; N$ e% I5 G
platform_device_unregister(&da850_evm_tl_leds_device);! n8 ]" }( j, V2 ?- L, [
; w5 r2 q; L5 n0 K) d T$ n5 x
printk(KERN_INFO "LED unregister!\n");% a$ p& z# k* a8 x# W' o8 R
}
0 ]3 T2 E; `1 ]* z7 R. ~$ E% B
% L. c! n, j a+ ]module_init(led_platform_init);' k/ K8 @/ D3 x
module_exit(led_platform_exit);" d( d/ p% J( D" S% ]! I( g6 C, A
O+ \7 y% R [MODULE_DESCRIPTION("Led platform driver");
6 q \! V, @9 `% ZMODULE_AUTHOR("Tronlong");( m. K# k2 _ M+ ?
MODULE_LICENSE("GPL");) Q4 Z$ }, n) Q
% f! n) K1 d* l) o6 M |
|