|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% v# L K# e2 C( C* q" A
#include <linux/init.h>+ M7 k {; N1 D) _9 y/ T' g) D. p
#include <linux/module.h>
" M2 M& n. b3 u: Q2 r3 j) C; e#include <linux/kernel.h>$ ~) M9 w* e6 P: F4 ?* W7 r
#include <linux/types.h>
0 p" {: B7 x' y2 C2 u2 r, e#include <linux/gpio.h>
6 j9 \7 w+ A/ N2 S: U8 ^. j' K#include <linux/leds.h>4 Q9 N2 m+ t& l' b* }
#include <linux/platform_device.h>0 u9 L! n4 k: B: r% {3 w% H
9 S) h! Z1 [% \: }( A#include <asm/mach-types.h> O. J( g ]8 B1 l
#include <asm/mach/arch.h>: q \0 ~& {/ u+ V! s
#include <mach/da8xx.h>2 H( H- K) [! `/ a8 [" F1 m7 | R
#include <mach/mux.h>
; i& u% W3 T( E
9 [7 s' W) ?$ F/ p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 D/ h+ K- V$ v# _7 P- }
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): @3 a" W( D+ d9 y' v ]+ X( ]) I8 h- N
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ \) ]3 g2 N w6 B0 G: J& i( z' t' O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# \0 j0 A- r+ L9 P0 u
/ [6 u0 s* _( u2 {/* assign the tl som board LED-GPIOs*/
0 S- o$ A* l9 J1 U8 t% n+ estatic const short da850_evm_tl_user_led_pins[] = {& l2 X0 j7 m1 z! v( \8 o0 v
/* These pins are definition at <mach/mux.h> file */
( Q2 W+ O7 t2 A! p. _ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 F" Q; y# z3 @9 c; f5 \+ y- G -1
: C- v+ p$ Y7 b I% k};
7 z& R3 m4 |1 Z9 d Y! z* J( [" c% L, x
- N( n! D. ]2 {5 Sstatic struct gpio_led da850_evm_tl_leds[] = {
3 U4 K+ O7 b, [# L) J4 p5 G) w {/ l& @) H7 d2 M* K/ h3 j J
.active_low = 0,
# B' W4 U7 A6 m .gpio = DA850_USER_LED0,
$ p4 }4 N& X8 p& f .name = "user_led0",
; b( \; d# Q6 | .default_trigger = "default-on",
/ F. i5 o0 a/ E, I& o# T },
( m) Q' P% g* _ {% R. t5 s# T& ^: ~+ d; D- E. W- }
.active_low = 0,
$ |8 t6 H% _6 l .gpio = DA850_USER_LED1,, K# n/ E- D8 _
.name = "user_led1",) n6 x' E7 ]. G- s3 [% m
.default_trigger = "default-on",# K7 k% H7 R1 w( j1 E6 w
},
h' R1 \/ w7 `" [! Q* u: I {
: g. w W+ V% ^ ] .active_low = 0,
" G$ V! I! T( S7 d7 R6 }2 e5 U" ]# ] .gpio = DA850_USER_LED2,( X' c- r' T8 t+ Q* \$ k* \
.name = "user_led2",
0 Z' C: e* W* r- K/ Z3 t3 [ .default_trigger = "default-on",
9 @" K: d0 Y; B! v7 P },
4 H' O. d+ k+ u: Z: ~4 b! @: K {
2 r) j* F5 ]- x3 h .active_low = 0,
7 a. _5 W( z- L8 \. h! ~& Q .gpio = DA850_USER_LED3,( G$ A7 P7 h' y
.name = "user_led3",2 V% y5 }0 L" `" o
.default_trigger = "default-on"," S+ w! `# W) e/ Z: J
},
3 d: S; [" d$ x% D U};4 q9 t5 t; H& n
- p3 [( U: V4 Y5 P* C1 ^, X$ Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' i- G& h% a5 r5 {
.leds = da850_evm_tl_leds,5 w. W2 `1 ~! E+ k; W
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 z2 p/ U$ d6 x( R4 G* u; H};
" @! a5 e; |( P; w6 n
: B, j, m: c) q6 `- Qstatic void led_dev_release(struct device *dev)$ ]7 g- Y, q6 K7 S
{" ^7 @& V' F4 @
};% Z3 y8 Q# ?& n/ ~; f8 V2 K+ s
; V( J" l$ v! e6 ^: `& ^
static struct platform_device da850_evm_tl_leds_device = {' K. R* Z. I6 b! \
.name = "leds-gpio",
: W( ?0 E. [" p% }! S .id = 1,: P" B3 V5 X M0 ?6 }6 i
.dev = {
1 p+ a7 y3 s1 A$ F0 z. Q o .platform_data = &da850_evm_tl_leds_pdata,3 k$ z; b3 ?* G* l0 W$ l2 k
.release = led_dev_release,
2 \. d: z; t. \% Q- r- ?1 P1 I& B }
% |3 m* `+ G1 A s# Q: N1 c};
8 B- C: T8 V7 e& ~" S/ S) z; w3 p$ Y' _ \ k) h A- w; S4 }2 m
static int __init led_platform_init(void)
+ n" h3 X* K8 k# e{
5 c. p7 P! F; U# G% G int ret;# I3 G* h- \# P% | G5 L( h
#if 0. r9 ~! d$ i; C- t
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ o) f3 E- S; |- Y8 h if (ret), q4 F# U& w. Q" T
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ e: \. L# z% s3 `
"%d\n", ret);
' A8 ^8 U; h. l( Q. q# }. V( m#endif
K6 v9 A- x9 ?7 Q1 S, c ret = platform_device_register(&da850_evm_tl_leds_device);
4 W2 \5 Z$ p4 y if (ret); Y& U3 w# N7 q( A- Q
pr_warning("Could not register som GPIO expander LEDS");
" ^' J1 B1 @' o* v k3 R else& u" y9 V- U6 @
printk(KERN_INFO "LED register sucessful!\n");9 f' y6 U. e$ I+ f1 F) R9 S
- j+ a' q7 }) T; b- W6 G
return ret;
: h; K* e' u$ Y/ C' c- v$ x4 s}* `: C$ Z& `; V9 ~ M, F8 \
8 ?& A2 P' N2 P: p1 L+ x( Estatic void __exit led_platform_exit(void)
9 ^& S; k( n7 Y# N; `{
3 u' Y- E* h4 l: N: M: O A platform_device_unregister(&da850_evm_tl_leds_device);4 j+ h) }+ Z5 `
. i0 C0 H' b6 [+ x, B; ^
printk(KERN_INFO "LED unregister!\n");* J/ \( o" Z& Q" I' r) t, m7 w
}
2 n, X5 ^4 h' q8 D1 j m6 A# `* P' d7 k
module_init(led_platform_init);
, Q+ Q/ ]8 L/ Amodule_exit(led_platform_exit);' S/ O4 S( j; w$ ?
1 F" t8 A$ g3 P
MODULE_DESCRIPTION("Led platform driver");; @. {5 R( }% e3 ]/ n8 v
MODULE_AUTHOR("Tronlong");
$ X# a; P$ E2 IMODULE_LICENSE("GPL");
2 Q! n2 h1 k( ]# F* n9 q. K
" W: N% U3 Z/ [# Q! J8 I |
|