|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( j* _1 P0 g. ~" s1 E9 w#include <linux/init.h>2 P D" S- H# p* W% f+ L0 N3 [( ^
#include <linux/module.h>, z8 I0 s# N7 o0 @
#include <linux/kernel.h>
# P3 i9 D0 e. B6 @4 a" P+ m#include <linux/types.h>
1 u* ]$ W6 j* ~# x$ X2 `#include <linux/gpio.h>6 t. y* q6 G6 ~6 H# D
#include <linux/leds.h>
, @+ u$ ^5 g9 A#include <linux/platform_device.h>
( T' J) T) `8 b8 I+ m9 [1 ?/ v* R* J8 |5 J. i9 x
#include <asm/mach-types.h>
* B* [/ Y0 P! v) R#include <asm/mach/arch.h>
0 v+ ~: P' ?4 E) B: ?& {#include <mach/da8xx.h>
, R3 V7 D8 ]+ A6 r2 j4 G#include <mach/mux.h>: I/ v4 C W" c. A/ i3 q
. d4 h N) ?/ K. n; `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 J. x* s+ R9 m" G
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ j8 e2 z: i8 p8 M7 H8 h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 w/ N( A/ _ f3 y4 l" O/ n* \: b#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 j" ]% ~7 H& N9 T7 d, k! U+ A0 A. G/ o j
' V8 j( Y* D: r$ c
/* assign the tl som board LED-GPIOs*/
M$ r) @/ Y# k" g2 ?/ v+ pstatic const short da850_evm_tl_user_led_pins[] = {, u3 v6 d7 I: o8 D5 c& D) k
/* These pins are definition at <mach/mux.h> file */: [/ w% _- x8 S$ p
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 G1 i9 u- _6 M -1
; l6 d% j7 v3 E' Q' R! n5 q};
/ l! X7 P9 M n, M7 X; W% s2 H/ H) m: j" w
static struct gpio_led da850_evm_tl_leds[] = {
) F3 g9 B5 a) }8 ]& q {6 v( C7 r3 f# }' r! I* u
.active_low = 0,
1 X8 x5 C6 U/ C7 G, m* i5 c6 b .gpio = DA850_USER_LED0,
) B! ]9 }: `% ~3 E4 ~) [- f; g .name = "user_led0",
4 m D9 F' P" W7 T8 g .default_trigger = "default-on",
~: P& c; F* d. Q, Z. {% e# v- u },
- N/ m% x' ?" v, _+ e" I9 h {$ _3 n3 j* \! B3 j- [: S$ V7 G, E# V
.active_low = 0,7 @2 V' N* S) P
.gpio = DA850_USER_LED1,
6 N- }, {6 ]% c# _/ o9 \; ` .name = "user_led1",
7 W- b0 M7 W- `5 X5 z3 l, V6 J .default_trigger = "default-on",
" H, f9 H. V O/ l' N0 ? },# x) Y. Y# U& ?
{
* O4 y( q! |7 U" R% p .active_low = 0,
4 b" V% ~8 ~4 N .gpio = DA850_USER_LED2,
: l% o! c2 `# X# c3 u# P6 e .name = "user_led2",
/ }; A) y( H. D) k' [) T0 v; G+ d .default_trigger = "default-on",
3 d4 P) O; z- ], `* ]2 C. c7 M+ F: Y },+ X# i/ \% v+ Q
{
4 p+ k! E" |# R" m" J! z .active_low = 0,
" P* v/ z5 b, J" e7 @# h .gpio = DA850_USER_LED3,) ^7 C8 A0 S# }# C3 t
.name = "user_led3",
2 o; ~' `# ^" V .default_trigger = "default-on",9 c2 B& E% @- ?
},0 Y$ Y4 D+ u7 ~4 ?8 i
};
) g# O7 `0 Z4 o& {# Z0 t' }: ~7 p2 q/ v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { |' z$ t6 A1 J1 N: q
.leds = da850_evm_tl_leds,
; J F. a4 n5 W9 H9 s! v& T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! P8 y/ [! N6 S3 e};1 ], G" n/ J: G2 W
# E0 p) v1 Q, Y P% Ystatic void led_dev_release(struct device *dev)& I$ \, U# J% L
{
2 z; u& J( n( t};, X: {! c0 t+ y) [
% \0 `2 v6 r9 J4 _9 Z/ v
static struct platform_device da850_evm_tl_leds_device = {
" [/ z* w& Y0 ]) y .name = "leds-gpio",9 S5 j3 x7 ~( p4 O5 Q* X
.id = 1,# D: I7 z9 }% t, ^2 f
.dev = {, f3 o3 A8 B& b/ [$ e4 k4 ?
.platform_data = &da850_evm_tl_leds_pdata," t+ n3 @) q5 \
.release = led_dev_release,
- Y# w7 e$ W, D7 V# w1 g% q }: O* C) e& D& c1 Y3 \
};6 e& a$ [% W; U+ ?4 b- R# I" `5 u1 f
# ]; d4 Y: M. e& Sstatic int __init led_platform_init(void)' ?# J0 X/ I p1 z* d" e* U) j
{/ E; V% Y. v3 F1 W
int ret;/ b5 m) [1 P( |$ r m {
#if 07 e, }2 m) K8 L5 r* q/ a: }$ s: y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! {# [3 H9 ?* _* h u, d if (ret)
* ]# D& t7 O' L5 f pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 y# z2 y' w9 S+ a7 y! ?8 ~ "%d\n", ret);( _: D* }9 G" A7 }
#endif
- J2 f7 X6 x" f0 `5 o) V7 W6 S ret = platform_device_register(&da850_evm_tl_leds_device);
$ o6 q0 f$ z( M5 Z if (ret)
$ ^1 `3 v; U/ P3 Z pr_warning("Could not register som GPIO expander LEDS");" ]6 v- C( n$ n+ p
else
3 p7 M) d& d, O/ ] printk(KERN_INFO "LED register sucessful!\n");
$ c! Y5 t" P# f- m
2 G4 W! R: e6 B% J7 [7 R0 l ? return ret;
( E; M3 m/ E7 W/ f8 w) t! I5 E) e$ |/ q}
& a5 b4 R- S: K1 ~0 r; A! }+ `
5 N6 E. I, v( v9 s9 Istatic void __exit led_platform_exit(void)8 y' i- A5 x0 I5 H' D
{
1 O; `2 J' D1 h' P5 Y- ]# U platform_device_unregister(&da850_evm_tl_leds_device);
( l' @/ ]% Y7 N9 S8 x$ n
* M C# F- O8 Q4 ?3 B. @$ A: q, S printk(KERN_INFO "LED unregister!\n");; S. Y: p r7 i/ N2 W7 Y1 X' R
}" O9 B. w8 J+ n2 L* l, p. D/ B
. p& Q) u9 X4 C; a" x1 Jmodule_init(led_platform_init);
9 H4 b* o' j+ @5 K( ^& bmodule_exit(led_platform_exit);5 l) ^4 p& j B# F9 n5 l
+ f5 g" o+ I0 d6 C+ r# x$ v5 v
MODULE_DESCRIPTION("Led platform driver");/ P$ y2 d. F0 D& I* F5 D
MODULE_AUTHOR("Tronlong");" `) z% v, X- Q
MODULE_LICENSE("GPL");- y, l* E( S+ Y; g7 o
3 ~& x! ^! k9 A3 d& G |
|