[a66a890] | 1 | Submitted By: Jim Gifford (patches at jg555 dot com)
|
---|
| 2 | Date: 2006-07-08
|
---|
| 3 | Initial Package Version: 2.6.17.4
|
---|
| 4 | Origin: Linux-MIPS Mailing List
|
---|
| 5 | Upstream Status: Not Applied
|
---|
| 6 | Description: These are patches that have not been accepted by
|
---|
| 7 | Linux-MIPS.
|
---|
| 8 |
|
---|
| 9 | 1 - iomap for MIPS - iomap.c io.h
|
---|
| 10 | 2 - Cobalt ide fixes
|
---|
| 11 |
|
---|
| 12 | diff -Naur linux-2.6.17.4/arch/mips/lib/iomap.c linux-2.6.17.4.kernel/arch/mips/lib/iomap.c
|
---|
| 13 | --- linux-2.6.17.4/arch/mips/lib/iomap.c 1969-12-31 16:00:00.000000000 -0800
|
---|
| 14 | +++ linux-2.6.17.4.kernel/arch/mips/lib/iomap.c 2006-06-30 10:37:38.000000000 -0700
|
---|
| 15 | @@ -0,0 +1,78 @@
|
---|
| 16 | +/*
|
---|
| 17 | + * iomap.c, Memory Mapped I/O routines for MIPS architecture.
|
---|
| 18 | + *
|
---|
| 19 | + * This code is based on lib/iomap.c, by Linus Torvalds.
|
---|
| 20 | + *
|
---|
| 21 | + * Copyright (C) 2004-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
|
---|
| 22 | + *
|
---|
| 23 | + * This program is free software; you can redistribute it and/or modify
|
---|
| 24 | + * it under the terms of the GNU General Public License as published by
|
---|
| 25 | + * the Free Software Foundation; either version 2 of the License, or
|
---|
| 26 | + * (at your option) any later version.
|
---|
| 27 | + *
|
---|
| 28 | + * This program is distributed in the hope that it will be useful,
|
---|
| 29 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 30 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 31 | + * GNU General Public License for more details.
|
---|
| 32 | + *
|
---|
| 33 | + * You should have received a copy of the GNU General Public License
|
---|
| 34 | + * along with this program; if not, write to the Free Software
|
---|
| 35 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 36 | + */
|
---|
| 37 | +#include <linux/ioport.h>
|
---|
| 38 | +#include <linux/module.h>
|
---|
| 39 | +#include <linux/pci.h>
|
---|
| 40 | +
|
---|
| 41 | +#include <asm/io.h>
|
---|
| 42 | +
|
---|
| 43 | +void __iomem *ioport_map(unsigned long port, unsigned int nr)
|
---|
| 44 | +{
|
---|
| 45 | + unsigned long end;
|
---|
| 46 | +
|
---|
| 47 | + end = port + nr - 1UL;
|
---|
| 48 | + if (ioport_resource.start > port ||
|
---|
| 49 | + ioport_resource.end < end || port > end)
|
---|
| 50 | + return NULL;
|
---|
| 51 | +
|
---|
| 52 | + return (void __iomem *)(mips_io_port_base + port);
|
---|
| 53 | +}
|
---|
| 54 | +
|
---|
| 55 | +void ioport_unmap(void __iomem *addr)
|
---|
| 56 | +{
|
---|
| 57 | +}
|
---|
| 58 | +EXPORT_SYMBOL(ioport_map);
|
---|
| 59 | +EXPORT_SYMBOL(ioport_unmap);
|
---|
| 60 | +
|
---|
| 61 | +void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
|
---|
| 62 | +{
|
---|
| 63 | + unsigned long start, len, flags;
|
---|
| 64 | +
|
---|
| 65 | + if (dev == NULL)
|
---|
| 66 | + return NULL;
|
---|
| 67 | +
|
---|
| 68 | + start = pci_resource_start(dev, bar);
|
---|
| 69 | + len = pci_resource_len(dev, bar);
|
---|
| 70 | + if (!start || !len)
|
---|
| 71 | + return NULL;
|
---|
| 72 | +
|
---|
| 73 | + if (maxlen != 0 && len > maxlen)
|
---|
| 74 | + len = maxlen;
|
---|
| 75 | +
|
---|
| 76 | + flags = pci_resource_flags(dev, bar);
|
---|
| 77 | + if (flags & IORESOURCE_IO)
|
---|
| 78 | + return ioport_map(start, len);
|
---|
| 79 | + if (flags & IORESOURCE_MEM) {
|
---|
| 80 | + if (flags & IORESOURCE_CACHEABLE)
|
---|
| 81 | + return ioremap_cachable(start, len);
|
---|
| 82 | + return ioremap_nocache(start, len);
|
---|
| 83 | + }
|
---|
| 84 | +
|
---|
| 85 | + return NULL;
|
---|
| 86 | +}
|
---|
| 87 | +
|
---|
| 88 | +void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
|
---|
| 89 | +{
|
---|
| 90 | + iounmap(addr);
|
---|
| 91 | +}
|
---|
| 92 | +EXPORT_SYMBOL(pci_iomap);
|
---|
| 93 | +EXPORT_SYMBOL(pci_iounmap);
|
---|
| 94 | diff -Naur linux-2.6.17.4/arch/mips/lib/Makefile linux-2.6.17.4.kernel/arch/mips/lib/Makefile
|
---|
| 95 | --- linux-2.6.17.4/arch/mips/lib/Makefile 2006-07-02 01:53:19.000000000 -0700
|
---|
| 96 | +++ linux-2.6.17.4.kernel/arch/mips/lib/Makefile 2006-07-07 12:40:23.000000000 -0700
|
---|
| 97 | @@ -5,6 +5,8 @@
|
---|
| 98 | lib-y += csum_partial_copy.o memcpy.o promlib.o strlen_user.o strncpy_user.o \
|
---|
| 99 | strnlen_user.o uncached.o
|
---|
| 100 |
|
---|
| 101 | +obj-y += iomap.o
|
---|
| 102 | +
|
---|
| 103 | # libgcc-style stuff needed in the kernel
|
---|
| 104 | lib-y += ashldi3.o ashrdi3.o lshrdi3.o
|
---|
| 105 |
|
---|
| 106 | diff -Naur linux-2.6.17.4/include/asm-mips/io.h linux-2.6.17.4.kernel/include/asm-mips/io.h
|
---|
| 107 | --- linux-2.6.17.4/include/asm-mips/io.h 2006-07-02 01:53:19.000000000 -0700
|
---|
| 108 | +++ linux-2.6.17.4.kernel/include/asm-mips/io.h 2006-07-07 12:44:03.000000000 -0700
|
---|
| 109 | @@ -519,6 +519,34 @@
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | /*
|
---|
| 113 | + * Memory Mapped I/O
|
---|
| 114 | + */
|
---|
| 115 | +#define ioread8(addr) readb(addr)
|
---|
| 116 | +#define ioread16(addr) readw(addr)
|
---|
| 117 | +#define ioread32(addr) readl(addr)
|
---|
| 118 | +
|
---|
| 119 | +#define iowrite8(b,addr) writeb(b,addr)
|
---|
| 120 | +#define iowrite16(w,addr) writew(w,addr)
|
---|
| 121 | +#define iowrite32(l,addr) writel(l,addr)
|
---|
| 122 | +
|
---|
| 123 | +#define ioread8_rep(a,b,c) readsb(a,b,c)
|
---|
| 124 | +#define ioread16_rep(a,b,c) readsw(a,b,c)
|
---|
| 125 | +#define ioread32_rep(a,b,c) readsl(a,b,c)
|
---|
| 126 | +
|
---|
| 127 | +#define iowrite8_rep(a,b,c) writesb(a,b,c)
|
---|
| 128 | +#define iowrite16_rep(a,b,c) writesw(a,b,c)
|
---|
| 129 | +#define iowrite32_rep(a,b,c) writesl(a,b,c)
|
---|
| 130 | +
|
---|
| 131 | +/* Create a virtual mapping cookie for an IO port range */
|
---|
| 132 | +extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
|
---|
| 133 | +extern void ioport_unmap(void __iomem *);
|
---|
| 134 | +
|
---|
| 135 | +/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
|
---|
| 136 | +struct pci_dev;
|
---|
| 137 | +extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
|
---|
| 138 | +extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
|
---|
| 139 | +
|
---|
| 140 | +/*
|
---|
| 141 | * ISA space is 'always mapped' on currently supported MIPS systems, no need
|
---|
| 142 | * to explicitly ioremap() it. The fact that the ISA IO space is mapped
|
---|
| 143 | * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
|
---|
| 144 | diff -Naur linux-2.6.17.4/include/asm-mips/mach-cobalt/ide.h linux-2.6.17.4.kernel/include/asm-mips/mach-cobalt/ide.h
|
---|
| 145 | --- linux-2.6.17.4/include/asm-mips/mach-cobalt/ide.h 1969-12-31 16:00:00.000000000 -0800
|
---|
| 146 | +++ linux-2.6.17.4.kernel/include/asm-mips/mach-cobalt/ide.h 2006-07-07 12:40:46.000000000 -0700
|
---|
| 147 | @@ -0,0 +1,83 @@
|
---|
| 148 | +
|
---|
| 149 | +/*
|
---|
| 150 | + * PIO "in" transfers can cause D-cache lines to be allocated
|
---|
| 151 | + * to the data being read. If the target is the page cache then
|
---|
| 152 | + * the kernel can create a user space mapping of the same page
|
---|
| 153 | + * without flushing it from the D-cache. This has large potential
|
---|
| 154 | + * to create cache aliases. The Cobalts seem to trigger this
|
---|
| 155 | + * problem easily.
|
---|
| 156 | + *
|
---|
| 157 | + * MIPs doesn't have a flush_dcache_range() so we roll
|
---|
| 158 | + * our own.
|
---|
| 159 | + *
|
---|
| 160 | + * -- pdh
|
---|
| 161 | + */
|
---|
| 162 | +
|
---|
| 163 | +#define MAX_HWIFS 2
|
---|
| 164 | +
|
---|
| 165 | +#include <asm/r4kcache.h>
|
---|
| 166 | +
|
---|
| 167 | +static inline void __flush_dcache(void)
|
---|
| 168 | +{
|
---|
| 169 | + unsigned long dc_size, dc_line, addr, end;
|
---|
| 170 | +
|
---|
| 171 | + dc_size = current_cpu_data.dcache.ways << current_cpu_data.dcache.waybit;
|
---|
| 172 | + dc_line = current_cpu_data.dcache.linesz;
|
---|
| 173 | +
|
---|
| 174 | + addr = CKSEG0;
|
---|
| 175 | + end = addr + dc_size;
|
---|
| 176 | +
|
---|
| 177 | + for (; addr < end; addr += dc_line)
|
---|
| 178 | + flush_dcache_line_indexed(addr);
|
---|
| 179 | +}
|
---|
| 180 | +
|
---|
| 181 | +static inline void __flush_dcache_range(unsigned long start, unsigned long end)
|
---|
| 182 | +{
|
---|
| 183 | + unsigned long dc_size, dc_line, addr;
|
---|
| 184 | +
|
---|
| 185 | + dc_size = current_cpu_data.dcache.ways << current_cpu_data.dcache.waybit;
|
---|
| 186 | + dc_line = current_cpu_data.dcache.linesz;
|
---|
| 187 | +
|
---|
| 188 | + addr = start & ~(dc_line - 1);
|
---|
| 189 | + end += dc_line - 1;
|
---|
| 190 | +
|
---|
| 191 | + if (end - addr < dc_size)
|
---|
| 192 | + for (; addr < end; addr += dc_line)
|
---|
| 193 | + flush_dcache_line(addr);
|
---|
| 194 | + else
|
---|
| 195 | + __flush_dcache();
|
---|
| 196 | +}
|
---|
| 197 | +
|
---|
| 198 | +static inline void __ide_insw(unsigned long port, void *addr, unsigned int count)
|
---|
| 199 | +{
|
---|
| 200 | + insw(port, addr, count);
|
---|
| 201 | +
|
---|
| 202 | + __flush_dcache_range((unsigned long) addr, (unsigned long) addr + count * 2);
|
---|
| 203 | +}
|
---|
| 204 | +
|
---|
| 205 | +static inline void __ide_insl(unsigned long port, void *addr, unsigned int count)
|
---|
| 206 | +{
|
---|
| 207 | + insl(port, addr, count);
|
---|
| 208 | +
|
---|
| 209 | + __flush_dcache_range((unsigned long) addr, (unsigned long) addr + count * 4);
|
---|
| 210 | +}
|
---|
| 211 | +
|
---|
| 212 | +static inline void __ide_mm_insw(volatile void __iomem *port, void *addr, unsigned int count)
|
---|
| 213 | +{
|
---|
| 214 | + readsw(port, addr, count);
|
---|
| 215 | +
|
---|
| 216 | + __flush_dcache_range((unsigned long) addr, (unsigned long) addr + count * 2);
|
---|
| 217 | +}
|
---|
| 218 | +
|
---|
| 219 | +static inline void __ide_mm_insl(volatile void __iomem *port, void *addr, unsigned int count)
|
---|
| 220 | +{
|
---|
| 221 | + readsl(port, addr, count);
|
---|
| 222 | +
|
---|
| 223 | + __flush_dcache_range((unsigned long) addr, (unsigned long) addr + count * 4);
|
---|
| 224 | +}
|
---|
| 225 | +
|
---|
| 226 | +#define insw __ide_insw
|
---|
| 227 | +#define insl __ide_insl
|
---|
| 228 | +
|
---|
| 229 | +#define __ide_mm_outsw writesw
|
---|
| 230 | +#define __ide_mm_outsl writesl
|
---|