|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ W0 @5 `1 z, w& C# } ^#include <linux/init.h>6 D% p) Z. Y7 U4 u6 S/ {* U
#include <linux/module.h>
0 Q5 o, B! b# q! J) d#include <linux/kernel.h>( A0 x+ D+ _7 B# K7 N( T
#include <linux/types.h>
% g' H& F/ j- y6 |8 X B3 S6 H#include <linux/gpio.h>
4 }# y ?" O7 V* M" z4 X1 J#include <linux/leds.h>
8 P6 U+ ?1 l) @1 u5 I! Y#include <linux/platform_device.h> R# ?/ ~5 v4 j9 l& m F
; |' E3 G5 I" B: s#include <asm/mach-types.h>" U* y/ q; h; d, p
#include <asm/mach/arch.h>. l7 K2 a/ X1 T5 g; \, m3 Y8 e
#include <mach/da8xx.h>) i# {: A6 l- q8 w% }- i- n) o
#include <mach/mux.h>
* t" m/ a3 V8 Z8 n: c
~4 w1 L& `+ r3 z, I1 V#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- ` X& h* ~ u
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) P& M4 C- J+ [9 D+ r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( _ \, G$ ~% x3 G. A/ V#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! |' |1 t1 n. I- m/ u
8 I8 |( \9 V4 R: b9 G% J- e
/* assign the tl som board LED-GPIOs*/9 s$ x8 D! l5 D3 h
static const short da850_evm_tl_user_led_pins[] = {
5 A4 G9 V) L( d' m /* These pins are definition at <mach/mux.h> file */
/ s6 w/ N( [! o% S# R5 i" D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% \* o/ C. r' T4 A0 n { -1! g+ C' b' e7 T% S# \' R4 U S
};" z; k* }. s# E$ F6 u; t! i: W
, W3 c+ } _9 s: w |static struct gpio_led da850_evm_tl_leds[] = {
7 f$ \" \; f$ v2 R) b; M9 E1 W K {
* {8 ~- U- h, s9 O+ C( A: P .active_low = 0,- G; d/ t. j9 X' v" b+ h
.gpio = DA850_USER_LED0,
* R8 d9 G# i6 W0 P8 T3 L .name = "user_led0",
2 h* w+ \' c, r3 h3 H& w- k .default_trigger = "default-on",
9 g/ A; ~2 X8 ?( \8 q },
6 ~8 s' u: l4 A; \$ A {6 _0 W# c# @4 ?
.active_low = 0,
1 | m5 v( j& ]. e+ t3 { .gpio = DA850_USER_LED1,& Y2 b0 B& g" b O3 a' y
.name = "user_led1",
$ @' i$ w( G# O4 K" @8 _4 u. X .default_trigger = "default-on",2 d& b; S4 B" q: G9 D3 b2 @
},* s+ t0 h3 |1 y: J/ h0 k& {
{
; `: O- r4 |% X0 K) o2 [ .active_low = 0,5 Y1 Q* K+ z" G( z
.gpio = DA850_USER_LED2,
, ]3 a; l* w1 Z' v. O3 ^6 h .name = "user_led2",
3 f) }* w7 G9 Q3 v3 S .default_trigger = "default-on",
$ D; O+ I: H% K; u& X/ ~ },. N7 q1 P8 B" P7 G( x+ U4 [( s
{
: N6 m; y/ }" ~/ ?$ T9 f2 m .active_low = 0,$ x$ d" ~. Z+ D( N
.gpio = DA850_USER_LED3,
) K: O: a' I. [ .name = "user_led3",5 W V" c. Q7 n X9 ^0 D/ A
.default_trigger = "default-on",
6 e# u1 ^5 r4 c( \ },
1 ^ V7 |* P7 J4 E3 S: F5 B$ T5 d};' C+ E6 U) d/ ]3 o1 e9 T
2 H% s$ w0 R$ f( p& y- s7 Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* H3 u& v# S, o2 \; B .leds = da850_evm_tl_leds,
/ f4 r/ Q0 W/ q# Z0 j9 K& [ n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 @* j) \6 C% }2 v
};
& s) x% h( B7 t
/ n& F3 P% n6 M1 d: ]; |# nstatic void led_dev_release(struct device *dev)
7 _) {* q+ Y& F2 a# n) u$ s0 k7 L" \{) A$ F8 l# f% p
};
! J0 m; A5 U; k7 C. Y4 ^4 a2 y* Z
static struct platform_device da850_evm_tl_leds_device = {
^ Y5 X2 j% \ .name = "leds-gpio",
/ y9 ?& q% Y$ H O .id = 1,
* a! e. M% ]4 F" R .dev = {
; M7 T, _! G9 t2 A/ y3 ~; W' F .platform_data = &da850_evm_tl_leds_pdata,
+ T' H w* t5 L* ~ .release = led_dev_release,6 W; }. t% M3 R$ _: F* i1 K& G
}& _' ?9 q2 |# |. U" t3 L; |! e
};
: d: I# v; U- k6 u
) t% D5 |% f) Y" w& _2 Tstatic int __init led_platform_init(void)4 Z) s/ c! N1 L3 y/ X
{
7 v! f2 T% p3 W8 ]# j% `9 ? int ret;4 ?4 y# f) q3 o$ G/ m
#if 0
, ~) K) A8 T9 { ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' `; ?1 e: [( F7 _. f( J
if (ret)- a6 \$ O* w5 r- K3 ]2 d& l& E
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. y) j6 d o0 x1 H* d0 K4 w. ] "%d\n", ret);
E' l8 l9 M1 T u& q5 h0 y" H Z#endif
) p) @, ^- |8 J( i# d ret = platform_device_register(&da850_evm_tl_leds_device);
" Q. g: ]8 d5 Q* u; y& c( Z9 B+ J if (ret)
. ~2 r% O# `* a$ B; p) u pr_warning("Could not register som GPIO expander LEDS");
% x" K' d ], t$ a- W else
7 x" x+ L5 T" T, Q printk(KERN_INFO "LED register sucessful!\n");3 g, Z o3 Q& X! H* u
7 d- Y3 L5 x! T0 ~ }# ^
return ret;) g0 `0 F/ D7 N6 z2 Z
}
, S F# @7 G+ S$ h1 P* C' N/ N% Y6 Q5 s: t' a
static void __exit led_platform_exit(void)# ^6 h% {' }% s, ^+ m9 u" s
{
& M; w& h6 L" o9 M& @! \5 d7 ]) V0 u5 J platform_device_unregister(&da850_evm_tl_leds_device);
0 c1 `% ]" ]6 T1 N' J. l- C9 n% V" n# k" N. u; ^0 S
printk(KERN_INFO "LED unregister!\n");. Y- B+ p g$ V, X. G$ l7 o: ?
}
6 E1 Q$ Z/ U6 `4 [# E. {' {: i/ C: _0 _" D
module_init(led_platform_init);# M9 `* c' ^9 ^
module_exit(led_platform_exit);9 a1 a/ w7 [7 Z! e$ j
# m# _0 {/ L: f- r$ I' t
MODULE_DESCRIPTION("Led platform driver"); W; l0 \1 w4 R: r
MODULE_AUTHOR("Tronlong");
6 G0 a0 o) I6 d+ c" I4 ?MODULE_LICENSE("GPL");
' J* E) z0 U$ L' d" t9 U0 R$ k2 D$ M( y$ `" J, h
|
|