|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ m4 p, ?% G8 E4 [#include <linux/init.h>1 F1 v1 \- y0 J; f5 e7 B
#include <linux/module.h>
4 O) P: v! Q. |* I4 R; p; C6 o#include <linux/kernel.h>; s: p, A9 {* ]
#include <linux/types.h>0 |: N$ M& E0 U' [/ q F7 |
#include <linux/gpio.h>9 y: O) I! M: K4 _
#include <linux/leds.h>
X) G# Q, S g6 U, u#include <linux/platform_device.h>: ?0 T" P: @. y# x
( z6 ^, }3 O* j. s( R7 G#include <asm/mach-types.h>
: x0 M) @4 q ], Q* z( g; U. ]+ x#include <asm/mach/arch.h>- L# |8 p6 ^: F6 U
#include <mach/da8xx.h>" T* x9 v0 Z* {& K8 C
#include <mach/mux.h>4 }* C8 P8 ~. }1 `" e; U2 P# i
. I7 k$ q* y! Y+ v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( e/ h0 J6 ^3 m8 D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 b, x; |+ i- I0 ~) a- S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' Y1 t) l" q3 c5 N#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- l& B# O7 t. Y" k7 O& w
$ e: S K9 l4 Y+ V( g" Z6 y" p& l" G
/* assign the tl som board LED-GPIOs*/$ k6 a! ^# @: T/ p5 k5 s# U
static const short da850_evm_tl_user_led_pins[] = {
& A1 F7 p: e+ `5 K' W3 I# Y /* These pins are definition at <mach/mux.h> file */0 `0 [# w+ i$ i# F7 F: P
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ `# ^+ A# I5 D( R& Q& u$ p+ Z -1
4 X, y2 X" u0 W$ {: x};
6 Z9 w* ^# E7 r# D7 F
+ k7 z; s M' x, f$ V+ Fstatic struct gpio_led da850_evm_tl_leds[] = {
/ ~$ p! l3 O9 E3 U) S, [ {
; E+ G; W/ f- g: j: i! r .active_low = 0,
: U2 i3 v' r( |5 M .gpio = DA850_USER_LED0,
* I0 R8 x* l& F& J .name = "user_led0",. A% O0 U# X! S% W' P
.default_trigger = "default-on",
# D4 R9 i$ J0 \! v6 Y! j },; Y0 u% u- \! g! s! `9 u1 k. H) y
{
: E6 S% x ?- Z+ l$ }) m, e' F, a1 Y .active_low = 0,
- r5 Q ~' A! ?8 s: N .gpio = DA850_USER_LED1,
# U& M7 O" A- K0 A3 j .name = "user_led1",( ^) P2 m Y( ?( T; H5 u! T
.default_trigger = "default-on",
% k1 l: a5 K0 @ },
2 K j7 l( ~. g- V( Y' S {7 A* Q. H. S) s7 Q1 S3 j3 I
.active_low = 0,' m; [5 |- `7 |9 N
.gpio = DA850_USER_LED2,' r+ J1 h* E. a5 f2 b# {
.name = "user_led2",
' B- }; d$ }. b; ]! E .default_trigger = "default-on",7 S( M' b8 F2 O4 J4 t. R
},
2 p& k6 c& W6 F! Q! l0 J; D. I' Y {
4 p/ ^/ x% o9 D! i .active_low = 0,0 t% B6 }5 u/ P) _& k1 L+ J
.gpio = DA850_USER_LED3,
6 l3 N$ z. x# w" j5 M .name = "user_led3",
: I0 G0 i7 Y3 P4 f .default_trigger = "default-on",7 r* M3 M4 [0 ~/ R8 W/ |! n. ]
},! X, |$ K& ?, t! x" H/ ^& w7 a
};) M# Q; Y( |3 e' E
' X! G _. C3 _3 Y* [/ z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# ]: @* v. ~. X, z. Z
.leds = da850_evm_tl_leds,. l9 j/ ?+ q7 S8 l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds), G+ Z; V# t5 r0 J0 T
};
% L- e% Y) {5 Y0 i/ y/ r) K, d# s E/ ^$ X
static void led_dev_release(struct device *dev)
3 c. X' n+ O: ^/ K, j. [: ^{
8 Y) S+ V' z% w% ]* N- C! {' D};( B: b' `: S$ A- |: @" _7 o& l
S7 ~( w2 A! x5 W l- A
static struct platform_device da850_evm_tl_leds_device = {
" k# X/ y- B, U .name = "leds-gpio"," h+ K6 v. e4 a5 [7 e) F4 l
.id = 1,. ?) {. D: h' N9 a7 a
.dev = {
# |" j: |# E3 v+ {8 x .platform_data = &da850_evm_tl_leds_pdata,
. @- _8 x# A$ @4 u t4 w3 d y% I .release = led_dev_release,0 k2 ?& b8 ?0 q( h5 @, p* L4 d5 C
}
4 P: V, Q5 m9 y. n! C2 Y' k};, ]- k q- K+ m# V% E0 F
' i9 h/ s' w; l2 P$ Estatic int __init led_platform_init(void)
! M# W8 i0 S9 m# K9 H" R) {1 P{2 G1 O6 F8 Y7 ~/ a, Q
int ret;
1 |- M$ ?/ Z: u+ N4 d8 _#if 03 f! E1 r8 c+ K
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" a# X( W8 c( ~0 s4 p
if (ret)8 g1 [7 `5 Y& I1 r2 P1 Q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 |9 I8 ^; e" O# x) K
"%d\n", ret);6 A# {, Z9 m: K6 M, v1 ?
#endif
+ }. v$ A3 D( |% j; i% N ret = platform_device_register(&da850_evm_tl_leds_device);
7 `3 n4 i% V) d% X, V! T if (ret)- S+ w. U' w! j+ |* Y" K& q
pr_warning("Could not register som GPIO expander LEDS");
, S; m# O9 _1 Y( s; |7 k else3 f& b* J z; N9 c- A8 b1 s! w
printk(KERN_INFO "LED register sucessful!\n"); j3 T% H( n1 t. i4 ^: c
% _4 w/ y9 g& R6 k1 V6 o return ret;) Z* Q3 O2 k/ ?; I% }. f
}
6 W# q# g0 d4 y5 Y
# W8 l: d; i) A* K& nstatic void __exit led_platform_exit(void)
' p* _5 e9 l0 h0 z- o{
/ \1 ^; Z0 Q: y0 A platform_device_unregister(&da850_evm_tl_leds_device);
$ ?$ }+ b9 U6 @8 H* ?: r: s' A* C, d2 Y- |
printk(KERN_INFO "LED unregister!\n");* w* a: x9 K0 \8 |7 @9 k
}+ k% C& _2 s* v$ ~! s- p) Q
$ H5 C2 a5 J. emodule_init(led_platform_init);2 p" K9 ^4 C0 H
module_exit(led_platform_exit);+ r% C" o$ [! X) v( A9 w, n
# z* d, l+ E& `/ C' ~' ^/ z
MODULE_DESCRIPTION("Led platform driver");
7 i; x6 o1 i( x5 j# g9 J) q$ YMODULE_AUTHOR("Tronlong");. ^+ K/ I% v% `# `) E
MODULE_LICENSE("GPL");
7 e3 {7 k* u- x; r9 X6 E' K3 _1 j1 B" Z l i& ^, v2 A
|
|