|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: c: j& }' m# ?' _
#include <linux/init.h>
) S; _; l/ A* d l& l9 `* _#include <linux/module.h># T9 x/ K$ g2 e ~' h
#include <linux/kernel.h>+ B# S% N$ I" J9 q/ e& @; {
#include <linux/types.h>
2 G' q( r7 _) w% m$ }1 ^#include <linux/gpio.h>& O- B. g, I$ w e* l
#include <linux/leds.h>
' l% q; N; Q# |1 h/ u' J#include <linux/platform_device.h>; J5 X2 t! P3 Q3 S
0 }3 `' W( H" h3 U1 r5 B
#include <asm/mach-types.h>
8 m0 V `$ }* Y7 _9 ~) I#include <asm/mach/arch.h>5 b9 l; i$ V3 c/ Q; S8 j
#include <mach/da8xx.h>
5 s5 h1 X5 v8 G: u- D; y& G9 p" a4 P#include <mach/mux.h>* i. n/ R; m( V2 ^& Q5 G6 ^' E) {3 L
! E) `+ H/ b8 p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ g& A7 u" M+ |- \/ O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 {6 |" ^9 a- v, N' q0 N#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' {7 c0 y R0 E% `0 K, `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( X7 e) g9 X2 T8 M
0 z) {6 z) Z! W p3 X# T" @( a/* assign the tl som board LED-GPIOs*/
2 A6 M% E3 ^8 R O' R, Y6 u5 Estatic const short da850_evm_tl_user_led_pins[] = {
* f8 f4 J' A6 n% Y. K /* These pins are definition at <mach/mux.h> file */, F' M6 `# g$ s! x# C! a+ I
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ c) a0 Z/ c! Q; P
-1
9 O8 ?/ D0 P4 o& A};- f: H2 U4 p9 s
3 j# k& D! \* y5 d" K- Astatic struct gpio_led da850_evm_tl_leds[] = {
7 M1 p/ F- {" B& ~& f# p {
1 n! }9 S8 f% @* {/ ?; l .active_low = 0,* y& V b( p) [- s# Z Q0 Y7 b9 @
.gpio = DA850_USER_LED0,* E/ T" l9 M8 H& h, A# v
.name = "user_led0",
/ Z9 H6 D. t5 u4 V% k% p .default_trigger = "default-on",
' b0 W/ d1 C" L7 W },0 G2 K# S5 M: O
{3 c/ p% k& g" d- m8 `; [
.active_low = 0,
' i6 f/ o6 c9 m .gpio = DA850_USER_LED1,, R" S, A* Z- D0 J) Q' w
.name = "user_led1",
2 N0 x8 k' h6 `7 T: S0 s8 e" r .default_trigger = "default-on",& D6 |9 I* ^( w. k( v; C7 R
},
; C: F. q& [: g: N" s2 W! C: I) v Q {6 Y6 g1 a/ ?: ^1 X; [3 K: i S
.active_low = 0,
& o! F* W4 U0 R( h, Y, K+ ^- h .gpio = DA850_USER_LED2,% f; ~: C; V1 t. P% R2 c' l
.name = "user_led2",
% G3 \. {2 c$ L& _& G0 O .default_trigger = "default-on",
; p% ^5 Q$ P+ A; M },6 k, @; z1 y7 Z! b% t. l
{
* X& Y* ]" o( Z' A+ @ .active_low = 0,) y$ O- s0 W$ n% Y6 |
.gpio = DA850_USER_LED3,
* I* B7 y! U0 L5 B .name = "user_led3",
9 @& {2 M& z4 N8 t* _ .default_trigger = "default-on",
: \) c* b) J2 |; i3 F+ ~% w },$ h& W! }$ v/ j- g
};
7 O; v: c* f" Q! a: C- z! b" i- \6 Q9 `
. s0 i+ |% C' S/ P; zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 ]8 q& m- R8 g9 j/ }0 c
.leds = da850_evm_tl_leds,4 H$ ~+ c# t8 C, w# J4 s, \ r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. d* c8 @" _. U: ` b8 a# t};. E! ^) M' F0 I( S0 H1 @
. s' E: `4 ?4 w/ E% B. |
static void led_dev_release(struct device *dev)
( ~# G2 U' y4 M" m0 V; f{
7 G) U5 J1 ]! h# u; l};' y) \4 ^1 @2 K8 o. N. n
! j. Y5 Z; t5 P1 u9 `! B! X
static struct platform_device da850_evm_tl_leds_device = {
o% C: C+ v( @. @ S0 T* L" i* F .name = "leds-gpio",7 \2 H* ]! l$ u; F
.id = 1,
4 }, W" \6 {+ m .dev = {
' J) ?5 j9 C3 r8 M0 M( F .platform_data = &da850_evm_tl_leds_pdata,% M% W& x3 B7 s
.release = led_dev_release,
5 r) }* w$ `$ m( ~5 x }
) f, V8 h, V$ Y3 Y+ z1 _};
% @1 c4 s' y+ n. W2 t) ^2 D4 P$ t! j: x0 ?
static int __init led_platform_init(void)4 K: G' r/ J( Y9 x" Q2 r; a. P) U( `
{2 c! n I5 n# f: c' A# A0 @2 i$ f0 E
int ret;
: }9 K" |; p; f5 |#if 0
6 r! J, z4 a$ ~ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 c3 A% {' Z/ d if (ret)) O% C+ B+ M0 C# O3 |4 Q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: H) n& e) f0 P "%d\n", ret);% x- c2 {$ i6 m$ m
#endif6 A( L/ h3 F- @9 O" t; P
ret = platform_device_register(&da850_evm_tl_leds_device);! V; i- T0 O5 A! y- j) M0 H/ U: U
if (ret)
; |: e$ `; @% `8 i# t" d% Y pr_warning("Could not register som GPIO expander LEDS");
" ^1 h3 j4 k- s9 ^( q1 t. H! _ else
F8 {9 e4 x+ |8 f7 F printk(KERN_INFO "LED register sucessful!\n");9 c$ e/ Z& L+ Y+ d! e6 X
) G' }% F1 d5 t: [2 Q. r8 r* W
return ret;% L5 b) F; j1 L8 \+ T
}
4 T$ ~" N* `. ^/ d
7 t5 V6 s! J! {$ _+ l9 \6 Qstatic void __exit led_platform_exit(void)# R8 W; H) {1 C+ {) G( e; l' n' ?2 N
{5 V. b0 b, y0 e/ s- B
platform_device_unregister(&da850_evm_tl_leds_device);
; f. K* j' `/ l! a' ^$ _, @) v; w
* u0 f1 V$ G3 f; \ printk(KERN_INFO "LED unregister!\n");4 F, z5 a6 f1 g
}1 ?. S A) b- H k$ u
% d& u" M+ S! X& ^ Qmodule_init(led_platform_init);! \4 c `" W' f d# s: D g {1 F6 x
module_exit(led_platform_exit);
7 |9 e: E6 ^4 {# h; q6 _ f5 P$ t ^ j
MODULE_DESCRIPTION("Led platform driver");
' e# k* a- b& X$ e# dMODULE_AUTHOR("Tronlong");
6 ?) Y/ I F# v2 k- WMODULE_LICENSE("GPL");% Z r6 O* C' Q/ M
6 t; Z2 a5 L' r# X1 w- S" |
|
|