|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 O1 X% ?9 Y5 W, v1 `% ^#include <linux/init.h>6 E) y2 E+ f1 f" R
#include <linux/module.h>1 f9 P# H2 W$ y2 ~5 U* r! j& z4 k
#include <linux/kernel.h>$ ~: n2 ?+ ^# B, D
#include <linux/types.h>0 S, t3 b& R; z! y% |: v
#include <linux/gpio.h>0 ^* A" |- p2 w% M
#include <linux/leds.h>
" ?1 t- K3 ~) ?. t- D; B5 m* m#include <linux/platform_device.h>
# I2 l' _7 c: H
+ c* u. Q, E Y) ]#include <asm/mach-types.h>
3 ?' d+ |5 q' L. K! t#include <asm/mach/arch.h>
- t& Z5 P6 `( R5 l- b#include <mach/da8xx.h>
, J' c2 [6 b# y/ D#include <mach/mux.h>! s( m) y/ Q) t2 G4 E5 h' o* M
0 v- p) P' w0 w0 P& d. F
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 M: H5 ?" s) x3 G' s% A3 H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* R7 ?& m* K5 E: R2 g( o1 E#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 K8 Y; \- X' M$ W, u2 R1 m; @/ N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ z. P: G+ v9 A8 t k" o, U6 m! o( a& }, I1 ?1 T" d0 \6 ~
/* assign the tl som board LED-GPIOs*/
7 Z5 k/ Z R# q! q( X$ O$ S: xstatic const short da850_evm_tl_user_led_pins[] = {; |0 z6 }1 B* ]# l% ~
/* These pins are definition at <mach/mux.h> file */) Y9 Q' R" G3 H0 p+ {, |# O
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 L8 }5 }$ W; `- r
-1
" i% M' V9 Q% C! c) k# F};5 I& _0 g6 [5 Y
' o9 X9 P/ F# H1 T$ ^$ @+ A# }static struct gpio_led da850_evm_tl_leds[] = {
0 @, u" F! Z2 q& E { ~; b. ^$ V$ c& \' t( p
.active_low = 0,
$ g0 b, _; P1 I |8 t: j; f .gpio = DA850_USER_LED0,4 M/ G! u! b+ j6 `+ H& y
.name = "user_led0",8 H3 N% o9 K' `: v# J
.default_trigger = "default-on",% g- T* W3 e; J' d
},
1 }- r* z, J; W8 H) h* T) W0 l {
0 ~ t5 ~, ?! D& z* c0 D .active_low = 0,( F$ {6 q% o) `9 D; y! P
.gpio = DA850_USER_LED1,
A5 \* c* P5 u: x6 [ .name = "user_led1"," i2 M' k+ ]+ y6 J% v' y' @
.default_trigger = "default-on",) T4 h7 e" B! F( Z+ h a- O
},4 c* ~: R; q; M
{
# A; o1 k6 X) S$ l2 ~5 @ .active_low = 0,
, l. v0 u4 b! E* ]) l7 H+ O .gpio = DA850_USER_LED2,8 R! E+ `1 B" H x$ X. h
.name = "user_led2",
& Z8 S( k, \5 i9 y4 \ .default_trigger = "default-on",' N6 ], k( s. n5 _" B; [" [
},
, J# g D( K; o! ]+ A a% u: ^ {) F2 Y/ l& S0 ?3 k/ ]1 |
.active_low = 0,6 c( y$ O6 Z$ A% D! h7 e" `
.gpio = DA850_USER_LED3,+ k8 k: E; d+ ~ h! g+ O+ y j9 n! H9 ~
.name = "user_led3",% x' D% a; c' O* N1 o/ s/ }/ A
.default_trigger = "default-on",
# O7 ^3 I7 |+ X },* G% l6 {; `5 O) G. q4 ~. j
};3 U& i7 r3 B6 Q$ ]$ Y' K
" T$ J) e0 B7 H- f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& Z: w0 _" V/ [
.leds = da850_evm_tl_leds,
% n8 I) B# H; K1 b2 V5 K( g- A# z: r .num_leds = ARRAY_SIZE(da850_evm_tl_leds), D, o! X" d1 J) k0 e- W: E
};
/ ^! ^1 v( X$ A+ k+ o( }1 O( j" t" c8 _
static void led_dev_release(struct device *dev)
, c- i1 w/ I: f1 T- d) D{1 I6 c1 }( _) Z2 P" I! O5 x! b$ U
};
- \' }# U( h* U8 K6 q( F/ H. o( z' }+ J' g$ y. I9 ^% _& h1 ?
static struct platform_device da850_evm_tl_leds_device = {
k( X: C0 ?$ a9 Z6 R5 v .name = "leds-gpio",0 s' Z+ n% O, ?% r" t7 y
.id = 1,
: x% Z1 u7 B9 S7 r .dev = {$ U R" ?7 P! o2 r
.platform_data = &da850_evm_tl_leds_pdata,6 @' y. d& Y% D1 w
.release = led_dev_release,
, q5 H* o2 G' B2 I: N! H }0 v3 a2 S' n& c0 M( Q4 C
};. q+ v: ?& z, ~) {9 J( z* }* D+ T
+ [4 F% Z" f. J( Astatic int __init led_platform_init(void)3 ?1 _8 b$ e" O; a
{
7 m- W: T( \8 E6 E int ret;6 b" l$ v6 s$ O2 W$ K3 D5 _. ^+ P$ T, t
#if 0
7 U1 W7 K. @, l, O ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( ]8 T" d, x3 ~/ Z
if (ret)
/ ~1 h( O" o# u- p/ m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 m$ B2 v! ^6 d
"%d\n", ret);$ B8 f! L) l' U# V- T
#endif
+ i2 h% `0 m0 ]/ N, A7 }% \/ E ret = platform_device_register(&da850_evm_tl_leds_device);
9 \! T$ ] _3 L3 Q# i if (ret)9 y- b6 _8 M0 w' L; R: u& f( O5 K; h
pr_warning("Could not register som GPIO expander LEDS");
! r$ s) A. o% h+ R) d7 l else3 K9 g& V: }2 w2 T( f% u+ n
printk(KERN_INFO "LED register sucessful!\n");
' u2 F# _9 |$ v1 ^# C
! G6 [5 i7 K) \3 [- n( c+ h3 c return ret;3 ^+ H" y7 U3 s6 y/ n
}
( x; @* }! P. M6 W8 F, T; s7 K" [/ `! @
static void __exit led_platform_exit(void)
1 Q* p% u7 S5 h" y/ h3 q{
! K$ F- [, W. S8 ] platform_device_unregister(&da850_evm_tl_leds_device);
" W& f) @+ s) B3 L' i) `- }7 W% v! s6 s& r, @( \8 Z+ J4 t
printk(KERN_INFO "LED unregister!\n");+ X- t* k$ L% \! A2 c3 K- ]
}& p3 z0 k+ w9 W+ a6 j U5 {) d
8 D/ L0 n: O! T+ J! P
module_init(led_platform_init);$ N( w5 I* n' R- h9 l9 ~0 |
module_exit(led_platform_exit);
9 T) q& O" h; y+ |5 {* J/ b0 n' y: }3 l3 a: j" q3 x
MODULE_DESCRIPTION("Led platform driver"); S3 W: }% o. M( }7 M
MODULE_AUTHOR("Tronlong");; ]& e7 Z* d$ L; r# K! r( O+ `6 D/ b
MODULE_LICENSE("GPL");
3 t% f7 v& X$ K
. G( {6 N9 T6 D& k5 P |
|