|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 b# f6 a. d( s2 ^+ H9 V# u
#include <linux/init.h>7 {! D3 t3 G1 l
#include <linux/module.h>
% \% H+ \/ a. N9 j#include <linux/kernel.h>
: T1 i% g) n$ e#include <linux/types.h>
8 J2 \ v& C# K* P" G0 T V3 ]#include <linux/gpio.h>
4 x7 t, l+ C, ~8 }! z#include <linux/leds.h>
4 G" {# {8 N# U: L" U#include <linux/platform_device.h>
" d, k: ~2 {; ]7 {4 V4 l; S3 f9 C8 S6 }3 i( ]
#include <asm/mach-types.h>
( F* U& z4 f# I5 r! l#include <asm/mach/arch.h>7 A0 n/ v7 g3 h: d+ b, A* G
#include <mach/da8xx.h>
# K# T5 u* d9 z3 d+ C#include <mach/mux.h>
X5 `$ ^7 V" L& d' Z N1 a, M
7 E( O, V& z8 {: H1 W: Y( s. h#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 V; \3 ?; p) B3 m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* { Z6 p5 z* `3 ~8 k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* c* m# O( Q4 Q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) B" f* h+ W. M, N1 ^8 G2 V/ n/ h0 P7 }
/* assign the tl som board LED-GPIOs*/* H3 b# t! ^4 q; z7 m0 X- l
static const short da850_evm_tl_user_led_pins[] = {
2 q) Z) s3 Q8 D8 S3 y; [; T /* These pins are definition at <mach/mux.h> file */
8 W6 d4 T$ l0 m& D. U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ y5 }* J( ^) b8 O -1
! _8 _( H/ Q" P# V' u4 m, r};1 K C) ?2 r. O1 T8 }) ?
0 I: H+ G% M, g5 @
static struct gpio_led da850_evm_tl_leds[] = {* q- @1 B) V) N. d9 R( D
{- g6 i+ h6 J& g$ Q3 n5 s+ i
.active_low = 0,* A2 Z2 t0 S: I7 O+ s
.gpio = DA850_USER_LED0,8 j1 y& G4 h3 t) w
.name = "user_led0",
2 ^$ X* d s( G$ p5 d6 P6 e .default_trigger = "default-on",
3 d' O* {+ @4 [) g7 Q },- |9 _) `2 i& H. a2 U4 ]' m
{
6 F8 w& M& u: y" J }% r& ^% M6 r .active_low = 0,6 J9 H5 E4 x" k
.gpio = DA850_USER_LED1,& V9 N# ^7 Y2 v& ]
.name = "user_led1",( q- T9 w: C- e3 d. H9 F6 Q
.default_trigger = "default-on",9 U& ~( o1 e$ G2 k2 z' x3 a% x% Y; {0 O
},
9 C4 \/ ~" [/ @1 n! G {
% k6 J- o4 q- c8 w" n% O .active_low = 0,
, v1 f4 W2 j) d4 a" u .gpio = DA850_USER_LED2,
& L6 P- c5 S6 k, ]/ c6 U7 G" V0 A+ u' A .name = "user_led2",
J* h+ w9 D. q' F p .default_trigger = "default-on",
' K" q+ c9 M( X' S' b5 G },
: p2 T0 i5 x; h3 `2 F: n1 P4 q" E/ Y {4 l& O1 O5 o7 c7 \) r* j
.active_low = 0,
7 c9 v! J- P4 F0 G U' p .gpio = DA850_USER_LED3,% z. K" s' t) X3 s/ _ a( k
.name = "user_led3",
2 j% p L$ g3 i6 Y! h .default_trigger = "default-on",& @! y8 ?( V, O+ N
},
0 C x( V- R+ ?2 O. @$ Q};
9 s3 J" ]2 t7 L. r& J( @1 ^- w2 Y- A4 \1 C( E; e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* M# U7 I% Z+ D1 q! V .leds = da850_evm_tl_leds,2 R" s5 H8 z. ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& Q) ^" [3 o5 f};7 g, z0 {* m' J) t& l+ A( p H
G" ^+ A1 i% D6 Bstatic void led_dev_release(struct device *dev)
9 c0 [. Y+ n+ T9 o) |{
) }( m* H6 F* I& D" T};8 X7 X: v. a% G: w% y
5 U0 H( i% G% x1 A6 ~3 @0 hstatic struct platform_device da850_evm_tl_leds_device = {
6 E/ h" w' v% P .name = "leds-gpio",
! A1 ]8 ^& b' n# d .id = 1,1 A9 L. I+ l; ^8 Y) U! a! J* v
.dev = {
& ^3 O( p# L W6 u) V& B3 ] .platform_data = &da850_evm_tl_leds_pdata," R8 d& o4 T6 n# x9 p
.release = led_dev_release,+ X1 P2 ?% |! q) ^
}! K( w. y e: F
};
0 Y( W) A) B) ~% n3 b
" ?& }1 X; ?' B5 ], |, ~static int __init led_platform_init(void)
$ W4 q! I5 Z) G; b8 R{) v& q/ [ g. e$ u7 u X. ?0 d
int ret;
( `" z0 Z8 T% }8 ]#if 0
: D, [. ]2 M* x' l$ ] ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( d) `2 {& s6 H5 ^ if (ret)
6 r; J' j/ q9 o }# i9 V pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- M: m" x6 Z7 Z# C% s "%d\n", ret);0 J6 @2 `! k- }; P
#endif
3 {% Z2 ]( Q3 b$ I% i9 O ret = platform_device_register(&da850_evm_tl_leds_device);' d- `% ]3 o. x
if (ret)' ?( C5 b! f& R8 G9 [! `
pr_warning("Could not register som GPIO expander LEDS");, @. ]) w9 `1 e' b: i B6 G
else4 |. n+ X; c: ~: i+ o, S
printk(KERN_INFO "LED register sucessful!\n");! A0 t9 _8 z \5 j
) O( d& }: _: L
return ret;1 U5 P; a4 D4 z8 i
}! d: K8 q$ Y" ^! `) C( G
# E- M/ ^2 A3 ~0 bstatic void __exit led_platform_exit(void), j( U7 k; h b5 i: R
{
, l4 I: w$ e. k$ e; a platform_device_unregister(&da850_evm_tl_leds_device);
, ^$ f/ R) g1 P# x& O; o6 O7 {) O- [- E3 C( W, h% Y# r, \! C1 B2 Q) ^+ H
printk(KERN_INFO "LED unregister!\n");1 f. k" h/ T% w4 V( q* e. ?9 g
}7 s! `7 ^- Z: O6 l
1 @* I- {; t8 w, i1 G
module_init(led_platform_init);* t! O$ S5 j0 b7 D6 W
module_exit(led_platform_exit);
8 ]9 O3 M! k: D0 [: \( q. L5 G6 W9 ~" ~2 K, b6 b9 B8 V" |
MODULE_DESCRIPTION("Led platform driver");
& {2 N& |: M! O2 D' wMODULE_AUTHOR("Tronlong");
" |- C% O/ U( {- p% CMODULE_LICENSE("GPL");! }5 ~0 G# r$ ?! h
# h/ J" Q4 a6 ^' g |
|