|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, A0 [5 Y- N+ f8 l" p5 B1 q' {# J* O#include <linux/init.h>
. |- u2 H; @# ]3 R _#include <linux/module.h>' q% e% f; u- u
#include <linux/kernel.h>
2 X+ {1 X# w' d' H' K( Y1 M! ^#include <linux/types.h>
: f7 k# z7 ~ |- T( Z1 G( L" ]#include <linux/gpio.h>
+ u0 f3 f; n7 Z* ~- u+ S% f% i) h#include <linux/leds.h>
% s1 X0 }4 P% g. W* o ?#include <linux/platform_device.h>
+ g9 x7 \$ i5 ~& p1 x: l. D: u: A( ^' [+ r
#include <asm/mach-types.h>3 }. c' M" Z9 F- {1 \
#include <asm/mach/arch.h>
_" c" x# Z8 X5 u* T6 V2 h#include <mach/da8xx.h>7 E# N. l( Q9 K1 ] i1 I
#include <mach/mux.h>
0 A$ i9 R4 ]* A% J5 G
: T7 ?) y* K# l' |1 }5 p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 G& K! c9 h) V& B
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# ~ ?8 S; P' e3 }' T+ Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" } W4 [ F9 P/ N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ ~: {# v, u+ [; T. [5 I
( i- A* U$ h, y9 R' f. z/* assign the tl som board LED-GPIOs*/. |& o4 _6 f) C, o2 T2 H
static const short da850_evm_tl_user_led_pins[] = {4 K' A( r, Q( [# g4 ^, h1 ^; d
/* These pins are definition at <mach/mux.h> file */
i) g2 f* d3 `; P- V9 s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 B5 e: h. m$ ~ -1
$ m$ j. L( m( G/ C# N$ S};
4 S4 E: G! B/ @5 F$ t
! `, T* i$ Z: M' _7 W+ H) l7 Wstatic struct gpio_led da850_evm_tl_leds[] = {
* p7 E2 M" ?: a {, S' l& p- L l- R; B1 ]9 g
.active_low = 0,
% h' t& X' f+ Y1 _# \ .gpio = DA850_USER_LED0,; [9 D* |: n4 c* o* h
.name = "user_led0",
4 N" b3 t6 m. x1 O8 ] .default_trigger = "default-on",! `2 v ]( f1 c V
},
* u% C( K6 k. }& z# U {
: q5 S1 B' l$ U .active_low = 0,
8 `9 u" ~0 n+ ~: R- Q* ? v; l* R' C .gpio = DA850_USER_LED1,2 J l5 {/ l8 D
.name = "user_led1",- J1 c8 Q/ s& u2 {7 h) w" ^! P8 C
.default_trigger = "default-on",/ |) e* [) _4 U
},
' h) z) q4 F# Y* @. P( n1 ] {
/ ^0 f: P- ~" x0 y# a .active_low = 0,- s' z8 G; g+ O, v9 I, y
.gpio = DA850_USER_LED2,
: K8 A0 |4 Q3 J8 c* m7 b$ G .name = "user_led2",8 E8 M G* Q7 i
.default_trigger = "default-on",& z1 K3 h; y: ?5 H9 T: M1 @" a* [
},
% z* E9 ?/ ~* h' S+ c+ o {7 L; r/ K1 C4 U' y u% `. @% z
.active_low = 0,
) e- V0 z3 d& C6 Y" q# ^( N .gpio = DA850_USER_LED3,
7 v/ o' f0 \* q! m .name = "user_led3",7 S9 J% k @4 m' J/ s
.default_trigger = "default-on",
# r' b0 C7 E! o: A7 d/ J4 S },6 U& Q5 B" [, O! O5 b% Z) H3 V
};8 w! ^7 D7 S# _0 T1 |, S3 o
, `/ q4 E8 e) B( B
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 K0 b. R4 c: ?" c9 o+ N* `
.leds = da850_evm_tl_leds,
1 U; ^5 H8 ~' t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
g8 t5 P& B T% @& E. u3 J};; J9 b9 w/ {+ {9 N! N& E
% P* i0 a+ r' M0 Qstatic void led_dev_release(struct device *dev)3 e2 \- C$ e2 L( y, N. f. K: K' ]
{
* l& I8 K' `0 g6 s};. V$ ?9 e7 C1 }1 ?9 }
0 }+ |. U8 H" B5 E6 a0 N
static struct platform_device da850_evm_tl_leds_device = {# W7 j3 y8 M+ k3 Y2 W
.name = "leds-gpio",
- l+ O b9 C7 O s8 v .id = 1,& G9 L! \$ N( X/ \7 o- R
.dev = {
, p/ I8 Z: d" f& V2 X6 h .platform_data = &da850_evm_tl_leds_pdata,
- b8 L% d8 q4 a. q, i/ y) k .release = led_dev_release,. F: Y7 ]* V: Z* `
}+ d. c+ t3 g8 ?1 s
};9 u) B$ z1 w6 _1 N. J" l& N0 s5 M' x
" a- P' E- _/ e5 R% e- T
static int __init led_platform_init(void)
/ L' e. R0 e' [ C; W% J{. v4 y7 p m5 B0 S/ N
int ret;: f" w+ h) f7 V# N1 P' E# c9 c+ h4 ]5 S
#if 0- e. ]% P5 x+ K
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! n E7 h* H9 I# h4 H2 ? if (ret)
# F) d1 K* g8 d8 i pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( |' ^+ G2 n/ [" E$ G! h8 {: @0 q# ^ "%d\n", ret);$ O& |5 @8 P7 S
#endif
; f( s* a- G. q8 l5 Q) u# k9 h ret = platform_device_register(&da850_evm_tl_leds_device);
) F3 N4 v8 o; `1 X- D/ \ if (ret)
" {6 x( }/ c* E$ a. Q; V pr_warning("Could not register som GPIO expander LEDS");
o8 ~; o1 n7 {( m% b6 u+ i else' P7 ^4 ]0 J& U6 `: w! f
printk(KERN_INFO "LED register sucessful!\n");/ R5 f1 s* E" L5 \& h
4 J+ i! F% f9 ]( H return ret;: s# m3 T- u$ ~' I- a" y
}
" y4 v1 \9 f9 m P. I' v2 P& G# ]3 x) J. j! L1 n
static void __exit led_platform_exit(void)0 A9 p7 n' p9 u) Q6 N
{
2 {* b& r/ n: Y platform_device_unregister(&da850_evm_tl_leds_device);& I3 k/ Y" Y6 R6 s7 Y7 s
: q8 D4 B Z; h! W2 } printk(KERN_INFO "LED unregister!\n");
; P @% W: L4 K: ~- o2 R" A}
$ v) d: e' t3 [. S9 I* N: T5 v! Y1 d b! p4 K; E$ u7 _
module_init(led_platform_init);- P; @" r% _% V4 F M) ^
module_exit(led_platform_exit);" f* }, ~1 M( N
+ _( Z* b0 q: ]MODULE_DESCRIPTION("Led platform driver");
1 t) d. s$ d' R+ x3 D6 LMODULE_AUTHOR("Tronlong");
' E% n; Q/ p% sMODULE_LICENSE("GPL");( j2 k1 S$ |5 `& [7 P- t
3 N1 k% Q. {8 l/ a: w |
|