On 8/27/26 11:36 AM, Neil Armstrong wrote:
On 8/17/26 19:15, Sean Anderson wrote:
Add support for amlogic s4 (S805X2/S905W2/S905Y4) SoCs. These are very
similar to other recent SoCs, with the exception of a workaround for
some BL2 (mis)behavior.

Signed-off-by: Sean Anderson <[email protected]>
---

  arch/arm/include/asm/arch-meson/boot0.h | 14 +++++++
  arch/arm/mach-meson/Kconfig             |  7 ++++
  arch/arm/mach-meson/Makefile            |  1 +
  arch/arm/mach-meson/board-s4.c          | 50 +++++++++++++++++++++++++
  4 files changed, 72 insertions(+)
  create mode 100644 arch/arm/include/asm/arch-meson/boot0.h
  create mode 100644 arch/arm/mach-meson/board-s4.c

diff --git a/arch/arm/include/asm/arch-meson/boot0.h 
b/arch/arm/include/asm/arch-meson/boot0.h
new file mode 100644
index 00000000000..7338171be15
--- /dev/null
+++ b/arch/arm/include/asm/arch-meson/boot0.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2026 Brivo Systems LLC
+ */
+b reset
+#if IS_ENABLED(CONFIG_MESON_S4)
+/*
+ * BL2 copies some keys to the start of DRAM, clobbering anything in the first
+ * 2k aside from the initial instruction. I measured the actual data clobbered
+ * as 1076 bytes, but I suspect the amount depends on the configuration, so
+ * just go with what amlogic does.
+ */
+.skip 2048
+#endif

How different is this boot0 with the one posted for T7 at [1] ?

https://lore.kernel.org/all/[email protected]/

Should be identical. Actually, the size is the same, but I couldn't figure out 
how
the "kernel key" was supposed to work. So using the same boot0.h should be fine.

diff --git a/arch/arm/mach-meson/Kconfig b/arch/arm/mach-meson/Kconfig
index c687ef822a2..91d1e8342e0 100644
--- a/arch/arm/mach-meson/Kconfig
+++ b/arch/arm/mach-meson/Kconfig
@@ -67,6 +67,13 @@ config MESON_A1
      help
        Select this if your SoC is an A113L
+config MESON_S4
+    bool "S4"
+    select MESON64_COMMON
+    select ENABLE_ARM_SOC_BOOT0_HOOK
+    help
+      Select this if your SoC is an S905Y4/S905W2/S805X2
+
  endchoice
  config SYS_SOC
diff --git a/arch/arm/mach-meson/Makefile b/arch/arm/mach-meson/Makefile
index 08a24d4b24f..2157c35c2d5 100644
--- a/arch/arm/mach-meson/Makefile
+++ b/arch/arm/mach-meson/Makefile
@@ -17,3 +17,4 @@ endif
  obj-$(CONFIG_MESON_AXG) += board-axg.o
  obj-$(CONFIG_MESON_G12A) += board-g12a.o
  obj-$(CONFIG_MESON_A1) += board-a1.o
+obj-$(CONFIG_MESON_S4) += board-s4.o
diff --git a/arch/arm/mach-meson/board-s4.c b/arch/arm/mach-meson/board-s4.c
new file mode 100644
index 00000000000..7d0bea9924f
--- /dev/null
+++ b/arch/arm/mach-meson/board-s4.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2023 SberDevices, Inc.
+ */
+
+#include <asm/armv8/mmu.h>
+#include <asm/io.h>
+#include <linux/compiler.h>
+#include <linux/errno.h>
+
+void meson_init_reserved_memory(__maybe_unused void *fdt)
+{
+}

No reserved memory at all on S4 ?

Well, ATF is signed by amlogic and can't be modified on this platform, so the
reserved memory can't change unless you use a new version of the ATF binary.
meson-s4-s905y4-khadas-vim1s.dts just hard-codes the block of memory.

+
+int meson_get_boot_device(void)
+{
+    return -ENOSYS;
+}
+
+static struct mm_region s4_mem_map[] = {
+    {
+        .virt = 0x00000000UL,
+        .phys = 0x00000000UL,
+        .size = 0x80000000UL,
+        .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+            PTE_BLOCK_INNER_SHARE
+    }, {
+        .virt = 0x80000000UL,
+        .phys = 0x80000000UL,
+        .size = 0x7FE00000UL,
+        .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+            PTE_BLOCK_NON_SHARE |
+            PTE_BLOCK_PXN | PTE_BLOCK_UXN
+    }, {
+        /*
+         * This mem region contains in/out shared memory with bl31,
+         * hence it's marked as NORMAL memory type
+         */
+        .virt = 0xFFE00000UL,
+        .phys = 0xFFE00000UL,
+        .size = 0x00200000UL,
+        .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+            PTE_BLOCK_INNER_SHARE
+    }, {
+        /* List terminator */
+        0,
+    }
+};
+
+struct mm_region *mem_map = s4_mem_map;


Reply via email to