|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 e7 m3 n7 g/ Y#include <linux/init.h>" W X. m; c. U' f2 U0 x
#include <linux/module.h>
; _! w( h; n1 a% p( I# q* q1 h#include <linux/kernel.h>+ Q: _, k% y3 f8 z
#include <linux/types.h>
3 L+ a2 `$ j9 ]0 B( L% b#include <linux/gpio.h>
' c- e$ v& ?' J n#include <linux/leds.h>' K' X: _# b; n$ u+ F% W, a. v
#include <linux/platform_device.h>
) \ d6 J6 K' W" t( \( ^$ e: \% ^$ K: t! R! u- ~. Z7 M
#include <asm/mach-types.h>
9 w5 W E. F2 I#include <asm/mach/arch.h>
9 t4 ?& D. f' i#include <mach/da8xx.h>
$ c5 ?! j2 l% j/ {7 m/ o( i3 ]#include <mach/mux.h>
2 m# h: k+ Q: a+ ~, u7 U( z G; t; \& ?7 e* p% X+ _* s2 o
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 M7 h6 m7 u5 X; v a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* r3 K& _; O4 {#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* T$ B, J, g! i6 _
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ ]6 T" {) F; ]% {/ B
' d+ ^9 W" M, @6 c) F/* assign the tl som board LED-GPIOs*/5 o! k5 ?2 K0 g8 t7 a
static const short da850_evm_tl_user_led_pins[] = {
$ H) Z/ ?4 E- j: D /* These pins are definition at <mach/mux.h> file */6 \$ W: V5 N) d6 O+ ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 e" r& I U V' r, q# [4 u& u
-10 `1 n5 M5 L6 F
};" a% H6 l& t9 `
$ X8 i: V4 Y) i
static struct gpio_led da850_evm_tl_leds[] = {
6 O# M _8 e: ]% N {
0 }% C4 b% a% ~# |6 [ .active_low = 0,
& K9 M" n2 z! N) j9 J .gpio = DA850_USER_LED0,$ q3 f) K, Q* I% Q3 f6 B# ~! Y
.name = "user_led0",+ ~% H: T/ V2 k& @7 X8 [, a
.default_trigger = "default-on",
' |* Y% n& V4 q6 |3 Z },% T( Y8 \6 B! l% t7 h
{
1 f( Y; {4 L/ X; i .active_low = 0,
% J! X T& T$ ]2 g: t4 A- h& Q .gpio = DA850_USER_LED1,$ u l0 ?9 ?3 X3 z* p8 Y5 B
.name = "user_led1",
0 V) _; Z( f2 _4 o .default_trigger = "default-on",
% k$ g4 G2 s7 T },
4 ?% F8 Y% N, y2 e; R; i: M3 J4 Y, \" Y {4 G' l: @9 U$ L% E
.active_low = 0,% ?4 H( z0 Z0 {( w) h& o( A) N
.gpio = DA850_USER_LED2,% P# L" ^3 F& ?7 ~) f! ^ h; e9 W
.name = "user_led2",& X, l7 J2 I& J7 i; b
.default_trigger = "default-on",
1 `) k* w5 a2 r9 D9 I },
3 C8 D* t9 b+ Q; |+ @ {
" f- X6 T; h+ x) _/ Y7 m) k .active_low = 0,
+ r8 P: _7 t0 B" ^ .gpio = DA850_USER_LED3,, q; ]& E) `: F2 A: G8 n
.name = "user_led3",0 T% T7 m5 ]9 Z4 y( M
.default_trigger = "default-on",
7 V! l( x# x& A8 H% m1 b' ? },
& U" w5 Y+ g% F% W3 C};4 U9 O6 E. J: l) b/ T7 d
6 S8 s3 f J- k3 e9 E0 Z0 G0 m' {
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! G/ N+ ^3 i; _3 I$ I
.leds = da850_evm_tl_leds,. `2 W6 V. E+ [0 z7 \0 D" ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 r8 E6 V4 F6 Z/ ^5 C* @" B. y
}; I7 M, i6 i2 D% Q
, |7 b. [9 n5 r% e4 v
static void led_dev_release(struct device *dev)) c: d8 F) i2 D. j( I2 {
{
' H( {" K! \8 U& H: G};8 p' @, J9 D6 v
$ `# E4 L3 f) K( h2 b
static struct platform_device da850_evm_tl_leds_device = {
y8 N8 N' x- @9 U' M# v% S& |' S .name = "leds-gpio",% w0 [5 A8 L2 F4 w* e- `; ?* u
.id = 1,6 Q' k( M9 y! y
.dev = {9 {- m4 l5 \, d% P* G6 J% k
.platform_data = &da850_evm_tl_leds_pdata,: b- `6 ]! F/ U: J
.release = led_dev_release,( i1 I, z- U+ b
}: p" @: l {3 g4 ]: Y8 G
};9 ^! b! f* @4 ?# `% B
5 d4 I4 ~3 V) C7 I+ ?
static int __init led_platform_init(void)
5 D% X' b8 E! j! J# f0 ^{
2 ~+ P) V% T( o' w1 K int ret;
$ L0 _1 b9 ? K" J* N#if 0/ `& B% O" t7 t0 }% u
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 I& `1 `& f1 r" x
if (ret)
- D3 D5 f$ x# S" d pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 _8 K, ?! E4 ?' L5 }. C J. k0 n0 K* d5 A "%d\n", ret);7 X. G- S" P+ M4 N: C' V
#endif" H9 @4 ?# G1 G
ret = platform_device_register(&da850_evm_tl_leds_device);
k# t- \& O4 p; K/ M6 K if (ret)
, h" \ t9 x; q: S# V pr_warning("Could not register som GPIO expander LEDS");- M0 b+ z( f# g% T9 L
else
8 j: p G; J5 A, C& n- Y printk(KERN_INFO "LED register sucessful!\n");. e3 f- F) o- F% B: y. W
- L. U7 U( N7 c: G3 t' `/ q8 d) ^5 q( z return ret;
# r6 P3 z: W5 A5 P} Y$ J4 X; d( a5 {+ ~
4 K; U4 ~+ Z: x- w& e5 Ystatic void __exit led_platform_exit(void)* l: j6 G) U5 b* J3 ^
{% m$ `2 e% j& h% a0 E# w& h( W
platform_device_unregister(&da850_evm_tl_leds_device);
% w) c! R8 i; p! y) ^% F( n: u2 b
printk(KERN_INFO "LED unregister!\n");
' S+ {5 m: x2 F( B4 o& Z}
* G8 v- Q1 X0 |: D& n
; n2 A [2 E4 {% ]4 omodule_init(led_platform_init);2 w8 C1 ?0 Z9 J5 Z I
module_exit(led_platform_exit);* I& [8 P+ w8 e5 O, I
0 b8 I7 `7 G7 ZMODULE_DESCRIPTION("Led platform driver");
' w/ L4 D% [, W3 n2 h" t- QMODULE_AUTHOR("Tronlong");
* ?5 b1 G+ |/ O* o0 P: y- FMODULE_LICENSE("GPL");
. L' T' A7 c5 y7 Q
! z2 a$ ?! ]( _* Y |
|