|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: K9 C/ i7 e3 j( Z" x6 Y/ ?
#include <linux/init.h>
, ?7 {% E: L1 o#include <linux/module.h>
! w. {* W' H; k8 F' n4 X' K5 [#include <linux/kernel.h>
4 \ {' l0 U, ]#include <linux/types.h>
) O5 i" O0 U e0 H/ q! _6 d4 m# Y#include <linux/gpio.h>
4 h1 J! o i. ]# I! D#include <linux/leds.h>2 J r& l/ S9 G- F2 q% e
#include <linux/platform_device.h>, h8 f; o9 Q# n
: t9 }# ]$ h" U& _% p0 @! {#include <asm/mach-types.h>( W! c$ N3 ~7 \1 a
#include <asm/mach/arch.h>7 k, Z" }! s; g; W z3 e
#include <mach/da8xx.h>
& Y: h" e( D# P S0 P% T#include <mach/mux.h>
+ \" V% z) D7 ^: B& J+ s' M3 q9 W
4 K3 }* ]. E1 X4 T+ [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( {+ X1 ~& W8 M& M" p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 s1 N0 L0 ]! w. Z! Z) p$ h#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 M' C( {2 l! p- F) J( `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. o& C7 z" G* v4 S1 K' w, I7 g' ^" e
/* assign the tl som board LED-GPIOs*/- \$ f, H# T$ A- N% o: ~# Y* Y
static const short da850_evm_tl_user_led_pins[] = {
9 B6 f9 k% C3 e5 F- [ /* These pins are definition at <mach/mux.h> file */
' X# j. D+ I# V$ ?9 s2 Q- j, m6 ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- C. o/ T( F* v- \
-1
; N3 Q0 }- J( z0 Z# R: G- l};
) N& m! A6 E; |9 s3 b) k/ `' ^ M- T( @7 N
static struct gpio_led da850_evm_tl_leds[] = {7 Q+ K% y7 u1 U% A- z E
{
) g, X; N3 I3 V5 b/ G; U7 n! T .active_low = 0,
0 p" G) @! D+ p6 ~# y: g3 m# U .gpio = DA850_USER_LED0,) i4 B3 N. v3 D) m
.name = "user_led0",
* `6 n/ Q' u7 \4 x$ i( Z .default_trigger = "default-on",
" _, [; O7 m. t; A },8 r+ Q% f" f0 i) e# _8 t1 o
{7 X5 q1 V9 n- M( E; y
.active_low = 0,: g: V. }( F' e% ~' D: E+ {
.gpio = DA850_USER_LED1,
( O6 ^# |! t: Y1 \ .name = "user_led1",
# U5 D; E' q$ J7 D8 p: n .default_trigger = "default-on",
" K- J% V1 z% y/ L, J2 h8 ? },. q1 E1 G6 v- n6 ^/ X. u
{
; k' Y# R9 g9 w: D .active_low = 0,
% J/ N" J7 [5 l8 ^ .gpio = DA850_USER_LED2,4 Z. s: S7 Z3 v1 m a# z4 b
.name = "user_led2", J$ {$ K# C0 z" D% m
.default_trigger = "default-on",
7 ~, r& O- f9 K0 T: t+ {' [' T8 V },- w% F+ u! r0 N# E9 v3 ]$ C) h
{8 g$ q' p& d% q% B2 T
.active_low = 0,
) s: O- w; w& H .gpio = DA850_USER_LED3,2 e4 `+ Z% I" \- \7 g/ M+ e7 ~1 q$ g
.name = "user_led3",+ W. N) H* m5 X( O6 S2 ^" n+ p' Z
.default_trigger = "default-on",
: I/ C1 j; C! t },$ v) J8 Y- `) j7 l+ l6 x% J
};
3 e/ n; F4 l4 d5 s" O% @3 N, i) n- v' S! }) ^# g( E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 C1 g; H4 _' X( E6 |- Y .leds = da850_evm_tl_leds,! Z" j/ }! [& Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: V7 c+ q; ^7 r: r
};: D( D _& e7 O( R
4 e1 H9 f8 w0 n5 @
static void led_dev_release(struct device *dev)0 k3 ?+ J R; s W+ O9 c! Q
{
& i" j9 {/ y2 v0 {, a6 Z};) a0 E& q' h8 F( v1 M! q
. I* R" G+ A9 M7 C6 j9 |" I' i
static struct platform_device da850_evm_tl_leds_device = {# H. s* p- p1 O1 \, p
.name = "leds-gpio",
. J! o/ d2 l0 ~1 N: Y2 G .id = 1,0 [8 Z# W& B$ L' g
.dev = {
/ h& ^; w5 o" F4 B: }* |7 V .platform_data = &da850_evm_tl_leds_pdata,, E) o* C, ~0 x. L( f) c
.release = led_dev_release,
/ x- H. O/ M- f' |3 @. _ }
0 _! |6 J8 X' Q. ~! F};
; e- b( N% E' b; P0 N2 U+ v
7 \# w K% @* j/ tstatic int __init led_platform_init(void)
5 u, W8 S7 X$ x" k{: m3 r2 w, n! ~9 p5 i
int ret;
}( V; L7 m9 j0 J h5 t5 u5 A#if 0. J! d; X5 A/ {9 Y) e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, ~$ ^1 F- Q+ e
if (ret)) N9 l7 G2 w7 \, n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* R+ k* I+ H0 C4 X, h "%d\n", ret);
& ]6 ^: c; ?& A5 P+ m! v#endif
6 c# V# y7 g$ O# ?+ T" v ret = platform_device_register(&da850_evm_tl_leds_device);
0 n# B8 Z" F, T6 l if (ret)8 z* N/ H2 ~$ e4 }. P
pr_warning("Could not register som GPIO expander LEDS");
/ F& {: K; M# ?& i else
% z" P& l! g8 X9 e( s printk(KERN_INFO "LED register sucessful!\n");) N! i! h+ @! U! [' K
* ]( ]$ R B) {: h
return ret;
* G) S0 Q2 S. ~}
% _# Y6 Z6 S9 J$ q: r: @; W/ x( H* `' ~$ S
static void __exit led_platform_exit(void)( V4 W$ l6 w3 p/ B/ U8 @
{5 F0 G# x. P1 W$ D1 D% ^
platform_device_unregister(&da850_evm_tl_leds_device);
6 j8 L6 Z5 i" O6 w. w/ k9 S
! p6 i$ I& l% n7 r7 p printk(KERN_INFO "LED unregister!\n");3 R& \7 U3 i% y" X6 V" ?) ^) B& ^
}
\" u' H+ w* {3 G9 M0 F8 _' n! f3 G) }1 M0 v( H }! I6 L) U
module_init(led_platform_init);3 m" X( o4 G, f4 }( \
module_exit(led_platform_exit);
" F6 v( w u9 k9 X- M) U( `. q1 G% A6 D. Y B
MODULE_DESCRIPTION("Led platform driver");
4 S! I' a/ V; m/ EMODULE_AUTHOR("Tronlong");
+ L$ [9 D( H7 Z* g, _MODULE_LICENSE("GPL");
1 X8 U' ~5 B1 P$ s Q/ U$ J# S: K+ @# R: U" c& ]+ J& n* B/ ~
|
|