|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 K2 U, q) R$ G#include <linux/init.h>
/ n1 Z9 @1 X7 y* L' H#include <linux/module.h>
W5 w7 L& g5 W( a$ I#include <linux/kernel.h>
/ X0 g3 R% d& _) @+ ]6 F& t5 r#include <linux/types.h>+ F( O. W6 E( c, B& S m4 [
#include <linux/gpio.h>& g/ y' Z" B' l7 ~) A
#include <linux/leds.h>
% r1 K1 E0 z3 Q#include <linux/platform_device.h>- N* j0 F0 D* H7 |9 u% g
7 C5 Z/ M; R. j: R( E- \' r
#include <asm/mach-types.h>: l: R, ?" C5 w+ ] t' c
#include <asm/mach/arch.h>
/ d. u! `9 @$ t$ x& a+ K% j#include <mach/da8xx.h>) q( M1 Z" l' q; ?- I4 D* S. p) V
#include <mach/mux.h>
3 |7 m* r2 H& z" f1 H6 a0 K5 T# I4 H0 a! O/ [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 T- x# W5 a4 x
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 P- k5 e' D8 |2 m. K5 {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ s+ C0 L4 Z; [" u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! \- T# J c% D6 F2 v* V" l5 b9 I
, v5 M7 q9 O x- ?/* assign the tl som board LED-GPIOs*/8 c3 f) e% W, y, | B, }9 g' K
static const short da850_evm_tl_user_led_pins[] = {6 b6 W0 w- M& M
/* These pins are definition at <mach/mux.h> file */
6 H* a) \7 e: {, p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 Y3 m, F" [) M
-15 \. E4 S& n% S
};* t( T5 P/ v1 r! b
, H* I0 N. y2 z( O0 z L: K- R
static struct gpio_led da850_evm_tl_leds[] = {: p' B9 B+ V$ _' S) |$ Y5 ]) y
{
+ j( W+ }, T" o E7 h .active_low = 0,
7 n' m, Z$ ?+ }+ K .gpio = DA850_USER_LED0,
) h, B& B# {' A6 S0 c! t .name = "user_led0",- x* b0 e& ~, O; G k
.default_trigger = "default-on",
5 o1 t' s/ P) Y' f },
9 K5 }& i2 f) f6 k6 y" C4 A4 N( j {* C* \# Y% x1 W
.active_low = 0,: Z2 a0 ^7 o3 ?' F7 T# M
.gpio = DA850_USER_LED1,! E' a: X7 v! }0 ]" O8 X1 N
.name = "user_led1",, U" P" x# ]. K) z: e
.default_trigger = "default-on",# V+ ?( U' [* v4 ?* b Y( A) p
},
; ?0 U5 l0 D/ i: h9 a7 U {
% [1 h: j6 `( K$ G .active_low = 0,, l5 D4 D! ^$ E8 a; k6 F+ t3 p
.gpio = DA850_USER_LED2,; i5 w& N' n6 _/ Y. e; T) \0 N
.name = "user_led2",# c" g7 A$ r$ h4 @7 v5 w
.default_trigger = "default-on",- k; y1 R" a" T& [' h7 U
},
# k6 v" ?( \7 p/ ? {- J- q% \3 j8 [1 ?
.active_low = 0,
% U$ J* u- g& {9 W8 m$ j* M0 ?3 P .gpio = DA850_USER_LED3,
6 V0 C6 v& m' O- d- |& _6 l .name = "user_led3",
' T+ C; d* C0 Y0 E0 I! s .default_trigger = "default-on",
- i, | v' [ p$ o },
1 V. J, u$ ^/ `8 B. ^7 _};2 V1 S9 @* p2 r6 T
2 b w; p% i5 g: q" z, c( H6 Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 f' h9 B7 y9 C: X1 h3 Z
.leds = da850_evm_tl_leds,
+ a2 R @5 r4 U1 _' X/ |$ q1 J .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
m) t+ h" x2 T/ @6 y};4 K$ |. r# t! b1 T# q) {
4 N& {# p9 l j" U- gstatic void led_dev_release(struct device *dev)
5 m/ C* Q# ~8 Q* l0 f{" V) ?; x0 y" Y$ v F
};) m9 l* Q3 D4 N3 T
. R- P: ^2 C, }0 W3 ~static struct platform_device da850_evm_tl_leds_device = {0 e r- w- H* L) ^
.name = "leds-gpio",
) i" F' _6 g1 V1 u .id = 1,3 |# b( c! I6 O2 D
.dev = {
. u1 f* X7 l { { [( ] .platform_data = &da850_evm_tl_leds_pdata,! ]* S; G7 f8 f5 e+ ]
.release = led_dev_release,6 E3 L& C3 Z' @) f! `/ p9 \. d
} r& t- o; u7 l: r1 r
};4 }; U, a3 [ ?. x# p7 _
p5 L) Q m) s) x5 c3 P$ x5 L
static int __init led_platform_init(void)
) |, A. e# o2 X{
4 r- ~1 d: H1 }2 A int ret;
% O! X' H, b4 ?3 _5 C#if 0
5 s8 [, b8 I! S! J ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 F. Y8 c4 J. {/ b6 l if (ret)6 z/ @8 y* m' N/ a( y s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 M5 I% Y6 J. ]& w, G0 W "%d\n", ret);
5 ?5 [" v) {( X( R' Z; A; O#endif9 g# @7 W5 {, r$ O u
ret = platform_device_register(&da850_evm_tl_leds_device);
# J; `/ A% I8 ^ [& P( K if (ret)
" ?% Y( j' R! E; Q/ D- j6 a b pr_warning("Could not register som GPIO expander LEDS");& \' w; [/ }/ ?" @2 f4 y
else/ v. e$ _8 T9 L- n
printk(KERN_INFO "LED register sucessful!\n");
+ \; x: D* ?, h; o3 V! }& c
6 r! X' Y4 j* D C1 W2 e5 i; w return ret;3 T. B/ p7 r0 ~/ P6 N
}
4 D6 I; ]6 ?$ j4 g
, [# u9 I0 A' \static void __exit led_platform_exit(void)- {1 b9 l% Q" b# P9 B* x
{! \/ w4 U* o/ R
platform_device_unregister(&da850_evm_tl_leds_device);
D P R; W B. g! p+ A4 i! L8 A" V8 T5 Z) [
printk(KERN_INFO "LED unregister!\n");
, g: P0 e' L. q z) m0 W7 D}: q1 ?, G2 |9 |, i! J5 N* G
- d# u0 _; \' u7 O" s+ ~2 `module_init(led_platform_init);
: d: m' P+ y2 t& j; c/ [module_exit(led_platform_exit);& f7 J, b# i% x E" u
/ e1 S" M; h' B% R% Q3 ], {! {) UMODULE_DESCRIPTION("Led platform driver");
6 H$ w+ R& _: Z1 x* N+ |2 aMODULE_AUTHOR("Tronlong");; k$ j9 _1 a2 I
MODULE_LICENSE("GPL");
! D# {9 V; N1 X
9 V1 G3 z ~$ o |
|