|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' e" R1 K8 p7 }1 ^5 i: t/ x6 S
#include <linux/init.h>
* l, S c* Q: G) A! `# j#include <linux/module.h># I! e! P+ q5 @* w+ h. C3 x
#include <linux/kernel.h>* Q6 I" `- z1 s. W$ }9 C, z [
#include <linux/types.h>
/ u) H; _' P) `7 S" \+ M#include <linux/gpio.h>; G" O" m6 b% p8 t% N6 z4 M% H+ j, d
#include <linux/leds.h>8 x7 n5 ?6 W& Z5 Q
#include <linux/platform_device.h>" U* x. [ R9 @; ]% I
0 x5 E- S6 Y7 V' M/ c#include <asm/mach-types.h>' S' c$ F0 [- V$ c) s$ a1 U
#include <asm/mach/arch.h>
1 x2 v# m# O. @9 W9 i% W) Z Q#include <mach/da8xx.h>
) S$ [' b8 x/ H5 g#include <mach/mux.h>
. B/ t- ^, {8 ^# `5 A2 Y1 E9 C) Q! i
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 U8 z' U2 B! ^ |6 y- x% t' o8 j#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). T# ?2 A3 n* ]* X& o& S) N
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' F" f, A7 b8 ]6 O/ a! r5 Z; x& o& h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 ^5 I! Y- w- M6 b2 [$ q# Y; T) e! D( k7 r. w
/* assign the tl som board LED-GPIOs*/" f' H6 c% e8 w/ U" e
static const short da850_evm_tl_user_led_pins[] = {6 S) N+ o$ N$ @1 b1 D
/* These pins are definition at <mach/mux.h> file */( C, J, [6 i2 n( W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, k/ l& Q& X( [ -1
' T: [% |9 Q9 w};; `# T( M; x& A
5 o1 F3 L: g& w0 m% ?, j) [static struct gpio_led da850_evm_tl_leds[] = {
4 P5 n' u/ _3 `! w) n; B* [% C$ j {& [8 Q& B6 t. g: T- d9 }
.active_low = 0,4 h8 n7 ]& k5 E5 c/ u" H
.gpio = DA850_USER_LED0,
3 \. K& V, A/ r0 i .name = "user_led0",; u# C! D/ N* i' D. ~3 M
.default_trigger = "default-on",
' d `" K$ Z: U" q },+ n' t, i' M0 J4 B
{& z, p* G" a+ @# t' L
.active_low = 0,* r" f# H& l% f' h8 h
.gpio = DA850_USER_LED1,0 d: B. [3 h# a9 K8 h
.name = "user_led1",
1 l0 H; l. j7 |8 v+ L& {$ `. R8 o7 i0 @ .default_trigger = "default-on",: T5 ^& | f2 c$ z2 p
},
1 _3 T5 \6 Q& K) K* \; w, M {
2 U0 X( B7 e2 H( v; G5 W. O( R .active_low = 0,2 M: D* M2 b6 g& E& r6 ~
.gpio = DA850_USER_LED2,1 N' T. x: b8 k+ d6 L
.name = "user_led2",
5 E! r% \! H' \4 R5 |5 h .default_trigger = "default-on",7 J, W: G' w. J0 I, L z
},
; \* j' ~6 L( [; z {
) D4 F0 }$ k$ x, i .active_low = 0,
6 j* ]$ Z7 d6 `, s- }4 L7 l1 d3 ^; \5 g .gpio = DA850_USER_LED3,* x+ Y# t$ n# |+ I t0 c$ Z
.name = "user_led3",& r0 I5 B+ b9 G4 A
.default_trigger = "default-on",
/ _* _# r5 O. H* p },
& C6 W4 Z+ Q$ N};) M2 v" R* H7 h* R/ J
3 f& Z$ E2 |- d# a# {6 v8 Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: J2 q" r1 \; F6 \* Q% n .leds = da850_evm_tl_leds,' Y2 ~( F2 ?$ M0 w9 O7 r; g! z2 x8 a; R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 U' p0 w% m! X) \* i};
5 f$ M0 _' d3 s5 O. J" P( ^ I7 Q0 w0 P! z1 E% ~+ f
static void led_dev_release(struct device *dev)
' e6 b" Q0 X0 {+ V( Y E& H{
; g/ a8 U/ k y0 K- z" d};
8 a r4 v! p1 T" ?0 d) ~
! ^1 n* S/ |7 o% P- }static struct platform_device da850_evm_tl_leds_device = {
/ w: |& V+ k. Q! ^* V8 E .name = "leds-gpio",
) X8 V+ k! `3 _5 ? .id = 1,# C0 h; p% r. i5 g* B; q
.dev = {* v; i" G: H6 o
.platform_data = &da850_evm_tl_leds_pdata,. y F' A% |6 {; p
.release = led_dev_release,8 }: t+ ?) ?" ?/ H
}
- E) x# X" z8 j. A6 a};6 k% G8 e5 O# v# R
" _8 X W( d3 S5 H3 C
static int __init led_platform_init(void)
$ B* M7 b% d: l( h{( J9 L# x" c3 ~/ P# o4 j
int ret;! _, e" e& T" J+ n
#if 0+ ^; F9 t/ m3 F7 p: z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- z( X2 W7 ]- d0 v. P6 @ if (ret)9 U* E0 ]* \1 v' k4 x* k, [4 Z9 C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" ^- h& J' t$ M! }: e4 ^
"%d\n", ret);5 r* F7 s% o: u& D
#endif3 t% _6 f% _( q( ?! }9 Z
ret = platform_device_register(&da850_evm_tl_leds_device);+ N. W. o1 | g. r& G; J: W' L& Z: x
if (ret)/ B% N# k, u. x" B7 ~2 a: `; o
pr_warning("Could not register som GPIO expander LEDS");# p( v7 u+ s& Q! K4 f
else- [) o- m, p1 m" K x
printk(KERN_INFO "LED register sucessful!\n");
6 ?% ]9 S( _ [) E' u. s1 p$ |
, S/ {. k! T% E7 ~ return ret;% O7 s7 h8 Y% e: e' H0 p
}
0 J Z8 E# k* j- H3 Q
7 G4 M7 r7 ]. ]7 zstatic void __exit led_platform_exit(void)
5 U: R0 a# x" G* Y+ v+ N) _: b{
4 C: `( V9 W6 m0 ^5 p3 {) } platform_device_unregister(&da850_evm_tl_leds_device);2 i0 F% b$ R4 I0 @4 {0 P2 x
; Z1 P% N- i! d# {$ f2 @: E printk(KERN_INFO "LED unregister!\n");
+ [( V6 H8 J _}
4 t* F0 _( S% ^; i% S
) c a. o* M1 zmodule_init(led_platform_init);
3 V" w/ Y. x' F0 e0 {1 ]module_exit(led_platform_exit);
2 W( j: z; P/ N8 X! C" p* p ?' }+ d0 A& V: g9 g) C( d
MODULE_DESCRIPTION("Led platform driver");6 E! |6 w, ?& ~4 k1 x
MODULE_AUTHOR("Tronlong");
6 C" X! v7 G1 @MODULE_LICENSE("GPL");
. j. R3 G# V+ k- A: D) r3 w. l
* u1 r v6 v0 w" H( M4 u |
|