|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 a0 A8 Z7 b2 k% l+ ]
#include <linux/init.h>
1 z. f/ Z) Z$ K+ A# k$ z- N) M#include <linux/module.h>0 I% k3 F! K. X' t [
#include <linux/kernel.h>
# ^% j+ e: t) H% W ` f- _#include <linux/types.h>
# y; t3 a" r- o+ e/ \4 e#include <linux/gpio.h>, K+ L0 c) m3 s) a8 E
#include <linux/leds.h>
& g, ~6 h8 L7 e7 x$ w E/ ^0 l#include <linux/platform_device.h>
% @0 G& E, P1 N7 G: a; G. U' {7 P1 H! D @0 g2 g9 Z$ p
#include <asm/mach-types.h>
4 j I" J) o# A#include <asm/mach/arch.h>
$ `0 }* c! {3 h" L1 u [#include <mach/da8xx.h>2 h( g- a3 _# q/ w: a: C# w9 R
#include <mach/mux.h>3 e. S" l2 S% n: L/ ~: D
" O8 \/ ^" z8 @. ^
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# Y$ ?9 `4 v8 n- I2 M% F
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) U. q5 z$ R5 F% o( I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 o' s: B) D: Z/ S6 R#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- y% X. f# _; \2 U: ?
8 M0 u6 p( v7 b
/* assign the tl som board LED-GPIOs*/, F, S3 T2 U! l* n4 ~& _
static const short da850_evm_tl_user_led_pins[] = {) ^9 |! B) ^7 }7 l) l8 e* @8 _+ Z
/* These pins are definition at <mach/mux.h> file */
) `: G f6 `; i) u8 | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 W& K4 T& b- s -1; I9 c. [4 e2 s) @2 d( z
};8 j/ M% G3 D5 b7 p0 I8 v. j- E. A
$ A0 i1 g) x1 Y2 vstatic struct gpio_led da850_evm_tl_leds[] = {
. v" \7 Z9 k' ?$ S& F! P* g, F& ^ {
' J8 o9 m/ R6 b/ ^/ f .active_low = 0,
: i X# S1 x3 P. P/ i6 y .gpio = DA850_USER_LED0,
! z D' m8 x. }$ o6 w& e( q3 {- b4 B .name = "user_led0",3 Q( z& j& ?4 X+ d2 l3 A. y' l: Q0 A
.default_trigger = "default-on",( V* W- e" g8 U1 i
},
5 E# N" @& a4 L4 k9 h {
# i8 ?2 g# Z2 m: _- E: Z3 T .active_low = 0,
& Q( Y! ~$ w" }9 `! E+ z% { .gpio = DA850_USER_LED1,! N3 d4 P r2 B, X7 W# H% ^
.name = "user_led1",4 Q& X( q) w" b; A' \- |3 Y, f
.default_trigger = "default-on",
0 O: |# i% U c, ^ },
9 O1 t7 ?/ ^2 k4 A6 L4 M3 N {: D$ E# f! Y- _" U+ x; S+ r
.active_low = 0,
/ p" h$ L) U' q3 H .gpio = DA850_USER_LED2,
1 @8 d& J, d8 i5 _. E .name = "user_led2",0 I6 k+ `& @1 F7 o5 Z
.default_trigger = "default-on",
9 x6 \# Y% L* M },
" ?0 N! C0 J8 s7 B" k, l8 Y6 _8 E9 h" w {- i" U, C/ v% t8 @0 y5 o
.active_low = 0,
* m- V0 B- Y( s* M9 R .gpio = DA850_USER_LED3, k1 m. W+ Y U. B% a
.name = "user_led3",
' ~# C. h( n" Y3 t; w! @. u .default_trigger = "default-on",
8 R# W$ _" Z @0 g4 {% X$ F },
, r) f$ u$ b3 ~# E. l};
$ R$ z( U8 Y7 t, \& h6 ?
0 |0 d) i7 Z$ O& \% P9 Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. e# Y$ z! g1 m$ n3 t* ` .leds = da850_evm_tl_leds,
; t* X; Z! U- d f .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- D; F% a) b9 l$ f6 B# S};0 k9 M; i6 [. M- c
& Y: X! s6 `+ H1 T# gstatic void led_dev_release(struct device *dev); y( P9 z \0 |# v' y
{
& h8 x1 z( ~5 }};
! m9 r7 F7 I8 E6 U* R' N2 q
0 J5 _& ^2 P; x8 cstatic struct platform_device da850_evm_tl_leds_device = {
* F% c3 [$ [8 ^, X .name = "leds-gpio",, A& s- T# ^' \' B
.id = 1,
5 x( ^9 U* v; \ .dev = {" [) x& P% f$ G3 g% \; e4 N7 {) r i& J
.platform_data = &da850_evm_tl_leds_pdata,
+ a1 d3 B# \( g [ .release = led_dev_release,) x0 _( D- c5 h4 H" ^
}, Q& r" @ Y; z& Y5 \: _
};/ f! F5 M3 f+ b' p. M; d m1 n
; o$ u- K9 O4 E3 r' \* C
static int __init led_platform_init(void)
1 I, m$ }; p2 g1 `& x{/ w* s" k% P" ~5 e+ r
int ret;
S: H" r% e7 R1 S1 P; R! w#if 0. A3 L7 k0 J( B# v& n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 V. |/ M, k" w' @% l: w6 z if (ret) E6 X9 ^/ a- e/ m) \- Q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! U3 f& {1 K: c; p "%d\n", ret);& k, E% C+ Z6 i- F. Q$ J4 l
#endif
& O" R# Q S7 w) m ret = platform_device_register(&da850_evm_tl_leds_device);0 U+ w' \; V1 p7 K& J8 f1 A
if (ret)2 D/ [- D r1 ~; p
pr_warning("Could not register som GPIO expander LEDS");
5 F# Y9 |; J, m+ d6 V2 A else
+ H) y! h/ G/ b9 N% ` printk(KERN_INFO "LED register sucessful!\n");1 N. ^ y0 T' o; d: _! T' d
) q7 `/ n7 m! I' i8 ?, v8 f3 `% j3 A
return ret;$ I$ p- H& p; e, H9 W' k
}
9 q; C# \- [0 l/ S: m; M4 k1 F
- J! Q0 I# Z. c" J( X- Astatic void __exit led_platform_exit(void)3 f9 ?+ w0 k' c' E/ ~& ]" b
{
! l5 X0 ^3 X. S7 j platform_device_unregister(&da850_evm_tl_leds_device);
4 B3 y7 K" I" |" u: J" M
+ A+ Y& p0 J( `# D7 o; _: u, ] printk(KERN_INFO "LED unregister!\n");
7 m; r/ t( D& N$ z}
/ I/ ^( B+ w* ^7 _7 s$ C0 ~
5 \3 q: F+ J4 i3 c7 s: u$ bmodule_init(led_platform_init);: p6 h+ T* ~/ f. o7 A
module_exit(led_platform_exit);
, u, j4 E2 I% @: a+ d0 M: M2 B3 A7 M: r+ k% i0 F# `; T, D
MODULE_DESCRIPTION("Led platform driver");3 o9 l; W8 u/ g1 H0 s) L2 d( j& z
MODULE_AUTHOR("Tronlong");
% b/ Y, R9 d$ m% H1 R" s8 VMODULE_LICENSE("GPL");
. t7 Z' U% R2 j0 A8 `
' `+ }- c$ i* s# u |
|