ARM: ep93xx: multiplatform support
authorArnd Bergmann <arnd@arndb.de>
Fri, 1 Apr 2022 13:58:09 +0000 (15:58 +0200)
committerArnd Bergmann <arnd@arndb.de>
Mon, 4 Apr 2022 08:22:37 +0000 (10:22 +0200)
With the clock support and the interrupts out of the way, ep93xx can be
compiled into the same kernel image as the other ARMv4/v5 platforms. The
last obstacle are the two workarounds for broken boot loaders that
require us to re-initialize the ethernet controller and/or the watchdog
on certain machines.

Move this code into the decompressor sources directly, checking for
each possibly affected machine individually.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
arch/arm/Kconfig
arch/arm/boot/compressed/misc-ep93xx.h [new file with mode: 0644]
arch/arm/boot/compressed/misc.c
arch/arm/configs/ep93xx_defconfig
arch/arm/mach-ep93xx/Kconfig
arch/arm/mach-ep93xx/include/mach/uncompress.h [deleted file]

index 5177e54cc14c06cc51a9ae8b4689561d4bd38b80..2bd611beefe116be5bb549185a95aca752e2f0b5 100644 (file)
@@ -347,22 +347,6 @@ config ARCH_MULTIPLATFORM
        select SPARSE_IRQ
        select USE_OF
 
-config ARCH_EP93XX
-       bool "EP93xx-based"
-       select ARCH_SPARSEMEM_ENABLE
-       select ARM_AMBA
-       imply ARM_PATCH_PHYS_VIRT
-       select ARM_VIC
-       select AUTO_ZRELADDR
-       select CLKSRC_MMIO
-       select CPU_ARM920T
-       select GPIOLIB
-       select COMMON_CLK
-       select IRQ_DOMAIN
-       select SPARSE_IRQ
-       help
-         This enables support for the Cirrus EP93xx series of CPUs.
-
 config ARCH_FOOTBRIDGE
        bool "FootBridge"
        select CPU_SA110
diff --git a/arch/arm/boot/compressed/misc-ep93xx.h b/arch/arm/boot/compressed/misc-ep93xx.h
new file mode 100644 (file)
index 0000000..3dc9425
--- /dev/null
@@ -0,0 +1,86 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
+ */
+
+#include <asm/mach-types.h>
+
+static inline unsigned int __raw_readl(unsigned int ptr)
+{
+       return *((volatile unsigned int *)ptr);
+}
+
+static inline void __raw_writeb(unsigned char value, unsigned int ptr)
+{
+       *((volatile unsigned char *)ptr) = value;
+}
+
+static inline void __raw_writel(unsigned int value, unsigned int ptr)
+{
+       *((volatile unsigned int *)ptr) = value;
+}
+
+/*
+ * Some bootloaders don't turn off DMA from the ethernet MAC before
+ * jumping to linux, which means that we might end up with bits of RX
+ * status and packet data scribbled over the uncompressed kernel image.
+ * Work around this by resetting the ethernet MAC before we uncompress.
+ */
+#define PHYS_ETH_SELF_CTL              0x80010020
+#define ETH_SELF_CTL_RESET             0x00000001
+
+static inline void ep93xx_ethernet_reset(void)
+{
+       unsigned int v;
+
+       /* Reset the ethernet MAC.  */
+       v = __raw_readl(PHYS_ETH_SELF_CTL);
+       __raw_writel(v | ETH_SELF_CTL_RESET, PHYS_ETH_SELF_CTL);
+
+       /* Wait for reset to finish.  */
+       while (__raw_readl(PHYS_ETH_SELF_CTL) & ETH_SELF_CTL_RESET)
+               ;
+}
+
+#define TS72XX_WDT_CONTROL_PHYS_BASE   0x23800000
+#define TS72XX_WDT_FEED_PHYS_BASE      0x23c00000
+#define TS72XX_WDT_FEED_VAL            0x05
+
+static inline void __maybe_unused ts72xx_watchdog_disable(void)
+{
+       __raw_writeb(TS72XX_WDT_FEED_VAL, TS72XX_WDT_FEED_PHYS_BASE);
+       __raw_writeb(0, TS72XX_WDT_CONTROL_PHYS_BASE);
+}
+
+static inline void ep93xx_decomp_setup(void)
+{
+       if (machine_is_ts72xx())
+               ts72xx_watchdog_disable();
+
+       if (machine_is_adssphere() ||
+           machine_is_edb9301() ||
+           machine_is_edb9302() ||
+           machine_is_edb9302a() ||
+           machine_is_edb9302a() ||
+           machine_is_edb9307() ||
+           machine_is_edb9307a() ||
+           machine_is_edb9307a() ||
+           machine_is_edb9312() ||
+           machine_is_edb9315() ||
+           machine_is_edb9315a() ||
+           machine_is_edb9315a() ||
+           machine_is_gesbc9312() ||
+           machine_is_micro9() ||
+           machine_is_micro9l() ||
+           machine_is_micro9m() ||
+           machine_is_micro9s() ||
+           machine_is_micro9m() ||
+           machine_is_micro9l() ||
+           machine_is_micro9s() ||
+           machine_is_sim_one() ||
+           machine_is_snapper_cl15() ||
+           machine_is_ts72xx() ||
+           machine_is_bk3() ||
+           machine_is_vision_ep9307())
+               ep93xx_ethernet_reset();
+}
index c3c66ff2d696b77126592886c3d9050e54d09843..cb2e069dc73fd0448454d78da92943f761365821 100644 (file)
@@ -23,6 +23,7 @@ unsigned int __machine_arch_type;
 #include <linux/types.h>
 #include <linux/linkage.h>
 #include "misc.h"
