|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" O3 Z; X7 g j#include <linux/init.h>
+ @. C" U2 l* ?5 C" I#include <linux/module.h>0 I) k, |1 K) N8 k! C8 m8 w
#include <linux/kernel.h># T# ^4 i1 v$ {- W( q
#include <linux/types.h>
, J; E! }6 o8 D8 J* t2 }#include <linux/gpio.h>
. d3 N: A7 D" U: q2 t#include <linux/leds.h>5 J. [0 B Y8 ~1 [
#include <linux/platform_device.h>% }$ C) M! @2 F7 q- G {) {9 ]
5 P3 a/ k$ [& r
#include <asm/mach-types.h>+ T! q* q* C$ K4 I6 e% W7 n6 |3 @
#include <asm/mach/arch.h>
4 y3 O1 o- G! s i; f B#include <mach/da8xx.h>+ Q4 O5 n& I" u7 {+ W2 E+ V" b
#include <mach/mux.h>
( o' G- ~% R% W# q. v5 k
3 x# G2 q2 u! A' A% R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); _8 K* S5 n( [/ ]) N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ A- h" ?" j7 H3 q9 J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): k: ]/ w, G' O* e* d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 c2 s' s" |% g5 w9 y7 j: `3 R2 g. e$ d3 t3 c6 L
/* assign the tl som board LED-GPIOs*/
- P$ p: W& }: }! Z' t$ Q) O2 Tstatic const short da850_evm_tl_user_led_pins[] = {# U/ M) X) [& N, K, i
/* These pins are definition at <mach/mux.h> file */
& G3 I0 P7 q* h! l/ k% ]& ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," e; H2 @) V0 u$ u
-1# r0 X1 R7 S. V# B- M
};/ i7 v. U5 k9 C
; p8 k6 [8 X& P* p8 f" ]. N$ pstatic struct gpio_led da850_evm_tl_leds[] = {" p3 w8 I* W, U4 S1 `. J
{9 s/ o q1 B: T2 ~
.active_low = 0,8 A6 }6 d2 O2 A, e
.gpio = DA850_USER_LED0,) b8 T7 z% g& \% u+ ]' e1 V3 b% a
.name = "user_led0",! n9 R/ \0 K& t% L: u1 ?6 G1 k
.default_trigger = "default-on",/ F# _' z- e5 G' N& M4 m
},
5 W$ J# ^; \. ]1 b {
# ]0 c' F8 `+ x/ ^0 H4 r; B4 m .active_low = 0,8 V! f4 t N4 s$ v
.gpio = DA850_USER_LED1,5 {, S; Q& ^4 u5 |& K7 G
.name = "user_led1",9 R. _# D" N; n
.default_trigger = "default-on",( v6 C+ S6 R; E- N3 B
},
3 x2 ^& l% y! R& A8 L {
9 f8 q' M+ c V) u1 z% }! f .active_low = 0,
9 \* u) ~# l, e b. K& x1 ?- T .gpio = DA850_USER_LED2,* j- g: D2 V5 D: b
.name = "user_led2",% G6 ?" K/ k8 b0 f8 n
.default_trigger = "default-on",
6 Q/ x0 s0 S( @, J$ K4 F }, `+ G' V7 s% B. a' Y( Q
{# N6 p* g6 B$ [; Y4 m& z
.active_low = 0,
5 J+ V! F, h& @ l% ? .gpio = DA850_USER_LED3,8 w) J: X! K/ G* K1 h% r
.name = "user_led3",1 {& }+ `6 Q9 A( i* U2 `7 I3 I
.default_trigger = "default-on",
: U* {1 d) R8 p },$ @% J1 [% E2 f" c
};1 ?/ X- T# b! }. H; b4 Z" h* `
7 w! B- k( p1 K; d* n! _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- n# S |9 y0 D5 V- F; U& f/ A) ` .leds = da850_evm_tl_leds,1 i- S# ~0 j D1 W* r$ T
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" H% i5 a: w" j1 y5 l& y" `% _};' r+ B8 R) Z9 ?+ @3 }/ O0 U; [
- M/ r3 R. p r% J; l5 s
static void led_dev_release(struct device *dev)0 j; G1 @3 ?' X0 b8 c2 r% _( p0 U$ j' L
{* q7 F4 ~5 G( r( L) Y- b
};( }- t" d# j3 @
6 z- h+ _+ f1 d% w o; Tstatic struct platform_device da850_evm_tl_leds_device = {# t4 I7 X' P8 P
.name = "leds-gpio", j' }% U. ^! m2 l$ P
.id = 1,& ~ t a- e8 r9 u
.dev = {" u* W0 T5 s, M9 f7 Y& B! L$ c
.platform_data = &da850_evm_tl_leds_pdata,
+ C Y9 P2 U: u. P! s .release = led_dev_release,
) G3 }+ J8 X- `- d; f$ T1 h }
" _1 ?% r! P5 b# D# T: E};
( i6 M ^2 |6 |# d$ x# R, l+ K! e7 w- A% }# j' `: ~+ B
static int __init led_platform_init(void)1 J+ T9 K( P/ t, p9 q" c7 X
{/ X6 b% b3 w0 v% c1 M* y" ~/ r3 S
int ret; d$ a; K) ]1 W6 L% K) T
#if 0
, `3 P s1 ~! _ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ K0 w8 _$ G# V0 u& r$ { if (ret)
8 a9 v( x4 n& l( i2 T! l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! E5 o- k# Z/ {! ?! C: w5 D
"%d\n", ret);8 q! S/ i2 N1 B% _# l: L
#endif6 S7 p4 c4 C6 U
ret = platform_device_register(&da850_evm_tl_leds_device);; Q, ^6 \4 g3 n9 w ]+ O
if (ret)
9 [) I' ~ c% I$ U9 @, a4 M pr_warning("Could not register som GPIO expander LEDS");3 `: |! t$ e; U( @9 N! ~
else0 w" V2 w/ w [. m
printk(KERN_INFO "LED register sucessful!\n");9 ]6 b2 w5 J# z% Q
, b* W& _( }2 A, \6 b4 @9 k
return ret;
+ M* L, X3 |" o( C. `" n) K ?4 y}. _5 v: s# z& I+ ~# ~/ {, _ G/ W6 \
# R& ]" I( Z$ p" b4 P" |) J
static void __exit led_platform_exit(void)4 S7 O1 s/ n: W7 C/ l. a, [
{' t2 ^7 |1 i( ]% i/ I' o
platform_device_unregister(&da850_evm_tl_leds_device);
5 M4 P9 ?% e+ J9 f* U0 d2 {& E4 E3 i: i5 E* Y. u
printk(KERN_INFO "LED unregister!\n");: ~% O6 B+ V7 g" n( W" G
}
9 c0 m- |) u6 p; K* B" E/ N8 c+ W T
module_init(led_platform_init);( Y* v4 z' q/ t9 M. [0 M
module_exit(led_platform_exit); B; J+ m) q8 x' n$ \# F- ]
7 S2 v) D$ u9 w( nMODULE_DESCRIPTION("Led platform driver");
2 H3 e0 K" O- i7 L; e& {9 ~MODULE_AUTHOR("Tronlong");
8 [+ B" ^6 y9 r5 Z6 h/ D7 @MODULE_LICENSE("GPL");$ m& v5 g5 X% B7 d1 c3 f
! \" }# x1 a& s8 \ A( L6 z
|
|