|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. n4 h) z# b+ g( O3 Q, @* Z#include <linux/init.h>
, c( t6 G' M) ]* B2 D#include <linux/module.h>
0 S$ }0 P1 z+ z#include <linux/kernel.h>( h( Q8 V8 m) M% g# h9 C( J
#include <linux/types.h>
g5 o: I! l" U' f) W! d#include <linux/gpio.h>
/ N- W6 |2 |2 H6 I#include <linux/leds.h>
) n6 F, z2 Q! f( u+ ~2 Z# o#include <linux/platform_device.h>
( n9 A% P% C% B ]8 v: E$ o) i1 G8 Q a$ m' t" y
#include <asm/mach-types.h>/ r$ a* W& b5 l5 i2 G2 F+ B( C$ h
#include <asm/mach/arch.h>' f. e" R% V, X0 C) Z$ T
#include <mach/da8xx.h>" Z: P$ k# X& J$ r, v
#include <mach/mux.h>& Y/ `! T' R/ W1 {
. `- J( n* C% @+ S q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' z5 Q- y) I/ t1 U. e. B+ F$ Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( i& |' O4 }) @7 J" x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 T9 S; `; |! F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ H' e" n, T: ]
3 e8 ?+ q8 Q. ? A2 x8 [# Q& [/* assign the tl som board LED-GPIOs*/
; X2 D/ x$ e! |+ K7 W- z) V& q$ Astatic const short da850_evm_tl_user_led_pins[] = {
# B- C1 ~; A" _' K+ T /* These pins are definition at <mach/mux.h> file */
0 x1 h% f1 w$ E7 i3 z" i3 l5 x3 G DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 f( w1 B0 P) M
-13 Y9 z2 x" ?7 y+ D7 Q \
};# Z) k3 D( Z2 w9 X- b) o
4 Y/ {3 I# R- {7 b" t o+ Xstatic struct gpio_led da850_evm_tl_leds[] = {. f- r9 q2 K0 u7 ~* C! @2 _6 J; L
{
9 _" p6 D- t; d ] .active_low = 0,
- i8 n R8 s4 ]4 w .gpio = DA850_USER_LED0,0 f l9 ?$ ~" ~5 W2 G* }
.name = "user_led0",
* `. D; M* ]5 H4 V" V: N5 D' E1 U .default_trigger = "default-on",
! T# q( ~3 K; M/ q },
^& x, \9 E& w. n5 s {
1 D7 K- a; Y9 j1 `' X& B& T .active_low = 0,/ F# b' p' C/ w0 _& j7 k! l
.gpio = DA850_USER_LED1,
) e6 z: b, |0 ~/ V4 ^3 V+ V .name = "user_led1",
* e7 k0 M" Y$ p4 Z .default_trigger = "default-on",7 p8 _$ y3 e3 ^1 ~ Y
},
4 n0 Z9 b) V8 Z {- e8 n/ p5 o/ c1 }3 g0 U2 D3 M' N
.active_low = 0,
V6 s9 t7 i" r. I* K .gpio = DA850_USER_LED2,
: z6 J; L, M4 ]/ U2 o .name = "user_led2",' v5 Q) L$ Y8 J' z
.default_trigger = "default-on",' {# m* b- ^/ U) S" R
},* h5 k1 v" H, B
{
8 J" f* c% A0 f0 u, K .active_low = 0,
& e% c) ~8 d( I& ? .gpio = DA850_USER_LED3,
5 b6 n# _" m! {! d" g" ~ .name = "user_led3",
1 u& c( }) b4 P" k# h .default_trigger = "default-on",
, X% n4 S* d7 C },& ?9 I) f' z& F$ O/ r0 o, F
};
4 w/ @) B8 D3 j/ t2 j; B$ e2 V. \; M9 g: @" ?( f3 z7 f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 o8 H% V9 o1 C# R5 }0 R .leds = da850_evm_tl_leds,% C0 w! `# O! D9 W& _ [
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),# v Q% Y6 A5 w# M5 R6 m
};
' E- ]: f9 ]: K/ z' m' z' o1 c2 \3 U- P3 t5 P
static void led_dev_release(struct device *dev)$ U2 A' j4 G; ?
{& b" Y( M& D. A: g! T6 B3 n
};
1 w! q8 Z; ^/ s2 Y* X* n! {( `% z- A' n- T ]+ V
static struct platform_device da850_evm_tl_leds_device = {" {' i. A" ~! x# d4 g) h( S; o
.name = "leds-gpio",
3 S$ w2 b) L8 m( O1 ?6 y .id = 1,4 o! }5 p& z' I% T8 _# c; r% u
.dev = {
3 U& L7 V1 S* }" D/ E% b- ? .platform_data = &da850_evm_tl_leds_pdata,3 }3 |2 {+ |$ g. L$ B9 N& Y
.release = led_dev_release,
) ]" U- P8 p( a+ r } [3 g+ z9 [; }$ y6 ?1 \
};
% F, v* U/ \( M2 c0 Y! V, |% {! t3 p) a5 J& [/ ?
static int __init led_platform_init(void)
$ e$ @) F/ M5 H4 f{+ y$ d; b8 L0 X- v0 _
int ret;
4 N1 C( d+ w3 d2 n% V ^#if 0
1 y+ n0 Q% I6 I1 S3 g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ S& t4 r3 R2 z( y2 Y, { if (ret)5 E; u3 @2 W' N* m
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: b0 u$ ]- e- g& F* @* h "%d\n", ret);! C4 M* m' |! Y
#endif
$ U7 d! L, D _ ret = platform_device_register(&da850_evm_tl_leds_device);
' W, V$ w8 A1 B0 J if (ret)
7 a3 G/ F( S! |& u' {7 J/ V pr_warning("Could not register som GPIO expander LEDS");0 Y; n6 ^: |9 x3 S5 H6 y
else5 X& h {0 z" ~ K2 M' J
printk(KERN_INFO "LED register sucessful!\n");5 y- V: O. s3 y9 w2 T: e
/ I, M* o& K; H* I2 V return ret;
9 _7 e# B& W( z& y; p}
A; w7 { W, M- N2 q; u! C4 s
, `- }5 d9 a9 x7 L: T3 Y7 cstatic void __exit led_platform_exit(void)
! [- E: d- w, d* w{
# p7 \ ]2 Y) y" K) j* ~ platform_device_unregister(&da850_evm_tl_leds_device);
( a; f0 S* M G3 v- F& P! R% R; q+ ~' E9 S7 F
printk(KERN_INFO "LED unregister!\n");4 i% s. Z$ ?$ n+ V$ h: H
}
_3 |6 k; F1 h5 K' V
2 r5 o* G7 M i) B7 Fmodule_init(led_platform_init);
% I& M9 W) M& V n+ a2 c. rmodule_exit(led_platform_exit);, q9 c; q4 r% \1 [- ?' [/ P8 x- U
* f" V: s' c2 a( r( k. g, dMODULE_DESCRIPTION("Led platform driver");3 P' s0 d4 q" ?$ Y7 h
MODULE_AUTHOR("Tronlong");3 n) U6 e3 Z$ c" o, H6 ]3 d
MODULE_LICENSE("GPL"); o- @4 @- b+ ~( l l8 A% z
; t5 v( R# k6 \2 N1 s) j1 E |
|