+#include "misc-ep93xx.h"
 
 static void putstr(const char *ptr);
 
@@ -143,6 +144,9 @@ decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p,
        free_mem_end_ptr        = free_mem_ptr_end_p;
        __machine_arch_type     = arch_id;
 
+#ifdef CONFIG_ARCH_EP93XX
+       ep93xx_decomp_setup();
+#endif
        arch_decomp_setup();
 
        putstr("Uncompressing Linux...");
index 88d5ecc2121e3af890442757b30ee0918efda2a5..fef802b7af8c6078c2e6438a18f2add451acd0c4 100644 (file)
@@ -11,6 +11,8 @@ CONFIG_MODULE_UNLOAD=y
 CONFIG_MODULE_FORCE_UNLOAD=y
 # CONFIG_BLK_DEV_BSG is not set
 CONFIG_PARTITION_ADVANCED=y
+CONFIG_ARCH_MULTI_V4T=y
+# CONFIG_ARCH_MULTI_V7 is not set
 CONFIG_ARCH_EP93XX=y
 CONFIG_MACH_ADSSPHERE=y
 CONFIG_MACH_EDB9301=y
index 15c68a646d512e568cde8ee6630113048dd70b30..aa502ab5740417408b5633459c4d5c556ab9c35b 100644 (file)
@@ -1,4 +1,16 @@
 # SPDX-License-Identifier: GPL-2.0-only
+menuconfig ARCH_EP93XX
+       bool "EP93xx-based"
+       depends on ARCH_MULTI_V4T
+       select ARCH_SPARSEMEM_ENABLE
+       select ARM_AMBA
+       select ARM_VIC
+       select CLKSRC_MMIO
+       select CPU_ARM920T
+       select GPIOLIB
+       help
+         This enables support for the Cirrus EP93xx series of CPUs.
+
 if ARCH_EP93XX
 
 menu "Cirrus EP93xx Implementation Options"
diff --git a/arch/arm/mach-ep93xx/include/mach/uncompress.h b/arch/arm/mach-ep93xx/include/mach/uncompress.h
deleted file mode 100644 (file)
index e20bcab..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * arch/arm/mach-ep93xx/include/mach/uncompress.h
- *
- * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
- */
-
-#include <asm/mach-types.h>
-
-static unsigned char __raw_readb(unsigned int ptr)
-{
-       return *((volatile unsigned char *)ptr);
-}
-
-static unsigned int __raw_readl(unsigned int ptr)
-{
-       return *((volatile unsigned int *)ptr);
-}
-
-static void __raw_writeb(unsigned char value, unsigned int ptr)
-{
-       *((volatile unsigned char *)ptr) = value;
-}
-
-static void __raw_writel(unsigned int value, unsigned int ptr)
-{
-       *((volatile unsigned int *)ptr) = value;
-}
-
-#define PHYS_UART_DATA         (CONFIG_DEBUG_UART_PHYS + 0x00)
-#define PHYS_UART_FLAG         (CONFIG_DEBUG_UART_PHYS + 0x18)
-#define UART_FLAG_TXFF         0x20
-
-static inline void putc(int c)
-{
-       int i;
-
-       for (i = 0; i < 10000; i++) {
-               /* Transmit fifo not full? */
-               if (!(__raw_readb(PHYS_UART_FLAG) & UART_FLAG_TXFF))
-                       break;
-       }
-
-       __raw_writeb(c, PHYS_UART_DATA);
-}
-
-static inline void flush(void)
-{
-}
-
-
-/*
- * Some bootloaders don't turn off DMA from the ethernet MAC before
- * jumping to linux, which means that we might end up with bits of RX
- * status and packet data scribbled over the uncompressed kernel image.
- * Work around this by resetting the ethernet MAC before we uncompress.
- */
-#define PHYS_ETH_SELF_CTL              0x80010020
-#define ETH_SELF_CTL_RESET             0x00000001
-
-static void ethernet_reset(void)
-{
-       unsigned int v;
-
-       /* Reset the ethernet MAC.  */
-       v = __raw_readl(PHYS_ETH_SELF_CTL);
-       __raw_writel(v | ETH_SELF_CTL_RESET, PHYS_ETH_SELF_CTL);
-
-       /* Wait for reset to finish.  */
-       while (__raw_readl(PHYS_ETH_SELF_CTL) & ETH_SELF_CTL_RESET)
-               ;
-}
-
-#define TS72XX_WDT_CONTROL_PHYS_BASE   0x23800000
-#define TS72XX_WDT_FEED_PHYS_BASE      0x23c00000
-#define TS72XX_WDT_FEED_VAL            0x05
-
-static void __maybe_unused ts72xx_watchdog_disable(void)
-{
-       __raw_writeb(TS72XX_WDT_FEED_VAL, TS72XX_WDT_FEED_PHYS_BASE);
-       __raw_writeb(0, TS72XX_WDT_CONTROL_PHYS_BASE);
-}
-
-static void arch_decomp_setup(void)
-{
-       if (machine_is_ts72xx())
-               ts72xx_watchdog_disable();
-       ethernet_reset();
-}