|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: A6 w4 G8 m) i#include <linux/init.h>
9 S# x0 ~0 _4 Q& t' [#include <linux/module.h>
$ b* B, v* H: |* w#include <linux/kernel.h>8 P6 [, f2 R. a: K8 L% E/ i
#include <linux/types.h>
; ]8 f; I: [ R" }#include <linux/gpio.h>
* S+ E j3 ~" J4 ^#include <linux/leds.h>
2 }( j' C- J8 g. b- ~+ c#include <linux/platform_device.h>( H! K# |4 V) a4 M- j8 h
7 Q, ^# A3 M) ?1 V#include <asm/mach-types.h>
! j* ?: i- _! G2 F6 G( L( S#include <asm/mach/arch.h>* E4 o2 T0 ~' i5 \. J# z
#include <mach/da8xx.h>
6 ]0 ~2 f+ F4 C8 S2 ^#include <mach/mux.h>5 w. _3 _7 M9 ?* G; t2 j! o
2 h! ]6 y7 c7 {# p( y0 }7 z" w
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 Q! ]. A8 l& n" r) a4 t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 b4 T3 y0 H9 M. u9 W4 _+ z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 T4 m. P4 `, i* l% M# ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. b k3 Z3 f: v' [6 t6 R: D1 ]. D9 F @5 `0 ~
/* assign the tl som board LED-GPIOs*/
) q4 P! s; Z* o' u8 H- Tstatic const short da850_evm_tl_user_led_pins[] = {, R! }3 e. E( o; G3 J/ b: P
/* These pins are definition at <mach/mux.h> file */
# p- s$ E5 U; B4 [5 g" ^* w DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. X8 V# d! B. x4 X) ^& r, t- o
-1
2 o! a6 H+ ]7 [6 T' N};
0 `5 s+ a( z1 U. x z% A8 P" k' A2 I3 e' T
static struct gpio_led da850_evm_tl_leds[] = {
e1 n, w0 D3 {% G1 h' G {+ ?( K) Y4 u, y# k0 ^/ E
.active_low = 0,: J; {- Z1 o9 g/ Q
.gpio = DA850_USER_LED0,
3 d+ Y8 n- y$ A2 E7 J$ ?# d) P1 ^ .name = "user_led0",
/ j1 G! t5 p2 u, r3 j7 _2 O7 X .default_trigger = "default-on",
" |, P6 a. @8 B8 X, Y6 Q8 c: o },& P1 g) @% H h' r+ Z, |* c9 d6 J
{4 t1 {+ `: k0 K
.active_low = 0,
+ k1 h- R* l4 j' R7 J# P7 F .gpio = DA850_USER_LED1,
0 A1 h* e$ b* O- ^( ?# l .name = "user_led1",
) y) x' Y5 i' K+ _ .default_trigger = "default-on",7 N5 p/ P9 M; s! L1 q. k+ P! Y t
},
; m, e" F8 W: e" ^* M. P; i( j {
7 z/ G' Z# y% r0 {: e$ O: s) f .active_low = 0,
* R3 F0 D6 X/ C0 I) Y .gpio = DA850_USER_LED2,, L1 c4 M0 n; z% s* q
.name = "user_led2",
Y5 R5 m, }' ]. { .default_trigger = "default-on",
% n7 e1 i/ ]* {$ ?9 Q; z; n$ K },
' y; Y8 D* f7 N' [# r% j {8 w" H5 w/ U" `' Y
.active_low = 0,
! V. T8 P9 b+ C, l2 x. c1 Q .gpio = DA850_USER_LED3, I3 n: b- G; T8 [ D# [
.name = "user_led3",- ~3 U- ~+ l& ]& O2 I' C/ x1 h
.default_trigger = "default-on",1 ]6 p* f- M m' W. U4 f5 ]
},
# J' d; M4 I o$ o9 H* J/ |$ u};
: g7 M! x1 K0 e* _! i9 {2 g! h7 S: S, O. m
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% a) ?: E) X2 z- T' ] .leds = da850_evm_tl_leds,
$ D; c" z. E. X: l/ x% f* l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& r6 \8 D8 B4 E0 Q2 _};
7 N* P4 D+ m! m4 H# j/ O+ \% P
( q1 D; e+ g: G7 U' e5 v- Kstatic void led_dev_release(struct device *dev)
# _) g; o b+ O, ]3 H9 c{- {* }% f, _( q3 x7 p6 n2 @
};
4 w6 b9 F& i4 R; j/ H' D9 \% R8 O% }) p8 b; L; v9 ?- U
static struct platform_device da850_evm_tl_leds_device = {
( V* j% w$ k, j, F .name = "leds-gpio",
8 ] v% \" d$ ]" z% ]. a R .id = 1,
# J7 [; _+ a; K .dev = {
7 \% d% o1 W/ x, K5 S" Y( Z .platform_data = &da850_evm_tl_leds_pdata,% p/ L' e9 y' |6 {- J
.release = led_dev_release, X2 U" p) q5 c( Q
}
' w) v" j0 Z+ j- j' Q};: ~ X" n4 G' c5 H1 n
* H( i+ Y" E# F/ S" g9 d! J1 d
static int __init led_platform_init(void)
8 U" u9 _- f8 w- ^* J{2 v3 |2 ?# Y' L5 ?
int ret;
; v5 O. Y" V+ Z2 x#if 0
6 a6 g& S5 R4 ~% v- m6 m7 p: g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( A0 @/ i: ]8 y if (ret)
* Z; J, g9 L& n; J0 D pr_warning("da850_evm_tl_leds_init : User LED mux failed :". c e' ~8 B& T+ s
"%d\n", ret);1 ~2 F$ a% m# N/ d
#endif
5 r$ L& S5 ~+ e% k; U3 o ret = platform_device_register(&da850_evm_tl_leds_device);
2 _' @" ?& d+ T2 V% F3 w2 { if (ret)4 M' d3 s6 T9 a7 m9 \
pr_warning("Could not register som GPIO expander LEDS");
# P& |: r9 ^7 G6 p! P. y8 Y else
4 a. W8 A7 S) j1 q% R5 j& V) z printk(KERN_INFO "LED register sucessful!\n");: U9 W: B& U+ J6 {
% u7 I& q' ^) k
return ret;
5 S- ?4 I t: s. I0 w, }}
% }/ ^' C C* R: G$ M: @3 S7 P% f
# m+ g5 ]# i2 Y/ {, p- J7 Hstatic void __exit led_platform_exit(void)
2 v3 B W. C1 `7 ^) a, U{
O% N& f* m( z4 I+ s7 M platform_device_unregister(&da850_evm_tl_leds_device);- a4 {1 s5 a2 u( n
, z. W9 d G Z
printk(KERN_INFO "LED unregister!\n");2 z% D2 b2 q: F9 a& p
}
, T) X5 e" u! q7 p/ V$ i
# A) J6 j7 e. d( M- K3 I4 y0 ?1 C" Umodule_init(led_platform_init);
3 _- Y! @! _$ w- ]9 E4 C/ d' p) zmodule_exit(led_platform_exit);
/ y N8 D6 i% q
0 S& Y) r# I$ W( U: I9 y/ H# ]MODULE_DESCRIPTION("Led platform driver");
! W; _, F6 `7 t$ gMODULE_AUTHOR("Tronlong");% N! [, w/ x& A4 |
MODULE_LICENSE("GPL");
0 D$ K! k. f0 ~' r/ m# U" R1 Q; Y; V9 D. @1 ?9 l0 ]" Z4 k
|
|