|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 C4 `8 ]" f& A, K0 n3 m
#include <linux/init.h>
& |% S" B! {" \) p$ b! h#include <linux/module.h>
" z- B! O- \# w5 O4 V#include <linux/kernel.h>, C V" J; W. s: c. `
#include <linux/types.h>$ k i& x$ v8 i G( Z
#include <linux/gpio.h>
( H+ L" N3 q; f+ y* F# G# c3 L% j#include <linux/leds.h>
0 _4 b- S5 p& v- Q( V#include <linux/platform_device.h>
" S0 x6 _" h2 u3 d- s# T
$ g# w( `, p0 W#include <asm/mach-types.h>
6 b) h3 c/ L1 l#include <asm/mach/arch.h>! I% G4 i, a& \8 ^2 p) n5 H
#include <mach/da8xx.h>, j1 Y* `/ c; r3 I. w
#include <mach/mux.h>4 X6 E: r6 A) M" ?1 z
1 K/ i2 {0 X H; A! k6 j
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! R6 r3 t# w& e$ ~, d: p1 ~
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
o3 g1 l; D4 x( {#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! u- `1 ^" |+ b* o, f% i" m3 W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# w: C7 w. D" j3 g$ o
1 }* \2 `. V. M% y! v
/* assign the tl som board LED-GPIOs*/
x6 W" w& w. fstatic const short da850_evm_tl_user_led_pins[] = {) I& J8 q7 ]6 D) ]
/* These pins are definition at <mach/mux.h> file */0 `! Q# u* C$ Z! n: t
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 J8 K4 z3 [4 p9 K
-1/ ?7 d2 a+ ^ ?2 n1 q2 q
};0 E0 {, ~4 g6 C( Z
0 F5 e# L7 E) t7 ~/ |5 y6 x; E' s# o: Mstatic struct gpio_led da850_evm_tl_leds[] = {
" W$ _; H0 W1 Q& J0 A) U! G {& i2 P8 p, u/ k2 ~; }* r I
.active_low = 0,& L; @2 H2 C. v" E' p3 R
.gpio = DA850_USER_LED0,
7 X/ e+ y* O; G .name = "user_led0",
0 P4 t* |) N- I' V, @8 c( ] .default_trigger = "default-on",
l3 B$ H' ?& N% Z. |. l },
' N# V; ~' U0 @. r0 K% c- ] {1 C/ k2 l" {7 \: M
.active_low = 0," ? Q4 z2 C: G% i
.gpio = DA850_USER_LED1,
K$ c! j& `/ o, M, ?7 U. D" p9 o .name = "user_led1",
% `' Q/ d' B. |, q5 } .default_trigger = "default-on",2 a+ j$ C* F( G4 W+ [
},1 O) S8 ]6 s3 H$ g, I* l/ M6 Y( w, ]' k
{* [5 A" H: h' V' Z) p) X& d2 r2 v+ f
.active_low = 0,
$ d% W3 K$ g% o- N" T( v .gpio = DA850_USER_LED2,
3 N( I7 e. C& F# \2 f2 r" m3 y9 Z .name = "user_led2",' z7 P7 r O- A9 w0 W
.default_trigger = "default-on",8 C; c+ T$ q; w. `
},
' W& E& b! x1 K. b% ?6 r D {
0 q- j. p* U( M& E, {4 b( u .active_low = 0,- Y e! n$ K1 c, P. \
.gpio = DA850_USER_LED3,
. X/ ~/ r& E; p$ A! {! S .name = "user_led3"," l0 [* \ ^9 J
.default_trigger = "default-on",% V$ _! n( a# C. C" G
},
) z K& t% ~+ q1 I4 n};5 M* X# w$ d( P0 l9 K5 n" h* [) C
& h4 m4 f) L) Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 M) i4 B+ f' L .leds = da850_evm_tl_leds,
J" T# y/ \ f# s .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: W! Y# w5 W8 t0 N5 J) J: \3 z};" ]5 Q \5 R, N6 K
1 x% \+ Y* X, C5 @$ Z
static void led_dev_release(struct device *dev)7 V! H! q K/ |: ~8 P' [5 L
{$ D: M5 I, f3 s9 m
};5 R1 z' W( Q, i
# `* H7 t: H3 X9 @& M$ X
static struct platform_device da850_evm_tl_leds_device = {
% z7 e c' e5 _ .name = "leds-gpio",
% H. I4 D: ^$ @/ i; j1 D .id = 1,0 Y. B; X$ E" E$ c1 K5 i. {$ n- _* s
.dev = {- B8 |" c8 |# z3 k) C: g
.platform_data = &da850_evm_tl_leds_pdata,. p0 P% {3 B7 U- b. u/ x! @
.release = led_dev_release,( |( L( g" R3 L- P& N, S; X, E
}
, a0 q+ J; r$ A+ D};
' {) y. T- z+ M# A" z6 K1 f9 m' a7 V" e1 q. @5 ?
static int __init led_platform_init(void)3 D% V8 `& ]- L( B* C8 f
{0 ~& M9 s6 v% {& S
int ret;3 s/ A+ u6 M8 r
#if 0
; ~0 i! A, e# J* I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ h( z; u2 N9 Y5 K, w* J/ e& w
if (ret)& K1 U( l, ?5 ]! k% Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 _$ n, X0 s2 V6 k; O$ w1 e( p
"%d\n", ret);
* r4 X( _1 p% b8 l% j4 r0 d#endif
( \6 f' S. ?8 N. h( E' w- B( M ret = platform_device_register(&da850_evm_tl_leds_device);
, _, F" v% l- t3 Y, J' j if (ret)* o. W" k+ p' ~
pr_warning("Could not register som GPIO expander LEDS");
4 [; i: D6 T4 m else' F% A5 ]# t! {- y
printk(KERN_INFO "LED register sucessful!\n");
- H# F u4 b, l. F) v
2 ?8 s; h# I& c' g" I h) h* G return ret;: d4 N c( d% U; K! l9 R* f3 v) ~
}
+ |' [1 i8 D) F7 A# @% R5 M$ t) n1 R
3 l/ ]7 h+ n, E2 A! j# |: m' Mstatic void __exit led_platform_exit(void)6 N1 R, G* |4 _+ t
{
- h4 Y1 I- E$ S7 S platform_device_unregister(&da850_evm_tl_leds_device);9 x$ E3 Y: f8 S& v
, ]- y/ A. ^1 y7 v6 M
printk(KERN_INFO "LED unregister!\n");
5 C5 l+ b% A6 a6 J4 M}- B5 C g" W6 Z* ?- e* O
3 o7 v+ o0 [7 N2 c `4 U
module_init(led_platform_init);, w# v0 k2 { f7 j" s' Z
module_exit(led_platform_exit);
9 C+ M& w& M6 C7 y5 d" o9 `. Q. C7 G6 m! c4 `4 H
MODULE_DESCRIPTION("Led platform driver");
N& h. M- n1 G" kMODULE_AUTHOR("Tronlong");5 _/ _" j' Y/ j
MODULE_LICENSE("GPL");: l( I+ y1 F+ Q8 V3 ]
3 W4 h4 `, c, ?! l! D% _' P
|
|