|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 n8 e. Q, m# y2 J#include <linux/init.h>0 t8 o$ g! A0 G1 k5 b# C3 E. g9 N9 {6 w
#include <linux/module.h>
- d( O. m/ b. |% T$ y; l( O#include <linux/kernel.h>
' S5 K3 a8 |- V% X& `0 [' Q' d#include <linux/types.h>
$ p- R. Q: F/ C1 a: k' q#include <linux/gpio.h>2 u. a3 t) V1 @" c* R" I
#include <linux/leds.h>: Y3 c) D: {3 w' j$ [, S
#include <linux/platform_device.h>
! v; h" ?) _1 o* T- [8 h' G: z
1 ~9 a& ?3 i# @ L o6 r#include <asm/mach-types.h>: j: J* ?( @1 a) J# p; Y1 N. r
#include <asm/mach/arch.h>4 g( j$ M: K" H
#include <mach/da8xx.h>1 f0 [ B- t0 _9 p: {
#include <mach/mux.h>2 |/ O8 l6 r, R" b9 Z
% y0 |. g/ j8 ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): \: x& h1 E3 X( s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ M6 l$ i; Z6 {% B' ` E0 y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 `( v. J1 I& H% G, s1 E9 v5 a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' E. {( M( w5 |# t! {
/ A3 U o& j" R2 r6 C$ w/* assign the tl som board LED-GPIOs*/3 Z) Y* u+ r9 L) t" a
static const short da850_evm_tl_user_led_pins[] = {
% E5 s: I6 L% k, \4 x3 t# L4 T /* These pins are definition at <mach/mux.h> file */- G0 E* m8 [' g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 Y! {$ T5 @2 G2 K3 [0 _
-1
e) W0 ^4 s. S- A};
+ C9 y# O( |# g3 o. f( O
* g4 [- w. z; G; k6 _static struct gpio_led da850_evm_tl_leds[] = {
/ u$ G u/ r! ]2 [ {3 @, q6 ^7 q1 f
.active_low = 0,( _1 I/ v9 N* V$ d, n0 J# T
.gpio = DA850_USER_LED0,
( V p; V3 B2 z2 x. K W .name = "user_led0",
! G, \: k. a; H8 i0 d$ [3 I+ a( E1 a .default_trigger = "default-on",
/ v) Z4 h) H! D Q },
9 Q6 q) J4 W P. A) @# X0 E {
5 \# t U1 E0 o8 d .active_low = 0,; A$ J' V8 ^, X1 m. O1 Y1 i1 H
.gpio = DA850_USER_LED1,# _+ F# k( | {, c: Q. Y$ `( T
.name = "user_led1",
, D& H7 e- Y& A! a! J# [ .default_trigger = "default-on",$ j; H$ O/ S) w- A8 f$ a s
},
& s" l9 M% a$ ^ g$ n6 V5 U5 s {
* Z6 e/ ^$ ^0 ?' h( f" D0 c1 h9 d .active_low = 0,6 l' Z, n2 n5 b8 |/ T: W" _/ R
.gpio = DA850_USER_LED2,* G6 O; J' v X0 U5 o
.name = "user_led2",
, s m$ C @. F( u .default_trigger = "default-on",
3 ]8 p+ F. a& u3 x% q },$ @& o0 Y2 E) f8 |' I8 \8 u5 h4 O
{0 y, {+ L2 [! u6 I6 E2 R
.active_low = 0,7 a( z5 k- M; B: J6 ~. U
.gpio = DA850_USER_LED3,
& w9 D6 J, C! f .name = "user_led3",# D; u& F1 v7 c. J! Z
.default_trigger = "default-on",9 r5 S- R4 @+ V- o, t5 c
},
- `9 ^+ C; `" r# ~};' {; f6 j F" P; N" g. s
! l# y; p/ w1 @6 b$ G) Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' @! p4 a5 c' Y+ y .leds = da850_evm_tl_leds,
/ K" L' i/ Z; S) e .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. `8 P7 g7 R! U7 T" O};) N" B. l: p" G' z. h
5 ], f0 t1 x6 C2 G
static void led_dev_release(struct device *dev)( k0 Z8 m( W' M: Q0 c# `
{
+ V9 U: w0 m @! O9 R- f};3 d" b) U2 M) P* |5 s. {/ R* E" G
6 W& K5 Q0 C) S! s% b# }static struct platform_device da850_evm_tl_leds_device = {- ]: j& z+ g8 T' S2 ]/ Z
.name = "leds-gpio",4 T( [# E, g- [& K' [% p2 t
.id = 1,
: g2 A0 B- G# K% C8 s3 X .dev = {
6 ~/ @& n1 C( m5 P O( h .platform_data = &da850_evm_tl_leds_pdata,: S& u1 d3 ?) |* I6 ]$ k( b
.release = led_dev_release,6 r0 I& {4 r7 i l/ A
}
e, j \; `/ P; |8 [9 z# g};- w+ |1 S5 n. T( |: n/ a; g
& x. Q# J/ W$ C
static int __init led_platform_init(void); L5 B8 z8 `9 G# p
{+ }8 Y& T3 h7 r) d7 j$ u
int ret;- q" j) g* L- L) a- B9 b( c
#if 0
0 v$ y- ~* K4 V9 S; Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( H# T0 O( W" z/ E- D
if (ret)
, p3 e/ l# `( L+ y! Y: O& ~ pr_warning("da850_evm_tl_leds_init : User LED mux failed :" k( V8 f7 R( P' M
"%d\n", ret);
, E) R' M( A2 T$ N4 k8 G#endif
4 y8 U+ ~2 t: [0 [* e: h. o ret = platform_device_register(&da850_evm_tl_leds_device);" A- X+ c% x! ~9 v
if (ret)
1 O4 s! i" U2 d. {* I& { pr_warning("Could not register som GPIO expander LEDS");1 y3 {. b' P0 V
else* a7 {5 m! b7 S7 r0 I& n A3 g
printk(KERN_INFO "LED register sucessful!\n");0 w- G: s% l6 @
" J/ }) o* _' B return ret;
' D5 b% I! w2 e& U; i}1 z2 v y, q' J' U" S$ [
. T$ x! `% a y4 ^* m- @
static void __exit led_platform_exit(void)
% S8 k8 ], b7 ]. ]" H{% e& G/ f8 q) h* T' _
platform_device_unregister(&da850_evm_tl_leds_device);3 l$ x8 G$ H3 i4 S O' T
$ h7 M2 P. F: M$ }* [: q( w printk(KERN_INFO "LED unregister!\n");% b' X; b- G9 ^3 [+ ?" |
}! X8 F: `- p* _' c C
0 U0 j" B. S# Z! `module_init(led_platform_init);: A- Q6 k7 Z& Z, i* [; k- F s
module_exit(led_platform_exit);0 g. Z3 ?: Y/ B5 \+ e" C$ P+ A
3 B" J3 ~; U7 W+ ?3 A" S4 v9 I+ K7 s
MODULE_DESCRIPTION("Led platform driver");4 j3 a+ }1 ~+ K! R! E ?+ Z
MODULE_AUTHOR("Tronlong");0 a" ^4 F9 S$ `4 u: u* {- f3 {
MODULE_LICENSE("GPL");
7 z; b: C: q$ R: ?. A/ \) p
7 Y! x( L5 y2 f2 K/ B2 I0 G2 O |
|