|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# ^ f. M* [3 [; P7 A* m8 q/ I#include <linux/init.h>
' K1 }+ w: \' c2 w6 K6 v/ ~# i0 `#include <linux/module.h># u" D' @. \+ P& T1 k# n) i
#include <linux/kernel.h>
; Q1 ]' j+ f4 X5 u: Q+ J: I3 S! D0 F#include <linux/types.h>+ a4 e. i& Q7 [+ e
#include <linux/gpio.h>2 G! u `: i0 H; I- M
#include <linux/leds.h>5 ?9 h& o7 g) k1 z0 A
#include <linux/platform_device.h>
+ }. j {" L9 C. D( k% u
3 v/ O3 M7 Q5 u! P! [' a#include <asm/mach-types.h>
; C3 E- T0 a! J' `. m3 @3 p2 h& v8 f#include <asm/mach/arch.h>1 e9 |( e) M: _
#include <mach/da8xx.h>
5 A& C) O& i1 m" `5 @ r1 d#include <mach/mux.h>
1 ]7 K, O; k# c( i" S1 ~
: M# p; e, g8 H3 I6 B' M0 `" s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' g! f/ s( W, ]/ a* z. U4 y. ?
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 Z* j# E4 Y: W8 V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 D0 o [4 Z& e4 Y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- ?# f1 z1 o# ?0 Z; O* D+ r% s: n3 u
/ C4 \5 F4 Q4 Q% r2 B4 Z/* assign the tl som board LED-GPIOs*/& s3 _! K% v1 h% a z" \' L
static const short da850_evm_tl_user_led_pins[] = {
; D* ^5 b, D# q( } /* These pins are definition at <mach/mux.h> file */: p: j# p0 E% ~1 ^' m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% L2 g5 d; t1 h! z: @7 t
-1
8 j0 p& ?3 }+ G};) Z% t; P8 Z1 _/ x% v$ |6 K
& u! `$ I% H( H% i* tstatic struct gpio_led da850_evm_tl_leds[] = {# R. B+ B \, v3 ]+ h& s( N. Q
{0 e; `6 a9 `) C! ]" w- c+ x
.active_low = 0,$ `( K. Q- N5 c$ f3 h- ^; Z. Q
.gpio = DA850_USER_LED0,& S( h. i6 a2 [
.name = "user_led0",
! ?7 W. }. e# U0 t) m7 K& g .default_trigger = "default-on",
; s. B5 n# G' a },
4 x" O( ~2 ~8 y4 _% d; L {
) A# W' R/ R+ l% O .active_low = 0,( `" ^1 M0 ^ K1 c
.gpio = DA850_USER_LED1,& t {- m2 ~( z: F P
.name = "user_led1",/ t# @, f; }7 ?0 A$ H5 o. M; S: y
.default_trigger = "default-on",. ?, O& f! z6 W. S2 b1 i
},
; \/ h& [8 H# T2 m1 o0 c4 g T$ r# Z0 G {9 ~3 g* ~$ ~. x6 Z; t ]
.active_low = 0,
/ L+ i; x$ _( w .gpio = DA850_USER_LED2," m9 J0 l5 C* v
.name = "user_led2",
% B/ y5 R. |: @ .default_trigger = "default-on",. X( q/ H: s5 |- q: s
},
+ q; X6 W# F' s- @ {
) Z3 v1 ?$ ^3 ] .active_low = 0,
6 ^% G3 H* O2 G" H7 {# R+ e .gpio = DA850_USER_LED3,+ _3 u3 ?- t1 J x6 J. K: N
.name = "user_led3"," i4 x8 z9 P* x2 C
.default_trigger = "default-on",
5 k7 F1 j F5 E },
% {/ Z% q' j2 H7 \. D6 U+ F. j};. e- ]# l, U U6 ^% _7 K
( K, C) ]: y4 R" [static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. ~$ B" W+ g( f1 K3 g" | .leds = da850_evm_tl_leds,0 G5 C) k/ O' \- T+ o
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' q. |% ]8 j+ a* A1 }
};
( u# k+ i* e! w; I1 _9 e# ]+ g
: }3 T) H% G" s/ [! fstatic void led_dev_release(struct device *dev)/ Y5 }( C! F" w# ^1 T4 w' w; I9 E
{6 J& X' o4 h/ d1 l
};
% j9 {; C( R. d/ x( G
2 S' s, N: i% l/ K: Lstatic struct platform_device da850_evm_tl_leds_device = {
9 m$ p7 l3 W8 p! O, A( n .name = "leds-gpio",9 j: T5 F; J# s1 U* r5 J5 @ h
.id = 1,
7 \# y7 B2 v: |/ s, N- T .dev = {
* J" C' ^" t2 L- A .platform_data = &da850_evm_tl_leds_pdata,; ]2 s7 R$ E, \9 r, _+ g$ V
.release = led_dev_release,
& k% {3 _; s5 W' ^/ x- r }3 g' [' `: Q/ [
};
7 \2 s! V1 g, l5 O: K) s5 m5 `3 P8 k2 v/ F. l& d n
static int __init led_platform_init(void); N' y: s3 m: b4 |0 [3 @1 i
{
5 M8 B' z2 z4 `0 a4 ^( c int ret;' _1 y" q4 z/ c5 J# d' V
#if 0
. H& I3 Y8 J( T1 a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' ~- f2 `& b4 C! ?1 i
if (ret)' B) F# }$ o% h+ g1 V, B! F6 _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ n! O; Z9 |& k( Y
"%d\n", ret);& m9 I n5 V: d F& J+ V
#endif
! y! n% x8 Z8 L7 ` ret = platform_device_register(&da850_evm_tl_leds_device);
- t( f3 Z# t, z9 f if (ret)) b5 \0 E% b5 N, R
pr_warning("Could not register som GPIO expander LEDS");3 b4 _) c6 t# k7 N# g8 j& |
else
5 Q5 _+ c8 z9 H l5 \ printk(KERN_INFO "LED register sucessful!\n");
+ b% ^% d$ o: N H" h) @; M5 W8 p7 S! ~1 L
return ret;
+ l8 m: A) [1 _}$ p4 m3 b' Q9 P" k# ~
6 l; w2 Z$ j9 q8 Hstatic void __exit led_platform_exit(void)
" k& T. m$ ^2 x/ Y9 w( j) G{
, n* C: S2 O @$ |2 S platform_device_unregister(&da850_evm_tl_leds_device);
J. v$ U& x# z0 V2 w& H" J; w* s4 y5 B1 L
printk(KERN_INFO "LED unregister!\n");1 f9 v N& @! o! _$ p
}
; e- l, {; W$ T/ v- h/ y; x. K$ Z: l& W$ B4 _; Z" }
module_init(led_platform_init);& o) j, P7 @7 z
module_exit(led_platform_exit);9 [5 l8 H5 Q+ b, J- n
# @+ ?$ i. J* m4 l* }
MODULE_DESCRIPTION("Led platform driver");
! o. U2 Q' t+ \0 `5 o0 D6 @MODULE_AUTHOR("Tronlong");3 Q' r: c( r+ w' D9 }2 d
MODULE_LICENSE("GPL");5 v6 I8 I7 B- a+ w- g
" K, d5 c; P. F9 k d! |( t |
|