|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 {. j* e1 Y1 U; V" U1 [#include <linux/init.h>
' Z0 n; ?0 l- \#include <linux/module.h>
9 N/ k6 e9 f- c/ Y- ^0 h K. l#include <linux/kernel.h>
# Y1 }$ r0 c, S#include <linux/types.h>% ^$ t6 Q9 ?) `1 Q7 B( n5 x6 r
#include <linux/gpio.h>
2 [, M1 O4 V8 {#include <linux/leds.h>( S6 W3 f, s: L/ Y- J
#include <linux/platform_device.h>' Y& k7 L1 a S9 Z( n- `/ r
; }4 l. U& ]# J5 g6 q# f- b+ t#include <asm/mach-types.h>
4 `/ K9 F: R3 F: X% f#include <asm/mach/arch.h>
9 I. R1 s% g% a+ f2 E$ Q' c#include <mach/da8xx.h>% J6 g& }. R* ?/ {" O$ p
#include <mach/mux.h>- K2 c# V4 R8 [! l5 Q' N0 n2 m3 s
3 Y6 a& O/ }/ C2 b3 z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 v% ?. E$ d' X
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), v5 u; v# y- T- ^: c
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 a0 N7 l- L, w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) ~7 | W% Y7 [1 }9 y0 D7 H& Y2 X2 N. L5 [4 @* D( B% H* e' q
/* assign the tl som board LED-GPIOs*/
o2 M8 I5 `3 g5 @8 L! Lstatic const short da850_evm_tl_user_led_pins[] = {
6 {6 i+ G5 N7 J4 ?; ~% k3 o% g, R /* These pins are definition at <mach/mux.h> file */; ]! I, j- H# c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," q1 L+ S3 [2 H& \
-1
( J+ c% ~# r6 a5 ]};: V a+ P" a7 r$ }) m
8 e' t% J+ h$ h6 k [$ s# g& \static struct gpio_led da850_evm_tl_leds[] = {
) _6 }# e5 x! ~9 \2 X) G {
% G2 v; x; |6 C f; U' I .active_low = 0,
, `) O) I( `5 h8 E* P .gpio = DA850_USER_LED0,5 z- B. W/ n/ G e5 F- i
.name = "user_led0",0 a* ~" q" K3 d- A' L" X" W
.default_trigger = "default-on",
4 b( S- b' a/ ?/ Q1 P7 Q- k! n },
/ s0 {( ~5 D$ w5 O3 I {
% I5 K! A/ f; c2 l) E .active_low = 0,
& G& d/ [2 g) }3 ^ .gpio = DA850_USER_LED1,
9 D, V+ C$ J7 \ .name = "user_led1",
4 _7 E% {* O8 d" o .default_trigger = "default-on",
0 x7 I, {3 i2 E, }6 ~" Z },
% P6 m2 t0 \$ U {+ p' a- ]1 u! x
.active_low = 0,
0 H, ^' y5 Z" q) \ .gpio = DA850_USER_LED2,: B; {! X* W' A' `2 f
.name = "user_led2",
4 M* H+ G2 J, d) P, n" N. h1 \ .default_trigger = "default-on",
' M. b& ]+ s5 `7 k },
5 V$ ]! G( y/ h2 v! `' u {1 \( r2 G/ ^+ m8 r. Y- F
.active_low = 0,* l4 @8 s, t- ~, d; X/ V3 Z" J {
.gpio = DA850_USER_LED3,
' g& o7 M# W8 U, h .name = "user_led3",/ f; p8 v9 h, f6 J% j
.default_trigger = "default-on",
: d, F, B9 |" u" d! B },
! Q! p6 N5 h @9 O; b2 m};
% g+ c5 A4 G( H8 E4 T( u n+ L2 }
) U; i4 h- E9 d* r8 h7 C" ]+ p, A* fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 P o3 M* a+ K$ |9 e& E
.leds = da850_evm_tl_leds,
& ?! }! u: F6 l& ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; h% z' E/ [, N! M' _7 J};8 i3 k& D+ f+ G% ?. ?. D1 w9 m
# h( r# |! x0 d0 o- e+ Gstatic void led_dev_release(struct device *dev)
" y8 A+ q0 P/ ]8 \{( F! S7 G% O$ g4 F3 i- X; b* [
};
1 e# ] M9 F0 e- \9 |
! S9 ]# M) M, R* s; |# Bstatic struct platform_device da850_evm_tl_leds_device = {
2 B, t- {( } j5 x9 c' p# ]4 L .name = "leds-gpio",
. q; I! i6 q! |" C* V& c .id = 1,
( ]) W: Y. m0 q .dev = {/ U- q2 q5 r/ J5 _1 ]+ W/ Q0 a5 x
.platform_data = &da850_evm_tl_leds_pdata,
$ [4 Y' I8 S0 J$ X g! y .release = led_dev_release,* c/ Z4 s5 S+ O S6 L4 R1 H
}( y: h) y# h/ i2 N1 W6 X
};
3 F! E$ s9 |: v1 j0 x: J3 T" B1 B9 f: Y Q( w$ r
static int __init led_platform_init(void)
' O% O- b) S$ I8 c{
4 i; |4 _7 _7 ~- D int ret;+ N) s; q! @' N8 A b
#if 01 f, K: b9 g! O! O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% @3 X3 H8 d }: }3 l3 J" [
if (ret)
0 q. s8 C/ c" ^. j6 S5 c pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 B( n6 v9 o* @( J4 G* `+ c% G* ]
"%d\n", ret);/ K+ Q3 `) @( X' O8 @5 l
#endif( |, q, q4 A" x
ret = platform_device_register(&da850_evm_tl_leds_device);! p" u+ m& p) {
if (ret)
. G+ D+ [5 [) } pr_warning("Could not register som GPIO expander LEDS");
6 p3 E# p7 U% A else6 p2 w& m! |# L( R3 h
printk(KERN_INFO "LED register sucessful!\n");- E5 Q, H( g e) o+ t- S) R
6 O: j9 `( ^8 s2 H% p return ret;
3 s) v8 @8 A# M}
- U5 }$ V( I* h7 v2 c5 \2 N' }: _6 ~3 @* f5 x
static void __exit led_platform_exit(void); \2 V [# g& ]7 D$ l) F* m
{# g; J5 Y! F6 }# F3 J: {
platform_device_unregister(&da850_evm_tl_leds_device);/ m- J+ J* K* J; c3 e- L
2 g! ~8 W: l. L, e$ q4 T6 {
printk(KERN_INFO "LED unregister!\n");
0 h( |: j# ^& W- d}
2 L8 n# J) Z6 F
8 R+ ~" S$ N- {( U9 lmodule_init(led_platform_init);
" F8 ]( M2 A; D* x8 imodule_exit(led_platform_exit);7 k- w2 {8 q9 m; L
# G: i8 f7 w* v1 f; IMODULE_DESCRIPTION("Led platform driver");# r& n( k F# x, b
MODULE_AUTHOR("Tronlong");
) J- o" l% V' c V2 F5 ^MODULE_LICENSE("GPL");
* K+ p! }+ w; o; W) G! U
$ t9 A& y1 P0 {0 o& O! R |
|