|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ ^7 c% x3 J' o3 k# C( y, z4 _
#include <linux/init.h>
6 |7 E9 k- L# O$ ^% ?; P5 `#include <linux/module.h>. f4 F; x, _3 T- Z5 ?
#include <linux/kernel.h>
. u; Q4 s/ _. u# G8 p% R#include <linux/types.h>+ p, _: j. |$ U4 X! w) @
#include <linux/gpio.h>( ^) @) p* f7 E) o' C
#include <linux/leds.h>
. i5 R4 J2 P; D" y0 t) [#include <linux/platform_device.h>
9 w! s; F7 J) z. q4 | l6 ?8 U' B4 |* w0 k3 ?/ t
#include <asm/mach-types.h>- e2 g9 ~5 \/ J3 A- X( C' Z; H' E+ k5 y
#include <asm/mach/arch.h>
" ^0 y% U( y6 y) {7 H/ K#include <mach/da8xx.h>( b* m% C1 T: F6 r, I6 y$ X8 b
#include <mach/mux.h>& f2 k! K* q& t& x# c0 ]
2 h2 S- ^ q2 x2 J2 D9 p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 `- P- q' R" s& K* g- D. _$ Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 I# |0 |! Y; v3 K4 B#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% ^1 x0 w$ D+ b) V# z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 x) E& {; {" A6 ^) G/ _4 l7 U. v+ x$ H. T
/* assign the tl som board LED-GPIOs*/
9 C5 ^8 I9 G$ gstatic const short da850_evm_tl_user_led_pins[] = {( b" Q7 ]9 f S$ a2 v
/* These pins are definition at <mach/mux.h> file */" P2 U- u; i5 T1 \3 u5 p- ?% C) U0 g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 F. M2 e" h- V+ R. O
-1: C; U' F' O l* t4 R3 A
}; ~$ y! _- _" c$ l
7 N+ `: l! ~8 h* u( M2 {: }static struct gpio_led da850_evm_tl_leds[] = {
. i. Z8 W: i3 `. g7 N5 F {
( M( i/ F' N3 b( X5 I .active_low = 0,
9 ?! E0 @% R7 ?- \' v, @ .gpio = DA850_USER_LED0,
! S9 |: y! c+ ?/ R/ P. U* V, G .name = "user_led0",
$ [" Z/ M+ h+ X, S3 ? .default_trigger = "default-on", N" Q9 p9 m" ?
},
- u: P/ K% k# ~/ | {
- A9 c% [" R$ O# m .active_low = 0,5 w+ q9 m% l3 Q0 @
.gpio = DA850_USER_LED1,4 k% o4 b/ x7 I9 Q1 z+ o
.name = "user_led1",. `# _+ | G. K
.default_trigger = "default-on",
2 |& ?/ y( B, L. _) y },& s5 j4 z- @- b
{; @% p% D6 ?6 d; H: \4 p
.active_low = 0,& w% f5 \! N C6 I
.gpio = DA850_USER_LED2,
8 s; \: L {9 v: B% ?: ]# E! E3 ^ .name = "user_led2",: v$ ~" c8 E3 B3 F( X; V
.default_trigger = "default-on",
, C3 F! ~( X5 w' X6 H, Z: s/ v },( ~7 |3 B' w) J. c2 T
{+ n; ^4 Q( @8 n6 \& K
.active_low = 0,6 r% e; v9 i" t8 E7 X$ d9 W' T
.gpio = DA850_USER_LED3,8 G. D& s4 s3 A' w
.name = "user_led3",6 _( A0 N/ i' u9 x K! T
.default_trigger = "default-on",: n' f% i# P9 b& P S) B& B c
},
# [# m; ~7 j# |3 i3 p( k' _6 S};
& Y* q0 ?" a5 F, P) u' o) R8 }4 B) A- ]: q9 t+ U( w7 D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, _" X+ u5 } ^
.leds = da850_evm_tl_leds,3 m, `5 x" ^% u% ?4 K1 |) s. I) m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," d* J" t) d: X4 @: h
};
$ v; M- y3 B1 `& T' d& e$ x: `
' |! _3 e2 ], z( Rstatic void led_dev_release(struct device *dev)7 h0 l' p+ z, c o' [
{# D* S( R, Q! u, |8 v
};( X/ e# M" M" r4 q& B. |
& A$ n1 H; @" e7 e& o/ j8 ~/ X& Y$ _
static struct platform_device da850_evm_tl_leds_device = {2 a5 A( }/ s, X2 h9 @
.name = "leds-gpio",& V* j8 l* P4 J$ z1 w% ^1 b
.id = 1,
! |3 x# H5 x/ a# o .dev = {* d, z+ d6 w# Q
.platform_data = &da850_evm_tl_leds_pdata,. R$ V4 f7 v8 h9 n6 F
.release = led_dev_release,
% Q* b! [! C3 \ }& Z1 \9 d) m: `, q7 Z" S( @9 N V
};9 W* k' Y* C( E; X1 S1 L
3 q; r! L3 R3 y" A( D0 Estatic int __init led_platform_init(void)9 P* c! x' F- Z# r" ]7 ^
{
" ]. k. D/ W" P! A; ^ int ret;
) F4 D/ F! H$ b' @3 G#if 0
8 ?/ C8 K0 @2 N* n4 u" L ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& U7 M; @6 F+ a0 @" O if (ret)! s- w" R+ W4 d) n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 i$ S: `" d3 D
"%d\n", ret);$ I$ l6 D7 r* y3 S, }( P; K- M
#endif2 ?) g. t$ q8 t; y( q8 R
ret = platform_device_register(&da850_evm_tl_leds_device);5 R- X2 g: I( k& R* w( N
if (ret)7 e% R/ I+ F$ W+ f" p6 O
pr_warning("Could not register som GPIO expander LEDS");
- }$ C! u$ `9 [ else
, O9 T. V2 `( y4 j% c printk(KERN_INFO "LED register sucessful!\n");1 x( L. o9 R5 e5 |; o, g
5 B* }7 V3 F$ D return ret;
: o$ ]% G% U- Z+ [+ v" ^; C7 A4 w}
- U! E! ?& W2 S
1 A" |0 z: K% r! [! F* x- T$ W& \static void __exit led_platform_exit(void)
4 T) F- X7 u" W" X3 n: n$ q{5 _ r2 B- Z1 R9 ~* F- ?9 p
platform_device_unregister(&da850_evm_tl_leds_device);& ?9 x$ m, g1 O6 }3 D' W% {
" a' c" x0 q0 e% O printk(KERN_INFO "LED unregister!\n");8 H: u: o& x+ j; K/ t A
}
L( m0 _( r& x- v' y: q) Z: e" @
module_init(led_platform_init);
. b7 \$ |8 Y2 @9 o) k) E. {2 Amodule_exit(led_platform_exit);
2 W" m8 z7 z4 ]8 K& M2 ^- }# D7 K y9 Y7 @* n' Z- B; h
MODULE_DESCRIPTION("Led platform driver");8 z& V3 V+ d' @
MODULE_AUTHOR("Tronlong");' @* p& a; E- D2 V
MODULE_LICENSE("GPL");
/ Z9 Y4 M( y' F; |) ^; ~" j& r! G# T a- J
|
|