|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 j+ x- F R) O/ `/ G8 @, `% I$ \6 N
#include <linux/init.h>. x& [3 s; \ _6 S: V! o6 q( d2 `
#include <linux/module.h>
/ y: E: Z$ h$ d, ^$ T2 K% W3 w1 g#include <linux/kernel.h>: W. |7 c8 U/ M6 i5 T8 ]$ b% f
#include <linux/types.h>
' h. B+ o; T" ]' g B1 z* Z#include <linux/gpio.h>
6 |' F/ C3 F, [) N& w: j( P1 f9 W, D9 g#include <linux/leds.h>1 b7 O/ M5 K& @
#include <linux/platform_device.h>8 c' X5 C* a4 L
$ W0 _. x* d+ W" s3 l6 m#include <asm/mach-types.h>* d: I' {6 h& d* T
#include <asm/mach/arch.h>
2 N2 \0 K- x; v8 |/ ^9 n. T7 y#include <mach/da8xx.h>
1 w6 @3 T2 N7 L7 g& k5 y#include <mach/mux.h>
. m/ F6 x4 {4 N m- K
G) r1 p5 F# k/ s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* M4 T% {; f" x5 P( i8 N3 ?# x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ G4 K5 l5 ^6 @. Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
|3 V4 e f) Z; p; A) I7 t; \#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 Z- A& h% j; x
) ?% o) u8 B9 E4 C2 K: V# C/* assign the tl som board LED-GPIOs*/
' ]+ E: R. p- b4 A: \static const short da850_evm_tl_user_led_pins[] = {
8 i5 T+ q, n2 }( |; n! j& s /* These pins are definition at <mach/mux.h> file */" t# |& e8 y K4 ~" d0 w+ V) P' P
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: S' `" j5 x) B% y* u h
-1
% e4 P* _6 I `0 I+ T( d5 P8 {};( ?8 B/ X; _# P# j
- L3 e* m+ A/ m
static struct gpio_led da850_evm_tl_leds[] = {
% s) ^& S6 b6 h% c2 m {' l" q; P% _* s) B& b/ c# R$ Z0 [# p' ?
.active_low = 0,; B1 r2 J( L; o) c8 q, T! f1 ?
.gpio = DA850_USER_LED0,
9 ~2 P& f6 B4 C0 H, U- g* c; U. v( v) W' m .name = "user_led0",$ A; R& r- u: e
.default_trigger = "default-on",
7 @4 E) ~* J+ h7 }/ V) v },
; x7 ]! n" b( @0 f3 V {% S2 N9 @9 x3 i6 ^( r9 ^* k. C& R
.active_low = 0,
8 A3 ]7 d y! N8 D: ^0 ] .gpio = DA850_USER_LED1,4 h# S" Z) G/ y) d
.name = "user_led1",% O: j x" S( M$ q
.default_trigger = "default-on",* ]: z4 N* S9 e
},$ n& |4 m c* o& _6 L) U/ [
{
2 y8 f0 W! k# L' `# |( B .active_low = 0,1 l3 g$ I; m8 n7 t7 M) b
.gpio = DA850_USER_LED2,
% b* k, { J9 [7 ? .name = "user_led2",
$ J/ c- R0 P; G/ _* b) E .default_trigger = "default-on",) c- V; g6 D7 q
},
$ m0 d8 r. S- h: J {
j% D |( W: l6 `! J: I' B2 e .active_low = 0,6 g" J" Y; G3 g
.gpio = DA850_USER_LED3,* y1 ?2 }2 x9 p% @$ E6 u
.name = "user_led3",% v( P& x; T# d# q1 C2 [* c' w, ?7 A( m
.default_trigger = "default-on",
G N& x& G5 I8 Y+ j },+ j: B0 Q0 v2 l# I2 O8 E
};, a* C# w; S& N9 k3 e2 c. L
' T; E; o/ e( [5 l1 i. R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& {( {8 c2 z3 E x+ f7 o .leds = da850_evm_tl_leds, c$ F+ x. z8 J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 E K" ^+ Y5 X+ M+ J" K
};
+ Z' i& _5 B N! y' w1 @$ B
* Q. L3 z* Z bstatic void led_dev_release(struct device *dev)
* Q! `" T& c, t! b# U8 t9 w{3 K9 b( ?9 O% Y8 c- G& M7 F
};
. U3 Y3 f {2 d1 \8 C! f4 s- T1 l7 Y8 z9 d
static struct platform_device da850_evm_tl_leds_device = {+ d' V' K3 \* Q- z+ Q" J! `. }
.name = "leds-gpio",% ?& D5 r. n2 l9 d
.id = 1,
L; o5 K7 t) p4 N* ]5 U .dev = {
% b; [9 Y% n4 W- g .platform_data = &da850_evm_tl_leds_pdata,
' U1 p' N4 ^4 D. g/ o& _: K .release = led_dev_release,6 Z$ D4 t3 v7 O- y8 f! W7 \
}8 F+ Z; |. ^7 }% k
};8 N2 F6 @/ |7 W& z' W( `
+ d- X5 ?, t& d% r
static int __init led_platform_init(void)" G3 P; m S5 D# b+ Q1 R0 x
{/ ?2 G& T$ r* X. N9 [1 a- F
int ret;
# O1 O- m, ^9 @, k' k#if 0 B4 L! k* l% g, I
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 h7 h+ `, }3 ?1 p1 [ if (ret)
( M, ^$ E2 b! R5 d2 m/ u. H V( L2 z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 J+ n; S( |* g: g, { "%d\n", ret);
$ e. H: y. f9 A/ x7 z& P7 m \#endif3 O! e; P9 J. Q4 N2 B. M! ]
ret = platform_device_register(&da850_evm_tl_leds_device);! l0 n+ H" L! J6 s: M3 r* J
if (ret)4 e/ D2 M7 g+ B" j' t
pr_warning("Could not register som GPIO expander LEDS");- O9 E# n i) Q5 K4 b+ _
else
' I1 e5 l! T# `% J, B6 ~ printk(KERN_INFO "LED register sucessful!\n");+ Q/ U& \4 f6 I0 a c# h$ M, N
3 t! B/ B. t* z' J. l" C return ret;
& m8 \% Q# N2 C; q}; H3 w& G1 ?# I6 G/ f4 `3 o
! g7 @6 p% p @9 t5 m% G5 J Y0 T
static void __exit led_platform_exit(void)$ c) I, S: K9 E g% U" @
{
/ m) I3 D, Q& z F5 J platform_device_unregister(&da850_evm_tl_leds_device);
1 H7 M" A5 N) k5 H
! R* P( P8 ~2 ] printk(KERN_INFO "LED unregister!\n");; s5 p, m7 k8 w& u
}
8 {7 W0 I4 o& Z! F- X$ O/ R
& I: j4 r+ x1 p% wmodule_init(led_platform_init);
$ R3 A0 B7 j- smodule_exit(led_platform_exit);! S x; }. B/ ]" ]6 A' Y: Y
( ]9 i) t6 t8 \9 T6 a7 Z" cMODULE_DESCRIPTION("Led platform driver");7 T2 H4 j3 S. p8 u6 F2 h
MODULE_AUTHOR("Tronlong");
8 z8 B% Q5 Z$ D+ p. |, l1 y$ OMODULE_LICENSE("GPL");
) [& ?6 ]8 l6 g; d$ \
- m t W, [/ Z. }1 |: ?. Y |
|