|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 u' Z0 H* p! U: n2 w6 D9 ^3 Y
#include <linux/init.h>
' [: k$ m# g3 T3 W. J% Y) Y2 a0 `#include <linux/module.h>
8 S+ r# h5 c6 A* P( h d( M: z#include <linux/kernel.h>
, n% _: m' u5 X# L6 T#include <linux/types.h>/ S% c1 ^; ?. x: H7 v
#include <linux/gpio.h>
& @; c: r4 \# `- q. s( W#include <linux/leds.h>* L, H+ X% m4 O9 A; C6 {
#include <linux/platform_device.h>
+ Y- I( G1 l. x& m
. y2 O( P+ ]4 _#include <asm/mach-types.h>5 X( k; ?9 |, D2 r/ c0 m
#include <asm/mach/arch.h>4 `/ ]- a0 e6 H2 d* e- I* s) n3 t
#include <mach/da8xx.h>1 N x9 [2 ~% w, D) P# X6 ~
#include <mach/mux.h>' _( Z, e& Q" t, F1 F# c: f# E
7 [" k& w# h2 v/ `* j
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
a$ Y! S* F/ ]; _7 v#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) W6 K$ F8 s5 l- J5 N. }" k) y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
j# r$ s9 M! W& F* l _# G#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( s- G4 m5 r3 l0 O v* O2 s, X
/* assign the tl som board LED-GPIOs*/
; \6 S5 H# b& s8 H8 J- vstatic const short da850_evm_tl_user_led_pins[] = {
3 N* F" F: V4 V: b: c /* These pins are definition at <mach/mux.h> file */ ~, Y8 ]* `2 ]0 [ G
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! z6 ]& y" b/ r/ z -1
; \* C, Z& H4 T};
1 K, Y- ?$ W y+ c: k
r& V. [" w5 E( u% `1 H7 I+ wstatic struct gpio_led da850_evm_tl_leds[] = {
" R; Z: ?7 b! ~3 o) w8 d: O3 H) K" C {$ f( S, {* A& d8 M
.active_low = 0,: b9 G, o# ^* p6 h1 F
.gpio = DA850_USER_LED0,
% y. M# W# ?) \( w/ w: j .name = "user_led0",
. ], C# I. J+ g9 V+ ^' c .default_trigger = "default-on",
6 W" L5 g! x) e0 K! r: U },
% b: s% ^- ^+ _! p$ q {
# f: M& a1 z0 W5 y .active_low = 0,/ R* L% b2 q4 x7 F! l( X
.gpio = DA850_USER_LED1,: R/ Z6 K0 u; n. q2 J, F/ {% W
.name = "user_led1",) s( h; y, T0 Q
.default_trigger = "default-on",9 N5 m3 n$ T* ]" S8 M
},
2 V3 y0 f( w! ~4 i2 g! T1 F {( n, T, u# e0 F0 P* M( M8 \
.active_low = 0,3 m9 P4 {" L. i" a9 j$ {
.gpio = DA850_USER_LED2,
) l8 [) x, N4 b9 B* l .name = "user_led2",; L9 I* M: E; n7 U
.default_trigger = "default-on",7 }0 l' M9 w2 s; A
},
* {( k4 G3 X4 T3 T$ o {
@/ Q4 t, u) @& q2 i: H d. j .active_low = 0,
' x8 e$ N4 A+ ]; [5 X& [4 | .gpio = DA850_USER_LED3,+ \( L0 v' @( f2 R6 K4 c0 [# u0 ]. R
.name = "user_led3",- _, p! H" W5 S( v( k9 C
.default_trigger = "default-on",
z1 @4 j# t* d5 G* C },
. r. [. Y% E0 \% C- N3 b) `};8 q/ a* C4 y; |, c
9 b# h/ W3 D; cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( s" m. f4 \- ^. Q# V .leds = da850_evm_tl_leds,6 n8 k2 L! ?7 [/ B* W6 G0 @" `2 Z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- X% x) w( K% c# o$ s7 U$ [
};' N2 G3 j; @$ O7 s; c, m
( F0 k" L+ t& Z3 m `$ K! e
static void led_dev_release(struct device *dev)$ n9 A- U0 T9 N, ^
{* f1 m. n! p S
};$ J9 u4 p# q3 R) t
4 G- w' }7 f0 ?8 U
static struct platform_device da850_evm_tl_leds_device = {: ]* s _9 b0 ?
.name = "leds-gpio",
! W0 a2 S" l# A- v' R .id = 1,
9 E ^- d& z. s, _* P .dev = {6 ]1 J2 I3 }0 Z4 F
.platform_data = &da850_evm_tl_leds_pdata,
6 @2 h: g6 \( A- G. q, w1 k3 X .release = led_dev_release,* ~. ~8 D- r9 A
}3 c5 A" \ \2 T5 c1 u# K- {
};4 R9 X m% A- P
' s e( F% @/ f/ t9 m Z. [% {, ~1 jstatic int __init led_platform_init(void)
; |2 h! v) h J. ~& o. p{; ]$ l4 f' \4 I7 E( @) W
int ret;4 f P$ t3 Q H# G1 R9 T+ g' S
#if 0
9 `4 {, J/ ~8 t' _0 B4 E+ A* C" N" a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ ?. ? I0 P- j if (ret)# w; ?; M( G, X) S1 D& c7 L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 `& s6 `! G. I
"%d\n", ret);% a1 Z0 c$ j1 w7 R
#endif
) `' Q* S; ?3 L* O n8 p% ] ret = platform_device_register(&da850_evm_tl_leds_device);" i- n0 _9 K% Q
if (ret)8 f2 z8 o* u2 B. c; Z
pr_warning("Could not register som GPIO expander LEDS");5 D. X+ x6 Q/ ?1 f# n
else( z' [7 }. O. ~2 N% a9 N8 A
printk(KERN_INFO "LED register sucessful!\n");
! m/ v6 P" V; a' U ^) M5 s5 E* g7 c8 g- f! p! b
return ret;) r6 e2 }7 z* T' F4 X
}
2 O1 |( U! J2 N. ?( h* u( M
2 r* D2 y( ~) o5 G9 [# @# [8 Estatic void __exit led_platform_exit(void)
, l' T H. q# P5 g5 X3 K$ [{
* ?( T0 M n4 B% _; m0 z" ? platform_device_unregister(&da850_evm_tl_leds_device);/ l Q3 L4 W) x. Y
7 w" J4 @) ^- v1 s6 d/ ?* y8 v
printk(KERN_INFO "LED unregister!\n");
( X1 f# F: y7 C% u( d+ B. |# O}
; a: y. q4 O Q+ p/ [
+ L! K* J8 p4 Gmodule_init(led_platform_init);. `) F: T X5 n' W( Z7 \& Y
module_exit(led_platform_exit);! P' i% Q; x) o$ f5 [2 \
7 N$ v A; n4 y( _/ p: A3 lMODULE_DESCRIPTION("Led platform driver");
7 }1 j: j* `# }" Y+ ^MODULE_AUTHOR("Tronlong");
/ @6 X7 A: ?2 }# W1 @* L. RMODULE_LICENSE("GPL");
1 J6 {( _4 Y& ~- z! I8 l; \) {" }1 z1 |% l0 M* k+ O" ~' d1 F
|
|