diff options
Diffstat (limited to 'arch/sh/kernel/io.c')
-rw-r--r-- | arch/sh/kernel/io.c | 97 |
1 files changed, 76 insertions, 21 deletions
diff --git a/arch/sh/kernel/io.c b/arch/sh/kernel/io.c index 4f85fffaa557..4770c241c679 100644 --- a/arch/sh/kernel/io.c +++ b/arch/sh/kernel/io.c | |||
@@ -1,12 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * linux/arch/sh/kernel/io.c | 2 | * arch/sh/kernel/io.c - Machine independent I/O functions. |
3 | * | 3 | * |
4 | * Copyright (C) 2000 Stuart Menefy | 4 | * Copyright (C) 2000 - 2009 Stuart Menefy |
5 | * Copyright (C) 2005 Paul Mundt | 5 | * Copyright (C) 2005 Paul Mundt |
6 | * | 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 | 7 | * 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 | 8 | * License. See the file "COPYING" in the main directory of this archive |
12 | * for more details. | 9 | * for more details. |
@@ -18,33 +15,87 @@ | |||
18 | 15 | ||
19 | /* | 16 | /* |
20 | * Copy data from IO memory space to "real" memory space. | 17 | * Copy data from IO memory space to "real" memory space. |
21 | * This needs to be optimized. | ||
22 | */ | 18 | */ |
23 | void memcpy_fromio(void *to, const volatile void __iomem *from, unsigned long count) | 19 | void memcpy_fromio(void *to, const volatile void __iomem *from, unsigned long count) |
24 | { | 20 | { |
25 | unsigned char *p = to; | 21 | /* |
26 | while (count) { | 22 | * Would it be worthwhile doing byte and long transfers first |
27 | count--; | 23 | * to try and get aligned? |
28 | *p = readb(from); | 24 | */ |
29 | p++; | 25 | #ifdef CONFIG_CPU_SH4 |
30 | from++; | 26 | if ((count >= 0x20) && |
31 | } | 27 | (((u32)to & 0x1f) == 0) && (((u32)from & 0x3) == 0)) { |
28 | int tmp2, tmp3, tmp4, tmp5, tmp6; | ||
29 | |||
30 | __asm__ __volatile__( | ||
31 | "1: \n\t" | ||
32 | "mov.l @%7+, r0 \n\t" | ||
33 | "mov.l @%7+, %2 \n\t" | ||
34 | "movca.l r0, @%0 \n\t" | ||
35 | "mov.l @%7+, %3 \n\t" | ||
36 | "mov.l @%7+, %4 \n\t" | ||
37 | "mov.l @%7+, %5 \n\t" | ||
38 | "mov.l @%7+, %6 \n\t" | ||
39 | "mov.l @%7+, r7 \n\t" | ||
40 | "mov.l @%7+, r0 \n\t" | ||
41 | "mov.l %2, @(0x04,%0) \n\t" | ||
42 | "mov #0x20, %2 \n\t" | ||
43 | "mov.l %3, @(0x08,%0) \n\t" | ||
44 | "sub %2, %1 \n\t" | ||
45 | "mov.l %4, @(0x0c,%0) \n\t" | ||
46 | "cmp/hi %1, %2 ! T if 32 > count \n\t" | ||
47 | "mov.l %5, @(0x10,%0) \n\t" | ||
48 | "mov.l %6, @(0x14,%0) \n\t" | ||
49 | "mov.l r7, @(0x18,%0) \n\t" | ||
50 | "mov.l r0, @(0x1c,%0) \n\t" | ||
51 | "bf.s 1b \n\t" | ||
52 | " add #0x20, %0 \n\t" | ||
53 | : "=&r" (to), "=&r" (count), | ||
54 | "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4), | ||
55 | "=&r" (tmp5), "=&r" (tmp6), "=&r" (from) | ||
56 | : "7"(from), "0" (to), "1" (count) | ||
57 | : "r0", "r7", "t", "memory"); | ||
58 | } | ||
59 | #endif | ||
60 | |||
61 | if ((((u32)to | (u32)from) & 0x3) == 0) { | ||
62 | for (; count > 3; count -= 4) { | ||
63 | *(u32 *)to = *(volatile u32 *)from; | ||
64 | to += 4; | ||
65 | from += 4; | ||
66 | } | ||
67 | } | ||
68 | |||
69 | for (; count > 0; count--) { | ||
70 | *(u8 *)to = *(volatile u8 *)from; | ||
71 | to++; | ||
72 | from++; | ||
73 | } | ||
74 | |||
75 | mb(); | ||
32 | } | 76 | } |
33 | EXPORT_SYMBOL(memcpy_fromio); | 77 | EXPORT_SYMBOL(memcpy_fromio); |
34 | 78 | ||
35 | /* | 79 | /* |
36 | * Copy data from "real" memory space to IO memory space. | 80 | * Copy data from "real" memory space to IO memory space. |
37 | * This needs to be optimized. | ||
38 | */ | 81 | */ |
39 | void memcpy_toio(volatile void __iomem *to, const void *from, unsigned long count) | 82 | void memcpy_toio(volatile void __iomem *to, const void *from, unsigned long count) |
40 | { | 83 | { |
41 | const unsigned char *p = from; | 84 | if ((((u32)to | (u32)from) & 0x3) == 0) { |
42 | while (count) { | 85 | for ( ; count > 3; count -= 4) { |
43 | count--; | 86 | *(volatile u32 *)to = *(u32 *)from; |
44 | writeb(*p, to); | 87 | to += 4; |
45 | p++; | 88 | from += 4; |
46 | to++; | 89 | } |
47 | } | 90 | } |
91 | |||
92 | for (; count > 0; count--) { | ||
93 | *(volatile u8 *)to = *(u8 *)from; | ||
94 | to++; | ||
95 | from++; | ||
96 | } | ||
97 | |||
98 | mb(); | ||
48 | } | 99 | } |
49 | EXPORT_SYMBOL(memcpy_toio); | 100 | EXPORT_SYMBOL(memcpy_toio); |
50 | 101 | ||
@@ -62,6 +113,8 @@ void memset_io(volatile void __iomem *dst, int c, unsigned long count) | |||
62 | } | 113 | } |
63 | EXPORT_SYMBOL(memset_io); | 114 | EXPORT_SYMBOL(memset_io); |
64 | 115 | ||
116 | #ifndef CONFIG_GENERIC_IOMAP | ||
117 | |||
65 | void __iomem *ioport_map(unsigned long port, unsigned int nr) | 118 | void __iomem *ioport_map(unsigned long port, unsigned int nr) |
66 | { | 119 | { |
67 | void __iomem *ret; | 120 | void __iomem *ret; |
@@ -79,3 +132,5 @@ void ioport_unmap(void __iomem *addr) | |||
79 | sh_mv.mv_ioport_unmap(addr); | 132 | sh_mv.mv_ioport_unmap(addr); |
80 | } | 133 | } |
81 | EXPORT_SYMBOL(ioport_unmap); | 134 | EXPORT_SYMBOL(ioport_unmap); |
135 | |||
136 | #endif /* CONFIG_GENERIC_IOMAP */ | ||