|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ n" s/ T1 h% j. G" T#include <linux/init.h>5 p. c; ?" U- `: M) L
#include <linux/module.h>) X% C6 S; O. r/ J) F3 A2 q
#include <linux/kernel.h>% q# D# }: O8 r! e( j
#include <linux/types.h>
/ h) }- {1 O# H! H3 i#include <linux/gpio.h>
9 u2 w9 e( f' T#include <linux/leds.h>
8 i# R& s7 g2 q8 M# S#include <linux/platform_device.h>3 f3 U' [& t. q& h( c- ]
n0 ]7 |, r8 g- C3 C# F& t
#include <asm/mach-types.h>" W6 A0 M' U2 F2 f$ E8 S& l
#include <asm/mach/arch.h>: n; Y) e: U# n
#include <mach/da8xx.h>
3 [* e, [ I$ I* W! h#include <mach/mux.h>1 v( _4 c7 R j' i1 Z+ a6 T: U$ R7 M
& }& |6 p3 U6 D: ~9 v/ b, A1 I+ |% @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 v9 y6 ~4 @' w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 z5 J0 e& S6 {0 c
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. ^: a2 ?' X& ]* E+ I6 P* ~#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# I; E. ?/ y1 N/ w
( o- D* Q8 G, e6 P7 i2 l5 G/* assign the tl som board LED-GPIOs*/
. K1 `' Z7 B, l3 Y9 N7 Ustatic const short da850_evm_tl_user_led_pins[] = {+ o8 \2 k5 g/ t5 P
/* These pins are definition at <mach/mux.h> file */! w' _3 c/ K7 K2 K
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 j& N* f/ A% u+ b D( l8 x -1' j+ ]- t1 y/ m4 p4 m% L% B0 P+ a. i$ J
};) B) P0 y( x2 Z! @' w- R
$ u0 H: c9 r' H: b9 c& \static struct gpio_led da850_evm_tl_leds[] = {
3 U, |; ~) b5 `6 P {2 c1 i! u. Z( s+ u$ z# x. W
.active_low = 0," a( m3 x, ~7 e6 A3 P- H: X8 Q$ j9 l
.gpio = DA850_USER_LED0,
% x$ D! M% o( W .name = "user_led0",
8 y& R1 Y9 H& y7 \% P/ } .default_trigger = "default-on",
* W6 H1 D: ~, n) j+ J/ ? },
5 i- l2 t3 U, ~, u$ E {
! b" e& J, @# l) k7 x .active_low = 0,
4 ]2 X- c3 j. ^8 D( b" o4 h6 V .gpio = DA850_USER_LED1,2 ~, D4 T% I4 F4 P
.name = "user_led1",
- X' f0 s1 s. K# { .default_trigger = "default-on",1 p3 w. h$ l+ H+ b! R+ x, q# C9 x
},: V3 l3 x ~) {8 ~" p
{5 W7 A' F7 G* r5 e) J! E
.active_low = 0,
1 A& P, _: z1 m6 W; F( N6 n/ S .gpio = DA850_USER_LED2,
' }6 I" R5 [0 H# W .name = "user_led2",
7 A* m8 V' k& S! t, f6 r( y .default_trigger = "default-on",3 o) h( G4 e ?2 g. q1 u
},
- p# P$ P4 V5 Y( r1 q8 g& c {
& M) `6 b0 C2 N1 H2 Q .active_low = 0,& V! |$ [& E% v* o5 C I
.gpio = DA850_USER_LED3,
}9 \7 n" o3 O8 i .name = "user_led3", Q, q) `! ~" }; W, Y
.default_trigger = "default-on",
* o n1 x( @& Y; @. r( Y; C" T },; e2 P+ o6 \+ i0 i
};3 @! w, ~: l; Q, h
9 l8 W0 ?: ~0 d# p8 Y/ x' l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 Q7 A/ y4 \7 N .leds = da850_evm_tl_leds,+ q1 R% w( W. L/ j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 {+ S* @( Q5 }$ H
};" D" ]4 j8 y4 m+ A
+ T8 z# m! ?* E. |3 [- \1 U; ]
static void led_dev_release(struct device *dev)
- m/ ^) v+ U( E, d+ e{
- m5 W8 R9 G9 I/ d7 o& N};
# ~% a- b/ E5 ^+ Y
) W! T8 e: n8 K+ f! \: P6 r. ]; Ystatic struct platform_device da850_evm_tl_leds_device = {, }& |8 `0 y4 W6 r
.name = "leds-gpio",; e1 r1 M* G( B$ b
.id = 1,/ Q% h9 f. @- e, s
.dev = {
' j; k3 Y( O/ ^9 K9 r. y .platform_data = &da850_evm_tl_leds_pdata,
2 V& {! ~% H6 X+ E9 p* O .release = led_dev_release,
8 F x# P4 }2 Q% t) b- @- N$ J }
" j0 Z. H2 \9 \9 S" ]& g3 h+ H};9 o8 r% l+ B1 l( j3 d) `* S# s
5 q p f0 J' y1 G# t- Ostatic int __init led_platform_init(void)$ _+ } [$ `$ Q
{, l& g3 [/ V8 w
int ret;
; K ~% }; L% t/ S( z) T$ Z#if 0
: r" {# F7 K m r H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ x9 {+ m6 I# }+ w% R' a if (ret)5 X# K6 y+ N/ |0 R: A
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& L% G4 K- R* {$ v "%d\n", ret);7 x3 R" f3 \: s% |3 u2 @+ L
#endif
1 c- X) t6 L$ f9 J1 u. f ret = platform_device_register(&da850_evm_tl_leds_device);
* P8 q4 Y8 V' E* l if (ret)( T5 D) n1 G, M" M( c! _
pr_warning("Could not register som GPIO expander LEDS");
% q- v1 g. {# P: [ else
/ t1 ?7 f! _' U$ R; P printk(KERN_INFO "LED register sucessful!\n");$ @5 y& Z3 o; z* I. V
3 ~9 R; N5 A( [- \' z& t
return ret;
+ z+ x. j- n& u7 S& D7 p}% ?7 L; D" N3 `2 @' f- q
9 k5 x5 X9 u( bstatic void __exit led_platform_exit(void)
* o; _* y2 C, e+ i) j+ d+ L{
7 Y* h# o8 _7 s% S* l( F6 t2 j: C. R! @ platform_device_unregister(&da850_evm_tl_leds_device);2 x5 v- _6 @' {; C3 K
# [0 T! n9 J j# l printk(KERN_INFO "LED unregister!\n");$ ]& I* f& i+ a0 w5 _1 [
}
5 J A: u* b1 f5 i+ U
' X9 M# U% B R5 H0 [( p/ J1 I2 dmodule_init(led_platform_init);3 u. e& n$ m5 F3 b V8 ^0 K
module_exit(led_platform_exit);4 m- F& L$ X, O. @
& [/ E- x& H! {
MODULE_DESCRIPTION("Led platform driver");
# h! |1 V& g6 D0 o+ o9 |9 E; Z; KMODULE_AUTHOR("Tronlong");
% h, [4 s5 G8 Y5 z: WMODULE_LICENSE("GPL");) C) e O- ?2 S( p% M6 h
! e. L0 X! q0 D, O) Q% T |
|