|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' x @/ q3 ~ M8 G5 G
#include <linux/init.h>
+ H' m6 o9 L, f, k#include <linux/module.h>
2 d! g) Z3 h# C/ ^: ]#include <linux/kernel.h>
0 ~' g3 k4 {1 y8 N2 E$ m$ Y#include <linux/types.h>$ h' \9 U u+ `3 }4 P3 x$ l
#include <linux/gpio.h>
% e; z( Y$ x) s) T% q8 S; A#include <linux/leds.h> y9 T( B& @; n/ `. C3 ]
#include <linux/platform_device.h>2 |, @* V3 w9 c1 E' @6 F3 D C9 ` q
& X; r6 }8 m S#include <asm/mach-types.h>8 C. @5 _& R* [ \- M+ L+ s3 p
#include <asm/mach/arch.h>
. t6 Z8 l5 _* y8 L0 t#include <mach/da8xx.h>
9 M) a0 Y2 y) o) [#include <mach/mux.h>9 H* A( P. n- @' `$ v4 ]- j! |
" U' b; T, [; g& `* w: t8 s" j9 s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 R' ^3 F2 u9 f8 `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 q6 ~8 {' V) L0 s! _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): K: X. N# B F2 z g0 |
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- D$ J5 b z& l ^& n( ?0 Z3 c/ h% E, V3 M4 Q3 I
/* assign the tl som board LED-GPIOs*/
# R7 k5 q- C8 i) c w. zstatic const short da850_evm_tl_user_led_pins[] = {
7 m, Z9 Z2 D& d /* These pins are definition at <mach/mux.h> file */
1 }' n2 w& ~. m/ @# H$ X9 n DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 ]" b: T9 Q& L2 E -1, [0 {/ `1 R" Y* g; Q
};# ^) a( k+ b; J+ z3 n
g0 ?3 ^! p/ e
static struct gpio_led da850_evm_tl_leds[] = {! }+ b) r. S! K3 R
{! P$ I/ L+ {5 p
.active_low = 0,0 e$ P/ F2 x( M! B
.gpio = DA850_USER_LED0," _1 o: @9 Z" o/ P
.name = "user_led0",0 ~9 X, p7 A, W) g) @: {+ x! c
.default_trigger = "default-on",% ~+ }6 y" C) p$ Z$ ~$ J' [+ a
},
9 B) R! F& q5 z8 ` {
. x. D) `+ b1 U7 W. p8 i .active_low = 0,
5 ?- Z0 [6 m2 y/ e6 ^4 i; a .gpio = DA850_USER_LED1,
" T; y5 F; s4 k: T& l2 }. D .name = "user_led1",5 W/ @* G: d. U) U" | R2 [
.default_trigger = "default-on",
. j4 z$ d2 z( v },6 t! Y1 T/ ]1 s, P8 D9 b
{
8 Q: l% V# `8 p Y. ]7 B$ H( S+ x .active_low = 0,; r1 I; W W$ B% ]
.gpio = DA850_USER_LED2, E) l Y) P* }# G6 E; t0 t2 |7 }
.name = "user_led2",
% a* |1 g. Y" y$ c" P9 T .default_trigger = "default-on",9 ^ h2 ]$ q3 S/ g
},
7 ?% R1 w4 _; A- d4 z) T) t, I {
5 ]5 ?) u. L3 ~1 l7 y* X( W/ C: C7 ` .active_low = 0,
# {6 ^' c7 O' L, s- f' i0 ` .gpio = DA850_USER_LED3,# Y9 ~ g; p/ T2 g7 l. z" X
.name = "user_led3",& i e6 W7 A5 J3 s# t
.default_trigger = "default-on",8 Q6 G8 g" S3 p$ P6 Z+ n
},6 U7 t0 K' h+ T; f2 R; v. j( _
};
9 ^& @6 L* Y9 ^0 T6 K$ Y# u4 ^+ ?( _" P1 {5 q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ k6 ]; v' j5 g8 }! B9 x% T .leds = da850_evm_tl_leds,
$ X3 ?! h+ g7 g2 b) p; }& j4 W( ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 f# E' j6 M/ T5 R$ l};
! U3 H4 N5 ^- _. i1 Y0 @; `9 Q: j1 p* e
static void led_dev_release(struct device *dev)' h& _% A" M+ x9 }
{
1 A! f( ^2 P b" x" O};
" m/ M/ a3 R+ u( h7 B' b" p; q9 G" ?* M2 B
static struct platform_device da850_evm_tl_leds_device = {7 c/ C( M( y7 R6 f7 Q! J
.name = "leds-gpio",
+ v4 p/ v) [- r1 ] .id = 1,, g! g) m& M$ _& x9 V& n
.dev = {
8 L5 _8 \# f$ ` X& u .platform_data = &da850_evm_tl_leds_pdata,/ K+ t: E( O4 g0 h
.release = led_dev_release,
0 u" R6 o/ Y- R) \" I- I5 E }4 u- o+ W; B2 A" |2 f6 [
};* P; b) l' t4 ~$ y
' H+ t3 s' a$ _$ t8 s pstatic int __init led_platform_init(void)
# m6 M5 u: i8 E/ f( W& n{ h* \9 q5 e; s3 Q8 J& [
int ret;
+ W6 v) T% {, x- L#if 0/ c- f7 q8 ^; K5 x- \
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! g) b: {' ]0 r1 R1 {# K" k/ }
if (ret)- a* q+ R. o" m, m" r+ i' G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 U" i) x& Y6 G) ?) n4 Y "%d\n", ret);9 {1 A E$ P# U1 \
#endif0 V+ {5 u* ~& v# Z4 I6 [) P
ret = platform_device_register(&da850_evm_tl_leds_device);
% _! n; O* s0 `$ W/ A if (ret)
3 t; _' f& b4 ~3 a4 c$ u0 ?! V pr_warning("Could not register som GPIO expander LEDS");0 t8 i2 ]# J9 r6 x
else# }& U+ x) |, u' Q' O& \1 m
printk(KERN_INFO "LED register sucessful!\n");* V! q3 V" c7 O7 \3 g3 n$ K
* d% h8 f+ D. d- L2 _
return ret;0 K7 l0 W, _, m+ u' q
}
0 W9 |% O8 s7 g+ M/ q+ c. g- W! K! F) u3 G r$ P
static void __exit led_platform_exit(void)
0 ?$ U U& w9 e/ O' P) y% L) _* Y, j{
8 f8 E; ]; V1 Q; j platform_device_unregister(&da850_evm_tl_leds_device);, S7 Z) \ Z$ _
6 \6 A, m! @3 `) Y2 f0 i0 v# z printk(KERN_INFO "LED unregister!\n"); P4 |9 a& Z; c3 {; M! c
} ?4 n! `+ d" ~5 {& X/ q, U' g
. U, R1 j7 Y2 Q. S; p9 @. Y
module_init(led_platform_init);2 z. H5 {% b$ Z
module_exit(led_platform_exit);
) r" e: j: @- A' ?$ V/ m: i& P' J. b' A$ m# A5 h8 e
MODULE_DESCRIPTION("Led platform driver");$ I( \9 t/ k& C Z f8 r
MODULE_AUTHOR("Tronlong");
4 c* O5 S4 u8 z! }2 RMODULE_LICENSE("GPL");" B' U0 d9 ]' U: A; n
$ l9 x* Z2 D! Y |
|