|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 z0 x: ^9 r0 b$ ^% v2 P+ x* W#include <linux/init.h># M \9 ?2 F( f
#include <linux/module.h>$ W( ^/ V" i+ o9 \+ Q t
#include <linux/kernel.h>/ z* a2 }; Y. w/ S, c% W3 N
#include <linux/types.h>
& N; ^% {; y$ e [#include <linux/gpio.h>& [( {" Q1 I- ?
#include <linux/leds.h>
& Y8 C& |# f* m/ U( U1 W# V#include <linux/platform_device.h>
' y3 O0 ^; [2 M- r: p
( ]2 B$ x: e8 I% q0 ^8 ~2 h1 y _#include <asm/mach-types.h>
+ @+ h8 g& F- O#include <asm/mach/arch.h>
6 B: L3 \& ^1 h2 b#include <mach/da8xx.h>) z$ `9 {% s. X- U8 O) V
#include <mach/mux.h>
, [7 k2 F2 b4 D* @- c- i5 p$ P; g9 E" V
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( Q! b/ I' g8 Z$ R% V T; _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 r4 s" P0 n7 q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 x/ s- n3 p) C2 c#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 I% X' K7 a1 Z
. C! z$ b0 t$ o. g) m( ^3 g5 ~
/* assign the tl som board LED-GPIOs*/0 s4 g) Z8 L6 f L; u8 G
static const short da850_evm_tl_user_led_pins[] = {' @6 F7 {: b% b4 ]5 L; I# W( p
/* These pins are definition at <mach/mux.h> file */
& @4 z/ x2 V3 F: ~. _6 h+ Y" N DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 h; F4 B' @* m. P
-12 [% K: F: s1 ^2 [* A
};# X# U5 ^5 |; Q' ~
9 ]- T: U. H4 A4 @4 Q1 l
static struct gpio_led da850_evm_tl_leds[] = {! P' ?( K5 r; A- Q( C! V( W
{0 ~2 W b$ Y% x# v
.active_low = 0,
# ?( {- n S5 ~* ^ .gpio = DA850_USER_LED0,
( l2 R" |1 g3 S9 U8 O .name = "user_led0",) x7 ~) O8 O7 ]: o6 O) X
.default_trigger = "default-on",
`$ }7 Y$ t8 U },
Q0 ^8 E2 F4 g {* G: T! S) S' z2 O4 |
.active_low = 0,
% A& G- p5 Z5 o( c* A .gpio = DA850_USER_LED1,5 o4 A+ K4 R4 R/ Y, K
.name = "user_led1",
% _" u; d' m, I7 h$ v8 n, @4 u .default_trigger = "default-on",. e# K4 F/ n5 h6 I: a9 l4 K6 M0 G
},
' K) I: z6 {& Y7 d: H {1 U' G, {; q1 \$ A! ^& a
.active_low = 0,6 n: s Q5 O8 ^6 m1 i: G8 |
.gpio = DA850_USER_LED2,- J" b2 ~! v/ _2 t% M! G0 _
.name = "user_led2",! H. r6 y/ \* T4 e' w. J( p
.default_trigger = "default-on",
G0 p) U- ]* o k, s3 s9 [ },# I2 V) {1 J3 o# y
{0 |) P w' ~3 p- Y3 H+ T. O0 C, N
.active_low = 0,1 a8 {* s9 p( P+ f: s7 X0 C
.gpio = DA850_USER_LED3,! j' E3 N' C: E% ]% d
.name = "user_led3",, V/ U7 ^% G) |' [7 O p
.default_trigger = "default-on",
- A! k, \. {& @6 X* @ },
/ z$ N9 S1 K8 b% @};
- v& \0 r4 A* c6 M0 M5 k7 O
O+ C% @+ Q1 U" |+ Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% n ?+ |0 \- p7 E& d7 }
.leds = da850_evm_tl_leds,
; d( y) r! j+ L6 p2 ?/ s3 w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 G* y' `+ _) k1 _* Y' J};
, W9 D% x3 i* w& H+ F( n0 S
t' F, d$ b2 M* E% O3 D% ^* h8 n' @static void led_dev_release(struct device *dev)
/ Y6 x3 X0 m1 p# F% k5 `{, h! s |( v B g" M
};3 y6 ^2 ~# w$ x; H r
/ P! T, Q ]4 G5 P7 cstatic struct platform_device da850_evm_tl_leds_device = {
$ { q P- s' \/ y# N( `1 z .name = "leds-gpio",, D# J3 t( c( x$ [6 i/ G
.id = 1,5 `& G+ U' w4 K8 r5 o5 f+ l. c
.dev = {: @# o1 E# P' T! X* j) {
.platform_data = &da850_evm_tl_leds_pdata,$ p7 \% n' |) k& Z/ I& {/ {; q
.release = led_dev_release,, x. E5 W9 g& m+ [* Q
}% D+ w. q/ @" ]. ]+ V( F
};1 G1 R2 ?: Z) W
& N6 p7 I/ g& g" P" h! }* T7 k- l
static int __init led_platform_init(void)
# O+ y+ g- k1 H' p, L2 R8 w8 b9 `& {{" y7 j6 c% \( W+ L
int ret;
+ ^* m9 z9 a3 l& M3 [#if 08 G w. R) j4 r% h/ o5 Q3 |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 e% l$ i4 x1 j+ B, {4 D( R- t if (ret)
/ k& r# G7 ^% {' ~ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& d. k! u1 E8 ]- ^# I! u
"%d\n", ret);
9 o: ^8 _1 h( C0 R: \( {2 |9 v' W! _#endif
. |6 x9 s C' N9 p6 p ret = platform_device_register(&da850_evm_tl_leds_device);/ m* B+ `/ u7 U6 s4 B% m
if (ret)6 {) h$ l4 A$ d6 k2 L
pr_warning("Could not register som GPIO expander LEDS");
e; F6 \" E/ @& n3 l6 \ else8 |* r2 X A7 [/ R+ ]6 I& i
printk(KERN_INFO "LED register sucessful!\n");5 U! V S2 M: v) f6 S- \) m9 Z
2 z, _% k/ C0 M
return ret;* @# B. B t+ O9 ]% i
}$ C5 l8 B6 H' o
6 Z5 q2 x4 `3 c4 Estatic void __exit led_platform_exit(void)
* I! ?& a+ r9 L& }{1 r! Y* {) T2 a7 h
platform_device_unregister(&da850_evm_tl_leds_device);
# j' s6 W* X" e/ I I1 Z
1 I) I2 g8 G+ ?, A printk(KERN_INFO "LED unregister!\n");$ ]+ E' N$ u" B
}3 Q# o0 v0 n, l. d9 V) u7 l
! Y g1 i3 P, k D) I2 xmodule_init(led_platform_init);1 u+ c2 v. C3 `7 w
module_exit(led_platform_exit);- Q/ M9 `6 P! l$ l6 t
% E+ ^+ j; W: x5 a% m% z% B kMODULE_DESCRIPTION("Led platform driver");5 S$ m) {- e' p% e- b* D9 N7 w
MODULE_AUTHOR("Tronlong");5 w& N7 K( |+ O1 B4 U
MODULE_LICENSE("GPL");3 ^ L" U; T8 A4 I! ]4 n6 p. J
# D& |8 n& T' {" q
|
|