|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ \0 \4 t$ \7 V' s& }" a6 D
#include <linux/init.h>; }* e, u: q$ J7 A i) I5 u
#include <linux/module.h>. ]5 S- [2 G8 y3 r$ \9 V
#include <linux/kernel.h>
! i2 |4 q# O. l2 U#include <linux/types.h>
2 L4 u" b1 V: A4 N#include <linux/gpio.h>
4 c* _6 B, h2 [) G#include <linux/leds.h>2 { |; r; B2 r" ]# Q V) f+ B
#include <linux/platform_device.h>% N- |) B$ g! f [! z2 g1 M4 u: G0 j
8 d6 W) N" e1 C# t
#include <asm/mach-types.h>. U" [: f6 v" D
#include <asm/mach/arch.h>0 x; ^' r* C: \- k+ E
#include <mach/da8xx.h>+ q+ v9 U, K) `, V* Y' t/ T
#include <mach/mux.h>
/ T% ^. W$ O+ |, X
2 @9 \, `5 M) W( {#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ V6 k$ O4 l7 y, p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 V; f4 r$ t8 f/ \ c3 G
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& r6 o) b4 A* f" w- w# c/ Z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 U2 h( N5 u6 @4 T @9 l, b8 }4 y2 l& o5 u0 V7 A
/* assign the tl som board LED-GPIOs*/( c# C7 {) d; k# f3 H
static const short da850_evm_tl_user_led_pins[] = {
4 C: W- m: O. U, E' n% K- x /* These pins are definition at <mach/mux.h> file */$ V3 g5 s2 |. A) D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. h4 U3 U; U3 K) l0 C! P& Y* i8 k
-1
x" i; [/ m& _, L/ V" N7 W3 V};8 E# e- _. R$ h
9 s% t$ U2 J- L% xstatic struct gpio_led da850_evm_tl_leds[] = {' e5 z( n# R m# r: \
{
1 s4 f5 J8 j% H9 ~" K0 \ .active_low = 0,: u4 o) r, K+ L; `
.gpio = DA850_USER_LED0,/ B! J. Y$ L+ x* F0 w+ X; q
.name = "user_led0",
1 v# |" |. u2 T: Y/ Z/ b .default_trigger = "default-on",
6 X8 }4 v% }5 D- u- O% {; P },
& ?, l$ B3 ~; P$ I- e' ^) o6 c {
* @0 U/ W% O/ | .active_low = 0,
) l, x; L k0 k" C- C d9 L .gpio = DA850_USER_LED1,& u$ }6 ?- h0 F% A6 T
.name = "user_led1",
M4 y$ F3 s- x2 {6 v% L .default_trigger = "default-on",
* T, n) U4 H) A9 g2 s },! c6 ~5 g6 [0 ? _- W
{6 t0 \4 s5 p2 m5 n% A& ~
.active_low = 0,
k4 s7 p @; S) g, V .gpio = DA850_USER_LED2,% L h( c. {# L$ D
.name = "user_led2",
! f" p! k$ y4 W9 L% c7 D0 o0 Q, R .default_trigger = "default-on",
* [0 _& Z. J) S6 T },
% e2 ?5 _; k a1 p* t" N$ T& ` {
- Y. j/ d8 ~$ j% }. e5 ]' J .active_low = 0,
9 @$ u9 c% o$ d. [9 v1 o S/ I .gpio = DA850_USER_LED3,
$ Q) i) H( C7 }& j# [0 ^ .name = "user_led3",
* H _' h. B9 X9 L9 V& V. Q! w8 X .default_trigger = "default-on",
) J7 r( U: {' y' x },. C T0 ^+ T4 G
};' I3 t3 k2 \; U9 N! _
/ y/ {, X- ~: V1 M% \/ Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) I6 n0 ?4 M% a
.leds = da850_evm_tl_leds,, \! d- o) k+ Y/ K, ]9 Z" y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ e( H" a+ p9 X4 W' W- Z c- t
};4 b$ }6 U2 {: _
4 q5 V" F/ z0 g# R( H; E& Dstatic void led_dev_release(struct device *dev)
: D5 r+ e9 r9 B{8 ?, P: }' }! v% h' n$ I2 Y& t
};
% }0 ]' x) h- i
2 Y @/ d' h. Y4 H* l! d0 ]static struct platform_device da850_evm_tl_leds_device = {
, b1 R, D) D; Y I& A+ \ V. d4 ? .name = "leds-gpio",7 r# f8 G' M. q2 B$ F
.id = 1,
' e4 d& u8 t$ A: N5 j .dev = {$ W: c4 B! v% f3 v& w) ^- f4 s
.platform_data = &da850_evm_tl_leds_pdata,
* S. S( u% J1 X6 b3 Y9 G& P i .release = led_dev_release,
7 {: V6 Q! E; d; `, C0 R' ` }
" N- I8 a3 A+ {1 V( w+ t+ ~};6 D1 I, a: x6 @; f
" T y$ H+ [1 \/ j& Y
static int __init led_platform_init(void)
9 ^6 Z9 \7 z9 |) _& `0 v* W{
, Z/ u, C% n4 B Q. ^" k int ret;
# _: ?' j" d2 f/ p7 T+ T v#if 0
. h) i* g% R+ H/ W$ y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- F1 \- ^8 s) G0 s if (ret)' u6 e3 y) Q, C* m3 V: e# g+ _3 I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, `4 |) ^4 R" z( z "%d\n", ret);' O2 }7 F1 D* ?; n4 M
#endif! b& @! l0 x$ z0 G9 W
ret = platform_device_register(&da850_evm_tl_leds_device);
, e% \$ a2 L, u7 y) D if (ret)
& t1 L( o. b5 q5 E- Z% B, e: q& e pr_warning("Could not register som GPIO expander LEDS");
f8 z2 ]; F( f1 Q! Z. B8 h# {2 L else& o& q% Q2 x- x- B2 O( T% |
printk(KERN_INFO "LED register sucessful!\n");
1 I) N" u: Y6 G3 O1 R' h9 M
- C* X( k; A9 S9 _+ I# \. R return ret;- p) k% _2 `0 o2 K4 o: S+ E
}
. L+ t# j! K1 F8 d H! k& D% p! q1 U0 t( X# }
static void __exit led_platform_exit(void)
; x! c- r2 m" x2 Y8 C, p' G{
; a' b7 M5 a8 y" V* @* J" ^ platform_device_unregister(&da850_evm_tl_leds_device);
' i/ R% ?5 o; x7 H1 r( u. G' P( R
printk(KERN_INFO "LED unregister!\n");% Q) _! ^9 E- w( Y% Y
}9 h8 x3 a/ J! Q! h1 J
- B5 i. J1 @0 \4 ]' ^
module_init(led_platform_init);8 U' w0 Q4 g4 M7 s
module_exit(led_platform_exit);, W+ O: f/ z3 d. J
" _8 D6 u/ I1 A3 ^
MODULE_DESCRIPTION("Led platform driver");
9 E9 _% e! D- n# \3 EMODULE_AUTHOR("Tronlong");+ Z1 w8 i' X. I2 q H& N8 n X
MODULE_LICENSE("GPL");
7 y! p+ F* ]2 L! s6 Z1 X( W
# _: G0 C. [* w |
|