diff mbox series

[1/4] ARM/ixp4xx: Move the UART and exp bus virtbases

Message ID 20210503211649.4109334-2-linus.walleij@linaro.org
State New
Headers show
Series IXP4xx PCI rework | expand

Commit Message

Linus Walleij May 3, 2021, 9:16 p.m. UTC
UART1, UART2 and the expansion bus config registers
are the only registers mapped in a fixed location
when using device tree.

For device tree we also want to get rid of the custom
<mach/io.h> for IXP4xx. So we need to undefine
CONFIG_NEED_MACH_IO_H. Doing that activates the fixed
mapping of the PCI IO space to PCI_IO_VIRT_BASE which
is hardcoded to 0xFEE00000 and this would collide with
the old fixed mappings.

Move the UART1 and UART2 to the beginning of the fixmap
region at 0xFFC80000-0xFFC81FFF and move the expansion
bus base to 0xFFC82000-0xFFC81FFF in order to be able to
accommodate for the fixed PCI virtual IO space.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Imre Kaloz <kaloz@openwrt.org>
Cc: Krzysztof Halasa <khalasa@piap.pl>
Cc: Zoltan HERPAI <wigyori@uid0.hu>
Cc: Raylynn Knight <rayknight@me.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
PCI maintainers: this patch is mostly FYI, will be
merged through ARM SoC
---
 arch/arm/Kconfig.debug                          | 4 ++--
 arch/arm/mach-ixp4xx/include/mach/ixp4xx-regs.h | 7 ++++---
 arch/arm/mach-ixp4xx/ixp4xx-of.c                | 8 ++++++--
 3 files changed, 12 insertions(+), 7 deletions(-)

Comments

Arnd Bergmann May 4, 2021, 7:38 a.m. UTC | #1
On Mon, May 3, 2021 at 11:16 PM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> UART1, UART2 and the expansion bus config registers
> are the only registers mapped in a fixed location
> when using device tree.
>
> For device tree we also want to get rid of the custom
> <mach/io.h> for IXP4xx. So we need to undefine
> CONFIG_NEED_MACH_IO_H. Doing that activates the fixed
> mapping of the PCI IO space to PCI_IO_VIRT_BASE which
> is hardcoded to 0xFEE00000 and this would collide with
> the old fixed mappings.
>
> Move the UART1 and UART2 to the beginning of the fixmap
> region at 0xFFC80000-0xFFC81FFF and move the expansion
> bus base to 0xFFC82000-0xFFC81FFF in order to be able to
> accommodate for the fixed PCI virtual IO space.

This doesn't feel right to me, for multiple reasons:

- I don't think putting something into fixmap is valid unless you assign
  a fixmap constant in arch/arm/include/asm/fixmap.h for it and
  use that constant.
  We do have FIX_EARLYCON_MEM_BASE already, and we could
  in theory use the same constant for both debug_ll and earlycon
  (I think), or we could have adjacent pages for the two.

- IIRC, DEBUG_LL always uses a section map, so if you just need
  a single page, it doesn't work right.

Would it be sufficient if you just move IXP4XX_*_BASE_VIRT
from 0xFEF????? to 0xFEC????? ?

