|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% o2 I0 _" ^6 f3 _, c( t4 n0 n5 h9 x#include <linux/init.h>
W c; l4 S" | ~- I/ x( M; n4 V#include <linux/module.h>; [; |3 s. ?% M5 f4 s! L
#include <linux/kernel.h>2 g5 t1 ~! ~8 o; w. f8 v! N1 R! t, @
#include <linux/types.h>
, o% n' Y( V2 H/ l0 r4 A1 u9 I#include <linux/gpio.h>
; K+ y0 R0 \1 s7 D" _ N9 j#include <linux/leds.h>: B" X, E/ P0 c* Q
#include <linux/platform_device.h>% Y5 o7 b# m }$ W+ Z: P
! {! [8 h' F p+ D! M r0 l
#include <asm/mach-types.h>0 X5 v. [. s, P9 ]
#include <asm/mach/arch.h>8 u2 Q. y: a) q- c
#include <mach/da8xx.h>
/ J2 M9 ]; M X- r( ]1 t! M4 c#include <mach/mux.h>
, s3 w8 T3 X' Y1 J, f( p! P8 N' h% R4 o
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 ~1 \. u3 e: M2 S6 J, D8 b#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. Q3 ~% Y- W, Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 _3 G# ]# K. P! U" L, V: {: U( C
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 a ~. h% E* E1 _5 z
) t8 H7 a% x$ O/* assign the tl som board LED-GPIOs*/
c/ k' x4 r% t4 W2 j/ B; Cstatic const short da850_evm_tl_user_led_pins[] = {: X S8 o2 r7 ~
/* These pins are definition at <mach/mux.h> file */) P0 M6 P! n: v3 Y) p4 v3 v0 ^8 t3 f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* \3 n% y& |1 @
-1
) {4 l# A9 {/ P9 c; b" f( T/ H};" q$ N3 E" t8 W" l5 H) \1 a; E
) c1 q( L5 M: Y- i) N7 [% P4 L( X& f
static struct gpio_led da850_evm_tl_leds[] = {
$ Q0 b1 f3 b8 H ] {
# l' i9 K- Q1 r1 ?2 { .active_low = 0,0 w5 g3 V( L9 H+ ^
.gpio = DA850_USER_LED0,
$ E$ }* D6 D* `7 |5 x+ u4 H+ A R .name = "user_led0",) M1 L4 a9 _; D2 ^ O# M
.default_trigger = "default-on",/ e! |1 ?) F% A( J" s
},
. E! X& A7 T) s" u {
5 l1 q2 N1 i$ N .active_low = 0,1 u1 ^1 V# r, \1 U
.gpio = DA850_USER_LED1,. P! T' E- z W }$ j, E4 y8 D
.name = "user_led1",
0 I7 H2 _$ ?2 N .default_trigger = "default-on",( ~1 Z, g6 A# A Y7 G" Y; \3 z; Q
},
2 ?* t% l6 ]/ y' Y5 O% ^4 o6 ]8 ]' H {; Z* W) W/ C& r2 a' g9 ~) |
.active_low = 0, T" N' M+ \" o, H, [
.gpio = DA850_USER_LED2,
0 n8 l8 h# b6 z* b .name = "user_led2",
9 c! }( t6 ^0 x# P .default_trigger = "default-on",, ?1 e2 R1 P3 x; m9 ^
},, q5 g; S7 Z# ?* A( d
{% u' {3 ?8 F* h
.active_low = 0,' e. O4 R% h( v5 q
.gpio = DA850_USER_LED3,
8 E0 t+ q; w9 B" }- H: e .name = "user_led3",
/ L6 V. ?2 Q) O2 ` .default_trigger = "default-on",
: C0 @# R1 t; b7 u },5 m. E0 P$ S4 K
};+ D1 ]8 |7 R# G9 R
8 ~3 ]1 R2 i" M0 @: I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { K4 b" j2 h# W G; a3 w. B
.leds = da850_evm_tl_leds,
& k+ `+ E3 _0 q, m4 W* y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- V0 Y& [& J' J* g+ M};
2 N% Y6 ], y: `, W. }/ a9 q" P8 h" ]2 D; G/ ]$ g. w
static void led_dev_release(struct device *dev)
5 G0 R5 H V2 O( d2 O2 j# t{
4 b' c% r* S; R5 R4 \! \/ O( V9 R% k- X};
. {* Y9 c5 b# j+ z% b# }) E
9 s) f( E1 V0 m0 a9 Y8 Istatic struct platform_device da850_evm_tl_leds_device = {
- b9 @6 h( E& C4 i* M .name = "leds-gpio",
0 B4 H s, Q$ p* a8 ~2 D: G% b .id = 1,
* }- L! u3 Q9 o, N0 M; u# G .dev = {
2 R1 f/ F$ @" q3 a' p .platform_data = &da850_evm_tl_leds_pdata,2 b6 B. r% A- u8 Y
.release = led_dev_release,
2 E7 E, G* R- f0 ^ }: c0 J# v! d8 x
};" f. U* \ d) N8 J$ g( \5 v
1 Q4 Z8 u* t! ]% h% rstatic int __init led_platform_init(void)
5 Q9 j+ t# C6 x4 U: B{
% D8 J1 W. Y0 a7 }4 D int ret;
$ J) B6 T% a: q# q#if 0- `7 C+ d5 E8 E9 D9 n @2 N
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( x7 ~' Z' y3 Q& B* W if (ret)3 p9 Z0 |0 M" B& M% y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 c- W. S# [, ^. \7 m( d "%d\n", ret);
6 K3 s: q5 _/ I' n7 c1 S B#endif& }5 V1 {; G% t# h+ @ r
ret = platform_device_register(&da850_evm_tl_leds_device);
w7 N) P, @" y0 r# z" X if (ret)/ F# n9 R+ U1 s& Q, u) P0 V+ P1 T
pr_warning("Could not register som GPIO expander LEDS");; ]5 \6 `) t7 q/ p) |
else% c7 f6 j& g$ v& s8 [ q. i
printk(KERN_INFO "LED register sucessful!\n");
/ ?: V1 o- F8 r0 g/ p5 i- P2 l
& C# z5 X% r' p. m' I return ret;! `+ {: A+ t8 `8 n4 }# Y
}
; }/ {; t( }1 l: ^, r& A. k
8 o; D: s; Y. h# u2 h* l# Fstatic void __exit led_platform_exit(void)' |9 F) W- M o7 e
{
' S: H; p3 p/ Y1 Y/ {" { platform_device_unregister(&da850_evm_tl_leds_device);
, f! z `$ O" g+ q* H2 i7 Z. E/ r; s" X& ~2 m3 z+ W
printk(KERN_INFO "LED unregister!\n");
( q7 X8 r/ h! \1 y0 Y( m}
g# [+ u: |+ }
5 ~4 u. `" A; k$ c( ~- \module_init(led_platform_init);
e* n; h- Z5 E- L- m/ nmodule_exit(led_platform_exit);# k7 ^# T9 }6 a- S2 J" l/ w
. A1 N4 l b8 G% v& y3 y
MODULE_DESCRIPTION("Led platform driver");
% k! E2 |8 z, _, G! q' K0 ZMODULE_AUTHOR("Tronlong");
7 W# f- a, Z9 a7 LMODULE_LICENSE("GPL");
0 o% U4 a4 W+ m/ D, D
M: d# n2 e$ u! L g |
|