|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 M J7 J; B& `" P( z, k#include <linux/init.h>
+ {; d& g* O% F8 h2 _#include <linux/module.h>
9 T+ i9 G9 d% X- ^) O. I, a& h#include <linux/kernel.h>3 s/ l! E3 F" S4 L, E
#include <linux/types.h>
5 F5 _: { i+ k5 {#include <linux/gpio.h>
3 o' C- ? L# O/ k& r; j( \' K#include <linux/leds.h>
" X7 _+ ~! u% ]8 b* p; C2 p#include <linux/platform_device.h>
- e7 L$ }6 X1 H7 a; E/ x
: j, D9 l; C* e# l7 B7 e, d: O#include <asm/mach-types.h>
0 D& h6 V2 A' S, A s#include <asm/mach/arch.h> d( g0 @. g! r
#include <mach/da8xx.h>' L; g% B8 d/ Q e' u+ Q
#include <mach/mux.h>
) k7 k! H# \. M1 u
8 s; M. m- ~; @5 g o' V m1 A#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, Q# w* a6 @" F' |" p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); [; p5 D) V; ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 P3 C; F1 j$ A" X3 J2 B" L, }! e#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), O2 s1 `2 \. D! t8 A5 Y) N! a
5 j8 p. t0 [ P# u
/* assign the tl som board LED-GPIOs*/
/ I, z) L2 Z* Q; w, D9 h' Y# Rstatic const short da850_evm_tl_user_led_pins[] = {
! c1 e7 w* k) e /* These pins are definition at <mach/mux.h> file */; F5 W f0 F/ m9 u3 w
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ B: A4 Z1 D- d K6 U7 C4 R4 h
-1
8 q, v6 {. B; R8 R- p};/ M0 ]6 q6 a% {" l' r$ h
/ r& Z2 k' P5 ~7 i, J; _3 o0 Nstatic struct gpio_led da850_evm_tl_leds[] = {$ x7 }7 w! L. P% s% F0 U
{' r& }1 K5 Z* S
.active_low = 0,
/ V1 I% W5 n3 m! M- y .gpio = DA850_USER_LED0,
1 Z8 H9 }/ h0 p' A .name = "user_led0",7 T3 M1 g/ |1 k0 s% x
.default_trigger = "default-on",6 Z' U$ q; Z) O6 `
},
& T2 h2 ?3 H o0 [9 s' {" h {# O+ K0 X5 {; Y
.active_low = 0,6 a- l" l7 c8 U5 J" V1 r. H0 ` y7 X
.gpio = DA850_USER_LED1,
' ]# k3 k* O u. `( K8 K# ] .name = "user_led1",
- {$ {& Y. K Y6 K .default_trigger = "default-on",
5 d' ~5 q6 G; }" G7 I- Y! T },- |: s0 Y5 s! a7 r" k
{
( v& {( ?; V" z A' @/ { .active_low = 0,* @3 X- W8 W" N
.gpio = DA850_USER_LED2,
; e5 |1 v, R7 v% B .name = "user_led2",: n' k' Z- J+ K% @
.default_trigger = "default-on",
3 }5 ~1 R6 m8 H },
; I+ S) {1 ~- f6 Z/ T- C { P. u3 E: l6 o4 [+ r4 B
.active_low = 0,1 A& P5 U0 A2 w
.gpio = DA850_USER_LED3,
0 M0 h0 o( y/ S: ? .name = "user_led3",$ q: E( A' S/ O: N
.default_trigger = "default-on",
# o9 \% e7 C& G },: H* J9 ]1 r1 I$ R: u
};+ q) b2 n7 C' u: U& F& c
" ^9 m' P6 Y \8 l6 ?% @$ jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& ^8 P; k: E' g! c' Y
.leds = da850_evm_tl_leds,& t' j2 t3 y! ~" H; P2 s. t2 }
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ C+ `3 }3 o# D2 m* V# K* E};
1 `; O! O" E4 |/ h$ l$ V: I9 U$ p3 k! i( B7 C+ Z3 s+ A3 P. D
static void led_dev_release(struct device *dev)
5 u! A3 v$ x5 B+ K' q2 s+ z$ h6 {& R{
V5 I4 u0 i; u" b4 s};. W- _! G1 w2 _, T' F- t8 P& V) @
^% |$ l, d, D6 c$ @- Estatic struct platform_device da850_evm_tl_leds_device = {
6 n* R0 D7 ~ \% l8 `7 l7 ?; } .name = "leds-gpio",
* M9 P1 a) O; i' Y. B6 c+ O .id = 1,8 Y9 B) x- T) Q) U8 x; Q
.dev = {" q0 T0 B5 `+ @% Z0 v J5 X" D# l D
.platform_data = &da850_evm_tl_leds_pdata, J& O2 U5 R0 ~: w' q% |
.release = led_dev_release,
2 F' N' |/ t2 E9 A+ S3 W }
4 U- N) C1 C; T! x};
* v7 H. a- G: ]6 E, R4 g% _7 _9 k% u5 c& S
static int __init led_platform_init(void)
0 w5 o& [7 ^) U B7 j) Y- k{8 v* `+ D5 o/ C" G
int ret;0 |* @% L9 [$ b8 g9 s0 U3 N
#if 0: a7 E* C/ m$ C4 y; B& Y# Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( w, \6 S9 L) J4 o* A9 ^# j
if (ret)' c! \% ^3 [5 F, L8 @) R" p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 L7 N# U% d! ~ "%d\n", ret);: \0 R2 `, y# Z, d
#endif
3 M6 A7 v5 N" A$ B ret = platform_device_register(&da850_evm_tl_leds_device);& U- Z3 J4 c7 r K' X
if (ret)6 b c) Z. p: T* @1 T# s
pr_warning("Could not register som GPIO expander LEDS");& e, P7 f) ? o
else
+ O# W2 u4 { P+ {, P" C5 { printk(KERN_INFO "LED register sucessful!\n");: N5 t+ V1 ^! X+ y8 |9 C
* b. G& |% H5 V* M9 B return ret;1 R4 w! R( f) X# u0 d% m: p% n# q
}
+ Z# S2 a! \/ Q0 y4 J7 c, c( M( @& B' I* @7 l% C. y/ E
static void __exit led_platform_exit(void)3 I; L; n- |/ b8 O& L- o
{
7 r2 i* M9 Q- y( S platform_device_unregister(&da850_evm_tl_leds_device);# x) @* n7 F4 e& q* y6 d* r6 C$ @0 P
1 W( v$ j! T, w) y printk(KERN_INFO "LED unregister!\n");# C" G. t A/ z$ I$ z8 p" M
}- Z* m0 A2 e2 T5 H6 X# i; f
: M, ~5 n3 R# I) `module_init(led_platform_init);! ~1 ]! M# e4 l9 q
module_exit(led_platform_exit);0 I7 v7 J5 e/ V
6 F; ~* q- t, Q. X$ H" m; y! U7 JMODULE_DESCRIPTION("Led platform driver");$ y& f1 _6 U3 M4 {
MODULE_AUTHOR("Tronlong");
5 j. e- v( E4 G o3 E [0 y8 m1 n# YMODULE_LICENSE("GPL");
0 V: x8 T% k+ G+ S% H1 S$ O! a/ a# U1 h
|
|