ARM: omap1: use pci_remap_iospace() for omap_cf
authorArnd Bergmann <arnd@arndb.de>
Tue, 6 Aug 2019 18:42:29 +0000 (20:42 +0200)
committerArnd Bergmann <arnd@arndb.de>
Fri, 22 Apr 2022 09:08:55 +0000 (11:08 +0200)
The ISA I/O space handling in omap_cf is incompatible with
PCI drivers in a multiplatform kernel, and requires a custom
mach/io.h.

Change the driver to use pci_remap_iospace() like PCI drivers do,
so the generic ioport access can work across platforms.

To actually use that code, we have to select CONFIG_PCI
here.

Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
arch/arm/Kconfig
arch/arm/mach-omap1/include/mach/io.h [deleted file]
drivers/pcmcia/omap_cf.c

index 700655e..a57ad09 100644 (file)
@@ -487,11 +487,11 @@ config ARCH_OMAP1
        bool "TI OMAP1"
        select ARCH_OMAP
        select CLKSRC_MMIO
+       select FORCE_PCI if PCCARD
        select GENERIC_IRQ_CHIP
        select GPIOLIB
        select HAVE_LEGACY_CLK
        select IRQ_DOMAIN
-       select NEED_MACH_IO_H if PCCARD
        select NEED_MACH_MEMORY_H
        select SPARSE_IRQ
        help
diff --git a/arch/arm/mach-omap1/include/mach/io.h b/arch/arm/mach-omap1/include/mach/io.h
deleted file mode 100644 (file)
index ce4f800..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * arch/arm/mach-omap1/include/mach/io.h
- *
- * IO definitions for TI OMAP processors and boards
- *
- * Copied from arch/arm/mach-sa1100/include/mach/io.h
- * Copyright (C) 1997-1999 Russell King
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
- * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Modifications:
- *  06-12-1997 RMK     Created.
- *  07-04-1999 RMK     Major cleanup
- */
-
-#ifndef __ASM_ARM_ARCH_IO_H
-#define __ASM_ARM_ARCH_IO_H
-
-#define IO_SPACE_LIMIT 0xffffffff
-
-/*
- * We don't actually have real ISA nor PCI buses, but there is so many
- * drivers out there that might just work if we fake them...
- */
-#define __io(a)                __typesafe_io(a)
-
-#endif
index 093022c..1972a8f 100644 (file)
@@ -205,6 +205,7 @@ static int __init omap_cf_probe(struct platform_device *pdev)
        int                     irq;
        int                     status;
        struct resource         *res;
+       struct resource         iospace = DEFINE_RES_IO(SZ_64, SZ_4K);
 
        seg = (int) pdev->dev.platform_data;
        if (seg == 0 || seg > 3)
@@ -235,9 +236,9 @@ static int __init omap_cf_probe(struct platform_device *pdev)
        cf->phys_cf = res->start;
 
        /* pcmcia layer only remaps "real" memory */
-       cf->socket.io_offset = (unsigned long)
-                       ioremap(cf->phys_cf + SZ_4K, SZ_2K);
-       if (!cf->socket.io_offset) {
+       cf->socket.io_offset = iospace.start;
+       status = pci_remap_iospace(&iospace, cf->phys_cf + SZ_4K);
+       if (status) {
                status = -ENOMEM;
                goto fail1;
        }
@@ -285,8 +286,6 @@ static int __init omap_cf_probe(struct platform_device *pdev)
 fail2:
        release_mem_region(cf->phys_cf, SZ_8K);
 fail1:
-       if (cf->socket.io_offset)
-               iounmap((void __iomem *) cf->socket.io_offset);
        free_irq(irq, cf);
 fail0:
        kfree(cf);
@@ -300,7 +299,6 @@ static int __exit omap_cf_remove(struct platform_device *pdev)
        cf->active = 0;
        pcmcia_unregister_socket(&cf->socket);
        del_timer_sync(&cf->timer);
-       iounmap((void __iomem *) cf->socket.io_offset);
        release_mem_region(cf->phys_cf, SZ_8K);
        free_irq(cf->irq, cf);
        kfree(cf);