diff options
author | Paul Mundt <lethal@linux-sh.org> | 2007-11-09 00:06:24 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-01-27 23:18:41 -0500 |
commit | 62d6b66edc68f906138df7ba01efd41a45981586 (patch) | |
tree | 98477be0c81e3db1a66646ca88db201a8ef6cd53 | |
parent | 7a65eaf4885d1d0afeec45239eaf9208a3235b51 (diff) |
sh: Move sh32 optimized I/O routines to arch/sh/lib/
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r-- | arch/sh/kernel/io.c | 67 | ||||
-rw-r--r-- | arch/sh/lib/Makefile | 2 | ||||
-rw-r--r-- | arch/sh/lib/io.c | 82 |
3 files changed, 83 insertions, 68 deletions
diff --git a/arch/sh/kernel/io.c b/arch/sh/kernel/io.c index 501fe03e371..71c9fde2fd9 100644 --- a/arch/sh/kernel/io.c +++ b/arch/sh/kernel/io.c | |||
@@ -61,73 +61,6 @@ void memset_io(volatile void __iomem *dst, int c, unsigned long count) | |||
61 | } | 61 | } |
62 | EXPORT_SYMBOL(memset_io); | 62 | EXPORT_SYMBOL(memset_io); |
63 | 63 | ||
64 | void __raw_readsl(unsigned long addr, void *datap, int len) | ||
65 | { | ||
66 | u32 *data; | ||
67 | |||
68 | for (data = datap; (len != 0) && (((u32)data & 0x1f) != 0); len--) | ||
69 | *data++ = ctrl_inl(addr); | ||
70 | |||
71 | if (likely(len >= (0x20 >> 2))) { | ||
72 | int tmp2, tmp3, tmp4, tmp5, tmp6; | ||
73 | |||
74 | __asm__ __volatile__( | ||
75 | "1: \n\t" | ||
76 | "mov.l @%7, r0 \n\t" | ||
77 | "mov.l @%7, %2 \n\t" | ||
78 | #ifdef CONFIG_CPU_SH4 | ||
79 | "movca.l r0, @%0 \n\t" | ||
80 | #else | ||
81 | "mov.l r0, @%0 \n\t" | ||
82 | #endif | ||
83 | "mov.l @%7, %3 \n\t" | ||
84 | "mov.l @%7, %4 \n\t" | ||
85 | "mov.l @%7, %5 \n\t" | ||
86 | "mov.l @%7, %6 \n\t" | ||
87 | "mov.l @%7, r7 \n\t" | ||
88 | "mov.l @%7, r0 \n\t" | ||
89 | "mov.l %2, @(0x04,%0) \n\t" | ||
90 | "mov #0x20>>2, %2 \n\t" | ||
91 | "mov.l %3, @(0x08,%0) \n\t" | ||
92 | "sub %2, %1 \n\t" | ||
93 | "mov.l %4, @(0x0c,%0) \n\t" | ||
94 | "cmp/hi %1, %2 ! T if 32 > len \n\t" | ||
95 | "mov.l %5, @(0x10,%0) \n\t" | ||
96 | "mov.l %6, @(0x14,%0) \n\t" | ||
97 | "mov.l r7, @(0x18,%0) \n\t" | ||
98 | "mov.l r0, @(0x1c,%0) \n\t" | ||
99 | "bf.s 1b \n\t" | ||
100 | " add #0x20, %0 \n\t" | ||
101 | : "=&r" (data), "=&r" (len), | ||
102 | "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4), | ||
103 | "=&r" (tmp5), "=&r" (tmp6) | ||
104 | : "r"(addr), "0" (data), "1" (len) | ||
105 | : "r0", "r7", "t", "memory"); | ||
106 | } | ||
107 | |||
108 | for (; len != 0; len--) | ||
109 | *data++ = ctrl_inl(addr); | ||
110 | } | ||
111 | EXPORT_SYMBOL(__raw_readsl); | ||
112 | |||
113 | void __raw_writesl(unsigned long addr, const void *data, int len) | ||
114 | { | ||
115 | if (likely(len != 0)) { | ||
116 | int tmp1; | ||
117 | |||
118 | __asm__ __volatile__ ( | ||
119 | "1: \n\t" | ||
120 | "mov.l @%0+, %1 \n\t" | ||
121 | "dt %3 \n\t" | ||
122 | "bf.s 1b \n\t" | ||
123 | " mov.l %1, @%4 \n\t" | ||
124 | : "=&r" (data), "=&r" (tmp1) | ||
125 | : "0" (data), "r" (len), "r"(addr) | ||
126 | : "t", "memory"); | ||
127 | } | ||
128 | } | ||
129 | EXPORT_SYMBOL(__raw_writesl); | ||
130 | |||
131 | void __iomem *ioport_map(unsigned long port, unsigned int nr) | 64 | void __iomem *ioport_map(unsigned long port, unsigned int nr) |
132 | { | 65 | { |
133 | return sh_mv.mv_ioport_map(port, nr); | 66 | return sh_mv.mv_ioport_map(port, nr); |
diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile index 9dc7b698505..6f7ac9eeb54 100644 --- a/arch/sh/lib/Makefile +++ b/arch/sh/lib/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for SuperH-specific library files.. | 2 | # Makefile for SuperH-specific library files.. |
3 | # | 3 | # |
4 | 4 | ||
5 | lib-y = delay.o memset.o memmove.o memchr.o \ | 5 | lib-y = delay.o io.o memset.o memmove.o memchr.o \ |
6 | checksum.o strlen.o div64.o div64-generic.o | 6 | checksum.o strlen.o div64.o div64-generic.o |
7 | 7 | ||
8 | memcpy-y := memcpy.o | 8 | memcpy-y := memcpy.o |
diff --git a/arch/sh/lib/io.c b/arch/sh/lib/io.c new file mode 100644 index 00000000000..4f54ec43516 --- /dev/null +++ b/arch/sh/lib/io.c | |||
@@ -0,0 +1,82 @@ | |||
1 | /* | ||
2 | * arch/sh/lib/io.c - SH32 optimized I/O routines | ||
3 | * | ||
4 | * Copyright (C) 2000 Stuart Menefy | ||
5 | * Copyright (C) 2005 Paul Mundt | ||
6 | * | ||
7 | * Provide real functions which expand to whatever the header file defined. | ||
8 | * Also definitions of machine independent IO functions. | ||
9 | * | ||
10 | * This file is subject to the terms and conditions of the GNU General Public | ||
11 | * License. See the file "COPYING" in the main directory of this archive | ||
12 | * for more details. | ||
13 | */ | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/io.h> | ||
16 | |||
17 | void __raw_readsl(unsigned long addr, void *datap, int len) | ||
18 | { | ||
19 | u32 *data; | ||
20 | |||
21 | for (data = datap; (len != 0) && (((u32)data & 0x1f) != 0); len--) | ||
22 | *data++ = ctrl_inl(addr); | ||
23 | |||
24 | if (likely(len >= (0x20 >> 2))) { | ||
25 | int tmp2, tmp3, tmp4, tmp5, tmp6; | ||
26 | |||
27 | __asm__ __volatile__( | ||
28 | "1: \n\t" | ||
29 | "mov.l @%7, r0 \n\t" | ||
30 | "mov.l @%7, %2 \n\t" | ||
31 | #ifdef CONFIG_CPU_SH4 | ||
32 | "movca.l r0, @%0 \n\t" | ||
33 | #else | ||
34 | "mov.l r0, @%0 \n\t" | ||
35 | #endif | ||
36 | "mov.l @%7, %3 \n\t" | ||
37 | "mov.l @%7, %4 \n\t" | ||
38 | "mov.l @%7, %5 \n\t" | ||
39 | "mov.l @%7, %6 \n\t" | ||
40 | "mov.l @%7, r7 \n\t" | ||
41 | "mov.l @%7, r0 \n\t" | ||
42 | "mov.l %2, @(0x04,%0) \n\t" | ||
43 | "mov #0x20>>2, %2 \n\t" | ||
44 | "mov.l %3, @(0x08,%0) \n\t" | ||
45 | "sub %2, %1 \n\t" | ||
46 | "mov.l %4, @(0x0c,%0) \n\t" | ||
47 | "cmp/hi %1, %2 ! T if 32 > len \n\t" | ||
48 | "mov.l %5, @(0x10,%0) \n\t" | ||
49 | "mov.l %6, @(0x14,%0) \n\t" | ||
50 | "mov.l r7, @(0x18,%0) \n\t" | ||
51 | "mov.l r0, @(0x1c,%0) \n\t" | ||
52 | "bf.s 1b \n\t" | ||
53 | " add #0x20, %0 \n\t" | ||
54 | : "=&r" (data), "=&r" (len), | ||
55 | "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4), | ||
56 | "=&r" (tmp5), "=&r" (tmp6) | ||
57 | : "r"(addr), "0" (data), "1" (len) | ||
58 | : "r0", "r7", "t", "memory"); | ||
59 | } | ||
60 | |||
61 | for (; len != 0; len--) | ||
62 | *data++ = ctrl_inl(addr); | ||
63 | } | ||
64 | EXPORT_SYMBOL(__raw_readsl); | ||
65 | |||
66 | void __raw_writesl(unsigned long addr, const void *data, int len) | ||
67 | { | ||
68 | if (likely(len != 0)) { | ||
69 | int tmp1; | ||
70 | |||
71 | __asm__ __volatile__ ( | ||
72 | "1: \n\t" | ||
73 | "mov.l @%0+, %1 \n\t" | ||
74 | "dt %3 \n\t" | ||
75 | "bf.s 1b \n\t" | ||
76 | " mov.l %1, @%4 \n\t" | ||
77 | : "=&r" (data), "=&r" (tmp1) | ||
78 | : "0" (data), "r" (len), "r"(addr) | ||
79 | : "t", "memory"); | ||
80 | } | ||
81 | } | ||
82 | EXPORT_SYMBOL(__raw_writesl); | ||