|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 a2 A2 [0 z5 _$ n8 s+ e#include <linux/init.h>
) e+ I" H' W' Y. Y+ v#include <linux/module.h>% |1 f3 V" F! p2 f6 }) \3 @1 a
#include <linux/kernel.h>/ @/ w* S0 R- u F9 ?9 a* V: W
#include <linux/types.h>
8 m, a7 S- v6 e; w#include <linux/gpio.h>9 c) S H$ O8 m* ?$ \2 h) P
#include <linux/leds.h>1 G4 x: _7 u) ~. k) {. \
#include <linux/platform_device.h>$ H( \* D- V7 a F
, V& q2 r9 b2 Y( L7 m) I#include <asm/mach-types.h>
Y8 n; r, l+ _/ _! r, h) _. J#include <asm/mach/arch.h>+ o( I. `; d/ l7 l0 n( d. Q
#include <mach/da8xx.h>: [1 ~' t6 n( v8 S5 F/ H; |9 z) R
#include <mach/mux.h>4 n6 p. x1 M, y
7 `: C0 L" y4 ~9 t" x) d( l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* r# k4 M6 ?* T% R#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: P. y: u8 _; I; y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 ~1 m/ l8 i8 D: N5 X4 A, {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' S0 l: G o$ S. S6 W& O, R
. Z$ G; w" t7 c" q6 g* H$ v/* assign the tl som board LED-GPIOs*/
, L4 O3 r& l0 b/ F. J* _static const short da850_evm_tl_user_led_pins[] = {* o+ n' j5 X& h& v/ G& B
/* These pins are definition at <mach/mux.h> file */3 W" ~) X* y: U1 z" i
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' N* ]! R1 c) ]4 ~1 ]9 N9 \ -1* l$ N# Q; w. g# `: Y
};
/ }/ F2 d! L# b, s2 a
$ R5 T0 g7 ?* Xstatic struct gpio_led da850_evm_tl_leds[] = {
8 }+ l- Y' t1 N/ ?! p, b. ^ {0 u4 |( Y" l" S- H$ ?! ~
.active_low = 0,) M0 R. a- v9 ~8 `* o5 u# v
.gpio = DA850_USER_LED0,
# z I/ I9 M% {$ A+ e, F .name = "user_led0",' [5 W- q4 l9 b
.default_trigger = "default-on",
& r# O6 B" w. Z5 \! u4 T/ d },1 P7 E5 S" C- c+ c6 Q3 l# d& m9 {
{
* @) y) u/ D, d: T0 c9 L .active_low = 0,8 x4 m* m1 a; o/ ]( L, S# Y
.gpio = DA850_USER_LED1,
2 N2 F7 I% J" r- Y .name = "user_led1",$ c! M" F4 x: p7 j, j" V% A- k9 R/ Y
.default_trigger = "default-on",1 Q ?" ]* p) y z5 H$ Z% L
},! t( U1 p: l. P9 q$ U. h
{
; h/ K0 g k3 X/ N .active_low = 0, w' s' d0 @" j+ ?" e& D8 H
.gpio = DA850_USER_LED2,. U R c7 V7 y- ^( }4 e+ L
.name = "user_led2",
6 S# u( R4 N* n! i1 B5 i( Q9 x .default_trigger = "default-on",& V0 d+ j$ O$ T. o4 ~; d
},5 b! o, M( C, f
{
8 ^9 D* N4 T0 s; K3 ^% W+ s5 T5 S .active_low = 0,
% z3 _. w! Q/ G1 j+ ^. K .gpio = DA850_USER_LED3,, c. c7 z) I# J; Y& K, S5 @
.name = "user_led3",. G* D+ N) z7 ~6 i; ?- V' S
.default_trigger = "default-on",' B1 V2 X# F4 y8 z
},2 j7 x% N, V% F
};& N0 `, n3 _/ ?$ ~4 l
# K$ X Y w' w) M. ]+ K5 C qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% s. a1 w% Q& x K' o$ i6 l. [
.leds = da850_evm_tl_leds,
4 z) P( U0 A. T( t4 z+ \ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 W5 L% r% f) g/ B o/ C3 I" H};* e/ W W# g9 r% g/ @) s0 I
, N6 c7 ~4 k) M: fstatic void led_dev_release(struct device *dev)
6 n( U) {' I/ j8 S( L8 J& ^{
$ [& _1 M& z' a [! C9 { y};
; {$ y( r& k# n/ V2 G1 {7 N! C! N5 m- N r6 z! [
static struct platform_device da850_evm_tl_leds_device = {
5 i2 g. y5 a4 k& m; Q+ p .name = "leds-gpio",5 G2 U, m j; M$ {! l; o
.id = 1,! M, t N/ e* h5 }+ z2 e$ s
.dev = {
( T, n; d% l8 J0 d1 F; \ .platform_data = &da850_evm_tl_leds_pdata,
- i( \' u! U8 E7 ~& w; k1 i0 Z .release = led_dev_release,
) f9 Q" Z' u: A0 T4 \" N9 R6 h }9 R" X, v$ P# L( k; e ]
};
2 W0 n/ `8 w. T: v. m- B7 @. |* N: c8 O; s: @
static int __init led_platform_init(void)
) |) F4 } V4 Q9 ]6 ~+ ^{* R/ a0 i4 v7 T. m! [; A3 |( z
int ret;& I* H# `- } C* U4 e7 t4 O6 Z# e4 H
#if 08 t: H% Q6 c3 Q( Z3 O8 Y( v5 }% W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" G: d6 u: @, L3 }
if (ret)/ H) n$ R! s5 q; T* ^6 L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' G2 G5 Y0 T0 {- B6 {. x u "%d\n", ret);- ? ?: t: M. m+ P; K7 ~
#endif
0 ~9 n' c$ K3 }7 i6 r ret = platform_device_register(&da850_evm_tl_leds_device);
. c+ K* H, l2 D, D9 U" y4 i if (ret)
; D) I3 D6 U- Y, a3 c9 S& ` pr_warning("Could not register som GPIO expander LEDS");
' c$ l. i- b4 M9 a3 H5 H1 \ else
$ \- {/ B8 W0 e printk(KERN_INFO "LED register sucessful!\n");; N1 ]! T2 C: h$ V& S, V
6 {! F4 z# c, J: q( ~. z& m# X. E return ret;( q- X) l/ v. R8 U# z' H% ]+ |& D
}: ?# n) P1 u$ Q. ^
) ~2 V! i9 e: L. L2 |
static void __exit led_platform_exit(void)6 J9 o- T: J& i7 G; B: B7 M& Z- |
{2 i8 D, _; W5 t$ A! V2 Z' z
platform_device_unregister(&da850_evm_tl_leds_device);
: M8 i/ c2 j3 B) }6 z3 r5 L! b8 e
4 q! Y* S w" ^, z printk(KERN_INFO "LED unregister!\n");5 r7 i! f9 C' j9 T
}
/ x. a& [+ g! z& C% _# N
0 J$ U) G( Y, Cmodule_init(led_platform_init);
: t9 p+ [% B& u. `; mmodule_exit(led_platform_exit);+ e% V$ p, i+ Y8 M; p" a; U& P
9 e' M2 d* H* F. M% o/ d M8 K, @
MODULE_DESCRIPTION("Led platform driver");
$ d' x( t& L z1 u- ]MODULE_AUTHOR("Tronlong");
# s- K& j! n" W. K: g5 kMODULE_LICENSE("GPL");
k" \. `4 f( g
8 q' N A/ w9 e1 z! I |
|