|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( v" F K2 s$ P' O4 U: W3 `# }; E& I#include <linux/init.h>
# R8 E5 F1 l6 S g: C#include <linux/module.h>
5 k7 ]9 s) P9 R( T#include <linux/kernel.h>
6 X/ v2 v3 ]* I3 Q8 X#include <linux/types.h>
9 e0 q! x( m b#include <linux/gpio.h>2 O9 Z0 q& d) B2 P; Y# `0 Q5 h6 L
#include <linux/leds.h>
/ \4 v( [" ~/ l* R#include <linux/platform_device.h>& y! R# p1 t7 S* s
" y0 A. n% T8 F7 z#include <asm/mach-types.h>
) G& b; k, X! _* ?- Q#include <asm/mach/arch.h>
% V3 B9 j3 S, } @1 f2 V. X#include <mach/da8xx.h>
& S) }0 Z4 U9 y#include <mach/mux.h>
5 X2 f5 Z7 N# ~3 ~6 x. c. N6 q1 P6 D2 |" n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" _6 n3 b" Y+ S ^' r#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( `$ V' Q2 ^+ U8 n0 ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& r$ a- D9 h0 N0 p/ Y( a4 w$ F
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 X' c9 E7 V5 a; P
3 b& k% ]: z# ?: S
/* assign the tl som board LED-GPIOs*/: j2 E$ \0 P4 y# ]8 i. U% V2 R
static const short da850_evm_tl_user_led_pins[] = {( G2 z& p0 S4 c. B: {" p/ v
/* These pins are definition at <mach/mux.h> file */+ Z0 v% Z' m4 e8 Y7 }5 X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; O/ `$ f, `" ^" T' | -1$ H4 j. V! t5 q1 [# U
};
* X$ h! P$ G9 _: Q) d6 n
/ r ?: R* I7 ]; H; g8 Vstatic struct gpio_led da850_evm_tl_leds[] = {3 l1 s5 l& g# I$ a$ [' T8 f7 B
{* b8 c7 ^* S. @! u4 C7 @( ^) |
.active_low = 0,2 W. n7 k+ ~9 R' W& S
.gpio = DA850_USER_LED0," w, P$ t1 B" ]- N8 o: l
.name = "user_led0",
6 a9 n' Y: \: b( K' w .default_trigger = "default-on",* \! e- A4 h2 D% _6 I" } O) Y
},, m* c! J/ E {! w! `' C
{
3 H4 t7 v$ }: E0 w4 o& d0 z$ d .active_low = 0,' U) D9 _0 |0 W
.gpio = DA850_USER_LED1,! N3 _' G, X1 Z
.name = "user_led1"," X. [! f9 L0 g' w8 J; Y2 w
.default_trigger = "default-on",
5 L) a, S: j& T },( E) D% b$ w2 F) q+ ~
{- [# P% \+ e0 P- |1 ~) K/ y
.active_low = 0,* k. R( r; y% U4 s
.gpio = DA850_USER_LED2,2 ~1 p* V, s& [
.name = "user_led2",
& A) L6 V, p5 U8 R8 g .default_trigger = "default-on",; K/ _: Q* D; C
},! y" N. I0 l6 J" H
{
; _5 z) |8 B5 T6 R .active_low = 0,- z+ F) p4 I3 j
.gpio = DA850_USER_LED3,
- S" i6 I j( U+ O1 X' k% g) | .name = "user_led3",. Y4 t! n7 Z& A9 }4 {. O
.default_trigger = "default-on",
/ [7 t7 [# l5 H% n }," c( G# H* s% A
};
( \7 M y# e8 g3 _* l& l4 t
1 a2 w0 z4 r4 U5 X8 Q6 Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 h9 b- C( q D* M; x) H
.leds = da850_evm_tl_leds,8 i& R% A( a+ b# t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- y/ v9 H7 G8 m0 p% d( I; a
};
! K) X3 `5 s/ J2 r' f5 \
1 H% H* G( z6 A+ E. Fstatic void led_dev_release(struct device *dev)3 x$ ^4 N$ k- ?) W* g& r K
{
5 ]: X$ F4 a* U0 ]& `7 C/ ]};
% ]+ F$ v G7 ^& L% |, x- i7 v6 B% Q4 x! r2 r
static struct platform_device da850_evm_tl_leds_device = {
+ [, N6 B! E0 L }0 t; b8 { .name = "leds-gpio",
6 h j$ |% D4 T/ x- w% u+ y .id = 1,. s! n& L# d5 c6 c$ A
.dev = {6 |: z( a" x, q5 j. h0 V1 J
.platform_data = &da850_evm_tl_leds_pdata,, y$ @; \% C! f9 @
.release = led_dev_release,, ~" {3 D. k5 x, h5 l. f4 Q" b
}
: n& O/ i! R* B% } _4 g};7 \' [* d( \- ]1 ^5 v/ n9 ~/ l
, h2 b: a0 R/ F# m! Tstatic int __init led_platform_init(void)
/ k3 O8 ^6 L( `* o1 _% ^: G# x{, e( }/ _* i! ^& \2 C
int ret;
7 j, Q# @" r, x+ e, p1 D, d, e: H#if 02 P3 K$ J% ]6 ^; q, e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: L* i5 ?% h' B4 {3 K/ v8 ~9 T if (ret)! J: e# e9 j$ C) f- T6 [
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ Z" ~! V6 z8 K" O6 r% m "%d\n", ret);
9 q" q# \. Y$ \7 S k0 l#endif- J. T1 t) Z( y
ret = platform_device_register(&da850_evm_tl_leds_device);: g) a1 {( E5 a' d% s; j/ \
if (ret)
9 I) c; _9 W+ f/ h& ^+ }& |2 i pr_warning("Could not register som GPIO expander LEDS");6 o4 u. _" j: A2 k/ |
else
, w2 K" `) R0 |; u. [7 ~ printk(KERN_INFO "LED register sucessful!\n");
% X: j( x6 I+ w5 N) f6 ]
1 a# p& g) j) D& _' f4 g, w return ret;5 v2 a p) w' n0 k7 Q6 z) ]" f
}
! W4 V3 Z. H2 g* L [
& i! g7 i; S9 V" y, Nstatic void __exit led_platform_exit(void)
1 H6 r$ v8 n" D9 I# W{4 }# h( ~4 A' L) p, i& H) K
platform_device_unregister(&da850_evm_tl_leds_device); H6 J1 k0 G6 _
! d5 W1 N# ]) i; X# k# r0 m printk(KERN_INFO "LED unregister!\n");. F( H- R: k8 \# i; X1 ^
}
: M0 A6 |- r! |8 n1 i
$ Y9 y- @' d1 d Z! g8 ~4 i: Omodule_init(led_platform_init);2 f2 J( k' V4 K; Z3 ^
module_exit(led_platform_exit);0 W3 S! ?9 ~, _! ~/ I' E* o7 E
3 o$ A% A8 f# zMODULE_DESCRIPTION("Led platform driver");
$ N n6 {# N6 v( IMODULE_AUTHOR("Tronlong");
4 O {% P V1 K0 s) n# lMODULE_LICENSE("GPL");
\8 l4 Q+ x6 q* R4 `- }1 R3 C( a3 I' d+ E0 k! H% P) K
|
|