|
求大神给下面的程序做注解,请稍详细些,谢谢。8 N) [) X1 p8 Z0 ?7 Y0 v) h) _
#include <linux/init.h>
* z X3 N/ B9 _' U9 C) K' S#include <linux/module.h>
# |* w$ J o3 f3 o2 {- q#include <linux/kernel.h>
; j* n) B8 H' C$ }% B. O#include <linux/types.h>8 g; K, o# `4 ]5 ~% o
#include <linux/gpio.h>& V4 K% N. L* c5 p& M4 r
#include <linux/leds.h>
q( H: s+ }9 e#include <linux/platform_device.h>
r: O! R" n9 K) ^6 g' S1 A/ w' @: h c0 Y
#include <asm/mach-types.h>. Q% o( W( |& \. t- a
#include <asm/mach/arch.h>
: R# r; n* H- Q! D9 a2 W#include <mach/da8xx.h> a8 l& G7 f% [9 \9 A" Y6 W) S
#include <mach/mux.h>
( E( @* P/ X$ K! Y5 p3 x
" n! P7 z% B. Q+ R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
?) b/ W( e( E) A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- O$ b4 p& @" y. {2 U
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( R" N* Q& A/ V- F: Z, q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& A; \: K7 E# Z* M, _
/ W6 e: c, u. l( H7 f" J3 B5 z/* assign the tl som board LED-GPIOs*/
) {4 W- ?' J4 Fstatic const short da850_evm_tl_user_led_pins[] = {
' ?' S& H n7 R! {7 W /* These pins are definition at <mach/mux.h> file */1 t( p1 g& T; L* o, A! Z7 u
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, K( n4 }/ H/ U; |* [' C" T
-1
; Y/ X+ z1 W/ `% k* J};
6 B# P- p' Y$ b u- {7 b1 ^: a- C& L5 ?. U
static struct gpio_led da850_evm_tl_leds[] = {
! w7 y: \8 c4 x1 t {- |( ~# K/ l) H8 {( y3 b- ~/ Y/ G
.active_low = 0,5 R0 v% T8 T' C0 H0 w3 Z
.gpio = DA850_USER_LED0,
F+ n. |" S* b0 ?5 f5 T7 O% U1 \ .name = "user_led0",
6 c. x, p0 `0 `$ j& ?, I6 C .default_trigger = "default-on",
( H5 G8 e! K4 m6 w* {5 k, w/ M },0 l, Y/ i. q( z+ a
{
9 U ]1 J/ r1 p0 _# N .active_low = 0,
) k% a/ k* V8 a6 b. ~, s( Y .gpio = DA850_USER_LED1,$ x9 u% g" w% C( j
.name = "user_led1",+ Y( X ?. Z0 h# ~1 ?
.default_trigger = "default-on",
0 ^: b! }8 {8 Y e+ @& O0 L },
" X8 K0 S0 \5 r {" K0 e* ~& ^0 D7 e3 I" h
.active_low = 0,
) o8 ~! o$ U% M! }$ R! K; I .gpio = DA850_USER_LED2,; b2 v3 @& O8 s/ u1 M8 p
.name = "user_led2",6 O0 z! a! ^' u6 _9 x
.default_trigger = "default-on",. w# w, F6 a- y
},
, c$ S6 g9 m5 W& u% n% m" ^( ]$ ~" w6 Z {. S8 v( @* X% g" u4 Y* J, N: F
.active_low = 0,
, Z5 X! |- R. K9 z1 a+ y/ x9 K .gpio = DA850_USER_LED3,
. v( N/ B( l" w. @/ T .name = "user_led3",8 ?0 |. X" s9 D( k) J8 R) p
.default_trigger = "default-on",
! [ K0 @- ~7 r. i1 O! W1 e5 V },
8 g( A# b2 R9 F& y4 f! X};) M& D0 w- I% _7 A1 ]' i9 E% m
0 x! c- T8 i% h* J" ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 @. i1 x- B% z
.leds = da850_evm_tl_leds,- c4 t& w' b( B0 e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" S. o5 G" c* z- y# ?6 d! B7 L1 m; v};
! Y, X m" ?; V6 z% k( Y! ?6 Y. b- T) S; o* w
static void led_dev_release(struct device *dev)
# d$ C; H( c% r7 Z% q4 g6 n8 [; o{
. h& V0 Z y @* E9 N P};
" v2 b7 L. o+ {; p' s
% D9 y! o& P/ }2 m4 jstatic struct platform_device da850_evm_tl_leds_device = {
! N3 G7 K% p$ z3 `' K8 J) f .name = "leds-gpio",
s; s, Y5 B5 [! F4 _2 F+ g .id = 1,9 ]- K/ x, S) P( k& }
.dev = {
; p) R. R3 v' _ .platform_data = &da850_evm_tl_leds_pdata, y! x; W U# j* J% _
.release = led_dev_release,( L. G1 t) q7 ]. p7 a
}/ Y5 V6 i; U- T; c6 n, E/ M) c' E
};
+ L* i* _8 `( G# f- f/ W$ a, e3 [- b1 b
static int __init led_platform_init(void)2 \/ ~5 k+ \$ F! V! c$ G- J; {, d, u
{
* V* l* X/ N" [: e0 Y9 {: A' J M+ E) S* f int ret;+ L0 P, b) A9 }) z- X P
#if 02 w0 z2 X' z* d9 H& {/ M: J2 }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; t" m [7 v3 ~6 Y
if (ret)
/ ~5 x! ^1 F. s4 E- U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 D8 n; x/ X0 P/ ^9 l J; {
"%d\n", ret);
1 V: }/ I( S0 b#endif
5 c4 t" L, O! J, `; } ret = platform_device_register(&da850_evm_tl_leds_device);
" ?4 R2 ]; x( z7 V3 w h9 X if (ret)0 V9 O5 E. L3 j1 b
pr_warning("Could not register som GPIO expander LEDS");+ Y1 [/ P/ o. @. Y; q
else% i4 X: r* b* C7 x; W1 v: f
printk(KERN_INFO "LED register sucessful!\n");
" |# A. S6 k4 l
1 j0 C, ?+ f1 X* c* e6 w4 g return ret;- ?$ W w" e8 h4 n3 w! }6 O
}
! S0 p& r' X8 G
3 }* [& |7 O3 _$ l! |" f; Tstatic void __exit led_platform_exit(void)
! r& a% P& [7 m) r{. c2 c0 t r/ V$ {" L/ b
platform_device_unregister(&da850_evm_tl_leds_device);
+ F& ?. q# U, K$ m7 s
/ i' T& A# k4 w1 ?+ w1 L' f+ b" o printk(KERN_INFO "LED unregister!\n");
: b* p& ?- M$ |/ ?7 H+ [. n}4 f6 ^: L1 D, y2 o
1 g \9 A+ r6 q( }8 M: P4 U
module_init(led_platform_init);
! p' \/ P z# }0 nmodule_exit(led_platform_exit);5 Y# q3 i0 h- J4 d. K# {, O
- P. u. m+ Y, y3 @/ c4 ]+ x* g$ \MODULE_DESCRIPTION("Led platform driver");
3 G- q. [! ~% i6 `* e7 G; h& W0 kMODULE_AUTHOR("Tronlong");
0 a; o+ V6 ~$ t& n0 _MODULE_LICENSE("GPL");7 z# Y) K7 @) v
. r4 A1 ?" r) R: ~1 G: y
|
|