|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 m' ]. z1 \0 i, L! O F! [#include <linux/init.h># X# f1 l( \9 ~" k8 x9 Z2 z1 z
#include <linux/module.h>9 C) x( `3 w3 I: H1 L6 q- `" t
#include <linux/kernel.h>" c0 u4 g8 b& D( B
#include <linux/types.h> a5 E# s& U. U
#include <linux/gpio.h>
* S6 y6 ^+ x6 T" L4 U. h* |! x% {6 T5 b#include <linux/leds.h>
0 D# H% C$ ]' [: I3 G#include <linux/platform_device.h>
& j/ }3 _' i6 s" g- p$ a+ t' h9 ~! A8 ?8 ^% ?# p4 n
#include <asm/mach-types.h>9 ^! H" `% g+ N* S
#include <asm/mach/arch.h>% h# I" K! W, O5 W6 r( T
#include <mach/da8xx.h>, z, s! b! O9 R9 @
#include <mach/mux.h>& x' r8 \7 Y( T& Y. t* u" \
( n$ e4 A: D5 J, ^* O0 J Z( A#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 R2 m% }$ B: n) n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- U+ O3 @' O1 w+ U7 h8 u% l7 B5 J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ }9 B" B+ g$ {
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 }( Q1 u: m7 s7 m. x
4 T6 L# j" Y/ c2 Z/* assign the tl som board LED-GPIOs*/1 _! \( J' w! \, O& n
static const short da850_evm_tl_user_led_pins[] = {
; d( F) R$ I9 }' i4 t% r. o: O: c /* These pins are definition at <mach/mux.h> file */4 v/ f/ \0 e, z, g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 _) z6 \ B7 G' H8 d* m9 V+ F -1# r3 q& w) x! x- {" f# P6 l+ \
};
3 M6 H% W3 h7 M2 w
( S3 m+ i: b& i1 O, k- t+ {) `8 tstatic struct gpio_led da850_evm_tl_leds[] = {+ @. H& P3 S3 ^% a2 H$ K
{
1 f' h0 |& i7 T .active_low = 0,/ p5 `: R4 X0 K$ d3 b
.gpio = DA850_USER_LED0,
5 M) z" I p; I9 ~# E .name = "user_led0",
2 |. D+ L! B4 _; X .default_trigger = "default-on",
* T- M' Z' h4 v; c+ G },
8 m* f K% j: v. ]- t. V- m$ [ {4 b- f4 b, f' [2 g* |
.active_low = 0,% x* A) ]# ]" Y1 `4 v8 X/ h
.gpio = DA850_USER_LED1,. `4 q; V5 g5 r/ _1 w
.name = "user_led1",( t) l% D! I0 G
.default_trigger = "default-on",
& C5 G. u* }, O; Y, P1 @. m! z+ B },' F4 Q5 k! X" i/ Z3 k1 b
{( }4 ^$ v! E! _
.active_low = 0,& _ B( k. Z) J. E4 C
.gpio = DA850_USER_LED2,
2 k" V( R9 C* N, f, \ .name = "user_led2",
5 G+ P+ k8 H8 H O6 \/ o .default_trigger = "default-on", P) _- l" s8 f* p6 I3 w; v8 S+ |3 ~
},& Q I% f! _9 N7 f- a% D
{1 e; w" a( g- `+ L" P% M- L; g. A+ V
.active_low = 0,/ [3 T" Y' A& F- i2 `3 Z1 ?* w+ w/ i
.gpio = DA850_USER_LED3,* e6 U" t9 o- {4 ]9 J! b
.name = "user_led3",8 W; p3 R! d% a6 o8 \+ v- ~
.default_trigger = "default-on",9 t1 W% [" Y9 I: ?" D& L1 g
},
1 U/ d' T' U" T8 L& q- u};
- L" B. s7 _7 G0 x7 M, j. U: G; y V9 I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' e2 [1 D2 y, r+ p/ |
.leds = da850_evm_tl_leds,7 h3 A3 I7 F( j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; N, y6 S8 F$ g* Q8 P, V0 R};
& Y" u9 x7 W7 M1 D% u- p% Q8 }* k+ U6 t
static void led_dev_release(struct device *dev)- X/ n' [% s) ~, Q
{
' ?! b" y7 _* ~' P/ F};
- }, \; \' w% i/ l6 a; C/ |$ e- u0 Q: M# q
static struct platform_device da850_evm_tl_leds_device = {
0 u p) }2 d E, r9 U0 V5 m .name = "leds-gpio",
/ @- I( i2 H& i. t6 s. } .id = 1,
6 I) I S( W' F/ y R5 K0 r .dev = {; H+ z% B( j5 x2 v T6 F
.platform_data = &da850_evm_tl_leds_pdata,# s G6 v% u7 z- [& g B5 X" K
.release = led_dev_release,$ o4 N) w& G/ A8 s7 A+ D: |: T# w
}- R) U( I- \$ u) e: W
};
9 U+ S: e9 Y7 m
2 \( Z0 ]8 b. Q5 Lstatic int __init led_platform_init(void)% V3 l0 z/ c" g, Y
{ @# Z6 T# u: V$ S8 m
int ret;
8 h. H; Y, C+ o* n6 z) D#if 0
& P- e+ q2 p( B1 I0 i/ I+ s- l( Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 O* I2 B1 F" g4 A- J0 k0 o if (ret)
) ^8 R" q) |' Z2 u/ P' k# q; J* ^* W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: C. }' X' ~; l "%d\n", ret);0 A, H* D+ a* k8 W+ j
#endif# b+ M7 D$ b8 k' e7 [; c
ret = platform_device_register(&da850_evm_tl_leds_device);) s y8 G1 j/ n3 }8 q
if (ret)
8 d* G! c% Q6 o8 J0 q* l! p5 F pr_warning("Could not register som GPIO expander LEDS"); j. Q6 I B; U5 R0 o7 P% P
else
9 y5 d$ l: [$ N0 `8 a printk(KERN_INFO "LED register sucessful!\n");! I2 i% d% Z% z9 k, i) G( |
& i. ^/ ?" f! a" |+ f return ret;/ Z1 f* ~- W3 p, L9 H
}7 j0 f# @. [) @9 S) |2 v2 s
: l. T8 Y4 c, H3 i6 A7 Ustatic void __exit led_platform_exit(void)5 X4 [1 Z* X0 p- ^% J6 m3 K5 L
{
b8 v/ ]% G) |7 L5 F+ N+ d. A9 Y platform_device_unregister(&da850_evm_tl_leds_device);4 ?2 Q Q, q+ }, l8 h+ M
R7 e: V* G: H- Z* Y) u ~ printk(KERN_INFO "LED unregister!\n"); _6 C& W1 ?% n: C. \1 c% o' T
}
: F% h; W c1 j# n: }) Z. }* b& k4 `& U* I/ O3 v! d7 M- Z: U
module_init(led_platform_init);
$ \- q$ _+ l% Q' I6 d+ n6 Q8 _/ Z* Gmodule_exit(led_platform_exit);
0 a, g" v; R. h( u! v
! L$ a- R4 w: [MODULE_DESCRIPTION("Led platform driver");
]0 @. T$ t$ b: H4 b$ s; E9 dMODULE_AUTHOR("Tronlong");. x3 a, T6 R0 b/ w8 X
MODULE_LICENSE("GPL");
f% g# \% ?7 } u
8 @$ _& {& I/ d& ] |
|