|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 L. u: G* W- d, {' x$ m0 l1 I+ k4 o& [
#include <linux/init.h>
# d8 l. o4 c h8 Y, @#include <linux/module.h>
$ \' j! h5 Y4 n3 F8 r8 \#include <linux/kernel.h>. V; }; W- O) U* _% d5 s9 q% c
#include <linux/types.h>+ {4 S, T% x% S& Z$ ^3 Y7 J5 N
#include <linux/gpio.h>* n! y6 X( y9 C
#include <linux/leds.h>: v- v9 u; ?2 Z l$ Z9 J s, v8 l k
#include <linux/platform_device.h>. J) ]4 f6 _5 O) n8 ]: v
7 T6 I5 s% m# }+ c7 _' [#include <asm/mach-types.h>" v- Q! X+ n) q& m, ~
#include <asm/mach/arch.h>5 r: ]( {& Z; \: I
#include <mach/da8xx.h> y1 o) Y% [$ B% r
#include <mach/mux.h>- a; Y' {) n2 P: q a* G! F c8 L
1 D5 H, O {; j) i" _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& N! r& l/ D- x6 T6 j- l#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ O; ]' Z F" k#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- {, Y( e1 w) I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 l7 X; Y6 L0 Z4 r' M
j2 ~7 g7 \2 F g/ }/ {( L/* assign the tl som board LED-GPIOs*/1 T2 H5 ~& ^5 y
static const short da850_evm_tl_user_led_pins[] = {
" j3 Q) m4 m: u0 B /* These pins are definition at <mach/mux.h> file */
, B) H. z. ?/ P3 F4 { DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 m6 h# m5 F% z/ J& G( v& v -1) m8 A" u) Y+ @0 |' E n$ T
};6 Q# Q) p9 |/ y: D& q5 o8 A
: }/ W( L9 h2 k: h( m4 Ustatic struct gpio_led da850_evm_tl_leds[] = {* i& f2 I* L" _* I/ p
{
; w' R6 J1 h1 T; h .active_low = 0,/ P! `- U V$ |: {) Z
.gpio = DA850_USER_LED0,
" D; p, W8 |1 i8 x6 h3 E5 l .name = "user_led0",
6 C* C7 H: a9 u% d1 W9 w9 h: \* e .default_trigger = "default-on",
, |- B* A" E. I" o' ^6 C },. r! F( i0 U" P2 `+ R9 T9 I1 K
{% M7 M1 J% f) s% c
.active_low = 0,: }' Z/ ~+ U( u/ \
.gpio = DA850_USER_LED1,' J; i" E9 @% _0 s! x
.name = "user_led1",
5 H+ {" L8 q* j4 ?: G: b1 V A8 O .default_trigger = "default-on",1 k- o9 R& d+ f+ z5 G. P
},
% R* S) J8 j6 d2 m. ^1 X! p1 l {+ l7 J% ^, Q) H+ v. \, S C
.active_low = 0,4 p( a& j" m( [" b: t& t" C- f
.gpio = DA850_USER_LED2,) Z) |& v& P- z. Z7 k; D4 X& G
.name = "user_led2",
* A0 Q% H* c D" E: N! i2 W; d0 T .default_trigger = "default-on",! s0 K! Y) a0 ^2 e. b6 b
},
3 N. s j- d+ ~; Z& q {
: k1 g. T! U! E) Y E3 z0 U .active_low = 0,: h5 ?2 q p! i# Q: O& V7 L, j
.gpio = DA850_USER_LED3,
3 f7 k5 R1 d8 V: p6 L. x! B .name = "user_led3",
+ I5 a- _& m7 c6 u- B .default_trigger = "default-on",
5 _& c5 }7 C, J" n1 G+ _+ I1 u },$ e) T( f! i8 c+ x; ~; `
};
2 d" s+ l/ K6 U1 h' q7 n
1 s3 a" X* v! i* astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) {: }* k w" v2 h" A, _, M .leds = da850_evm_tl_leds,2 f; O0 r- L8 v7 E! P3 T+ r% ?
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( R$ V& G% O5 U};
- M+ i7 v8 Y6 {7 ~, `- T; N
7 A% i. Q$ {" D# Hstatic void led_dev_release(struct device *dev). Q: n2 @8 ~4 y9 ^9 K2 [) P1 K5 A$ j, _
{
& n& ?" ~7 q6 D1 ^0 P j1 t};
# r( L- d, ]# v' s& R, i; G+ m5 |$ G+ m+ j9 @) w( s* ]$ p
static struct platform_device da850_evm_tl_leds_device = {' o3 E5 z% C4 _7 V
.name = "leds-gpio",
/ d# x" _# l2 }6 n* {9 K4 C .id = 1,
2 d. P# Y/ s3 Z( w7 S .dev = {
4 h# O, g/ ]) `! o2 f3 F( m .platform_data = &da850_evm_tl_leds_pdata,
# I+ d6 T3 i! K* s7 f$ V) O2 E% S .release = led_dev_release,2 U$ `! r! ^, ^; J6 I3 l$ r
}
; ~& v, [ D% c' O$ m7 G6 g};
) G6 F) `! \9 Q3 _) u( M0 z* V4 f0 P+ k% H, F3 t& i) {( j
static int __init led_platform_init(void)
$ o+ w9 r: @& g{: G+ V5 E' b2 q F
int ret;
+ _$ ?" F U2 i$ d#if 0
7 v1 Q+ b, ~1 P. r+ M- v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! Q+ U( w2 X6 X, w _. J: {1 S/ t
if (ret)
% D" g4 e0 y4 K6 P, z' z8 p. o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" ~9 p, @- X; Y6 r: O8 }4 e
"%d\n", ret);
6 A8 B( R/ Y! ~- \# _: [4 z9 J4 U#endif
1 [5 \* }, g' H* Y" U5 c* T( m ret = platform_device_register(&da850_evm_tl_leds_device);
1 `, C0 F8 D0 P. |! [ if (ret)5 o n; i& p! y' N
pr_warning("Could not register som GPIO expander LEDS");
( X% e7 h+ O! V O# k; r( v else3 M7 w! [8 A2 ]+ g, u( L4 o
printk(KERN_INFO "LED register sucessful!\n");: n9 n1 A1 e( a& E% R5 q
& E9 c/ O, ?" H
return ret;9 T; w# W8 p5 w0 v1 f
}
; B" Z+ P5 {7 ?7 t
; y! }! ]9 S; F& A, `) Xstatic void __exit led_platform_exit(void)! s1 i; d7 S y r+ u) z
{* A( {0 ]8 R7 ?( g) F' n( o2 I! c
platform_device_unregister(&da850_evm_tl_leds_device);
2 x4 l" U8 _- g, E$ [9 w: {2 L& Z' ^: \. V* }6 L) v3 |
printk(KERN_INFO "LED unregister!\n");) L3 Q$ q! O9 } e( b
}6 @; A; ]0 e% w1 g. P
0 K2 S1 _) d0 ~5 s2 ^, E3 w
module_init(led_platform_init);
5 |* P8 G- M/ X$ f' y. Zmodule_exit(led_platform_exit);
- V! n7 q$ e3 h: n
. l6 c: p2 Q( f L: h; Q' c& Q- _! \MODULE_DESCRIPTION("Led platform driver");0 _+ `. J( ~. q" U3 C
MODULE_AUTHOR("Tronlong");
* X1 t- i+ ~# _! aMODULE_LICENSE("GPL");3 A6 h" p# h8 s' U1 m2 t
4 H5 O7 S4 d) B/ r; d2 s' h% R |
|