|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 e/ d. K( g6 u y7 S/ v
#include <linux/init.h>
9 o& u: W0 u# f; m* `/ s% q! [#include <linux/module.h>9 c* N A, l2 j! j3 V
#include <linux/kernel.h>) y) h' k( t% s9 M& S3 K& P
#include <linux/types.h># e( e; h7 A7 Z! C z
#include <linux/gpio.h>
' ?5 G# v# `8 ?4 `1 q4 ]#include <linux/leds.h>
9 o3 Z0 }" C1 E; s) G* G#include <linux/platform_device.h>2 T! G% n7 h0 X$ {5 f9 a; w
5 f* a% W! s" a4 M
#include <asm/mach-types.h>
1 h6 [5 c2 y2 {#include <asm/mach/arch.h>
9 G# I5 Z" f' x" [#include <mach/da8xx.h>. F g$ Z+ ^$ W' D
#include <mach/mux.h>& w) S: o7 k9 z2 }4 J6 g5 X2 ~( |
( C; `& q( G8 D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( d/ [ V1 \1 ]. Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). }% G z# u) d- T: f
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 H) ?8 \: ]/ r! `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' S1 d8 z: I& ~3 Q G
/ c, \2 |) x, S; J, k* c' C
/* assign the tl som board LED-GPIOs*/
" B3 X8 L! M7 t& S0 ?static const short da850_evm_tl_user_led_pins[] = {5 q6 J' b$ B7 N$ o
/* These pins are definition at <mach/mux.h> file */
: f1 s- B# v# D8 N DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ W+ o2 j; T5 r3 ~" R
-16 p: {) W! m$ n" x9 B
}; I0 h3 i! r5 E
1 ]: K) M8 e9 ~9 l) ostatic struct gpio_led da850_evm_tl_leds[] = {
" \9 R: G( N% W( \0 p+ O+ O( E, {- T( }4 k {
2 {: B; F# \1 E4 c$ g .active_low = 0,- v7 H* x, o7 R7 u) j, G
.gpio = DA850_USER_LED0,
3 m! S$ H, d! u+ ]1 o% j! {0 I& x .name = "user_led0",0 p- \) e6 F) X; @' c' D
.default_trigger = "default-on",* J* s5 } Y* I2 m: g6 X
},& S% c% c( c4 _& b; x
{
5 ^) _. @8 a8 y% Z9 |! e1 N1 r$ s .active_low = 0,+ u. X1 O( _8 _+ H4 S) j
.gpio = DA850_USER_LED1,2 d7 |8 v6 \- g0 o4 a4 `4 _
.name = "user_led1",3 O9 C9 h$ I2 F5 D h' d
.default_trigger = "default-on",. u7 q0 ]# p) O8 [) n
},4 y' C! S0 c6 Z; m9 e' S- Y
{9 U X) ^' Z5 s4 \9 m. s$ |
.active_low = 0,
( u' c" X, Y6 p& X* P .gpio = DA850_USER_LED2, R3 a/ r$ y: p) u. x
.name = "user_led2",. t* g3 ~9 f* a' ^- e- J* A" n* O+ T/ \
.default_trigger = "default-on",
6 ?5 n* Z+ u/ r6 f8 f% ? },
/ g, g9 H' G2 |2 I4 E {8 T0 b$ ^8 W0 | [. f
.active_low = 0,4 R2 @/ E. E1 B
.gpio = DA850_USER_LED3,) G) T! v1 B: {: u. P8 \2 V
.name = "user_led3"," Q" B& |1 q# @' u
.default_trigger = "default-on",
; f5 d4 V* t6 ^- f X J },
) j8 q1 u3 J; j};
1 Q( ?, ~2 y# l: y$ {, E' i: U& C) r6 U6 A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) Q W% I# j9 J9 Z" M+ }9 ^
.leds = da850_evm_tl_leds,
* U" V: S* ?8 X' ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 }2 m2 j" |" R* j' n9 m2 s};
2 W5 z$ ^0 V3 U6 h1 w- l7 t* W1 P- F) D# I
static void led_dev_release(struct device *dev); H0 M. W0 B5 }+ j7 y9 q
{5 L1 I% e) L) e+ R9 u" i
};7 d% U# m. ?9 |
, O3 A% J6 E5 v% ^& d
static struct platform_device da850_evm_tl_leds_device = {
( b; g; m7 o$ R3 ?. K3 V .name = "leds-gpio",
3 b4 E+ F9 v' R; D .id = 1,
" L, R( b' s5 F3 B1 ?9 g0 e- F8 ] .dev = {
" A+ W. d; o( ?1 P/ U, p$ B& w .platform_data = &da850_evm_tl_leds_pdata,
! ?2 G! s5 C7 X, W" i .release = led_dev_release,6 ?. Q! ~, I9 G6 B$ @* h6 n: O
}
4 b6 ^; X! n. d" ]( S};" K( f+ Z$ \7 w! n( t( P% c
0 l( c3 e+ @( X) zstatic int __init led_platform_init(void)
* O8 E3 N' y/ A" @+ V{
3 n$ S" l( g' r5 s0 {$ O* S int ret;
5 a4 e0 X# z7 c2 g- y. n#if 0
. }$ C8 A3 h" O4 S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! Z, ]9 L |& @
if (ret)( p. i4 |# A; i: S# b
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 p* c8 n( v, x3 E- X "%d\n", ret);
' D& {9 V0 ~6 g#endif
8 I! H1 S& o7 H( J ret = platform_device_register(&da850_evm_tl_leds_device);
9 ]$ G* s$ @5 p$ J; C if (ret)
( H2 G9 s, c: d pr_warning("Could not register som GPIO expander LEDS"); l: _, J( W: c2 L
else M: B( t4 s4 s# f6 H8 r2 C& ^
printk(KERN_INFO "LED register sucessful!\n");, u, Q$ n. g0 T p6 s4 G6 G
: }. t, `) Q0 U4 u& Z
return ret;
! q, j& z N5 M+ W P}
# j4 o8 b, d' H$ i
$ O) d8 J! V9 [6 B" Z' ^2 Mstatic void __exit led_platform_exit(void)8 G) |2 v$ R Z8 J
{; c# V9 w4 I! a5 r1 v
platform_device_unregister(&da850_evm_tl_leds_device);( s! Z& E9 p6 {" Q6 \
) ^, i. E! u2 w" p& X/ a printk(KERN_INFO "LED unregister!\n");
. E# }( n& [& ~) S7 s6 B}% f8 H; p4 @, l; \7 e: I2 j& E
6 x8 o. B. ^6 g H7 x/ F& V$ x9 `* j dmodule_init(led_platform_init);: c& b0 ^2 ]9 P U0 x' m
module_exit(led_platform_exit);/ ?1 i1 F" i3 C/ l! N3 B1 r: ^# s
; v$ b( u' H$ }6 ^
MODULE_DESCRIPTION("Led platform driver");
1 \! f0 l9 \7 F! P; XMODULE_AUTHOR("Tronlong");+ R2 k0 P. t' s$ r
MODULE_LICENSE("GPL");; |/ q+ o7 a. o! c/ K) i( D
+ x& [4 v" ~. W8 b& T# C
|
|