|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" s- y- x/ K1 t& V( N$ {# |$ b#include <linux/init.h>
( j$ L) q$ L+ w#include <linux/module.h>
' q9 w) g6 _% F. ?" D#include <linux/kernel.h>1 H y; A1 s' a6 m
#include <linux/types.h>' W8 e5 Q/ ]7 j8 J `9 Q
#include <linux/gpio.h>
+ a2 A; O& a# _#include <linux/leds.h>) E8 Y E5 v: l) e) k* [
#include <linux/platform_device.h>
2 p4 {/ [9 [% n: N. p
4 f! X! ^9 m% I/ m+ w! J#include <asm/mach-types.h>/ R2 ~. ^# R. W j! M
#include <asm/mach/arch.h>
$ Z$ ~ p9 G! R#include <mach/da8xx.h>
r( O1 y( a9 D#include <mach/mux.h>% Y% {/ Y) w4 r$ x
3 [% T$ ~5 B, X1 x% [ }#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( _7 Z0 t. r4 I) V+ _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 V3 m2 {- [( o" }' X; C) H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! C) U3 t. y/ A% g' B* Y) w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 A% `5 Q, {# e6 K
# {4 s: J! A# Q9 C4 d- }/* assign the tl som board LED-GPIOs*/" x+ Y2 b3 p3 Z, @
static const short da850_evm_tl_user_led_pins[] = {) W3 n0 i1 a" t+ A$ P$ ` Q
/* These pins are definition at <mach/mux.h> file */' n# c7 ?- S3 k# ^9 M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 d" p' J& r1 Y, }/ }
-1
# Q1 z( s" G1 i, w/ D% P1 ?};
) D5 V' o/ }; R0 H+ z8 R( A8 b, S) Q
static struct gpio_led da850_evm_tl_leds[] = { I7 @5 w3 J% q0 V) {+ ?
{
* i& Y' v1 R+ K! i; l6 R .active_low = 0,
8 i/ ` S4 I! w6 p .gpio = DA850_USER_LED0,! S* r7 ?) g* R0 j! b. S
.name = "user_led0",* W% r% u) u: ?8 A" E
.default_trigger = "default-on",
0 X4 @9 Q% a, v/ o4 x- o },
9 j7 b+ U) i+ C& O* q9 k {
2 @7 B+ m: ?9 s1 j' H* Z) | v3 G2 B .active_low = 0,* Z1 M. q" B4 W n* Q% x; ~4 n
.gpio = DA850_USER_LED1,
- ^( Q3 j' d( \$ G .name = "user_led1",# `8 o# ~# |" ~% y2 Z& `6 X
.default_trigger = "default-on",
! P1 X$ a: \# ]1 P },+ c8 @* L! C% K) o Q1 w- y5 @
{
N+ N5 g3 \8 s7 S c) Y' M7 T .active_low = 0,
( H; r* f5 \3 V8 H% o( A" c7 W .gpio = DA850_USER_LED2,
) i! {. h2 W, q" f( c. p" ]3 t .name = "user_led2",0 A2 \" y4 F. I# \+ v& N M) P- O
.default_trigger = "default-on",
5 M6 Y+ e; l# M% _; `& i; U' @3 G },3 s8 ]- c6 l$ z7 o# h8 I
{
8 X- w5 b/ ~0 @) h2 w- h9 F .active_low = 0,
' F- h: U& M3 a3 b .gpio = DA850_USER_LED3,
$ |, ?# M, J+ O .name = "user_led3",/ o( ]4 v9 p$ u* }
.default_trigger = "default-on",
$ o% K7 G! U. d! y0 l) n },! P: m: c# O6 r+ ~1 H# u- |
};4 o2 J# Q1 I, b5 T$ _4 W
1 T8 N) k7 F+ ~: x$ Z ? B. N7 D. C
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 M( ?, {$ Z4 {) p6 ~. V
.leds = da850_evm_tl_leds,; c1 [( m* }7 ^( O6 @8 f% M4 R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, @, g; | g2 W8 C9 D/ s* L G};4 b, N- x$ `. H) g. `7 F
/ ], V+ A" D2 u* ^6 x
static void led_dev_release(struct device *dev)
; A" b) n1 N. P! i) T' q! p, U{
$ c8 P3 Y( z# n# F0 {1 L};& V. |. @5 N0 ` M2 y
3 g3 J9 K8 y% ~4 ^) |, u9 H$ k
static struct platform_device da850_evm_tl_leds_device = {" h' h+ K: B2 b6 e" Q+ x- I
.name = "leds-gpio",
# s6 A, _( n8 `( v2 `9 l4 ? .id = 1,
& a: K. k" G- W; L9 }" b) r .dev = {/ R; _5 Y8 R0 |. s
.platform_data = &da850_evm_tl_leds_pdata,
. Y' y& F1 ], y3 Y2 I .release = led_dev_release,
5 V1 r( B6 B) c5 Z' [- B+ r }, b8 J m% R r3 X! {* k* a
};
1 ^* z- p8 B! U' Z4 E, v8 x
; H$ t' h" F3 y( h0 I: o( J- Tstatic int __init led_platform_init(void)
; M# c/ N7 D( n' U{; J" X" V( u/ ]; u' {2 x
int ret;/ |+ H# d5 G8 A' \( i
#if 0
9 y- f1 ~4 U. a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 V' T/ O% a5 R2 [5 F. b( b. R if (ret)/ O! W) _5 Z x- a; Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 x. k; B; h' j2 B% w3 P& @/ r; l
"%d\n", ret);
1 N$ ^9 ]# E" r1 K. T' r0 M8 V7 A#endif
: q" O ~% k4 o ret = platform_device_register(&da850_evm_tl_leds_device);
3 q4 f/ @ \3 Q9 f/ b if (ret)
% W% u, R3 W0 k9 i# p4 [. t7 K pr_warning("Could not register som GPIO expander LEDS");1 X4 ?2 h/ V$ ^# d J; [
else
8 n( F9 ~7 u' F5 M printk(KERN_INFO "LED register sucessful!\n");
, l. F* H9 B8 P4 q
' v9 a/ }5 t: B; h: Y% X) S return ret;7 k8 I$ @- e7 G4 f* u( P
}( n9 E! _8 ]: {5 H
3 C# o( `) D. P; i
static void __exit led_platform_exit(void)
% i) c" e2 _+ m: k' J! D. x{2 b5 m" z: {! _+ E2 }
platform_device_unregister(&da850_evm_tl_leds_device);
4 d( d9 r! D, X8 R0 H# h M9 v1 |/ a( x9 E1 r3 k
printk(KERN_INFO "LED unregister!\n");
( H0 S2 s$ @7 d. E' I' f}
; z( ]4 Y9 u1 P1 y9 d# Y9 \+ Q
! f# l; ~& w: {$ pmodule_init(led_platform_init);
/ e; F7 S: {# `module_exit(led_platform_exit);
; p' e( e& _& G% F
1 o1 t* @% a+ k5 W" `0 MMODULE_DESCRIPTION("Led platform driver");
/ k+ t: T5 H4 NMODULE_AUTHOR("Tronlong");
& _% Y) x7 f/ S: |% P$ o( BMODULE_LICENSE("GPL");
5 f% z' ` T% Y1 n% r! c% ^- G
" b4 L2 ?5 c$ f# v( F |
|