|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& f3 [+ r# q1 [- i. d2 F" _* l$ A#include <linux/init.h>: |* L( I6 f" Y# R7 l# P2 X
#include <linux/module.h>0 K3 }" y% p4 h2 P
#include <linux/kernel.h>' F/ }2 q* H |: l
#include <linux/types.h>
: H' L( @: @+ Y4 a! O#include <linux/gpio.h>0 u4 r' Y8 }" T4 Y% W
#include <linux/leds.h>
& z, ^5 s, d7 P1 `( p; m+ F#include <linux/platform_device.h>% V0 V/ M6 l+ I; w* ~# W+ @/ s
& Q" T8 ^* d# V# j4 H0 t, _#include <asm/mach-types.h>; Q* q: W- d8 p8 t
#include <asm/mach/arch.h>& V$ T( C& w2 [# `8 u9 x
#include <mach/da8xx.h>; R5 r, N! h0 Z& _7 y4 F
#include <mach/mux.h>" }% c, |1 Y+ }# b) t. i [( g
# r E5 n6 o b# F, u- u/ [3 x
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 Z4 ?; a" P7 I9 _% S' D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 `- D+ `4 X( Z8 {5 B#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* \: h) A8 i! E; Z7 _" D# j# S8 ?. X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 }$ `# g3 P- F3 r+ |% T4 w2 G; f& Q" n; d: T9 m' H8 b1 m
/* assign the tl som board LED-GPIOs*/
6 c. \$ _& P# b m; Rstatic const short da850_evm_tl_user_led_pins[] = {4 O! E$ v% G+ `8 I
/* These pins are definition at <mach/mux.h> file */- N$ ~+ S N v! h+ A f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 r/ z. W( ]3 Q5 k7 P7 c3 _' D' U( g7 [ -1
# v4 M, m" B; r) l. l};7 ]8 m' K! @! x8 r8 Z- d1 B* y# Z' R% k% }
" ]0 o, {% p4 b
static struct gpio_led da850_evm_tl_leds[] = {6 | I3 p! F3 C) C' Q
{ [. L( S) t+ D* u* n/ {
.active_low = 0,9 f$ h2 w8 I# D! l0 H$ T8 |
.gpio = DA850_USER_LED0,. e& G3 [9 E: K' B& ~6 {* U. w
.name = "user_led0",7 k- o; T6 L- F7 J* A/ [
.default_trigger = "default-on",
5 r0 s4 C8 T* u( Z. Q },
1 b7 u6 H4 y: b1 ~! E {
* S& E* Y: _" D. C, S) t .active_low = 0,
4 n5 O5 `* r l6 D& F. Y/ }- }; S .gpio = DA850_USER_LED1,$ n- e1 W+ m9 |3 N
.name = "user_led1",1 q1 d5 o+ c/ h- {: u; Q+ u2 A
.default_trigger = "default-on",
- a2 `0 A* ~; p" m* w' X },: u7 F6 K5 V0 |% F- J3 X' Y
{- Y% O9 s( K9 W: b
.active_low = 0,1 }# Q7 N. W2 S3 R
.gpio = DA850_USER_LED2,+ s$ G8 i( S! |3 E: e! f) t5 `
.name = "user_led2",: ?! E( m# P7 ~( s: ^2 @) r
.default_trigger = "default-on",; V1 P, A. z1 K# Y( ?# ?9 u
},; d& r" v2 ?$ X3 o8 }2 o2 C
{
/ T% n2 h1 O- e/ _: X' j .active_low = 0,
4 H/ H# G- w0 B6 V9 f' [6 D .gpio = DA850_USER_LED3,
4 P7 e7 u% q4 f: v# ^4 b a .name = "user_led3",
7 ]4 z/ X3 f/ ]) h .default_trigger = "default-on",, x" v0 ], V3 A9 R6 ]1 |- p0 f
},
" W( M- \+ j) j! ^};; L$ p1 M9 |9 m# x$ v8 {
! P. {7 \0 x% g9 hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { p8 F2 g1 ]- Q; E
.leds = da850_evm_tl_leds," R* F' H$ x$ p5 n# U5 N- f0 f
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, z4 z: [. w; p+ ?/ @};
7 a+ F9 R0 g/ {$ W: @
7 ]2 N) K9 a9 s6 J1 D( ?+ t& Rstatic void led_dev_release(struct device *dev)
, A3 c6 }" r( j! c8 p0 Z{ V' v. B; S7 k5 d: P F1 B \4 g% ~/ v
};* a# j+ ?, k& D& `6 Z3 v
" f( A' S% w! m" ?5 J6 u5 j
static struct platform_device da850_evm_tl_leds_device = {( e6 o3 ]3 ]$ p$ M% x; i6 l0 Y! r9 e
.name = "leds-gpio",
! j5 L+ S1 }. u) F' N* s4 l" b .id = 1,
9 y) H# }! ~+ g3 T/ \2 W$ ?0 I, O" Z .dev = {: Z2 a% N9 e# p
.platform_data = &da850_evm_tl_leds_pdata,( y! I( i: X8 |3 `$ V
.release = led_dev_release,
" L3 C) y! M2 ~8 b }
2 Q7 [. d4 E7 e) @# l B1 S};
# w( P1 b0 b# e3 r
. B" T/ w/ k7 Z! e8 x; z( wstatic int __init led_platform_init(void)
# w! ]+ L( s) C8 i{
- w7 ^; {; S7 l int ret;
c' b6 s' ^6 D#if 01 m7 b! G- A8 C& } q* n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); \ J4 O* F1 E+ Y) }9 f% [: o1 Y1 ~) p* A
if (ret)
8 q1 O/ p3 A9 ?) ]/ L pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: \4 p* H4 W8 i/ K "%d\n", ret);
, J# f0 T( P, @#endif. d$ _5 f! W. V: a1 [
ret = platform_device_register(&da850_evm_tl_leds_device);
, {8 q! |% }( S% |, G if (ret)
- ]+ z& b9 M, l# ?! ` pr_warning("Could not register som GPIO expander LEDS");1 x" c2 r7 ?: C7 N- ?/ A
else n; i$ \6 \6 K' d
printk(KERN_INFO "LED register sucessful!\n");
) N8 q4 P; I" l, l, n# X) i& E
1 @& e' C) V( H8 r5 i+ s2 \ return ret;3 ?, y5 b" ?- h$ K& p7 L. m
}/ `4 K/ _4 D1 A7 V) O
" Q u, a2 R0 x4 L( mstatic void __exit led_platform_exit(void)7 v: \+ k9 T- G% `( @- B
{
; Q7 B0 h) V- W+ a, l- s platform_device_unregister(&da850_evm_tl_leds_device);
: ~4 n* n, y0 w+ ~ W. K8 k: B5 I! Y: E; E8 U1 H; C
printk(KERN_INFO "LED unregister!\n");
5 s/ R, ^& O6 F9 B}* d$ ]# \" z: K
& Q7 d- E& B0 @$ X! \module_init(led_platform_init);% {8 C6 E* H( y4 o7 T* T
module_exit(led_platform_exit);0 M( w5 M' `6 |8 x5 q; P
0 S8 b G$ y$ ~7 x1 qMODULE_DESCRIPTION("Led platform driver");
' g' b3 Q) Y! m4 }0 f- zMODULE_AUTHOR("Tronlong");
1 @, F9 ?8 O; d: l9 K( YMODULE_LICENSE("GPL");
" T& Y/ P$ w2 T! P! |+ _& s( q* ?" c9 I' e
|
|