|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ I/ X" u% S! b3 i#include <linux/init.h>8 d0 Z/ q4 W' e: j( I9 g% I) t
#include <linux/module.h>
" Q% C. R# f; }2 |% }- E t, R) r#include <linux/kernel.h>) N% S3 x* B/ `8 a5 W5 ?0 g. C
#include <linux/types.h>( [: ?: Z& y+ H7 i; g
#include <linux/gpio.h>, ~6 c2 d7 l( }
#include <linux/leds.h>
( i! H; t5 r8 |! k2 E#include <linux/platform_device.h>& u/ k8 ~& S% h, t) o$ {$ Z$ H
Z( P% H# e/ V$ `
#include <asm/mach-types.h>
) M1 o. L; y, }2 V' e# G' M5 w6 ~7 E#include <asm/mach/arch.h>
) D* S! q6 l. Y( E$ p$ V% p5 u6 O9 E#include <mach/da8xx.h>2 i5 s* x8 e2 ^% `1 H: l3 ^
#include <mach/mux.h>
, `; y8 c: x- o+ r7 c/ E$ ?7 o: v5 R1 q$ }: G( J& L
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 c) H) W \4 B3 a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* Z9 c. @! V; ^- c. K7 ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& `- K* ^3 q# i, W% D# J# F, `3 Y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* S2 j t E8 i7 }4 o
! n! P3 t4 S; v$ q. Z4 H
/* assign the tl som board LED-GPIOs*/- I! J, o: ~" k2 z' o
static const short da850_evm_tl_user_led_pins[] = {% q3 A u% {, o; E+ R i, }( |
/* These pins are definition at <mach/mux.h> file */, k5 J, }; x9 S, J' S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ v: x$ t6 P7 p9 P' C -1
5 M0 B; R( x6 n6 H1 g& u* n0 P1 b};
( Z2 ?* T8 H0 r6 V
, K+ G P- ]8 q, a) D1 Wstatic struct gpio_led da850_evm_tl_leds[] = {, V# {4 f3 K. L- e) _
{
7 f7 {+ I0 n' y& Q( X' i3 U/ ^ .active_low = 0,( T( f! e( d; k
.gpio = DA850_USER_LED0,
" Y5 a6 j- q+ H1 `9 _, z .name = "user_led0",: B# n6 \( s1 m1 ?: W4 j6 b9 b
.default_trigger = "default-on",1 f; F4 E& W! C( x/ }
},5 f8 n, L6 C& U8 H4 s$ n
{3 r5 l! l1 ?* c
.active_low = 0,
2 V0 I: x4 Z4 n .gpio = DA850_USER_LED1,; `7 t |- P! |* F
.name = "user_led1",
+ Q! X2 f9 J2 Q .default_trigger = "default-on",; ` {. G0 q6 P% `6 d t
},# c3 o. d3 s0 k% {7 S4 j6 l) J
{
0 {: S9 C' d- f+ A .active_low = 0,
( a' K7 t0 x/ D0 V; B; f a% q$ F .gpio = DA850_USER_LED2,1 `7 |2 S# a& M
.name = "user_led2",
* r) T" d, [5 u$ P6 w .default_trigger = "default-on", J9 b) m& R! {8 P
},' A6 B- m( D3 A: R& R. S2 y
{0 K6 G! r Q0 E* q8 t( C+ M" l
.active_low = 0,
/ S; r0 R' R" c v% P .gpio = DA850_USER_LED3,- y& \3 @$ \, u' x
.name = "user_led3",) R/ Z6 v9 C( I; ~, _
.default_trigger = "default-on",5 s4 L$ h8 L; W) m# Y# g0 @
},
4 p- V! A' g7 F9 y0 b5 [};
7 G" p% d G+ N. C( x- ^1 y0 |8 N7 \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; \) S/ w8 p: @+ R! B M$ r" C
.leds = da850_evm_tl_leds,
5 | | t9 h8 q. L& A .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) C3 _. g9 n8 j* y) b: W};
! N% X Z$ Y. M j
2 m% i* u( J6 x) m$ V2 ?1 y! jstatic void led_dev_release(struct device *dev)- Z! |2 l Q- ~8 Y/ m" m/ G
{: M5 ?" |' w: S
};( @7 m: [4 W: f ?' V3 q
^+ f6 D) [( S4 k' G/ n2 U& Gstatic struct platform_device da850_evm_tl_leds_device = {
2 @: n$ z* |0 L .name = "leds-gpio",8 G9 _6 O! |& A) h+ y' s! s
.id = 1,
3 I- Y- U9 ]$ K0 I) Y% P2 S' L .dev = {5 l/ e# X+ _, Q9 {( {
.platform_data = &da850_evm_tl_leds_pdata,
4 |, |/ D; X3 | h% \8 ` .release = led_dev_release,
6 ?( d1 ?- R( V" X# @$ M }5 D4 n9 u) B8 E; z" l
};/ G' a! w1 z; U8 I1 z
; |9 m+ e l3 h) e' ~* {4 u+ Q' E
static int __init led_platform_init(void)4 L+ D2 w* h0 Q; I9 A3 b3 T' k6 L1 m
{1 }. |5 D4 n( }# @5 `2 T4 c
int ret;& d. D7 j. T4 b- e E- T
#if 0; q* J6 k2 n) n7 Y2 K, X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( x' R! |2 p2 O5 S8 T, v3 L" r if (ret)! Q( u% {* y# ^4 O2 [% ?5 m0 h- t. _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 r. L- I" T- P7 h" M: V
"%d\n", ret);" r, m- \0 h: | y' y
#endif* I; S/ g @: b3 Q2 V5 w" o" h
ret = platform_device_register(&da850_evm_tl_leds_device);2 j. c) D" W' C- B0 y0 s
if (ret)% @5 n! N' B S. C7 |
pr_warning("Could not register som GPIO expander LEDS");
y8 j; S: `, _: x else" |/ M1 i, V3 A9 ^
printk(KERN_INFO "LED register sucessful!\n");
1 A, d! [% R% B$ o1 A) p
7 s2 f) m: }( b" e' e return ret;5 [- q9 C9 ?( {
}
J7 h9 d/ V P; I7 B+ M2 x
& D6 x3 Y7 M9 G& vstatic void __exit led_platform_exit(void)
8 D" n. \ S4 H{
9 {! u2 u* J3 P$ w platform_device_unregister(&da850_evm_tl_leds_device);4 F, h( T1 t# s0 t; |' V
/ {7 r; \3 Z! O- ^9 x% [. [
printk(KERN_INFO "LED unregister!\n");' `* p6 ?% w0 N- Y( H
}) N) U* ]% p6 \8 p0 K8 r" I
$ ^0 o( }/ k2 W8 ~, K% @module_init(led_platform_init);
5 r+ p, T$ t6 h! gmodule_exit(led_platform_exit);4 _/ `5 p) u3 @( \( u5 S+ B8 n" @
& S9 q$ O' j3 g0 j! tMODULE_DESCRIPTION("Led platform driver");
( }! J. o+ C3 W: ~9 @8 S2 e4 w; ^MODULE_AUTHOR("Tronlong");
0 `# G+ Z0 U& @1 P/ ?/ t# p hMODULE_LICENSE("GPL");
, }0 x8 K0 {9 J' J8 V& w$ q8 Y4 T% ]: {7 l* s0 @2 {
|
|