|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 F U) N# Y2 B- w
#include <linux/init.h>- `4 n4 g" E% H' E
#include <linux/module.h>4 { B' T) _0 a
#include <linux/kernel.h>, r/ |" O) p& O0 D* N7 ^7 R
#include <linux/types.h>
( S+ Y0 j x3 a& m" l7 V#include <linux/gpio.h>
$ [: z% P- d* t4 a8 @3 \5 E#include <linux/leds.h>1 @) K% T5 ~! E
#include <linux/platform_device.h>5 X4 T: X, ?3 h' u
0 l, {/ ^. \. F1 B#include <asm/mach-types.h>
% ?1 d q" W. k5 q#include <asm/mach/arch.h>
/ l" Q) z& P3 L( A* B& K#include <mach/da8xx.h>; ~2 u/ T% ~5 c$ g, d8 o
#include <mach/mux.h>
; M3 _5 \$ Z+ I' d8 n M/ _; b
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 X0 l2 g$ E9 ~; @. g- a# @, i#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, o! T6 f r2 f( }5 e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ }* q/ j5 G' X$ H/ D/ k3 `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 b- ?' G" M' t3 y
% t2 R0 b, B! l/* assign the tl som board LED-GPIOs*/ E( A& J) u6 S: V/ y
static const short da850_evm_tl_user_led_pins[] = {
4 P4 z! q4 F# G) m5 y o s9 b /* These pins are definition at <mach/mux.h> file */' x2 A" n: x9 ?7 N: J" A6 X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
T0 K/ I/ [. M x3 M -1 M/ A0 R( u" t' s G
};, A ]+ |. R! B
1 i' v) C7 s5 a: J4 e6 B
static struct gpio_led da850_evm_tl_leds[] = {7 P' C5 k( Y$ P0 I1 t
{; x6 n W4 B. R4 X- v
.active_low = 0,8 N+ m0 L# l4 _, c4 b) K4 R6 {5 o
.gpio = DA850_USER_LED0,
) I) j2 Z0 f+ O$ b& s .name = "user_led0",( r* [6 }6 |8 I4 A5 ]8 @" f9 ]$ C6 U
.default_trigger = "default-on",5 u3 X1 \% n+ y" a6 ~( |$ N
},' Z8 w6 f9 K+ k: W! ?# d
{4 ^% C; t6 y/ L Z
.active_low = 0,
2 j o6 R; P4 G, h .gpio = DA850_USER_LED1,/ t+ P6 l0 f3 f2 Q$ Q
.name = "user_led1",3 K! s, k3 E2 ~: w5 Q" D
.default_trigger = "default-on",
4 }6 i2 p+ }/ z! d- y% A( I+ |$ ` },
! y1 C% M- v7 ^6 }) w0 v {
0 q' J& X& D5 \+ Z4 }6 U( T .active_low = 0,
% @# }, \) o% L# h' t9 \6 ^7 \4 D .gpio = DA850_USER_LED2,
& E6 p3 R) b& \& E .name = "user_led2",
/ R4 \( f- R9 a .default_trigger = "default-on",
9 k) k- i3 C$ W c2 u },* \0 _4 g D" U! `9 Q
{7 w# y" v9 K* [$ y3 I6 l) m
.active_low = 0,
) h, b& H$ V3 f T .gpio = DA850_USER_LED3,. w- @ c. f! w4 v' {& t! I
.name = "user_led3",
. u" Z9 a4 n1 [) R7 o# K .default_trigger = "default-on",5 V# Q# M/ y8 n1 Z. ~
},
7 q! H3 V) o, d& _- d! v0 r3 T- h: T }};6 @; Z8 h1 L% t7 E
# [2 `+ k1 q( t9 r" R) @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
[) E$ e3 [+ m' H6 A .leds = da850_evm_tl_leds,
/ g" G1 y7 T( k& e0 J P .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 d) h7 x. N' X% R" Z; t4 E/ _
};
: h- F' l9 P7 e0 j3 b( ~+ T Y# C+ s3 J* F) C& q
static void led_dev_release(struct device *dev)! x, Y1 R$ R* J" V$ }" c8 L
{2 T5 a: N0 z0 B j
};
; c# n) ]: d/ e4 ~) Z- W3 S
* F& J& J; n# _static struct platform_device da850_evm_tl_leds_device = {7 v9 l: V! I! y5 y/ c
.name = "leds-gpio",. t/ e, P# H, d* o5 F
.id = 1,
: y/ X0 C- x9 M* {$ R4 p- U .dev = {
: F: t* {) o$ U- |. R6 v$ ^& y .platform_data = &da850_evm_tl_leds_pdata,' r$ H: z: W" n& F3 A# ]8 s+ \5 i
.release = led_dev_release,
; ]3 D' x: q; v# ?: e% P) X1 ~ }
. o& P* K+ q8 P/ f# |};+ q- v8 c7 ]' g9 i; l5 [
- A6 b( o' D, r$ X2 Q3 ?8 hstatic int __init led_platform_init(void)- P/ I: N, T8 A
{
$ b" g% n% T4 Y2 L" V5 I int ret;4 F# o1 u, ~" w8 M$ Y+ ?
#if 0- N! ~, ]& a# R3 f( R3 y/ Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 a' V0 P( ~, I1 B1 u- \
if (ret)7 V. g, n! ^5 H3 h F" o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 R7 P! r' d' V: u5 ]/ w0 A "%d\n", ret);
9 [ r7 _) _; K#endif7 x" x; v& W) o$ f& Q2 ]
ret = platform_device_register(&da850_evm_tl_leds_device);
+ y7 I( V# S- k; X. Z6 [. m if (ret)! X) B( d" Z$ C z2 O
pr_warning("Could not register som GPIO expander LEDS");% l4 x# g. f; J* }% Y
else
% Q: y) e3 i6 ?' s7 }# g, m printk(KERN_INFO "LED register sucessful!\n");
0 G. h9 G- \9 k8 f2 [7 z9 K6 [- q- c; R! p6 j6 _$ _! |' M
return ret;
" Z3 W, T6 q3 m}
; v6 g5 Z) Y" f3 ^7 R G: g* D- Q0 |! a
static void __exit led_platform_exit(void)! _; ^3 J& r$ z: v+ \
{
3 l" ?% a1 {7 J% A) m1 }8 I3 h platform_device_unregister(&da850_evm_tl_leds_device);
+ T! ]9 ^) P6 a- R8 S% F& ~& w/ L9 D5 w$ y0 w
printk(KERN_INFO "LED unregister!\n");
0 `7 l7 D5 g" R2 r}, u2 Z# o% C% R4 g2 o
6 b: M# T" z& S% w$ A: f" V
module_init(led_platform_init);
4 U% [' }4 {+ v, P. m% d$ l) umodule_exit(led_platform_exit);
# R% y& o$ G. |; F' g
3 U. X7 u% W5 K) g7 C5 [' ?& C2 GMODULE_DESCRIPTION("Led platform driver");$ s. ?6 d. |. P* F) {# U
MODULE_AUTHOR("Tronlong");+ F0 | E" \: r, F8 {5 e# {7 |
MODULE_LICENSE("GPL");
" t- I+ L' y0 S3 g: K1 {
- G+ T: _9 I x7 i" E2 I! Z |
|