|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 W& X$ B7 \# c#include <linux/init.h>4 [- T/ k( S k
#include <linux/module.h>' Z- o; p8 C6 L+ {7 Q
#include <linux/kernel.h>. }: l" S9 u/ i7 e
#include <linux/types.h> V: Z4 O- b6 {+ p
#include <linux/gpio.h>3 K5 D/ Y; o' \( t+ z6 N
#include <linux/leds.h>- ^: P- l# s) l' V
#include <linux/platform_device.h>
0 i8 ]( X0 c0 |' P U, f) }7 B; V! ]& a( \$ a; E( m' X
#include <asm/mach-types.h>
3 ~- P1 H! I0 |6 d4 d#include <asm/mach/arch.h>2 ~+ ^, k3 D. M$ T5 D
#include <mach/da8xx.h>
7 f5 z, B# M o+ u b, W8 s# }* S#include <mach/mux.h>: y' | E8 j. p% K( [1 @) ^
# i) ?2 ~# @" {2 s7 ]#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* x) [# m2 O5 X# }, r: F#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. ^3 ]$ y7 ]5 `% i- C#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" ?" P: D7 x- U. r4 n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& V8 t& q5 a: V# \8 O% |9 d# n2 S4 K; `8 w
/* assign the tl som board LED-GPIOs*/ V! f3 ^: |" b, @
static const short da850_evm_tl_user_led_pins[] = {
; z+ Z8 @' {/ W1 ^4 A6 a /* These pins are definition at <mach/mux.h> file */9 x/ i. l' R$ I0 N3 y2 S+ f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- |/ a; c/ ?+ U) R5 c$ { -1
. l& ~: N5 G3 s6 o8 ~0 R' T/ Q+ y. ?};
1 `) P! Z* W+ c( D6 K6 \+ r/ h( S. C5 u7 F, g0 s1 Q2 d
static struct gpio_led da850_evm_tl_leds[] = {
* } p8 C4 ?: D; U, ^ {# h7 `* p3 a# P- x1 H7 b$ d! \
.active_low = 0,6 Y7 `( | o7 }2 j" X1 X
.gpio = DA850_USER_LED0,
2 a" F) k1 o3 ?/ {9 x& {! P .name = "user_led0",
& ^4 X' g7 L, {) f* z .default_trigger = "default-on",
+ m2 u" D/ C3 G" i. J* | },' y# m! w/ ~4 Q
{( ^# ^2 L5 E G! x. z- M" I
.active_low = 0,- n4 @: ^+ A g3 K
.gpio = DA850_USER_LED1,
: w% d2 a v3 t4 v* s .name = "user_led1",6 M+ h5 w) s$ C9 x) y5 A4 \
.default_trigger = "default-on",4 m. v1 s- l. e" N& I
},
0 E# E" H/ H1 w ]) D, x {
7 `2 \1 R- Z Q8 Z .active_low = 0,
/ x( d; \& A) S% y# W/ s .gpio = DA850_USER_LED2,6 v( Y$ Z) e# w. M
.name = "user_led2",
2 K/ \' S- |& \ .default_trigger = "default-on",
% g- y" X+ u# X; B },
2 S1 v3 _: A( Q {- H0 n! [- x$ n0 r# b! ^( z+ M2 e0 N
.active_low = 0,! m8 l! X# ]$ U9 n& @2 b' o R
.gpio = DA850_USER_LED3,- p4 l+ n0 o/ w9 |; a4 s' E. J! k
.name = "user_led3",
. o) _" W2 N& t .default_trigger = "default-on",
$ x2 ?& l! U& c- K# z0 z! v, c },
8 M' c7 A8 r3 h3 C# V% Q( n};! p m. r C. s2 W% @* |: O7 ?9 K
, A: f5 C( f; o$ h9 E5 @& ]0 H! mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% Y- V4 q3 l. [* z1 [3 K
.leds = da850_evm_tl_leds,
* ]! ]: d1 `( ?9 Q6 ? K, x5 } .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& D0 q* v- Q. T};
! j9 Q% |; k* ~6 V) a
/ E; J+ O8 d4 d; `static void led_dev_release(struct device *dev)
) n9 }0 z- I, C0 x2 o" O* t{8 X& i. M4 r/ Q
};& t9 l E; ~ F2 h
) Y# A/ u, h# W0 bstatic struct platform_device da850_evm_tl_leds_device = {
" Y P5 I1 i: `8 E' Q' \+ g! y' J .name = "leds-gpio",0 h/ A9 J- p1 l, q
.id = 1,
3 q0 x! ^; V, ~) n B& Z7 \ .dev = {1 z1 Y$ z! { r- j( R- T
.platform_data = &da850_evm_tl_leds_pdata,( M. T8 P# e$ l( G
.release = led_dev_release,7 p0 [' x' R( V/ m7 _
}
( B- N& U* m: }' \};
* h8 J; m0 h: } m0 j L% k
" E( [, A! e' r+ y7 k' a0 Zstatic int __init led_platform_init(void)
. ^" ^ B* p$ p0 N+ z{7 U3 T" C3 i$ a$ I6 h$ x I
int ret;
6 l' ?* y$ X7 S0 Y, v#if 0
" @' {' J& _8 Q2 w! b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ g% J8 C0 t& S
if (ret)
* ] b6 \% V7 ^5 r& k pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# R2 O3 U: z& e8 @) c1 m/ m+ @ "%d\n", ret);
; Y6 |0 g* ]3 c9 r4 Z#endif
; U% M4 Y4 _7 @* a8 o ret = platform_device_register(&da850_evm_tl_leds_device);
+ B6 h. P: q+ b J# r5 O6 G- a if (ret)
! W$ b# H y0 w O6 S+ J pr_warning("Could not register som GPIO expander LEDS");0 T9 K Y( W) o# `
else/ |0 F. G* M+ X
printk(KERN_INFO "LED register sucessful!\n");. X$ w2 {1 F4 G% b: n/ [6 J- D
0 A5 n9 Z* u5 h% u' f3 {' x
return ret;) d; C# h5 D% M; q7 S& C
}- S& I- ~5 T& h* J, _
6 A s- |& E8 E7 d! `static void __exit led_platform_exit(void)4 f4 ?. u" {. Y5 H/ l
{0 q4 }8 `9 \3 b) X6 N4 [; G6 y) b, `
platform_device_unregister(&da850_evm_tl_leds_device);- k0 z; w% Z; ?9 t; d- k
& z4 S' a: A/ ? L$ y printk(KERN_INFO "LED unregister!\n");1 w- L& y. G( Q; K6 A
}* O- N* R+ ^7 E6 c" I8 W
# M0 x) D2 R6 ~& Lmodule_init(led_platform_init);
! S6 u3 N" t/ Q T3 D( D% ~module_exit(led_platform_exit);' Z' j9 g* S( S, E3 O* D$ I
3 k1 s: a3 t3 T! q4 nMODULE_DESCRIPTION("Led platform driver");
' Z! x6 I2 I+ x. {* Y1 M3 i1 CMODULE_AUTHOR("Tronlong");
9 Q# U) M9 ]6 X" R) WMODULE_LICENSE("GPL");
h" d. Q" Z8 x2 p- E3 z1 ^! A# ^0 i) m% ^: W1 x7 `9 q! I
|
|