|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, {6 ?* N l8 B7 h4 \( W#include <linux/init.h>1 e/ v3 q) \: V. D" r
#include <linux/module.h>0 B! G% f6 n( q1 z
#include <linux/kernel.h>
) p" B5 p; c0 Z' r5 [8 F#include <linux/types.h>3 L$ y. D# D8 [) d0 ^( w
#include <linux/gpio.h>
* Q" y! J6 p4 ~3 E#include <linux/leds.h>
~2 `, z/ F, Y6 f! u, D#include <linux/platform_device.h>
* U* G x/ u/ F- w: _1 W
, P7 ?& z v) N s#include <asm/mach-types.h>8 s: e2 d4 u. L+ d) @# r: v5 w
#include <asm/mach/arch.h>
: A5 I$ G. V' k# s#include <mach/da8xx.h>5 x. q( s4 N7 v# Y& n @
#include <mach/mux.h>
8 r, r) G3 v" m2 J- T
! n k" @ \1 \' x) ]6 d# j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ }" a& O; X' V% g#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 n, n; ~: Y' M/ Y' V#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( [. A# r {" d& P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 e) c% m+ S# o! D1 Z' C% d+ x9 e. y9 L" y
/* assign the tl som board LED-GPIOs*/: {3 N) H9 P* p& G( x, Q
static const short da850_evm_tl_user_led_pins[] = {
( i1 H0 K; ]1 t$ {) }0 ^ /* These pins are definition at <mach/mux.h> file */ H/ K: l9 P- B1 R. F1 z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 S4 _! m$ p6 u& H -1
, ]% h0 G) a/ E: f* a}; e# I; l& E- d M7 \" R2 e
4 h) S4 H3 |4 g; v, i. g0 hstatic struct gpio_led da850_evm_tl_leds[] = {5 f$ r- m1 c# B% g
{
" B8 l* }$ G- X V# \+ g: U .active_low = 0,, ~. j# P5 n% {; s7 v
.gpio = DA850_USER_LED0,( _! N" J0 G; n- i# ?& J
.name = "user_led0",
) T" o% H! V/ L% c: j3 \- y .default_trigger = "default-on",: R W6 ?3 U0 H o1 Q1 l
},
( L4 {' t2 b! a* u C {. |( T* H, `3 R# `& t2 P& A9 I
.active_low = 0,! H& ~+ N: S4 e% E6 M6 r4 o0 j
.gpio = DA850_USER_LED1,
) [& @' Q L) P7 R3 V9 U. n/ I; D .name = "user_led1"," q) u3 G" }0 J: ^/ `' N) S0 K
.default_trigger = "default-on",. W, x# h( U+ x% A) ^& O) O/ I
},0 M# K- i+ J- |; Q- P% T
{
& g6 O, v0 q( G$ c- t .active_low = 0,
* a9 \2 ~6 r3 e .gpio = DA850_USER_LED2,7 a0 k7 W" L/ P: Z8 q
.name = "user_led2",& a4 X8 {& Q% b3 k+ u$ c
.default_trigger = "default-on",
8 m, w1 B1 d" S/ q- H5 @ | },- @1 I, d5 |& y$ l n
{
9 A9 _' W' Q' e. n, T" e .active_low = 0,% a& H& T Y4 g( g% u
.gpio = DA850_USER_LED3,
9 c$ d# _, q8 s5 |5 y7 l: E4 m .name = "user_led3",
Q; H. | [) P3 d. c7 l7 _ .default_trigger = "default-on",
7 {( [2 R* C/ q },: {# R% q8 A( I8 z* X; |# e
};2 F8 B0 I- S a- x
1 a4 _( X6 z" k pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ f7 L- v- b( i0 A
.leds = da850_evm_tl_leds,
. d; ` M+ W* k% V .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" `* ?; q4 I9 s# v/ a5 q; R' {' {8 M7 {}; I/ N4 x( E- v, l) ]
. N5 ]' t6 c* \. p
static void led_dev_release(struct device *dev)$ c4 T) O3 Y- \, a0 e& c& N
{
! g8 o7 K: `1 @. Z5 r0 e};
# B- E* }, y6 f) ]4 D/ ?1 q0 o' y: M# N% j/ [
static struct platform_device da850_evm_tl_leds_device = {; c$ N* L4 F0 Z. a( a
.name = "leds-gpio",% @, }8 N8 l4 l5 M8 `: b1 I% O
.id = 1,; Z( L& }) {6 k- e- w$ r3 a
.dev = {
) N+ B. O- t- ?. W' M: X .platform_data = &da850_evm_tl_leds_pdata,6 u. B, t4 w+ _0 f
.release = led_dev_release,, r: A- i- f! _! L
}
) z" c% z, n7 _9 m2 v1 Z/ ~};
0 D: o/ S; A9 }. n7 {- m/ K( _3 h6 b7 T5 a0 M, b7 s
static int __init led_platform_init(void)
' y2 @8 e2 _$ B0 G9 \{8 `+ U' _" E( I6 T; V
int ret;
# }! ^+ [% u6 \4 v#if 0
, b! _& j n0 R ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& y) e8 \% n( J* T
if (ret)& X) t( f* Y- u, N* F$ t' }
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 S; q% {$ `8 T" b1 d
"%d\n", ret);- S4 d, X* I' K& `/ F
#endif8 K4 r8 k* V9 d" p' V' d
ret = platform_device_register(&da850_evm_tl_leds_device);7 }7 P: l1 V( B& g) s: Q
if (ret)+ n, F8 v+ o* G4 h1 z9 Z: P+ B/ i: ]
pr_warning("Could not register som GPIO expander LEDS");
) D, T1 v) F7 ?! B* [4 m" O else$ k$ W# H5 `; X. r" d4 e
printk(KERN_INFO "LED register sucessful!\n");' I$ f! ~6 `' s1 A( l- d
8 o1 V7 a8 }8 T+ Q8 j9 p6 t2 T [ return ret;" I9 f, I6 w! E1 V
}
8 O) h6 V! A& q( E, I1 d! s/ s5 p8 O9 S. f
static void __exit led_platform_exit(void)
* Y# C$ O' E* Z' u! X" s Z# ]{+ E2 Y \' f1 {
platform_device_unregister(&da850_evm_tl_leds_device);
0 R6 S2 N$ Q! U. v3 ?- A0 \8 F1 Q( K. u* k6 C3 a/ A1 I
printk(KERN_INFO "LED unregister!\n");
4 x( A9 k4 Z( S}
8 z3 ]; }7 H5 k* O9 w3 }$ R- i$ J. M' I) K
module_init(led_platform_init);: c) n6 M& d3 }/ {; C- N. e y
module_exit(led_platform_exit);- v& g% L: \* x1 ~
. ?, _+ {. y* d: F5 QMODULE_DESCRIPTION("Led platform driver");+ O4 `5 {5 ]: F( j% ~$ \+ s
MODULE_AUTHOR("Tronlong");5 \% h+ z( t# i- k
MODULE_LICENSE("GPL");
$ d. _) O1 |: Q, S9 d
+ A* _2 V$ H C# [ |
|