|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; Y. K4 K& U8 S1 ^) G" P; k. F#include <linux/init.h>* \, h) ~8 y: F
#include <linux/module.h>. D; K2 E1 I4 n! Q: y
#include <linux/kernel.h>
' U; f$ U* m( ]/ _& j; j) O#include <linux/types.h> Z) A& ~% d( W2 v1 i' k
#include <linux/gpio.h>
. Y4 D4 i( H3 R#include <linux/leds.h>
$ [( x" i- k4 v6 [#include <linux/platform_device.h>) ]3 |/ y3 a! a4 l2 u0 a
^, _. A) _/ a. B$ l+ ^#include <asm/mach-types.h>
8 x( t, u; T; x$ f#include <asm/mach/arch.h>
" B' O! K! [( G#include <mach/da8xx.h>! Y6 E* Z! g+ q5 _8 W; |
#include <mach/mux.h>
9 a8 o/ d$ k) c9 ^2 V
9 U* ^$ i+ b( _1 m8 P2 P#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); q5 ~: }+ a# N! H8 k$ @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# `7 h7 X6 e2 }/ M* `
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 Q1 k6 F# O" R9 K. b#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 B7 y# f& J" M- |
1 S+ W1 r, W! U
/* assign the tl som board LED-GPIOs*/# s; a+ g6 S4 y& K: J- M P
static const short da850_evm_tl_user_led_pins[] = {2 J" c8 Z K. g6 D# d
/* These pins are definition at <mach/mux.h> file */
' Z. g5 j8 m8 z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 @) q7 y; y- m3 W+ }/ h+ d( P0 u -1! X0 T0 M, }. r3 t* W% G, u
};
( {' ~0 c, z, v* q' ^2 \' N% E
0 D0 Y# z" ^5 Gstatic struct gpio_led da850_evm_tl_leds[] = {
7 r& x% S: {1 G) C0 P; S {
2 ^" n% V$ y2 w. k& e, X' s6 { .active_low = 0,+ O4 T J0 Q6 J( z1 ?% r
.gpio = DA850_USER_LED0,0 o) q' d4 _" P1 O2 @. ]. H# ^
.name = "user_led0",% O. {. |% C, L% `0 r5 S) k/ d2 d3 j
.default_trigger = "default-on",
% @( w& i! e w },
0 l2 X9 w# U- U/ q! `' g {
4 V1 Y5 J) {" b .active_low = 0,
. z- d7 d; U" G. C6 i: P .gpio = DA850_USER_LED1,
, k7 d1 [0 G$ q8 v# q, i# w& \ .name = "user_led1",3 S/ C# }% z0 \0 a! v+ Y; D; n I
.default_trigger = "default-on",
6 w, a& V b+ R5 z+ I7 n) T }, b: {- \1 W: [
{
' Z0 {+ X, U: w5 F& U .active_low = 0,
1 v( O, x* |4 R/ c0 {0 P0 \ .gpio = DA850_USER_LED2,9 B) U0 l' A5 Q/ m. A
.name = "user_led2",
5 W8 c& f; q+ ]2 _7 _, h .default_trigger = "default-on",
- |. o( C5 M8 \. _6 S- L% e- W; s# O },! c" V# D! a4 J3 o' G" |
{
% A- g3 e" q4 \4 d, {8 h .active_low = 0,
9 `/ ]* T# ~$ o b1 N$ V' u .gpio = DA850_USER_LED3,
6 ]7 ^( [% k% f: ]; \ .name = "user_led3",$ w- |: v( K# v2 b' W2 G- c7 c4 K
.default_trigger = "default-on",) O4 `/ D) |: x3 \ x& d
},
' R& w) T K- I6 _- O};
4 v6 e$ M1 Y1 _; j z
& O( a* M4 H' F C9 B6 vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ ~/ O* y! a' m2 ]
.leds = da850_evm_tl_leds,
% ~! l2 E& X/ j3 `% s* X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! A7 @ Z% H9 w4 I7 B4 d0 q
};, w. n: x7 ~% f7 e
* K0 m* E) S" {4 G( o. astatic void led_dev_release(struct device *dev)
3 J, @) k$ H4 n8 w8 [{
9 k1 z0 H" @1 d" ]$ O3 @ `};
9 I' _4 O" x k0 n' p; Y, [& ~% C; q2 Z; [
static struct platform_device da850_evm_tl_leds_device = {
3 R+ w, X3 J& X j: c1 r .name = "leds-gpio",
" D n; n* H) E+ _% j) Y1 \ .id = 1,
! S% J$ c; d9 d: a .dev = {) U6 T, Q9 G) B- v* b+ p+ O9 c
.platform_data = &da850_evm_tl_leds_pdata,
5 |9 G9 i' b4 V& r1 C$ _ .release = led_dev_release,
- m, s1 J$ i5 a1 ^ }: V7 o, o% F7 r# C; d4 @
};
# V' E7 X) j; C. {5 P/ n. a3 i; G5 T A N- W# n
static int __init led_platform_init(void) Z3 ]6 C1 Z- K h% {6 V1 h4 k
{& s5 |4 `0 m% `& ?8 \" K g* I
int ret;) F4 P3 |; o" a
#if 0, x, j" I) {% V2 {0 q! G' [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 c& o6 E; L0 L( ]( q+ }8 |# U) @ if (ret)
" P- R: A9 S* T. y4 u pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" @/ ]4 i. |1 ~" K, ]. D6 o "%d\n", ret);
% `1 v3 g& x. w$ v8 I: X#endif( a. L& H" z" t5 A w" o
ret = platform_device_register(&da850_evm_tl_leds_device);7 C) z7 z6 x# A- d
if (ret)
5 W( G& @3 i% P$ { pr_warning("Could not register som GPIO expander LEDS");
: I2 l* Z8 @* r" G else# A8 y( ]5 }4 Z& r
printk(KERN_INFO "LED register sucessful!\n");5 }( T/ U9 H; P v3 J3 G7 n1 R& k/ P+ ?
, y; ~$ d2 H# ?6 e; r: X return ret;7 Y: I }% I) h/ f
}
9 I8 k4 ~5 @1 V* x3 J" Z+ T. ?
- E6 g2 B1 |4 V- r% ustatic void __exit led_platform_exit(void)
5 a/ ~6 x, @) L9 f6 Z+ S; a{8 x( F3 y" S! h c+ j" n+ s8 h/ |
platform_device_unregister(&da850_evm_tl_leds_device);
: R ?7 I1 h8 ~2 j' X+ o; U. ]0 e7 W
printk(KERN_INFO "LED unregister!\n");9 T' ^+ G* X% j: [: M! @
}
: ]( W! }+ `2 x$ y$ H+ d$ l C( U0 e6 f. m
module_init(led_platform_init);
6 B; V' J7 @1 s7 Xmodule_exit(led_platform_exit);
- i/ l2 @- g/ h; V" X5 H4 h
% f) i) e; q7 `& \ u6 ~MODULE_DESCRIPTION("Led platform driver");
5 L) f1 ~+ X+ i6 ?4 zMODULE_AUTHOR("Tronlong");
; M' c3 [* U& \2 C, c) VMODULE_LICENSE("GPL");
$ C8 Q* @3 l( c
$ k# h, g$ h2 C0 ]) W |
|