|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) S! J/ L7 H! [
#include <linux/init.h>8 v) e& t$ P* S# D# r; m2 ~
#include <linux/module.h>
( e# y8 w, X3 ?3 @#include <linux/kernel.h>
, C# o$ p5 e9 b8 U- p2 B- O#include <linux/types.h>
* e% M$ B8 _% ]& k% H# P3 D6 I#include <linux/gpio.h>
) m" I f& H( v% w$ {#include <linux/leds.h>) m- B7 R+ f/ ]% h8 K
#include <linux/platform_device.h>' @4 Z* K- K. ^$ T) W% S
$ ?3 B) W. a5 F; h% e& d8 O#include <asm/mach-types.h>
( }1 l# Z' t. @#include <asm/mach/arch.h>
0 k& A$ J; ]: ~* k+ F#include <mach/da8xx.h>! x1 M" i% o+ F2 z
#include <mach/mux.h>
2 h5 Y1 A) ~8 i# O$ P( ^0 G1 o, A9 @7 m, C; R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ y0 v% m0 T1 y @( f: `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) l9 F: B0 Y* ^* n) ]- |, W% Z/ @2 B#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* f. d7 p5 B) h
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 i9 ]: e' h% X# C0 C3 T. j' ]) J* Q/ X
/* assign the tl som board LED-GPIOs*/
" F: a' U7 `9 u' m& O1 E4 Wstatic const short da850_evm_tl_user_led_pins[] = {
0 D# N% {4 r# r7 @: T! L" } /* These pins are definition at <mach/mux.h> file */
2 B. j; \2 |* w; W+ k0 a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," ^, C6 x% w; h4 F1 e" |
-1+ m7 D4 F/ o0 c# k6 r, v0 q
};7 A# ^/ m/ ^' ?1 h- m7 H* n
- q. Q/ _# N' E! Z# M- C% ]3 Astatic struct gpio_led da850_evm_tl_leds[] = {
* X! r _1 o* V0 A$ b/ X {* ~/ n4 g% _0 q, x5 t8 b; G
.active_low = 0,
5 ^" \) _. M0 A .gpio = DA850_USER_LED0,( @# i# Q% G3 u' J- h
.name = "user_led0",2 w# G$ j# b1 `- {
.default_trigger = "default-on",
( D c; i0 S; n# x ~ },! w l: `% b. n8 S
{
% S/ ?1 n! h. h .active_low = 0,
- P/ w0 W- ^/ O: [' e" @0 R .gpio = DA850_USER_LED1,
2 V) ]" {- D) G9 d4 p5 G: G) ^ .name = "user_led1",
, J; V% D3 I5 ]9 Z9 N .default_trigger = "default-on",
. K: q( A8 U6 d+ v) @: T },1 ?3 s6 }* `% H4 @5 T# r0 p5 t
{5 x7 u: U) }! {3 x
.active_low = 0,
# g2 ~. }+ u* D) @ .gpio = DA850_USER_LED2,
* v3 {$ G$ ^3 J1 v .name = "user_led2",# U* f+ a+ j4 T7 Z/ Z3 k! d
.default_trigger = "default-on",
1 }: s) T; Y/ n: s+ |" } },
6 L! t4 ], j7 V l" ~/ M& X1 W {5 T; K: E1 Y$ G- e
.active_low = 0,
4 ^, @; |7 X$ P .gpio = DA850_USER_LED3,
" l% x% L$ s0 F( h7 U5 f .name = "user_led3",
" @" n# ?# V* p6 [ .default_trigger = "default-on",$ h7 x/ B. _- ?2 W
},
# ]/ I$ _7 L; i3 G% O2 k# ~3 f: E};2 F" K3 }% F5 m8 D) P* ]
* H7 @( U3 z! \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) b+ c# |: e ~4 n5 M, S, X .leds = da850_evm_tl_leds,4 B" P5 b3 S3 X- o" o/ q+ C3 e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 o/ M- `* e* v5 Y* c1 q
};& l I k$ |3 A5 V# F& C
9 ]' F8 \0 K- N+ K4 f
static void led_dev_release(struct device *dev)5 ^. w9 M: J: }7 ? o; I
{
^- Y. j1 I' B( `* W* A};
8 S/ Z+ A9 C9 K8 P$ n7 G$ e* K0 `7 d/ }& q& n
static struct platform_device da850_evm_tl_leds_device = {* C4 e8 ]+ ?9 b7 ]/ |: B' r
.name = "leds-gpio",
! G" ~2 u5 u9 N; D! q .id = 1,
4 O0 r8 k8 M! T6 N .dev = {
& Q {$ x2 n% U! C) G .platform_data = &da850_evm_tl_leds_pdata,
. f5 A* |1 E! V- m" N .release = led_dev_release,* O5 [* \1 p) I `
}
# A. ?% e6 I+ Z0 J) w};
8 p/ n0 S5 B6 X4 u0 {5 y7 |( J W! d w6 I
static int __init led_platform_init(void)
8 l& h5 r- M. h5 ^" v{9 |* W$ h, @$ a G+ F, H9 B/ X
int ret;
+ f2 \# H1 K5 U8 l8 h& v#if 06 u- O0 a& r6 Z( i( P/ B2 \
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. k% P8 Y3 s# r: ` L, s if (ret)
9 B/ ?% [' }0 X7 n) C- P3 L7 v pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* @6 H, X( s3 s& R3 O "%d\n", ret);
) z6 A5 K* H; d' k; U1 j+ x: Y% ^#endif
! z' `2 ?6 Q0 f7 { ret = platform_device_register(&da850_evm_tl_leds_device);
8 w. ]. |8 n! e# g if (ret)& V8 c4 y; t1 O
pr_warning("Could not register som GPIO expander LEDS");; ~6 @5 ~2 d9 ^6 ]) i) P& |/ ?( a
else( W9 W% q$ D3 [2 P+ t L
printk(KERN_INFO "LED register sucessful!\n");1 v! |5 i, j2 {) N7 s& v% b4 m
8 d; D' A5 W9 c& s return ret;- l& d7 }, M; Y
}5 O4 n' V5 k* l# q
* x1 h2 B/ C2 w/ _. n+ b/ Nstatic void __exit led_platform_exit(void)! B! f$ S. C, ]4 z
{
$ I7 }; h. i: i( ^ {) H platform_device_unregister(&da850_evm_tl_leds_device);
0 ]( M: p: {, }% t& d
6 e! d0 N% ~/ Q3 n printk(KERN_INFO "LED unregister!\n");
! o: y t U2 U! I" q0 `}
, L2 e3 K$ n; w# O$ ~6 [& ]6 Q, @& j) u3 E
module_init(led_platform_init);( K6 e9 t, W% h: Z
module_exit(led_platform_exit);" y0 T! V9 `: n: w8 I1 v
9 V& s8 F* D! O" X
MODULE_DESCRIPTION("Led platform driver");
# V, L* A8 n: g" b+ `. B8 iMODULE_AUTHOR("Tronlong");' C# c, E" v2 G' t1 N
MODULE_LICENSE("GPL");
; q0 z6 ~/ q" Z* ^
8 ~/ f% c5 M% A% ~; c* ] |
|