From b519c9c7e68d5e2e9d5aaff3843fda09342c79d7 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 18 Aug 2022 17:18:12 +0200 Subject: ARM: footbridge: remove addin mode This does not appear to have been used in many years, we can kill off some of the uglier code. Among other things, it avoids a randconfig issue when both modes are disabled: arch/arm/mach-footbridge/common.c:149:24: error: 'ebsa285_host_io_desc' defined but not used [-Werror=unused-variable] 149 | static struct map_desc ebsa285_host_io_desc[] __initdata = { | ^~~~~~~~~~~~~~~~~~~~ arch/arm/mach-footbridge/common.c:136:24: error: 'fb_common_io_desc' defined but not used [-Werror=unused-variable] 136 | static struct map_desc fb_common_io_desc[] __initdata = { | ^~~~~~~~~~~~~~~~~ The recently added phys_to_dma() functions are now trivial and could probably be removed again as a follow-up, if anyone knows how. Cc: Christoph Hellwig Tested-by: Marc Zyngier Signed-off-by: Arnd Bergmann --- arch/arm/include/asm/hardware/dec21285.h | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'arch/arm/include/asm') diff --git a/arch/arm/include/asm/hardware/dec21285.h b/arch/arm/include/asm/hardware/dec21285.h index 3f18a56a025d..eee390e8d4dc 100644 --- a/arch/arm/include/asm/hardware/dec21285.h +++ b/arch/arm/include/asm/hardware/dec21285.h @@ -81,19 +81,6 @@ #define SA110_CNTL_XCSDIR(x) ((x)<<28) #define SA110_CNTL_PCICFN (1 << 31) -/* - * footbridge_cfn_mode() is used when we want - * to check whether we are the central function - */ -#define __footbridge_cfn_mode() (*CSR_SA110_CNTL & SA110_CNTL_PCICFN) -#if defined(CONFIG_FOOTBRIDGE_HOST) && defined(CONFIG_FOOTBRIDGE_ADDIN) -#define footbridge_cfn_mode() __footbridge_cfn_mode() -#elif defined(CONFIG_FOOTBRIDGE_HOST) -#define footbridge_cfn_mode() (1) -#else -#define footbridge_cfn_mode() (0) -#endif - #define CSR_PCIADDR_EXTN DC21285_IO(0x0140) #define CSR_PREFETCHMEMRANGE DC21285_IO(0x0144) #define CSR_XBUS_CYCLE DC21285_IO(0x0148) -- cgit v1.2.3-59-g8ed1b From e7536617baec3b4717a37795cec306df9d655d07 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 1 Jul 2022 11:44:52 +0200 Subject: ARM: footbridge: move isa-dma support into footbridge The dma-isa.c was shared between footbridge and shark a long time ago, but as shark was removed, it can be made footbridge specific again. The fb_dma bits in turn are not used at all and can be removed. All the ISA related files are now built into the platform regardless of CONFIG_ISA, as they just refer to on-chip devices rather than actual ISA cards. Reviewed-by: Christoph Hellwig Tested-by: Marc Zyngier Signed-off-by: Arnd Bergmann --- arch/arm/Kconfig | 5 - arch/arm/include/asm/mach/dma.h | 5 - arch/arm/kernel/Makefile | 1 - arch/arm/kernel/dma-isa.c | 225 ----------------------- arch/arm/mach-footbridge/Kconfig | 2 +- arch/arm/mach-footbridge/Makefile | 3 +- arch/arm/mach-footbridge/dma-isa.c | 226 ++++++++++++++++++++++++ arch/arm/mach-footbridge/dma.c | 57 ------ arch/arm/mach-footbridge/include/mach/isa-dma.h | 14 +- 9 files changed, 231 insertions(+), 307 deletions(-) delete mode 100644 arch/arm/kernel/dma-isa.c create mode 100644 arch/arm/mach-footbridge/dma-isa.c delete mode 100644 arch/arm/mach-footbridge/dma.c (limited to 'arch/arm/include/asm') diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 87badeae3181..ec7e48f6bd91 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -989,11 +989,6 @@ config ISA (MCA) or VESA. ISA is an older system, now being displaced by PCI; newer boards don't support it. If you have ISA, say Y, otherwise N. -# Select ISA DMA controller support -config ISA_DMA - bool - select ISA_DMA_API - # Select ISA DMA interface config ISA_DMA_API bool diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h index 1506422af383..5ec11d7f0d04 100644 --- a/arch/arm/include/asm/mach/dma.h +++ b/arch/arm/include/asm/mach/dma.h @@ -44,8 +44,3 @@ struct dma_struct { * isa_dma_add - add an ISA-style DMA channel */ extern int isa_dma_add(unsigned int, dma_t *dma); - -/* - * Add the ISA DMA controller. Always takes channels 0-7. - */ -extern void isa_init_dma(void); diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index 553866751e1a..95034d32213c 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -45,7 +45,6 @@ obj-$(CONFIG_ISA_DMA_API) += dma.o obj-$(CONFIG_FIQ) += fiq.o fiqasm.o obj-$(CONFIG_MODULES) += armksyms.o module.o obj-$(CONFIG_ARM_MODULE_PLTS) += module-plts.o -obj-$(CONFIG_ISA_DMA) += dma-isa.o obj-$(CONFIG_PCI) += bios32.o isa.o obj-$(CONFIG_ARM_CPU_SUSPEND) += sleep.o suspend.o obj-$(CONFIG_HIBERNATION) += hibernate.o diff --git a/arch/arm/kernel/dma-isa.c b/arch/arm/kernel/dma-isa.c deleted file mode 100644 index 2d90ecce5a11..000000000000 --- a/arch/arm/kernel/dma-isa.c +++ /dev/null @@ -1,225 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * linux/arch/arm/kernel/dma-isa.c - * - * Copyright (C) 1999-2000 Russell King - * - * ISA DMA primitives - * Taken from various sources, including: - * linux/include/asm/dma.h: Defines for using and allocating dma channels. - * Written by Hennus Bergman, 1992. - * High DMA channel support & info by Hannu Savolainen and John Boyd, - * Nov. 1992. - * arch/arm/kernel/dma-ebsa285.c - * Copyright (C) 1998 Phil Blundell - */ -#include -#include -#include -#include - -#include -#include - -#define ISA_DMA_MASK 0 -#define ISA_DMA_MODE 1 -#define ISA_DMA_CLRFF 2 -#define ISA_DMA_PGHI 3 -#define ISA_DMA_PGLO 4 -#define ISA_DMA_ADDR 5 -#define ISA_DMA_COUNT 6 - -static unsigned int isa_dma_port[8][7] = { - /* MASK MODE CLRFF PAGE_HI PAGE_LO ADDR COUNT */ - { 0x0a, 0x0b, 0x0c, 0x487, 0x087, 0x00, 0x01 }, - { 0x0a, 0x0b, 0x0c, 0x483, 0x083, 0x02, 0x03 }, - { 0x0a, 0x0b, 0x0c, 0x481, 0x081, 0x04, 0x05 }, - { 0x0a, 0x0b, 0x0c, 0x482, 0x082, 0x06, 0x07 }, - { 0xd4, 0xd6, 0xd8, 0x000, 0x000, 0xc0, 0xc2 }, - { 0xd4, 0xd6, 0xd8, 0x48b, 0x08b, 0xc4, 0xc6 }, - { 0xd4, 0xd6, 0xd8, 0x489, 0x089, 0xc8, 0xca }, - { 0xd4, 0xd6, 0xd8, 0x48a, 0x08a, 0xcc, 0xce } -}; - -static int isa_get_dma_residue(unsigned int chan, dma_t *dma) -{ - unsigned int io_port = isa_dma_port[chan][ISA_DMA_COUNT]; - int count; - - count = 1 + inb(io_port); - count |= inb(io_port) << 8; - - return chan < 4 ? count : (count << 1); -} - -static struct device isa_dma_dev = { - .init_name = "fallback device", - .coherent_dma_mask = ~(dma_addr_t)0, - .dma_mask = &isa_dma_dev.coherent_dma_mask, -}; - -static void isa_enable_dma(unsigned int chan, dma_t *dma) -{ - if (dma->invalid) { - unsigned long address, length; - unsigned int mode; - enum dma_data_direction direction; - - mode = (chan & 3) | dma->dma_mode; - switch (dma->dma_mode & DMA_MODE_MASK) { - case DMA_MODE_READ: - direction = DMA_FROM_DEVICE; - break; - - case DMA_MODE_WRITE: - direction = DMA_TO_DEVICE; - break; - - case DMA_MODE_CASCADE: - direction = DMA_BIDIRECTIONAL; - break; - - default: - direction = DMA_NONE; - break; - } - - if (!dma->sg) { - /* - * Cope with ISA-style drivers which expect cache - * coherence. - */ - dma->sg = &dma->buf; - dma->sgcount = 1; - dma->buf.length = dma->count; - dma->buf.dma_address = dma_map_single(&isa_dma_dev, - dma->addr, dma->count, - direction); - } - - address = dma->buf.dma_address; - length = dma->buf.length - 1; - - outb(address >> 16, isa_dma_port[chan][ISA_DMA_PGLO]); - outb(address >> 24, isa_dma_port[chan][ISA_DMA_PGHI]); - - if (chan >= 4) { - address >>= 1; - length >>= 1; - } - - outb(0, isa_dma_port[chan][ISA_DMA_CLRFF]); - - outb(address, isa_dma_port[chan][ISA_DMA_ADDR]); - outb(address >> 8, isa_dma_port[chan][ISA_DMA_ADDR]); - - outb(length, isa_dma_port[chan][ISA_DMA_COUNT]); - outb(length >> 8, isa_dma_port[chan][ISA_DMA_COUNT]); - - outb(mode, isa_dma_port[chan][ISA_DMA_MODE]); - dma->invalid = 0; - } - outb(chan & 3, isa_dma_port[chan][ISA_DMA_MASK]); -} - -static void isa_disable_dma(unsigned int chan, dma_t *dma) -{ - outb(chan | 4, isa_dma_port[chan][ISA_DMA_MASK]); -} - -static struct dma_ops isa_dma_ops = { - .type = "ISA", - .enable = isa_enable_dma, - .disable = isa_disable_dma, - .residue = isa_get_dma_residue, -}; - -static struct resource dma_resources[] = { { - .name = "dma1", - .start = 0x0000, - .end = 0x000f -}, { - .name = "dma low page", - .start = 0x0080, - .end = 0x008f -}, { - .name = "dma2", - .start = 0x00c0, - .end = 0x00df -}, { - .name = "dma high page", - .start = 0x0480, - .end = 0x048f -} }; - -static dma_t isa_dma[8]; - -/* - * ISA DMA always starts at channel 0 - */ -void __init isa_init_dma(void) -{ - /* - * Try to autodetect presence of an ISA DMA controller. - * We do some minimal initialisation, and check that - * channel 0's DMA address registers are writeable. - */ - outb(0xff, 0x0d); - outb(0xff, 0xda); - - /* - * Write high and low address, and then read them back - * in the same order. - */ - outb(0x55, 0x00); - outb(0xaa, 0x00); - - if (inb(0) == 0x55 && inb(0) == 0xaa) { - unsigned int chan, i; - - for (chan = 0; chan < 8; chan++) { - isa_dma[chan].d_ops = &isa_dma_ops; - isa_disable_dma(chan, NULL); - } - - outb(0x40, 0x0b); - outb(0x41, 0x0b); - outb(0x42, 0x0b); - outb(0x43, 0x0b); - - outb(0xc0, 0xd6); - outb(0x41, 0xd6); - outb(0x42, 0xd6); - outb(0x43, 0xd6); - - outb(0, 0xd4); - - outb(0x10, 0x08); - outb(0x10, 0xd0); - - /* - * Is this correct? According to my documentation, it - * doesn't appear to be. It should be: - * outb(0x3f, 0x40b); outb(0x3f, 0x4d6); - */ - outb(0x30, 0x40b); - outb(0x31, 0x40b); - outb(0x32, 0x40b); - outb(0x33, 0x40b); - outb(0x31, 0x4d6); - outb(0x32, 0x4d6); - outb(0x33, 0x4d6); - - for (i = 0; i < ARRAY_SIZE(dma_resources); i++) - request_resource(&ioport_resource, dma_resources + i); - - for (chan = 0; chan < 8; chan++) { - int ret = isa_dma_add(chan, &isa_dma[chan]); - if (ret) - pr_err("ISADMA%u: unable to register: %d\n", - chan, ret); - } - - request_dma(DMA_ISA_CASCADE, "cascade"); - } -} diff --git a/arch/arm/mach-footbridge/Kconfig b/arch/arm/mach-footbridge/Kconfig index 3497ea8e91e3..1a3676109654 100644 --- a/arch/arm/mach-footbridge/Kconfig +++ b/arch/arm/mach-footbridge/Kconfig @@ -48,7 +48,7 @@ config FOOTBRIDGE def_bool y select ARCH_HAS_PHYS_TO_DMA select ARCH_MIGHT_HAVE_PC_SERIO - select ISA_DMA + select ISA_DMA_API config ARCH_EBSA285 bool diff --git a/arch/arm/mach-footbridge/Makefile b/arch/arm/mach-footbridge/Makefile index 30bae6684dce..55d570739f19 100644 --- a/arch/arm/mach-footbridge/Makefile +++ b/arch/arm/mach-footbridge/Makefile @@ -5,7 +5,7 @@ # Object file lists. -obj-y := common.o dma.o isa-irq.o +obj-y := common.o isa-irq.o isa.o isa-rtc.o dma-isa.o pci-y += dc21285.o pci-$(CONFIG_ARCH_CATS) += cats-pci.o @@ -18,4 +18,3 @@ obj-$(CONFIG_ARCH_NETWINDER) += netwinder-hw.o isa-timer.o obj-$(CONFIG_PCI) +=$(pci-y) -obj-$(CONFIG_ISA) += isa.o isa-rtc.o diff --git a/arch/arm/mach-footbridge/dma-isa.c b/arch/arm/mach-footbridge/dma-isa.c new file mode 100644 index 000000000000..0fc0705fd58b --- /dev/null +++ b/arch/arm/mach-footbridge/dma-isa.c @@ -0,0 +1,226 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 1999-2000 Russell King + * + * ISA DMA primitives + * Taken from various sources, including: + * linux/include/asm/dma.h: Defines for using and allocating dma channels. + * Written by Hennus Bergman, 1992. + * High DMA channel support & info by Hannu Savolainen and John Boyd, + * Nov. 1992. + * arch/arm/kernel/dma-ebsa285.c + * Copyright (C) 1998 Phil Blundell + */ +#include +#include +#include +#include + +#include +#include + +#define ISA_DMA_MASK 0 +#define ISA_DMA_MODE 1 +#define ISA_DMA_CLRFF 2 +#define ISA_DMA_PGHI 3 +#define ISA_DMA_PGLO 4 +#define ISA_DMA_ADDR 5 +#define ISA_DMA_COUNT 6 + +static unsigned int isa_dma_port[8][7] = { + /* MASK MODE CLRFF PAGE_HI PAGE_LO ADDR COUNT */ + { 0x0a, 0x0b, 0x0c, 0x487, 0x087, 0x00, 0x01 }, + { 0x0a, 0x0b, 0x0c, 0x483, 0x083, 0x02, 0x03 }, + { 0x0a, 0x0b, 0x0c, 0x481, 0x081, 0x04, 0x05 }, + { 0x0a, 0x0b, 0x0c, 0x482, 0x082, 0x06, 0x07 }, + { 0xd4, 0xd6, 0xd8, 0x000, 0x000, 0xc0, 0xc2 }, + { 0xd4, 0xd6, 0xd8, 0x48b, 0x08b, 0xc4, 0xc6 }, + { 0xd4, 0xd6, 0xd8, 0x489, 0x089, 0xc8, 0xca }, + { 0xd4, 0xd6, 0xd8, 0x48a, 0x08a, 0xcc, 0xce } +}; + +static int isa_get_dma_residue(unsigned int chan, dma_t *dma) +{ + unsigned int io_port = isa_dma_port[chan][ISA_DMA_COUNT]; + int count; + + count = 1 + inb(io_port); + count |= inb(io_port) << 8; + + return chan < 4 ? count : (count << 1); +} + +static struct device isa_dma_dev = { + .init_name = "fallback device", + .coherent_dma_mask = ~(dma_addr_t)0, + .dma_mask = &isa_dma_dev.coherent_dma_mask, +}; + +static void isa_enable_dma(unsigned int chan, dma_t *dma) +{ + if (dma->invalid) { + unsigned long address, length; + unsigned int mode; + enum dma_data_direction direction; + + mode = (chan & 3) | dma->dma_mode; + switch (dma->dma_mode & DMA_MODE_MASK) { + case DMA_MODE_READ: + direction = DMA_FROM_DEVICE; + break; + + case DMA_MODE_WRITE: + direction = DMA_TO_DEVICE; + break; + + case DMA_MODE_CASCADE: + direction = DMA_BIDIRECTIONAL; + break; + + default: + direction = DMA_NONE; + break; + } + + if (!dma->sg) { + /* + * Cope with ISA-style drivers which expect cache + * coherence. + */ + dma->sg = &dma->buf; + dma->sgcount = 1; + dma->buf.length = dma->count; + dma->buf.dma_address = dma_map_single(&isa_dma_dev, + dma->addr, dma->count, + direction); + } + + address = dma->buf.dma_address; + length = dma->buf.length - 1; + + outb(address >> 16, isa_dma_port[chan][ISA_DMA_PGLO]); + outb(address >> 24, isa_dma_port[chan][ISA_DMA_PGHI]); + + if (chan >= 4) { + address >>= 1; + length >>= 1; + } + + outb(0, isa_dma_port[chan][ISA_DMA_CLRFF]); + + outb(address, isa_dma_port[chan][ISA_DMA_ADDR]); + outb(address >> 8, isa_dma_port[chan][ISA_DMA_ADDR]); + + outb(length, isa_dma_port[chan][ISA_DMA_COUNT]); + outb(length >> 8, isa_dma_port[chan][ISA_DMA_COUNT]); + + outb(mode, isa_dma_port[chan][ISA_DMA_MODE]); + dma->invalid = 0; + } + outb(chan & 3, isa_dma_port[chan][ISA_DMA_MASK]); +} + +static void isa_disable_dma(unsigned int chan, dma_t *dma) +{ + outb(chan | 4, isa_dma_port[chan][ISA_DMA_MASK]); +} + +static struct dma_ops isa_dma_ops = { + .type = "ISA", + .enable = isa_enable_dma, + .disable = isa_disable_dma, + .residue = isa_get_dma_residue, +}; + +static struct resource dma_resources[] = { { + .name = "dma1", + .start = 0x0000, + .end = 0x000f +}, { + .name = "dma low page", + .start = 0x0080, + .end = 0x008f +}, { + .name = "dma2", + .start = 0x00c0, + .end = 0x00df +}, { + .name = "dma high page", + .start = 0x0480, + .end = 0x048f +} }; + +static dma_t isa_dma[8]; + +/* + * ISA DMA always starts at channel 0 + */ +static int __init isa_dma_init(void) +{ + /* + * Try to autodetect presence of an ISA DMA controller. + * We do some minimal initialisation, and check that + * channel 0's DMA address registers are writeable. + */ + outb(0xff, 0x0d); + outb(0xff, 0xda); + + /* + * Write high and low address, and then read them back + * in the same order. + */ + outb(0x55, 0x00); + outb(0xaa, 0x00); + + if (inb(0) == 0x55 && inb(0) == 0xaa) { + unsigned int chan, i; + + for (chan = 0; chan < 8; chan++) { + isa_dma[chan].d_ops = &isa_dma_ops; + isa_disable_dma(chan, NULL); + } + + outb(0x40, 0x0b); + outb(0x41, 0x0b); + outb(0x42, 0x0b); + outb(0x43, 0x0b); + + outb(0xc0, 0xd6); + outb(0x41, 0xd6); + outb(0x42, 0xd6); + outb(0x43, 0xd6); + + outb(0, 0xd4); + + outb(0x10, 0x08); + outb(0x10, 0xd0); + + /* + * Is this correct? According to my documentation, it + * doesn't appear to be. It should be: + * outb(0x3f, 0x40b); outb(0x3f, 0x4d6); + */ + outb(0x30, 0x40b); + outb(0x31, 0x40b); + outb(0x32, 0x40b); + outb(0x33, 0x40b); + outb(0x31, 0x4d6); + outb(0x32, 0x4d6); + outb(0x33, 0x4d6); + + for (i = 0; i < ARRAY_SIZE(dma_resources); i++) + request_resource(&ioport_resource, dma_resources + i); + + for (chan = 0; chan < 8; chan++) { + int ret = isa_dma_add(chan, &isa_dma[chan]); + if (ret) + pr_err("ISADMA%u: unable to register: %d\n", + chan, ret); + } + + request_dma(DMA_ISA_CASCADE, "cascade"); + } + + return 0; +} +core_initcall(isa_dma_init); diff --git a/arch/arm/mach-footbridge/dma.c b/arch/arm/mach-footbridge/dma.c deleted file mode 100644 index 228757c8e06f..000000000000 --- a/arch/arm/mach-footbridge/dma.c +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * linux/arch/arm/kernel/dma-ebsa285.c - * - * Copyright (C) 1998 Phil Blundell - * - * DMA functions specific to EBSA-285/CATS architectures - * - * Changelog: - * 09-Nov-1998 RMK Split out ISA DMA functions to dma-isa.c - * 17-Mar-1999 RMK Allow any EBSA285-like architecture to have - * ISA DMA controllers. - */ -#include -#include -#include -#include - -#include - -#include -#include - -#if 0 -static int fb_dma_request(unsigned int chan, dma_t *dma) -{ - return -EINVAL; -} - -static void fb_dma_enable(unsigned int chan, dma_t *dma) -{ -} - -static void fb_dma_disable(unsigned int chan, dma_t *dma) -{ -} - -static struct dma_ops fb_dma_ops = { - .type = "fb", - .request = fb_dma_request, - .enable = fb_dma_enable, - .disable = fb_dma_disable, -}; -#endif - -static int __init fb_dma_init(void) -{ -#if 0 - dma[_DC21285_DMA(0)].d_ops = &fb_dma_ops; - dma[_DC21285_DMA(1)].d_ops = &fb_dma_ops; -#endif -#ifdef CONFIG_ISA_DMA - isa_init_dma(); -#endif - return 0; -} -core_initcall(fb_dma_init); diff --git a/arch/arm/mach-footbridge/include/mach/isa-dma.h b/arch/arm/mach-footbridge/include/mach/isa-dma.h index 8a1b991076e1..b10731a1f66a 100644 --- a/arch/arm/mach-footbridge/include/mach/isa-dma.h +++ b/arch/arm/mach-footbridge/include/mach/isa-dma.h @@ -10,17 +10,9 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -/* - * The 21285 has two internal DMA channels; we call these 8 and 9. - * On CATS hardware we have an additional eight ISA dma channels - * numbered 0..7. - */ -#define _ISA_DMA(x) (0+(x)) -#define _DC21285_DMA(x) (8+(x)) - -#define MAX_DMA_CHANNELS 10 +#define MAX_DMA_CHANNELS 8 -#define DMA_FLOPPY _ISA_DMA(2) -#define DMA_ISA_CASCADE _ISA_DMA(4) +#define DMA_FLOPPY (2) +#define DMA_ISA_CASCADE (4) #endif /* _ASM_ARCH_DMA_H */ -- cgit v1.2.3-59-g8ed1b From be7f3f901c619e24c93b8044c074306feedd8ee9 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 25 Aug 2022 10:51:42 +0200 Subject: ARM: footbridge: remove custom DMA address handling Footbridge is the last Arm platform that has its own __virt_to_bus()/__bus_to_virt()/phys_to_dma()/dma_to_phys() abstraction, but this is just a simple offset now. For PCI devices, the offset that is programmed into the PCI bridge must also be set in each device using dma_direct_set_offset(). As Arm does not have a pcibios_bus_add_device() helper yet, just use a bus notifier for this. For the ISA DMA, drivers now pass a non-translated physical address into set_dma_addr(), so they have to be converted back with the corresponding isa_bus_to_virt() function and then into the correct bus address with the offset using the isa_dma_dev. Tested-by: Marc Zyngier Signed-off-by: Arnd Bergmann --- arch/arm/include/asm/dma-direct.h | 1 - arch/arm/include/asm/dma.h | 2 +- arch/arm/include/asm/hardware/dec21285.h | 7 +++++++ arch/arm/include/asm/memory.h | 11 ----------- arch/arm/mach-footbridge/Kconfig | 1 - arch/arm/mach-footbridge/common.c | 10 ---------- arch/arm/mach-footbridge/dc21285.c | 21 ++++++++++++++++++++- arch/arm/mach-footbridge/dma-isa.c | 4 ++++ arch/arm/mach-footbridge/include/mach/dma-direct.h | 8 -------- arch/arm/mach-footbridge/include/mach/memory.h | 9 --------- 10 files changed, 32 insertions(+), 42 deletions(-) delete mode 100644 arch/arm/include/asm/dma-direct.h delete mode 100644 arch/arm/mach-footbridge/include/mach/dma-direct.h (limited to 'arch/arm/include/asm') diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h deleted file mode 100644 index 4f7bcde03abb..000000000000 --- a/arch/arm/include/asm/dma-direct.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/arch/arm/include/asm/dma.h b/arch/arm/include/asm/dma.h index 05f29a72150b..c6aded1b069c 100644 --- a/arch/arm/include/asm/dma.h +++ b/arch/arm/include/asm/dma.h @@ -106,7 +106,7 @@ extern void set_dma_sg(unsigned int chan, struct scatterlist *sg, int nr_sg); */ extern void __set_dma_addr(unsigned int chan, void *addr); #define set_dma_addr(chan, addr) \ - __set_dma_addr(chan, (void *)__bus_to_virt(addr)) + __set_dma_addr(chan, (void *)isa_bus_to_virt(addr)) /* Set the DMA byte count for this channel * diff --git a/arch/arm/include/asm/hardware/dec21285.h b/arch/arm/include/asm/hardware/dec21285.h index eee390e8d4dc..894f2a635cbb 100644 --- a/arch/arm/include/asm/hardware/dec21285.h +++ b/arch/arm/include/asm/hardware/dec21285.h @@ -22,6 +22,13 @@ #define DC21285_IO(x) (x) #endif +/* + * The footbridge is programmed to expose the system RAM at 0xe0000000. + * The requirement is that the RAM isn't placed at bus address 0, which + * would clash with VGA cards. + */ +#define BUS_OFFSET 0xe0000000 + #define CSR_PCICMD DC21285_IO(0x0004) #define CSR_CLASSREV DC21285_IO(0x0008) #define CSR_PCICACHELINESIZE DC21285_IO(0x000c) diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index a55a9038abc8..d8eef4bd8c71 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h @@ -369,17 +369,6 @@ static inline unsigned long __virt_to_idmap(unsigned long x) #define virt_to_idmap(x) __virt_to_idmap((unsigned long)(x)) -/* - * Virtual <-> DMA view memory address translations - * Again, these are *only* valid on the kernel direct mapped RAM - * memory. Use of these is *deprecated* (and that doesn't mean - * use the __ prefixed forms instead.) See dma-mapping.h. - */ -#ifndef __virt_to_bus -#define __virt_to_bus __virt_to_phys -#define __bus_to_virt __phys_to_virt -#endif - /* * Conversion between a struct page and a physical address. * diff --git a/arch/arm/mach-footbridge/Kconfig b/arch/arm/mach-footbridge/Kconfig index 1a3676109654..b7a4e403ba0f 100644 --- a/arch/arm/mach-footbridge/Kconfig +++ b/arch/arm/mach-footbridge/Kconfig @@ -46,7 +46,6 @@ endmenu # Footbridge support config FOOTBRIDGE def_bool y - select ARCH_HAS_PHYS_TO_DMA select ARCH_MIGHT_HAVE_PC_SERIO select ISA_DMA_API diff --git a/arch/arm/mach-footbridge/common.c b/arch/arm/mach-footbridge/common.c index 9483eccea5ae..629e4676ed77 100644 --- a/arch/arm/mach-footbridge/common.c +++ b/arch/arm/mach-footbridge/common.c @@ -281,13 +281,3 @@ void footbridge_restart(enum reboot_mode mode, const char *cmd) *CSR_SA110_CNTL |= (1 << 13); } } - -dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) -{ - return paddr + (BUS_OFFSET - PHYS_OFFSET); -} - -phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr) -{ - return dev_addr - (BUS_OFFSET - PHYS_OFFSET); -} diff --git a/arch/arm/mach-footbridge/dc21285.c b/arch/arm/mach-footbridge/dc21285.c index 372600bc15c8..f8920d0010de 100644 --- a/arch/arm/mach-footbridge/dc21285.c +++ b/arch/arm/mach-footbridge/dc21285.c @@ -5,6 +5,7 @@ * Copyright (C) 1998-2001 Russell King * Copyright (C) 1998-2000 Phil Blundell */ +#include #include #include #include @@ -241,6 +242,22 @@ static irqreturn_t dc21285_parity_irq(int irq, void *dev_id) return IRQ_HANDLED; } +static int dc21285_pci_bus_notifier(struct notifier_block *nb, + unsigned long action, + void *data) +{ + if (action != BUS_NOTIFY_ADD_DEVICE) + return NOTIFY_DONE; + + dma_direct_set_offset(data, PHYS_OFFSET, BUS_OFFSET, SZ_256M); + + return NOTIFY_OK; +} + +static struct notifier_block dc21285_pci_bus_nb = { + .notifier_call = dc21285_pci_bus_notifier, +}; + int __init dc21285_setup(int nr, struct pci_sys_data *sys) { struct resource *res; @@ -266,6 +283,8 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys) pci_add_resource_offset(&sys->resources, &res[0], sys->mem_offset); pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset); + bus_register_notifier(&pci_bus_type, &dc21285_pci_bus_nb); + return 1; } @@ -329,7 +348,7 @@ void __init dc21285_preinit(void) */ *CSR_PCICSRBASE = 0xf4000000; *CSR_PCICSRIOBASE = 0; - *CSR_PCISDRAMBASE = __virt_to_bus(PAGE_OFFSET); + *CSR_PCISDRAMBASE = BUS_OFFSET; *CSR_PCIROMBASE = 0; *CSR_PCICMD = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE | PCICMD_ERROR_BITS; diff --git a/arch/arm/mach-footbridge/dma-isa.c b/arch/arm/mach-footbridge/dma-isa.c index 0fc0705fd58b..937f5376d5e7 100644 --- a/arch/arm/mach-footbridge/dma-isa.c +++ b/arch/arm/mach-footbridge/dma-isa.c @@ -11,6 +11,7 @@ * arch/arm/kernel/dma-ebsa285.c * Copyright (C) 1998 Phil Blundell */ +#include #include #include #include @@ -18,6 +19,7 @@ #include #include +#include #define ISA_DMA_MASK 0 #define ISA_DMA_MODE 1 @@ -221,6 +223,8 @@ static int __init isa_dma_init(void) request_dma(DMA_ISA_CASCADE, "cascade"); } + dma_direct_set_offset(&isa_dma_dev, PHYS_OFFSET, BUS_OFFSET, SZ_256M); + return 0; } core_initcall(isa_dma_init); diff --git a/arch/arm/mach-footbridge/include/mach/dma-direct.h b/arch/arm/mach-footbridge/include/mach/dma-direct.h deleted file mode 100644 index 01f9e8367c00..000000000000 --- a/arch/arm/mach-footbridge/include/mach/dma-direct.h +++ /dev/null @@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef MACH_FOOTBRIDGE_DMA_DIRECT_H -#define MACH_FOOTBRIDGE_DMA_DIRECT_H 1 - -dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr); -phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr); - -#endif /* MACH_FOOTBRIDGE_DMA_DIRECT_H */ diff --git a/arch/arm/mach-footbridge/include/mach/memory.h b/arch/arm/mach-footbridge/include/mach/memory.h index 8f0ca8e8b37e..9516877667d7 100644 --- a/arch/arm/mach-footbridge/include/mach/memory.h +++ b/arch/arm/mach-footbridge/include/mach/memory.h @@ -16,15 +16,6 @@ #ifndef __ASM_ARCH_MEMORY_H #define __ASM_ARCH_MEMORY_H -/* - * The footbridge is programmed to expose the system RAM at 0xe0000000. - * The requirement is that the RAM isn't placed at bus address 0, which - * would clash with VGA cards. - */ -#define BUS_OFFSET 0xe0000000 -#define __virt_to_bus(x) ((x) + (BUS_OFFSET - PAGE_OFFSET)) -#define __bus_to_virt(x) ((x) - (BUS_OFFSET - PAGE_OFFSET)) - /* * Cache flushing area. */ -- cgit v1.2.3-59-g8ed1b