|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 G" P1 E) X, I' G% s#include <linux/init.h>
. g3 b/ `& @5 e( ^#include <linux/module.h>
- ]1 v( J' P8 A/ A" {3 V- ?( j#include <linux/kernel.h>
1 r1 B; n9 I( O' J$ V5 C% m& j#include <linux/types.h>* i- n+ V. i2 X% r0 l i
#include <linux/gpio.h>5 v4 Q/ a* D q4 k3 Y
#include <linux/leds.h>1 g* @2 Y4 N6 {) A0 n
#include <linux/platform_device.h>' Q$ C* Z, a8 r9 ?# `3 Z E3 c
6 L5 ^- f) u4 @! ^#include <asm/mach-types.h>
f+ d R" {9 t. j$ \/ o#include <asm/mach/arch.h>
% y0 u( k* k$ s7 q6 U; h#include <mach/da8xx.h>" Y l0 _) g( T, m
#include <mach/mux.h>+ y! t/ h$ l- f2 \) R
7 e& U1 |7 ^4 F. ?; A& j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 p3 m+ `( A; d; v+ v* n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 B7 o1 ]0 ^1 g! X#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 [ D j4 m3 ?6 m' I4 } a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. b1 F. K1 H/ J; T; c: E8 m% K$ r! W0 D, M* _; R
/* assign the tl som board LED-GPIOs*/) O( ^0 {0 ^* N9 W
static const short da850_evm_tl_user_led_pins[] = {
9 [) {' y5 n4 o9 E /* These pins are definition at <mach/mux.h> file */' V% W; @5 m6 r$ }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ X; I7 p1 T& m8 S: J
-1* E5 h/ T) P' l8 q8 I1 D. U' y
};# d3 {$ \$ k/ _' f
0 S) p5 N. [4 a8 ^( fstatic struct gpio_led da850_evm_tl_leds[] = {
" }2 y2 V+ u) A {3 T$ @( |6 X, ], l$ v
.active_low = 0,) O% ]! _; Z" Y8 t" K' i
.gpio = DA850_USER_LED0,
; K, ?/ W0 G; U6 A* P .name = "user_led0",/ V$ ^* v" T5 \$ K6 u: y2 y! q5 X
.default_trigger = "default-on",5 A8 f' M# g! {7 _& d& H1 ]
},' S4 H; T5 ?6 P, y; U
{; R+ t8 x5 x1 H& g( D. c& ]! N
.active_low = 0,
# x. @' X! {8 m5 k- N g2 q9 b .gpio = DA850_USER_LED1,
1 X3 C: p9 X2 T' x .name = "user_led1",6 T' [* a8 j. {0 c" h/ z
.default_trigger = "default-on",
* Q0 L# l9 H% K8 a$ \ },
Z. P5 i7 g3 }' C# I {
5 n. j" Y9 x# n .active_low = 0,
. |( q/ h7 }# d) Z: ~, z .gpio = DA850_USER_LED2,
1 t' _/ e8 j' P4 q5 I .name = "user_led2",
/ D: z5 k1 x- N. j .default_trigger = "default-on",
( f# N9 x1 R+ h! h: H7 r$ U7 k },4 a8 X# ^* [1 z. Q/ J; N
{
- _7 K; a3 s5 H, W7 V% J: u .active_low = 0,( b- B) }2 O2 O" x- L- i( I# g
.gpio = DA850_USER_LED3,
6 j, n$ c8 B0 a/ T9 D/ C .name = "user_led3",8 h5 D1 U5 s8 x' y% c" ]0 ?3 V
.default_trigger = "default-on",
6 Q& f, m& h) ~6 x) k },
/ h; Z- c e F) {- K1 }9 G};5 p3 N2 c$ Y4 N1 C5 G
5 B2 Y# `. ]( c+ | @, ~0 _: _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 m* y9 {) ` g- b! R4 @' `; U0 X
.leds = da850_evm_tl_leds,9 `7 \/ M$ c) K! j& d$ {
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! Y8 b7 }0 m* }6 W. A! J7 K, F}; g0 b- z! u) k+ B& f$ f' `
2 D1 B& h* P& z& K" G0 U
static void led_dev_release(struct device *dev)& \8 A+ k$ w) s2 M6 \
{, D" n0 q# ?8 }5 h3 [
};
2 ~' {* X* x" z4 Y6 z0 G q$ D% B4 `; z2 ]
static struct platform_device da850_evm_tl_leds_device = {7 ~$ Q X' H( I* s
.name = "leds-gpio",
, _' ~1 n; u; H8 e7 Z .id = 1,
, |/ v' r% `' C$ A0 l( g% j .dev = {
+ j) S% b0 B* D4 q3 A6 o. w .platform_data = &da850_evm_tl_leds_pdata,
$ @+ N' ~8 G' E- J .release = led_dev_release,
& C: ]- _% b7 ?% ]' G4 O/ b" e }
0 H$ z# b$ v# ^, x$ Z3 l2 E};$ G6 u7 I) r) ~9 _
; k) D3 y+ g% x8 m- A+ a) Astatic int __init led_platform_init(void)
* M( U6 C3 d( V6 }+ _5 ]* E{2 m& R- n- H/ T& l
int ret;
+ a7 x0 W$ |* X$ X#if 02 N/ d. u5 ?& i. Z8 ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); V4 p3 c5 ` D6 M( \& v- b W
if (ret)& j/ K6 M6 O5 R" c4 O
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, d& v$ ?: c& h" V1 A! F' o "%d\n", ret);3 k3 j. M9 v- ]; _
#endif
" m; O1 b s8 k9 u! t. |, U0 ^ ret = platform_device_register(&da850_evm_tl_leds_device);
, Q/ R6 t @ w0 `/ B- f% D0 H r- K0 D if (ret)3 _$ \4 c( C% G5 @6 E2 F% Y
pr_warning("Could not register som GPIO expander LEDS");
7 A; n) P$ H5 d7 K$ ~ else; Y+ V; X$ f- s- C* ? Z9 w
printk(KERN_INFO "LED register sucessful!\n"); m0 d- _4 }5 ~% H! f* [9 C6 S9 g
3 z! @$ F( V' S0 h M
return ret;' r8 \' z3 \4 O8 J8 l, N
}
! J+ `+ {6 h6 L! J' T7 y# z: l7 S) ?- D9 u z$ w3 {) Q# P( B
static void __exit led_platform_exit(void)
' q; C9 I0 k6 [ r$ S- D: E{
* k8 D6 `: ?6 H9 K platform_device_unregister(&da850_evm_tl_leds_device);
7 A8 f. _8 V% E$ V; {( ?# n' o) j/ p" m
printk(KERN_INFO "LED unregister!\n");( }: y: ~$ E+ y
}5 B$ M' o5 P# B4 J. t; D3 v, n
2 g2 v b2 v" k7 Mmodule_init(led_platform_init);
6 j7 j6 f' x6 [, Nmodule_exit(led_platform_exit);
( V! }+ p( D* F! l S! |- E
* A R" z5 T% B' y* J7 ]MODULE_DESCRIPTION("Led platform driver");
a1 W$ r% G" A2 @MODULE_AUTHOR("Tronlong");
0 B1 v" m3 E" PMODULE_LICENSE("GPL");
' D A) C1 h5 b& w; _/ `2 |6 M& [7 ~/ X" `! i ~+ s
|
|