|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 n3 t; R! A0 X* K#include <linux/init.h>
* W \# b c& M#include <linux/module.h>- X2 X0 Z6 n1 C/ @, d
#include <linux/kernel.h>
: l4 M3 U0 ?8 b! N" `#include <linux/types.h>
1 w" _) z- L g1 H#include <linux/gpio.h>$ ?) j0 f! W9 F6 T9 w2 u. C i
#include <linux/leds.h>
( R& l! D! ]5 g+ q#include <linux/platform_device.h>
% B. B) {: V H: O; c
7 o# n( L/ d1 ~# i* e) y3 \#include <asm/mach-types.h>
1 C& }. \2 s' U' e* h#include <asm/mach/arch.h> A6 B3 t' ]0 [3 u: i& W
#include <mach/da8xx.h>
j: u+ k' \) I' i#include <mach/mux.h>
9 T% W+ }7 {8 A( [
Y G2 k2 s H( I, s1 _, `7 O; J#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' A9 U; Y. w# n+ \, |2 n* s- S- R#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 m& n- U2 n' b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). h- j, x7 c0 l& e6 m1 V7 [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% p8 C! M0 l6 n
# i! H5 G8 \ _! v: g
/* assign the tl som board LED-GPIOs*/. _- f' M6 a: E' l) C8 |
static const short da850_evm_tl_user_led_pins[] = {+ I' P" S7 `# ]- ]
/* These pins are definition at <mach/mux.h> file */: { Y/ c- [0 E) H% O
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 s9 M+ y# F9 Z -14 B5 N5 L' d1 n
};; K! Z( x! y/ c& x8 u8 _ c4 Z
' o/ f5 L1 p# l, Ustatic struct gpio_led da850_evm_tl_leds[] = {5 i9 O1 R+ x: r- ^) E4 Y" i6 u" v
{7 E, u& A' R( P0 N; R. a; d! W
.active_low = 0,
. F8 X! ]4 l/ B .gpio = DA850_USER_LED0,. [/ s5 B. L! }
.name = "user_led0",' N- l. a# h) i4 \. X8 ]
.default_trigger = "default-on",
' v/ M ^) W5 T3 U },
( O3 q" q0 N: A% r$ a, m3 S {7 E, ^7 I" ?- r! J, U( d
.active_low = 0,
. y& {2 {/ L! f+ ] .gpio = DA850_USER_LED1,# Q P3 P5 q9 }8 V" j1 Z
.name = "user_led1",/ U6 p' b5 G7 k; h- F* K" v
.default_trigger = "default-on",0 G# V# V h, ]' L
},/ e) N8 F! J, r. {! E
{
Q3 \7 F9 t9 c$ A$ S .active_low = 0,) E( X1 y1 h( |9 X
.gpio = DA850_USER_LED2,- p4 a; A5 R4 K# b
.name = "user_led2",* [. C2 M7 S' m2 Z
.default_trigger = "default-on",, _# {# G; z8 c: B$ T9 z4 \
},/ l0 o6 e, F4 n( U* i; `
{
: N$ m" F0 X3 X$ b .active_low = 0,
) n1 Q; f& x. p0 t- n, Z .gpio = DA850_USER_LED3,- Y6 g. I. _/ n( H% k9 Y; R
.name = "user_led3",
' T# ~2 A% y! X) b: h .default_trigger = "default-on",) M% v: Y$ l" J7 _" h7 l1 _+ ~% K
},
f$ c9 w* c' v* p};' I" s! j8 K) X0 y7 f/ Q
! _8 |: f3 B$ H- e# `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 |$ O6 z% O9 _9 s1 T
.leds = da850_evm_tl_leds,( c$ G T, V" W1 W
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& G. U6 d+ @2 X+ {; a
};+ c4 v" ]1 h9 L! m- Z1 w, z
9 a7 U5 U: k+ [4 Q# astatic void led_dev_release(struct device *dev)6 T4 ]7 x$ u$ r* L$ k0 `# D
{5 c [! H; J5 _/ N7 r, t
};
0 i* x0 v7 M3 e, C) K8 W. L0 Z
4 Z" y2 ~; H# Y2 A* E( Ostatic struct platform_device da850_evm_tl_leds_device = {6 G6 r9 c$ t0 L! `. Z% [
.name = "leds-gpio",
U+ f$ v5 P9 n& c9 Y* a* M: g .id = 1,
' ]" t1 T S1 c& h$ c' S; o .dev = {) I) Y: s+ t& c, L: A
.platform_data = &da850_evm_tl_leds_pdata,
: c4 ^7 f% O7 q- ~' r- a5 t .release = led_dev_release,
, A9 q; \2 y7 y. Z. C/ a }$ `: C0 @/ }2 q( C, J) m( I( \! p
};
4 X' W6 |, t$ E; [3 y9 d1 R/ D5 X( p5 E7 n: h7 y& a
static int __init led_platform_init(void)7 W5 D/ w' a, }2 v' s8 W
{
3 J+ ?2 k0 Q* E# o6 B* f- k3 I int ret;7 S- T3 \ @+ y; |' T, p- h
#if 0
$ A) ?) |! g& q, H' ?- m1 l4 C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; R' h/ V. S7 r if (ret)5 L, q7 y4 [: l: l+ i) Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 T5 n& F. L, Y% `! Q' k0 t
"%d\n", ret);
) ]& I$ M' _% m#endif
+ J2 Y; i7 X N7 u+ ^% d) R* L5 ^ ret = platform_device_register(&da850_evm_tl_leds_device);. m; T. r! r! a
if (ret)
6 ^' z u) D% j; L% X$ M3 S pr_warning("Could not register som GPIO expander LEDS");
6 A4 Z5 l5 [/ l2 b3 }! t. z else- R5 c) ^/ j* m1 @
printk(KERN_INFO "LED register sucessful!\n");
" B; `$ K- p; V; x0 ]. p/ W. D# g5 u9 _
return ret;
, A6 b9 V v$ p( V}- \! V$ z" I% w" A
! q/ [3 _5 @1 K& P9 L8 Hstatic void __exit led_platform_exit(void)
. y) g& c+ @2 E4 S$ ^3 H{
0 `0 z) Y% @. I+ t' C- \2 f platform_device_unregister(&da850_evm_tl_leds_device);
* E( x" I+ W7 f c& g- C9 r; U" E$ B% W8 j3 ^5 |1 E
printk(KERN_INFO "LED unregister!\n");& ]" @! F- w: M4 ?
}
6 L6 \+ w- V6 ^: ~ L4 `( G6 E
' a$ j, v$ W! f. A/ H1 @9 L1 }module_init(led_platform_init);: `- l3 m N+ \' C
module_exit(led_platform_exit);- c! A5 P% U1 J4 a& h K& [& F
$ m' m8 o. k: `" o" QMODULE_DESCRIPTION("Led platform driver");
* J4 O7 f4 |/ A7 @ \+ _MODULE_AUTHOR("Tronlong");
* D; O7 S" O6 P$ B& c3 yMODULE_LICENSE("GPL");1 n4 J) S8 f2 J' }- W4 h2 b
. w4 @! G# S: b5 }3 I" K' K8 u |
|