|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 w% e& s8 w( m" R
#include <linux/init.h>
( V" I& R/ I$ ~#include <linux/module.h>
. A7 r1 v/ D4 K- C3 t#include <linux/kernel.h>
2 Y6 {+ q$ w6 Z6 g#include <linux/types.h>
5 v" q, i9 G& d/ } t#include <linux/gpio.h>
2 }( u) o4 e9 ^4 @* b7 `9 Y# h#include <linux/leds.h>
+ c p- S' D% M' _# W5 z#include <linux/platform_device.h>
7 ]4 a8 o3 q( f. q( W& D0 v% K4 x/ F3 h: j+ k* j% h- b6 ]
#include <asm/mach-types.h>( e* X4 U5 B. q r8 X
#include <asm/mach/arch.h>
. l5 C- o5 u* C6 m5 U9 D#include <mach/da8xx.h>! u, } X1 L6 l: C5 i) D
#include <mach/mux.h>" V2 R; C0 V+ s( d0 i4 u" K
5 `0 y/ W+ ?. K4 I6 ~6 }#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 k0 e0 x7 I; b$ d" R) `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 x% J7 W" {( [, @/ U) }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ |% }8 c9 e/ G/ z2 h3 u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- S/ M2 f: _% } y: q' i% `# }/ }9 v2 W* O" T7 e6 z2 R
/* assign the tl som board LED-GPIOs*/5 Q$ h, U( [8 w& U
static const short da850_evm_tl_user_led_pins[] = {' f. i5 U8 F1 f( r$ o
/* These pins are definition at <mach/mux.h> file */
$ B% P L3 D/ d$ J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 m! F/ a, c r/ e( F. [9 \
-1
' l' [) j w9 V0 @' w};7 Q# N0 n1 @9 a; X3 V, F8 w8 r
) E* _ p- a E+ jstatic struct gpio_led da850_evm_tl_leds[] = {
' a$ j+ B: t. l0 H! R9 f2 w& N* O6 a {
1 {1 t* Y0 r1 U3 t ^ .active_low = 0,# l6 R0 [2 Q' ^( c2 [! ~
.gpio = DA850_USER_LED0,
) A1 @- Z% R7 ? .name = "user_led0",
# A+ j8 ~) e1 m/ g5 X" x: ? .default_trigger = "default-on",- h0 ]1 A3 Q# }5 i7 Q0 n X
},
! G0 c$ l1 w6 x {
1 ~- z4 _7 D1 h# E' k .active_low = 0,4 a1 T, K) v3 N+ _4 j3 S7 g
.gpio = DA850_USER_LED1,
" J5 v! v& [4 o8 W$ U' Z' u% ^ .name = "user_led1",
+ M- U3 |1 [. l- C .default_trigger = "default-on",
. q$ x @3 R% E) I+ J },- l X3 n. s4 P, b- n# H3 b' R
{
- t9 m2 `6 w4 x7 H( o4 t. Q1 ^ .active_low = 0,
/ q+ w8 U0 G0 s: U: U .gpio = DA850_USER_LED2,2 r5 L/ o$ W. S3 r4 ]. I9 T
.name = "user_led2",
) ] w; q K; V, s/ ~ r+ V .default_trigger = "default-on",
1 Y- B/ p0 p7 D },1 A. r& L# F+ Q) t7 `/ |, p
{0 E9 f! f; H/ }* F
.active_low = 0,
6 u& K# O3 B z8 s, r .gpio = DA850_USER_LED3,
- m+ c9 K, y& t q& y# r2 |& ]6 | .name = "user_led3",1 _" J7 h7 H2 ^
.default_trigger = "default-on",! I) q& X1 Z1 B X- q F0 b
},
% q! Y' H m! p b% K. z6 _};: `8 Q4 `' | q% p7 g+ M
- J% ~4 c0 v6 m. \ b) x; K( @& Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ }+ e# o" y% h8 Q
.leds = da850_evm_tl_leds,
' {9 _( e: ^9 ~3 g* v .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 d6 |; u6 Z2 J, @
};
# c8 }8 g* ]4 Q4 H6 |7 m. x- X+ M
% q7 H' p# z+ `3 \static void led_dev_release(struct device *dev)7 ~/ A7 d4 |) ~1 r# }" u% q
{6 I$ Y9 S* }4 s+ H, ?0 ?. _
};7 z; s- w0 _, r* O* `1 H
) w- j' P7 L- p9 nstatic struct platform_device da850_evm_tl_leds_device = {: G. d, E- S+ V) r4 _
.name = "leds-gpio",, B. [$ y6 [, N; |, R; g
.id = 1,
& J8 C& W. d# {4 f1 W" Y+ U .dev = {2 C9 ^2 ?# |$ p8 Q7 i
.platform_data = &da850_evm_tl_leds_pdata,
; x& ?, h, u9 ~ .release = led_dev_release,
6 w! ~2 K7 A, F3 M0 K' ` }' Q' e5 z1 }3 L* L: t
};
. r- A# [- h: D6 {( |, |6 q2 A
g+ v; b; d/ O3 w1 _% j! V" ~static int __init led_platform_init(void)
0 h. s1 K' L: P8 T: |{
% B% K) S f2 ^ g W" h int ret;
. C* m) S5 j& C; x, O#if 0
x& M7 T% m4 u* ], z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 c1 d- \5 E f' Z6 G
if (ret)' W) ~+ }' ~% E0 z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& l# Q% d( l3 V* Z( k "%d\n", ret);1 B2 i6 T7 z" Z; P
#endif
2 O4 L* ~. p2 {) B, X ret = platform_device_register(&da850_evm_tl_leds_device);
. x1 ?5 b/ Y P/ z& D4 { if (ret)& B, r( h2 u+ M$ O& p$ k; p* b
pr_warning("Could not register som GPIO expander LEDS");
# w. `) @+ M, b) C else
3 D& X& L# D! j( y printk(KERN_INFO "LED register sucessful!\n");3 v( N G6 V# X& h, o5 s
0 ?( ?. D6 i, c! |# g$ Z# O& a return ret;
r1 i8 N' O! e2 s}
, W1 w1 L5 H' C. r
. r! e& @, f9 H4 c5 V& {4 P1 F6 E& Dstatic void __exit led_platform_exit(void)
, W. ?3 M' e* E; U/ Z9 A( n{
2 w5 r/ L8 M6 v" e' E platform_device_unregister(&da850_evm_tl_leds_device);2 w/ Z# R! F/ {- O0 \% z4 ^6 L
9 D- ?! T3 N& X$ i) n0 u0 h
printk(KERN_INFO "LED unregister!\n");0 z$ _- l4 \& d2 N0 @
}' ~) b2 {& Y# C5 V. o
w, M$ N* N% e' nmodule_init(led_platform_init);
5 e4 k! F( t+ O) V$ B$ S. p$ _module_exit(led_platform_exit);
" r( B, S( v0 ~+ h: {2 E2 [7 e4 v I& J2 {# a0 U+ y+ f
MODULE_DESCRIPTION("Led platform driver");
: f" g( H4 n" m6 z* RMODULE_AUTHOR("Tronlong");
6 x1 s; U$ @# LMODULE_LICENSE("GPL");% _' w0 C4 y& I+ k
9 [: U+ a6 s' t4 v& d( s# E- w
|
|