|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# t5 Z" m& U% `1 D& t#include <linux/init.h>, T& ~8 b- C# ]; r: e
#include <linux/module.h>9 A. i% a- h7 Z: j4 J0 ^
#include <linux/kernel.h>% ^) p9 ^& p# h! {
#include <linux/types.h>
X+ w3 M9 f, ?! {3 y#include <linux/gpio.h>0 }. G, Z, \6 X( g
#include <linux/leds.h>
7 H& [6 P# d, S#include <linux/platform_device.h>8 w$ ]1 S# {& b
9 K% _2 t9 [2 V
#include <asm/mach-types.h>
; X, O: A4 K0 w0 d* W7 q+ s#include <asm/mach/arch.h>
) j0 ^- ]- c) ?0 a: q#include <mach/da8xx.h>& U- d+ m8 c* H; V, ?
#include <mach/mux.h>
: A/ y: I1 {; w7 s; ^9 \8 m J$ f2 X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& L* ~0 p+ U9 Y% N# ^# D
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( `: X! p; F' ~( v7 g A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 U. y; }2 _$ V$ s7 h6 n9 K5 f$ e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! ]5 e1 W1 O! J. b2 @) g6 r
6 }' s& I7 _6 G$ p/* assign the tl som board LED-GPIOs*/
+ ]9 y1 Y, ~$ i) Estatic const short da850_evm_tl_user_led_pins[] = {4 H2 }3 _3 m* ?% ]! Y6 ?0 |
/* These pins are definition at <mach/mux.h> file */# o8 J! g) d( |2 a! {1 |( r2 h
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: b6 c0 x2 d7 _; D+ z6 J, g -1
; _- ~/ \0 o8 h8 F, u1 Y+ [};: E; s0 I5 I; |5 r: `
2 P m2 A, |+ e: r0 Astatic struct gpio_led da850_evm_tl_leds[] = {
' V) F5 t$ h9 p {6 e. ?( s/ U" ~0 l4 R3 W
.active_low = 0,# W1 H# E% E3 B- `' Z4 }: q
.gpio = DA850_USER_LED0,5 t1 Q+ |9 E! }( M
.name = "user_led0",$ p$ A. N/ r0 I, n8 ~2 v
.default_trigger = "default-on",
! v, d) V6 C$ ` p0 J },7 i8 g- b& u7 O1 q) U
{
$ J+ {9 X# \' v, A .active_low = 0,+ x4 |$ S. z% ~0 V0 q8 D
.gpio = DA850_USER_LED1,
b) L) u0 K9 t P# J }( L6 Z .name = "user_led1",
& H% G* d) L! i7 F .default_trigger = "default-on",
5 a7 [6 t: A8 p7 y& h },) c- b, P" ]5 A& g8 q
{
! `3 B5 ^& w7 c8 Q/ P+ r; A .active_low = 0,
! j: ?9 D2 _; J" s A6 \ .gpio = DA850_USER_LED2,* K7 a! @( j# F3 [6 H1 B
.name = "user_led2",
: x) A9 O( a+ H) |+ \; t& [# F9 L6 o5 M) N( r .default_trigger = "default-on",& N& ]) X7 j' [1 J* F3 C7 n7 F/ u
},& i% y3 z# J* y
{
& y" ^- \5 g4 K .active_low = 0,, b% q+ k( @ n; F; \- K
.gpio = DA850_USER_LED3,
% H( H* W1 n: ?- _ {7 x3 H .name = "user_led3",
7 {6 n- ?9 Q* v1 | .default_trigger = "default-on",
+ z- O8 m& ~0 q# a% {" G7 g8 G },& {' K2 r {& S7 L
};
+ }. z, z4 M5 p$ F4 `! \
3 Y& F0 X/ B! ?/ _6 w8 H( T% Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 B! K& L. [: ?" f$ T$ E, B9 u
.leds = da850_evm_tl_leds,* m7 S4 r6 M) b- G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ k9 K6 k9 J' b* [, C# J
};; ]: R7 _4 k' v! E
+ i4 p9 e& P$ \ z( }
static void led_dev_release(struct device *dev)! B$ I" V% f1 q+ M
{7 ~+ i) Y. L! N0 |* b+ s1 s ?
};
6 {# w# _0 F* Z7 q! l% q$ g+ y3 G& @# D6 {- S; N* o
static struct platform_device da850_evm_tl_leds_device = {" j6 h- i8 B7 Y( [$ w, @. C2 M
.name = "leds-gpio",
; h4 r: Y' i7 V7 D .id = 1,
' K$ J1 Z. y$ ~. N .dev = {
" V! d1 E; z, z6 C3 X. E2 b, P0 a .platform_data = &da850_evm_tl_leds_pdata,
* F) W# B# w. G' H0 X .release = led_dev_release,
1 J: S+ k0 u8 u( E) E, j }0 T) n7 y2 `) G( s& a
};
# g* [/ V6 Q3 A$ k1 f! K( Q( U: G$ a2 Z# f+ U) i$ Y
static int __init led_platform_init(void)
4 ^( ^7 W! Z, ^% z) n{* y" z( }! @6 K$ h0 e7 |1 V
int ret;
9 s* ]% L6 B0 O" o6 Z#if 0
# o# ]+ e! V2 P- [* \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. n B8 J8 z$ Q" P* F t8 W
if (ret)
% t0 |, z; y8 c pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 Y" B4 d5 _( e% w" h3 _; t
"%d\n", ret);
# ^8 _: `8 l% d8 H, Q. I2 Q5 J#endif
3 F7 f1 m7 [3 y) O' m ret = platform_device_register(&da850_evm_tl_leds_device);
9 U1 g' ^& f. t/ \+ W if (ret)# D# z- D! n4 L+ ?
pr_warning("Could not register som GPIO expander LEDS");/ ]1 I- N$ @& a- ?# X& I4 G
else$ ^1 z# b- l; P+ L
printk(KERN_INFO "LED register sucessful!\n"); u7 p+ W a( r0 n
( V6 O! A2 h8 L ~) c2 f
return ret;/ r8 p! o ]" X' X( Z" l
}$ E9 P y5 a' |* l* k
7 ^6 F/ r t6 V* [5 i' astatic void __exit led_platform_exit(void)5 w! q& l1 U+ D
{# z C1 R1 v! x. ~! M9 X3 n
platform_device_unregister(&da850_evm_tl_leds_device);' @" C% e8 f# V* g$ B# ^
& v* I% O% \! u% T/ \) H printk(KERN_INFO "LED unregister!\n");; \: `+ l) |, z' L8 |" L4 C7 @; O
}) c5 M3 C) b# V- s& A: ?
1 M; V) f' m, a0 R! L8 K
module_init(led_platform_init);6 x6 V& U/ a! k+ i
module_exit(led_platform_exit);
{/ ]/ J3 v9 V" X& j0 C2 m. f* K. ^& @* d R
MODULE_DESCRIPTION("Led platform driver");3 }# t* `9 Y* a8 ^+ a0 u" \5 h
MODULE_AUTHOR("Tronlong");
9 ?/ T4 V# E3 |# FMODULE_LICENSE("GPL");
5 M6 N# Y3 I8 b& ]' j, j+ h5 b$ ?( t) h0 l: F$ Z; V1 G- g
|
|