Idea I've had in the past was to treat DEBUG_UART_VIRT==0
as a special case that automatically picks a reasonable fixed
address, such as (0xfec00000 | (DEBUG_UART_PHYS & 0x1fffff)
and document that area in Documentation/arm/memory.txt as
the default place for debug_ll.

        Arnd

> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Imre Kaloz <kaloz@openwrt.org>
> Cc: Krzysztof Halasa <khalasa@piap.pl>
> Cc: Zoltan HERPAI <wigyori@uid0.hu>
> Cc: Raylynn Knight <rayknight@me.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> PCI maintainers: this patch is mostly FYI, will be
> merged through ARM SoC
> ---
>  arch/arm/Kconfig.debug                          | 4 ++--
>  arch/arm/mach-ixp4xx/include/mach/ixp4xx-regs.h | 7 ++++---
>  arch/arm/mach-ixp4xx/ixp4xx-of.c                | 8 ++++++--
>  3 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
> index 9e0b5e7f12af..bbe799f6bc03 100644
> --- a/arch/arm/Kconfig.debug
> +++ b/arch/arm/Kconfig.debug
> @@ -1803,8 +1803,8 @@ config DEBUG_UART_VIRT
>         default 0xfedc0000 if DEBUG_EP93XX
>         default 0xfee003f8 if DEBUG_FOOTBRIDGE_COM1
>         default 0xfee20000 if DEBUG_NSPIRE_CLASSIC_UART || DEBUG_NSPIRE_CX_UART
> -       default 0xfef00000 if ARCH_IXP4XX && !CPU_BIG_ENDIAN
> -       default 0xfef00003 if ARCH_IXP4XX && CPU_BIG_ENDIAN
> +       default 0xffc80000 if ARCH_IXP4XX && !CPU_BIG_ENDIAN
> +       default 0xffc80003 if ARCH_IXP4XX && CPU_BIG_ENDIAN
>         default 0xfef36000 if DEBUG_HIGHBANK_UART
>         default 0xfefb0000 if DEBUG_OMAP1UART1 || DEBUG_OMAP7XXUART1

Please keep these sorted numerically

        Arnd
diff mbox series

Patch

diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 9e0b5e7f12af..bbe799f6bc03 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -1803,8 +1803,8 @@  config DEBUG_UART_VIRT
 	default 0xfedc0000 if DEBUG_EP93XX
 	default 0xfee003f8 if DEBUG_FOOTBRIDGE_COM1
 	default 0xfee20000 if DEBUG_NSPIRE_CLASSIC_UART || DEBUG_NSPIRE_CX_UART
-	default 0xfef00000 if ARCH_IXP4XX && !CPU_BIG_ENDIAN
-	default 0xfef00003 if ARCH_IXP4XX && CPU_BIG_ENDIAN
+	default 0xffc80000 if ARCH_IXP4XX && !CPU_BIG_ENDIAN
+	default 0xffc80003 if ARCH_IXP4XX && CPU_BIG_ENDIAN
 	default 0xfef36000 if DEBUG_HIGHBANK_UART
 	default 0xfefb0000 if DEBUG_OMAP1UART1 || DEBUG_OMAP7XXUART1
 	default 0xfefb0800 if DEBUG_OMAP1UART2 || DEBUG_OMAP7XXUART2
diff --git a/arch/arm/mach-ixp4xx/include/mach/ixp4xx-regs.h b/arch/arm/mach-ixp4xx/include/mach/ixp4xx-regs.h
index 708d085ce39f..45b0f2c3a1d6 100644
--- a/arch/arm/mach-ixp4xx/include/mach/ixp4xx-regs.h
+++ b/arch/arm/mach-ixp4xx/include/mach/ixp4xx-regs.h
@@ -59,7 +59,7 @@ 
  * Expansion BUS Configuration registers
  */
 #define IXP4XX_EXP_CFG_BASE_PHYS	0xC4000000
-#define IXP4XX_EXP_CFG_BASE_VIRT	0xFEF14000
+#define IXP4XX_EXP_CFG_BASE_VIRT	0xFFC82000
 #define IXP4XX_EXP_CFG_REGION_SIZE	0x00001000
 
 #define IXP4XX_EXP_CS0_OFFSET	0x00
@@ -120,8 +120,9 @@ 
 #define IXP4XX_SSP_BASE_PHYS		(IXP4XX_PERIPHERAL_BASE_PHYS + 0x12000)
 
 
-#define IXP4XX_UART1_BASE_VIRT		(IXP4XX_PERIPHERAL_BASE_VIRT + 0x0000)
-#define IXP4XX_UART2_BASE_VIRT		(IXP4XX_PERIPHERAL_BASE_VIRT + 0x1000)
+/* The UART is explicitly put in the beginning of fixmap */
+#define IXP4XX_UART1_BASE_VIRT		(0xFFC80000)
+#define IXP4XX_UART2_BASE_VIRT		(0xFFC81000)
 #define IXP4XX_PMU_BASE_VIRT		(IXP4XX_PERIPHERAL_BASE_VIRT + 0x2000)
 #define IXP4XX_INTC_BASE_VIRT		(IXP4XX_PERIPHERAL_BASE_VIRT + 0x3000)
 #define IXP4XX_GPIO_BASE_VIRT		(IXP4XX_PERIPHERAL_BASE_VIRT + 0x4000)
diff --git a/arch/arm/mach-ixp4xx/ixp4xx-of.c b/arch/arm/mach-ixp4xx/ixp4xx-of.c
index 7449b8319c8a..e3d823c077e8 100644
--- a/arch/arm/mach-ixp4xx/ixp4xx-of.c
+++ b/arch/arm/mach-ixp4xx/ixp4xx-of.c
@@ -9,8 +9,12 @@ 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 
-#include <mach/hardware.h>
-#include <mach/ixp4xx-regs.h>
+/*
+ * These are the only fixed phys to virt mappings we ever need
+ * we put it right after the UART mapping at 0xffc80000-0xffc81fff
+ */
+#define IXP4XX_EXP_CFG_BASE_PHYS	0xC4000000
+#define IXP4XX_EXP_CFG_BASE_VIRT	0xFFC82000
 
 static struct map_desc ixp4xx_of_io_desc[] __initdata = {
 	/*