|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% L# _- V- R+ N#include <linux/init.h>
' J. T* }. N. t% d" _#include <linux/module.h>+ n7 N8 z6 j: y3 D' t. x d
#include <linux/kernel.h>
0 V5 ?4 w! x t: f#include <linux/types.h>3 ~7 Y8 W* a7 E, O B3 |
#include <linux/gpio.h>7 K: V ]) |( x8 b% a5 B& G7 o( [
#include <linux/leds.h>
8 {+ V& ~9 U" J2 f) F4 f+ L#include <linux/platform_device.h>
8 j3 C" E% F8 t& g( I7 @
. i) b: t" K- y: e/ y* G#include <asm/mach-types.h>8 m2 o$ g* F# J0 V \) ?8 _
#include <asm/mach/arch.h>
E7 e5 v+ [2 S7 _#include <mach/da8xx.h>2 |. W3 u, T* R D2 F0 @5 h, K: j
#include <mach/mux.h>/ r5 f' m1 S3 t( P/ q7 Y
# L( e5 \, d) q: V) l! ~; `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). S4 d* l, @+ c8 w+ W* E" G
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) k, Q& a6 s5 N$ Y: @9 k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 u" P9 v, A7 C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* E3 _, U& ^6 V8 N
* g9 d" y @! V5 q3 A, Z: n% ^6 K/* assign the tl som board LED-GPIOs*/! U s+ g) |0 E6 P4 x( T8 C/ e
static const short da850_evm_tl_user_led_pins[] = {) R/ t$ r3 w$ q3 `% a8 R8 k
/* These pins are definition at <mach/mux.h> file */
. e! e+ _; Q9 u0 z4 T/ l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, a3 D- L& N3 y/ o# U6 H" L! G -16 y% t7 S# C+ q% Y% F {2 I
};
6 n4 b5 O3 U- Y2 F- [* }% N! W- H; t; X3 c! d; S' u, T' W: ?7 F
static struct gpio_led da850_evm_tl_leds[] = {$ P; [* l$ p1 Y4 w# W$ B, Y& e' [; Z
{
7 _/ N; I: c5 |1 E0 ]( ~( u .active_low = 0,
; \2 P1 }) e( g" R' R .gpio = DA850_USER_LED0,0 d! N* F4 ?) [/ r) K
.name = "user_led0",5 q3 i( L) ~# Q4 G, t
.default_trigger = "default-on",
. w4 G2 k9 a. D9 { },: V2 \% B Q) B' S$ @7 F3 f
{
5 l7 E: q! H( @* V .active_low = 0,% U r4 q+ U+ m7 }+ ]
.gpio = DA850_USER_LED1,
# t$ B" p# F; i. P+ o0 j' K$ X .name = "user_led1",. N) D) V# z k6 o I$ a: y% d
.default_trigger = "default-on",
/ H2 I% Q3 w+ D4 ], w! F2 R: u; d },
* Q9 E8 H7 ~' V8 r5 I {; e0 Q. c4 e( |8 l
.active_low = 0," _4 U' _4 W5 K: R
.gpio = DA850_USER_LED2,8 V5 J5 {4 i7 g3 ^
.name = "user_led2",
# [$ O2 G% C) p0 u% g& V% { .default_trigger = "default-on",# t" i: ?3 x# p8 ^9 ]
},! M: p1 ^7 a, S( w6 _
{ n& r# V' n) B
.active_low = 0,
# E o8 ^# i5 w3 E a3 c .gpio = DA850_USER_LED3,
9 V% h7 Z0 ~8 i$ u( l .name = "user_led3"," T% M5 _7 Q" O$ c* |
.default_trigger = "default-on",
5 ]8 t) d& R2 y },4 ]; ~7 ]8 c- K" x9 b
};
# h+ i2 z, P, k* W( _2 f4 H V, Z
% R# B. l; D( g9 A) z& z/ C9 ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 n, l T d' z6 ^. C2 O& @5 } .leds = da850_evm_tl_leds,3 B! O5 u9 P8 u
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- |. z0 b8 Q7 e};
8 q) s" k; g% E8 @
, Z* Z) J; e8 y- \" Bstatic void led_dev_release(struct device *dev) S. T% c( q9 B6 Y1 f
{
/ ]; E% ~" C& l6 A, ?};
5 h3 P" ~+ P! [7 r
; z# }4 a1 |! |+ i$ ?; {* ^static struct platform_device da850_evm_tl_leds_device = {
, e3 O- Z* l% F .name = "leds-gpio",
. m" r2 X3 k& n6 f/ Q! j .id = 1,; r+ T: @' |* h2 W
.dev = {+ r6 D3 _, Q/ { t0 Z$ A
.platform_data = &da850_evm_tl_leds_pdata,
) P, I- N: V% ~$ G" g" }* S. R .release = led_dev_release,4 A8 _, i1 w' d* v. c( d6 I& \4 c
}
7 I3 Q' [ s4 A: g) }8 P, x};
- V! \ e& _, z1 w4 m. |5 e) O# h0 d9 I6 C# L# \' o- u2 z2 n
static int __init led_platform_init(void)+ \2 ]1 a# g, y- W- o
{
' M' v) z% M! A4 D5 G8 Q int ret;! i2 N5 ?) v6 i8 `$ f
#if 0
7 C& S' r0 _: r5 k. r$ Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) Q) r) w0 p, g! S- e8 b7 U* J if (ret)
/ P* @1 M" q. J% u* p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: i/ p6 L- [! ` ?9 D "%d\n", ret);$ O; W% k# V& n/ ]# F9 [
#endif2 o" P- Y- I* f' }. A. _" i
ret = platform_device_register(&da850_evm_tl_leds_device);
1 L; O- T* W! K4 m1 d. } M1 Z if (ret)
+ L1 y. B3 z9 a% R pr_warning("Could not register som GPIO expander LEDS");
- E# ~: \) @9 g else
- `( e, l# C. Z, k# u6 ?7 g printk(KERN_INFO "LED register sucessful!\n");
n7 Z! z/ `8 A0 P5 [. \+ L
, q( U( F2 P3 x return ret;
1 V1 _: J8 b0 C% B; f. c}3 ^2 ]% f! d5 u* c' `3 d1 H. c; b
( L4 q5 p+ p* D2 D. @static void __exit led_platform_exit(void) _! U( Z; [9 q" b0 r
{
" @1 ~2 G# h9 E" j( t+ J platform_device_unregister(&da850_evm_tl_leds_device);" y7 |- t- k7 ^5 c8 |
+ R* M3 [9 B' H6 j9 N9 g3 u" n
printk(KERN_INFO "LED unregister!\n");! l3 I9 w3 q+ D; A
}
* w; d$ K+ e0 j5 J, `5 x0 a
5 ^0 y3 d( ^3 ]: w0 rmodule_init(led_platform_init);
8 X9 ~0 ?1 c+ T; A M8 b$ Xmodule_exit(led_platform_exit);
: o0 `8 ^7 O! ]+ W. H7 Z0 c( J8 T1 N* ^6 L
MODULE_DESCRIPTION("Led platform driver");- { w2 j. }( D0 U4 r$ b, P
MODULE_AUTHOR("Tronlong");; q+ |. b* ]0 a2 f$ z7 N
MODULE_LICENSE("GPL");! x* h1 K' z. C9 }! V. _3 m
' a/ D/ ?# o: H |
|