|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 ^! f3 L0 d* C% a- k2 K& T1 b; `/ ^#include <linux/init.h>7 P; l. D- Q2 i# ^
#include <linux/module.h>
% z. s, I! l$ w- P#include <linux/kernel.h>
) T. j9 K' X) N4 P3 }#include <linux/types.h>, \' ^& H- f6 K* X2 x
#include <linux/gpio.h>
* p2 y1 A% z2 D! X! ^" F#include <linux/leds.h>
- c1 ~- t7 Q. q, `! O* {$ \; U1 `#include <linux/platform_device.h>2 C4 Z% u& K9 t, e/ D
[2 ?7 t; |3 R3 _#include <asm/mach-types.h>3 D( p' c+ l t5 K! v. S( A
#include <asm/mach/arch.h>% `4 I& @7 ?8 u3 c C
#include <mach/da8xx.h>7 Q! O) z u% q/ k: W. A8 `: Y
#include <mach/mux.h>
- ?) G' w1 f& i, F8 k/ `) h3 ^; p0 i9 i$ e- G5 O+ s0 s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& d; r$ ? a/ Q6 s# G8 f5 h
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
g( {, ?8 Z, J' ]0 R5 y- o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 a' R0 I; }2 k- M" @" {" a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ h) ~/ R% Z5 d4 Q% a1 {, w" b/ I$ l$ [ R2 |
/* assign the tl som board LED-GPIOs*/$ v3 A! [* [0 |1 g0 q
static const short da850_evm_tl_user_led_pins[] = {: W4 R( ?$ r5 z# s, Z/ L
/* These pins are definition at <mach/mux.h> file */
3 b% P0 |5 f6 g }+ | {+ `) | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# j! u1 ]! T6 `9 x1 {7 B
-1
) B9 q3 J, t2 r9 W};, ?& Y! `1 T% a$ M
$ q9 \( X' j: T# F- I/ f' Zstatic struct gpio_led da850_evm_tl_leds[] = {
' l2 A S0 ? \! I) H, F: @ {, M/ J! Q# ?; o8 z0 n1 t8 ~9 }
.active_low = 0,
+ q# m! ~; m" Q4 H& C* J& ` .gpio = DA850_USER_LED0,
/ i2 O% E$ Y" J9 [/ } .name = "user_led0",
+ N+ O$ Q( @7 h) }& t/ B .default_trigger = "default-on",% `: b7 o( n$ ^" s" `$ ]5 i
},
4 `, Q+ a6 L3 U% z1 F1 @ {
5 z; s3 B- {# `& m .active_low = 0,
6 D; d( p# `( K) f3 W .gpio = DA850_USER_LED1,
, M2 ~7 V8 H/ \: N! r+ Z8 K .name = "user_led1",$ z2 U- N1 G7 n* ^
.default_trigger = "default-on",; [+ H( i- }* n" s# G5 P# S8 x
},
4 N, a3 w0 S/ T% I {" @' j' L" Z9 I% H! S
.active_low = 0,1 @- ~. W* Z8 P4 I' ]0 l, N
.gpio = DA850_USER_LED2,
L1 u# P8 ?: U ]* ?- r .name = "user_led2",: F0 H# G/ k' C: S
.default_trigger = "default-on",/ r, `% _! C9 A$ k: Y
},* L5 @! |0 C. N, t
{5 j* C! m8 F+ ]* _2 ?/ w4 o
.active_low = 0,
* e+ f$ e. s/ s! } .gpio = DA850_USER_LED3, M6 ^' |+ d- E8 w6 L+ a
.name = "user_led3",7 d8 s. ^4 y9 a
.default_trigger = "default-on",
( J6 C. E- r( m, l; E },9 I+ J% G' S2 O1 d0 U
};& r: ^( ?3 s* q/ u$ o- Q/ [
6 v$ q* ?0 U% r2 s2 Q$ p0 @ T# \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 F- x4 a" |. j1 m: \3 a. ` .leds = da850_evm_tl_leds,! `3 a! S& I: ^& k y0 H, H J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 }$ \: A; T$ v0 h
};
- T% b4 o# ?, w6 W0 z$ f
0 K3 k1 `2 [) A$ }, ustatic void led_dev_release(struct device *dev)- b# Y8 J C6 i6 s. t
{6 Y# Q M# c) v2 Z
};
[) e6 R8 i {7 C0 b2 H
2 c0 N( X! I+ a& I# m; m6 Ostatic struct platform_device da850_evm_tl_leds_device = {( r \ V9 T F l6 G
.name = "leds-gpio",
7 f$ ~* m" `; ~: k .id = 1,
$ c) s! X# y v+ e! b: ] .dev = {
5 {1 S- A; E9 O2 h1 @ .platform_data = &da850_evm_tl_leds_pdata,
- ]( y; {9 B3 \ .release = led_dev_release,* o! O+ ~ {9 I6 I, ~& S
}/ a2 n& I7 Y8 J6 R3 ~/ E
};
/ c) O# Z: m, d X7 H+ d# `3 z9 m, G3 H) L
static int __init led_platform_init(void)# j) E; q2 E q; S' |
{
/ V+ D+ }2 d0 n& n/ m7 W' d6 i int ret;
) p% i% z, r4 F# K5 \#if 0
; U! W: ?: d6 g: |- u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, q, V3 P7 P0 i7 { ^' S; k# U
if (ret)
M3 ?7 D& V) E8 B) @9 X- r( h0 s pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' H0 u* v3 o# D% s- C- S "%d\n", ret);
' E- ]7 {/ {; y#endif# Q; a& }8 d5 G' k; f
ret = platform_device_register(&da850_evm_tl_leds_device);
+ j3 z( f6 z# u( a: C/ @ if (ret)
. ?' F' f }8 a1 p% D$ _ pr_warning("Could not register som GPIO expander LEDS");
& i* X9 i( w4 S1 } else
b/ G/ R% J' z1 B' I5 T. ]2 g printk(KERN_INFO "LED register sucessful!\n");6 B. W1 J$ O) ]
4 c# o5 d9 E" Y5 ? return ret;
! f( Y2 H. Z; K; o9 L}
! i7 Q, {% S2 u3 U& w8 e" W2 H
) _) [0 I- z7 ^: Y4 A+ v/ Sstatic void __exit led_platform_exit(void)
* }) Y: n5 f0 u/ l; n{. o& B7 j* j' C
platform_device_unregister(&da850_evm_tl_leds_device);0 W5 J: D6 V& G0 k7 U! c4 ?$ e
: s$ D* A4 H) Z( l$ _ y printk(KERN_INFO "LED unregister!\n");
* [) ]7 J4 F" e |, p& X}. k+ j% S1 ?1 H( s
1 i7 n9 t. p: d1 L: Xmodule_init(led_platform_init);6 k6 E1 ^) Q( _* e
module_exit(led_platform_exit);
* i( x% _4 x$ O' O, J: W3 J
% S, O* K6 V9 vMODULE_DESCRIPTION("Led platform driver");* `3 Y/ Q* B8 j- j8 f( c) a( j- z3 H
MODULE_AUTHOR("Tronlong");! A- [ ^5 {$ l
MODULE_LICENSE("GPL");7 C6 S# H* p' V1 {1 a. r( B
. Q: m" | n/ q) c, E: `8 }3 N' P( `
|
|