* [PATCH 1/4] serial: meson: add Amlogic S4 UART support
2026-08-06 10:18 [PATCH 0/4] Add Amlogic T7 (A311D2) and Khadas VIM4 support Lucas Tanure
@ 2026-08-06 10:18 ` Lucas Tanure
2026-08-10 14:01 ` Ferass El Hafidi
2026-08-06 10:18 ` [PATCH 2/4] arm: meson: add Amlogic T7 SoC family support Lucas Tanure
` (4 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Lucas Tanure @ 2026-08-06 10:18 UTC (permalink / raw)
To: u-boot
Cc: neil.armstrong, trini, ilias.apalodimas, funderscore,
u-boot-amlogic, Lucas Tanure
The S4-generation UART (S4, T7, ...) derives its baud rate from the
24 MHz crystal divided by 2, selected via the XTAL_DIV2 bit in the
baud rate register, while older SoCs divide the crystal by 3. Add the
"amlogic,meson-s4-uart" compatible with driver data selecting the
div-by-2 scheme, matching the Linux driver (meson_s4_uart_data) and
the configuration the vendor BL2 programs on T7 hardware.
Older SoCs keep the existing div-by-3 behaviour: Linux also uses
div-by-2 on G12A, but both modes work there and switching would risk
regressing boards that have shipped with div-by-3 for years.
Also drain the transmitter before changing the baud rate so in-flight
characters are not garbled, as the Linux driver does.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Lucas Tanure <tanure@linux.com>
---
drivers/serial/serial_meson.c | 51 ++++++++++++++++++++++++++---------
1 file changed, 38 insertions(+), 13 deletions(-)
diff --git a/drivers/serial/serial_meson.c b/drivers/serial/serial_meson.c
index cc71381f87e..d909fedcfc4 100644
--- a/drivers/serial/serial_meson.c
+++ b/drivers/serial/serial_meson.c
@@ -62,26 +62,49 @@ struct meson_serial_plat {
#define AML_UART_REG5_USE_NEW_BAUD BIT(23) /* default 1 (use new baud rate register) */
#define AML_UART_REG5_BAUD_MASK 0x7fffff
+/* Driver data flags */
+#define MESON_UART_XTAL_DIV2 BIT(0)
+
#if CONFIG_IS_ENABLED(DM_SERIAL)
-static u32 meson_calc_baud_divisor(ulong src_rate, u32 baud)
+static u32 meson_uart_xtal_div(struct udevice *dev)
+{
+ /*
+ * S4-generation UARTs (S4, T7, ...) derive the baud rate from the
+ * crystal divided by 2, older ones divide by 3.
+ */
+ return (dev_get_driver_data(dev) & MESON_UART_XTAL_DIV2) ? 2 : 3;
+}
+
+static u32 meson_calc_baud_divisor(struct udevice *dev, ulong src_rate, u32 baud)
{
/*
* Usually src_rate is 24 MHz (from crystal) as clock source for serial
- * device. Since 8 Mb/s is the maximum supported baud rate, use div by 3
- * to derive baud rate. This choice is used also in meson_serial_setbrg.
+ * device. Since 8 Mb/s is the maximum supported baud rate, use a
+ * divided crystal to derive the baud rate. This choice is used also in
+ * meson_serial_setbrg.
*/
- return DIV_ROUND_CLOSEST(src_rate / 3, baud) - 1;
+ return DIV_ROUND_CLOSEST(src_rate / meson_uart_xtal_div(dev), baud) - 1;
}
-static void meson_serial_set_baud(struct meson_uart *uart, ulong src_rate, u32 baud)
+static void meson_serial_set_baud(struct udevice *dev, struct meson_uart *uart,
+ ulong src_rate, u32 baud)
{
/*
- * Set crystal divided by 3 (regardless of device tree clock property)
+ * Set the divided crystal (regardless of device tree clock property)
* as clock source and the corresponding divisor to approximate baud
*/
- u32 divisor = meson_calc_baud_divisor(src_rate, baud);
+ u32 divisor = meson_calc_baud_divisor(dev, src_rate, baud);
u32 val = AML_UART_REG5_USE_XTAL_CLK | AML_UART_REG5_USE_NEW_BAUD |
(divisor & AML_UART_REG5_BAUD_MASK);
+
+ if (meson_uart_xtal_div(dev) == 2)
+ val |= AML_UART_REG5_XTAL_DIV2;
+
+ /* Drain the transmitter before changing the baud rate */
+ while ((readl(&uart->status) & (AML_UART_TX_EMPTY | AML_UART_XMIT_BUSY))
+ != AML_UART_TX_EMPTY)
+ ;
+
writel(val, &uart->reg5);
}
@@ -109,7 +132,7 @@ static int meson_serial_probe(struct udevice *dev)
return ret;
ulong rate = clk_get_rate(&per_clk);
- meson_serial_set_baud(uart, rate, CONFIG_BAUDRATE);
+ meson_serial_set_baud(dev, uart, rate, CONFIG_BAUDRATE);
meson_serial_init(uart);
return 0;
@@ -165,8 +188,9 @@ static int meson_serial_setbrg(struct udevice *dev, const int baud)
{
/*
* Change device baud rate if baud is reasonable (considering a 23 bit
- * counter with an 8 MHz clock input) and the actual baud
- * rate is within 2% of the requested value (2% is arbitrary).
+ * counter with an 8 MHz, or 12 MHz for XTAL_DIV2 devices, clock input)
+ * and the actual baud rate is within 2% of the requested value (2% is
+ * arbitrary).
*/
if (baud < 1 || baud > 8000000)
return -EINVAL;
@@ -179,14 +203,14 @@ static int meson_serial_setbrg(struct udevice *dev, const int baud)
if (ret)
return ret;
ulong rate = clk_get_rate(&per_clk);
- u32 divisor = meson_calc_baud_divisor(rate, baud);
- u32 calc_baud = (rate / 3) / (divisor + 1);
+ u32 divisor = meson_calc_baud_divisor(dev, rate, baud);
+ u32 calc_baud = (rate / meson_uart_xtal_div(dev)) / (divisor + 1);
u32 calc_err = baud > calc_baud ? baud - calc_baud : calc_baud - baud;
if (((calc_err * 100) / baud) > 2)
return -EINVAL;
- meson_serial_set_baud(uart, rate, baud);
+ meson_serial_set_baud(dev, uart, rate, baud);
return 0;
}
@@ -244,6 +268,7 @@ static const struct udevice_id meson_serial_ids[] = {
{ .compatible = "amlogic,meson-uart" },
{ .compatible = "amlogic,meson-gx-uart" },
{ .compatible = "amlogic,meson-a1-uart" },
+ { .compatible = "amlogic,meson-s4-uart", .data = MESON_UART_XTAL_DIV2 },
{ }
};
--
2.55.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 1/4] serial: meson: add Amlogic S4 UART support
2026-08-06 10:18 ` [PATCH 1/4] serial: meson: add Amlogic S4 UART support Lucas Tanure
@ 2026-08-10 14:01 ` Ferass El Hafidi
0 siblings, 0 replies; 10+ messages in thread
From: Ferass El Hafidi @ 2026-08-10 14:01 UTC (permalink / raw)
To: u-boot-amlogic, tanure, u-boot
Cc: neil.armstrong, trini, ilias.apalodimas, funderscore,
u-boot-amlogic, Lucas Tanure
On Thu, 06 Aug 2026 10:18, "Lucas Tanure via groups.io" <tanure=linux.com@groups.io> wrote:
>The S4-generation UART (S4, T7, ...) derives its baud rate from the
>24 MHz crystal divided by 2, selected via the XTAL_DIV2 bit in the
>baud rate register, while older SoCs divide the crystal by 3. Add the
>"amlogic,meson-s4-uart" compatible with driver data selecting the
>div-by-2 scheme, matching the Linux driver (meson_s4_uart_data) and
>the configuration the vendor BL2 programs on T7 hardware.
>
>Older SoCs keep the existing div-by-3 behaviour: Linux also uses
>div-by-2 on G12A, but both modes work there and switching would risk
>regressing boards that have shipped with div-by-3 for years.
>
>Also drain the transmitter before changing the baud rate so in-flight
>characters are not garbled, as the Linux driver does.
>
>Assisted-by: Claude:claude-fable-5
As I understand it, LLM-assisted patches are not welcome in U-Boot right
now: https://lore.kernel.org/u-boot/20260515220758.GM1858239@bill-the-cat/
AFAIK there isn't an official AI policy yet, but it seems the concensus
on that matter is currently "please don't". Sorry.
>Signed-off-by: Lucas Tanure <tanure@linux.com>
>---
> drivers/serial/serial_meson.c | 51 ++++++++++++++++++++++++++---------
> 1 file changed, 38 insertions(+), 13 deletions(-)
>
>diff --git a/drivers/serial/serial_meson.c b/drivers/serial/serial_meson.c
>index cc71381f87e..d909fedcfc4 100644
>--- a/drivers/serial/serial_meson.c
>+++ b/drivers/serial/serial_meson.c
>@@ -62,26 +62,49 @@ struct meson_serial_plat {
> #define AML_UART_REG5_USE_NEW_BAUD BIT(23) /* default 1 (use new baud rate register) */
> #define AML_UART_REG5_BAUD_MASK 0x7fffff
>
>+/* Driver data flags */
>+#define MESON_UART_XTAL_DIV2 BIT(0)
>+
> #if CONFIG_IS_ENABLED(DM_SERIAL)
>-static u32 meson_calc_baud_divisor(ulong src_rate, u32 baud)
>+static u32 meson_uart_xtal_div(struct udevice *dev)
>+{
>+ /*
>+ * S4-generation UARTs (S4, T7, ...) derive the baud rate from the
>+ * crystal divided by 2, older ones divide by 3.
>+ */
>+ return (dev_get_driver_data(dev) & MESON_UART_XTAL_DIV2) ? 2 : 3;
>+}
>+
>+static u32 meson_calc_baud_divisor(struct udevice *dev, ulong src_rate, u32 baud)
> {
> /*
> * Usually src_rate is 24 MHz (from crystal) as clock source for serial
>- * device. Since 8 Mb/s is the maximum supported baud rate, use div by 3
>- * to derive baud rate. This choice is used also in meson_serial_setbrg.
>+ * device. Since 8 Mb/s is the maximum supported baud rate, use a
>+ * divided crystal to derive the baud rate. This choice is used also in
>+ * meson_serial_setbrg.
> */
>- return DIV_ROUND_CLOSEST(src_rate / 3, baud) - 1;
>+ return DIV_ROUND_CLOSEST(src_rate / meson_uart_xtal_div(dev), baud) - 1;
> }
>
>-static void meson_serial_set_baud(struct meson_uart *uart, ulong src_rate, u32 baud)
>+static void meson_serial_set_baud(struct udevice *dev, struct meson_uart *uart,
>+ ulong src_rate, u32 baud)
> {
> /*
>- * Set crystal divided by 3 (regardless of device tree clock property)
>+ * Set the divided crystal (regardless of device tree clock property)
> * as clock source and the corresponding divisor to approximate baud
> */
>- u32 divisor = meson_calc_baud_divisor(src_rate, baud);
>+ u32 divisor = meson_calc_baud_divisor(dev, src_rate, baud);
> u32 val = AML_UART_REG5_USE_XTAL_CLK | AML_UART_REG5_USE_NEW_BAUD |
> (divisor & AML_UART_REG5_BAUD_MASK);
>+
>+ if (meson_uart_xtal_div(dev) == 2)
>+ val |= AML_UART_REG5_XTAL_DIV2;
>+
>+ /* Drain the transmitter before changing the baud rate */
>+ while ((readl(&uart->status) & (AML_UART_TX_EMPTY | AML_UART_XMIT_BUSY))
>+ != AML_UART_TX_EMPTY)
>+ ;
>+
> writel(val, &uart->reg5);
> }
>
>@@ -109,7 +132,7 @@ static int meson_serial_probe(struct udevice *dev)
> return ret;
> ulong rate = clk_get_rate(&per_clk);
>
>- meson_serial_set_baud(uart, rate, CONFIG_BAUDRATE);
>+ meson_serial_set_baud(dev, uart, rate, CONFIG_BAUDRATE);
> meson_serial_init(uart);
>
> return 0;
>@@ -165,8 +188,9 @@ static int meson_serial_setbrg(struct udevice *dev, const int baud)
> {
> /*
> * Change device baud rate if baud is reasonable (considering a 23 bit
>- * counter with an 8 MHz clock input) and the actual baud
>- * rate is within 2% of the requested value (2% is arbitrary).
>+ * counter with an 8 MHz, or 12 MHz for XTAL_DIV2 devices, clock input)
>+ * and the actual baud rate is within 2% of the requested value (2% is
>+ * arbitrary).
> */
> if (baud < 1 || baud > 8000000)
> return -EINVAL;
>@@ -179,14 +203,14 @@ static int meson_serial_setbrg(struct udevice *dev, const int baud)
> if (ret)
> return ret;
> ulong rate = clk_get_rate(&per_clk);
>- u32 divisor = meson_calc_baud_divisor(rate, baud);
>- u32 calc_baud = (rate / 3) / (divisor + 1);
>+ u32 divisor = meson_calc_baud_divisor(dev, rate, baud);
>+ u32 calc_baud = (rate / meson_uart_xtal_div(dev)) / (divisor + 1);
> u32 calc_err = baud > calc_baud ? baud - calc_baud : calc_baud - baud;
>
> if (((calc_err * 100) / baud) > 2)
> return -EINVAL;
>
>- meson_serial_set_baud(uart, rate, baud);
>+ meson_serial_set_baud(dev, uart, rate, baud);
>
> return 0;
> }
>@@ -244,6 +268,7 @@ static const struct udevice_id meson_serial_ids[] = {
> { .compatible = "amlogic,meson-uart" },
> { .compatible = "amlogic,meson-gx-uart" },
> { .compatible = "amlogic,meson-a1-uart" },
>+ { .compatible = "amlogic,meson-s4-uart", .data = MESON_UART_XTAL_DIV2 },
> { }
> };
>
>--
>2.55.0
Best regards,
Ferass
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/4] arm: meson: add Amlogic T7 SoC family support
2026-08-06 10:18 [PATCH 0/4] Add Amlogic T7 (A311D2) and Khadas VIM4 support Lucas Tanure
2026-08-06 10:18 ` [PATCH 1/4] serial: meson: add Amlogic S4 UART support Lucas Tanure
@ 2026-08-06 10:18 ` Lucas Tanure
2026-08-10 14:15 ` Ferass El Hafidi
2026-08-06 10:18 ` [PATCH 3/4] board: amlogic: add Khadas VIM4 support Lucas Tanure
` (3 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Lucas Tanure @ 2026-08-06 10:18 UTC (permalink / raw)
To: u-boot
Cc: neil.armstrong, trini, ilias.apalodimas, funderscore,
u-boot-amlogic, Lucas Tanure
Add initial support for the Amlogic T7 family (A311D2). U-Boot runs
as BL33, loaded at address 0x0 and entered from the vendor BL31 at
EL2, either uncompressed or LZ4-compressed inside the boot image (the
BL31 decompresses it).
The secure firmware writes the SCS device keys into the first page of
the loaded BL33 image (2 KiB for the BL33 key followed by 2 KiB for
the kernel key). Reserve that page with a boot0 hook, as the vendor
U-Boot does, so the keys do not overwrite U-Boot's entry code.
The firmware also enters BL33 with the non-secure watchdog running:
disable it in board_init(), otherwise the board is reset about a
minute after boot.
The memory map leaves 0x05100000 - 0x09000000 unmapped: the secure
world owns this span (the BL31 and BL32 runtime zones described in
the upstream devicetree, plus further firmware-protected pages), and
this matches the vendor bootloader's own map. The whole span is also
added to the devicetree and EFI reserved memory at boot time so no
allocation is placed in memory U-Boot cannot access.
get_effective_memsize() is capped at 0xdf800000 because the top 8 MiB
of the first DRAM bank contain pages the secure world protects at
runtime; U-Boot and its heap must stay below them.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Lucas Tanure <tanure@linux.com>
---
arch/arm/include/asm/arch-meson/boot0.h | 18 +++++
arch/arm/mach-meson/Kconfig | 10 +++
arch/arm/mach-meson/Makefile | 1 +
arch/arm/mach-meson/board-t7.c | 97 +++++++++++++++++++++++++
4 files changed, 126 insertions(+)
create mode 100644 arch/arm/include/asm/arch-meson/boot0.h
create mode 100644 arch/arm/mach-meson/board-t7.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..3ec085ccd64
--- /dev/null
+++ b/arch/arm/include/asm/arch-meson/boot0.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2026 Lucas Tanure <tanure@linux.com>
+ */
+
+#ifndef __MESON_BOOT0_H
+#define __MESON_BOOT0_H
+
+/*
+ * The T7-family secure firmware writes the SCS device keys into the
+ * first page of the loaded BL33 image (2048 bytes for the BL33 key
+ * followed by 2048 bytes for the kernel key). Keep that page reserved
+ * so the keys do not overwrite U-Boot's entry code.
+ */
+ b reset
+ .space 4096
+
+#endif /* __MESON_BOOT0_H */
diff --git a/arch/arm/mach-meson/Kconfig b/arch/arm/mach-meson/Kconfig
index c687ef822a2..40aafc0b922 100644
--- a/arch/arm/mach-meson/Kconfig
+++ b/arch/arm/mach-meson/Kconfig
@@ -67,6 +67,15 @@ config MESON_A1
help
Select this if your SoC is an A113L
+config MESON_T7
+ bool "T7"
+ select MESON64_COMMON
+ select ENABLE_ARM_SOC_BOOT0_HOOK
+ imply OF_UPSTREAM
+ help
+ Select this if your SoC is from the Amlogic T7 family, like
+ the A311D2 found on the Khadas VIM4 board.
+
endchoice
config SYS_SOC
@@ -91,6 +100,7 @@ config SYS_BOARD
default "q200" if MESON_GXM
default "s400" if MESON_AXG
default "u200" if MESON_G12A
+ default "vim4" if MESON_T7
default ""
help
This option contains information about board name.
diff --git a/arch/arm/mach-meson/Makefile b/arch/arm/mach-meson/Makefile
index 08a24d4b24f..dc2bc0ceecb 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_T7) += board-t7.o
diff --git a/arch/arm/mach-meson/board-t7.c b/arch/arm/mach-meson/board-t7.c
new file mode 100644
index 00000000000..a6ccec25c0e
--- /dev/null
+++ b/arch/arm/mach-meson/board-t7.c
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2026 Lucas Tanure <tanure@linux.com>
+ */
+
+#include <init.h>
+#include <asm/arch/boot.h>
+#include <asm/arch/mem.h>
+#include <asm/armv8/mmu.h>
+#include <asm/global_data.h>
+#include <asm/io.h>
+#include <linux/bitops.h>
+#include <linux/compiler.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define T7_WDT_CTRL 0xfe002100
+#define T7_WDT_CTRL_EN BIT(18)
+
+int board_init(void)
+{
+ /*
+ * The secure firmware boots BL33 with the watchdog running,
+ * disable it.
+ */
+ writel(readl(T7_WDT_CTRL) & ~T7_WDT_CTRL_EN, T7_WDT_CTRL);
+
+ return 0;
+}
+
+/*
+ * The secure world owns 0x05000000 - 0x09000000: it contains the BL31
+ * and BL32 runtime zones (also described as reserved-memory in the
+ * upstream devicetree) and further firmware-protected pages, and is
+ * left unmapped in t7_mem_map below. Reserve the whole span so nothing
+ * (EFI allocations, boot-time relocations) is ever placed in memory
+ * U-Boot cannot access.
+ */
+#define T7_SECMON_RSVMEM_START 0x05000000UL
+#define T7_SECMON_RSVMEM_SIZE 0x04000000UL
+
+void meson_init_reserved_memory(__maybe_unused void *fdt)
+{
+ meson_board_add_reserved_memory(fdt, T7_SECMON_RSVMEM_START,
+ T7_SECMON_RSVMEM_SIZE);
+}
+
+int meson_get_boot_device(void)
+{
+ return -ENOSYS;
+}
+
+phys_size_t get_effective_memsize(void)
+{
+ /*
+ * The top 8 MiB of the first DRAM bank contain pages the secure
+ * world protects at runtime, keep U-Boot below them.
+ */
+ return min(gd->ram_size, (phys_size_t)0xdf800000);
+}
+
+static struct mm_region t7_mem_map[] = {
+ {
+ /* DRAM below the secure monitor reserved zone */
+ .virt = 0x00000000UL,
+ .phys = 0x00000000UL,
+ .size = 0x05100000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+ PTE_BLOCK_INNER_SHARE
+ }, {
+ /*
+ * DRAM between the secure monitor reserved zone and the
+ * end of the first bank. 0x05100000 - 0x09000000 is
+ * protected by the secure world and must not be mapped.
+ */
+ .virt = 0x09000000UL,
+ .phys = 0x09000000UL,
+ .size = 0xd7000000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+ PTE_BLOCK_INNER_SHARE
+ }, {
+ /* Peripherals, GIC, ... */
+ .virt = 0xe0000000UL,
+ .phys = 0xe0000000UL,
+ .size = 0x20000000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ }, {
+ /* List terminator */
+ 0,
+ }
+};
+
+struct mm_region *mem_map = t7_mem_map;
--
2.55.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 2/4] arm: meson: add Amlogic T7 SoC family support
2026-08-06 10:18 ` [PATCH 2/4] arm: meson: add Amlogic T7 SoC family support Lucas Tanure
@ 2026-08-10 14:15 ` Ferass El Hafidi
0 siblings, 0 replies; 10+ messages in thread
From: Ferass El Hafidi @ 2026-08-10 14:15 UTC (permalink / raw)
To: u-boot-amlogic, tanure, u-boot
Cc: neil.armstrong, trini, ilias.apalodimas, funderscore,
u-boot-amlogic, Lucas Tanure
On Thu, 06 Aug 2026 10:18, "Lucas Tanure via groups.io" <tanure=linux.com@groups.io> wrote:
>Add initial support for the Amlogic T7 family (A311D2). U-Boot runs
>as BL33, loaded at address 0x0 and entered from the vendor BL31 at
>EL2, either uncompressed or LZ4-compressed inside the boot image (the
>BL31 decompresses it).
>
>The secure firmware writes the SCS device keys into the first page of
>the loaded BL33 image (2 KiB for the BL33 key followed by 2 KiB for
>the kernel key). Reserve that page with a boot0 hook, as the vendor
>U-Boot does, so the keys do not overwrite U-Boot's entry code.
>
>The firmware also enters BL33 with the non-secure watchdog running:
>disable it in board_init(), otherwise the board is reset about a
>minute after boot.
>
>The memory map leaves 0x05100000 - 0x09000000 unmapped: the secure
>world owns this span (the BL31 and BL32 runtime zones described in
>the upstream devicetree, plus further firmware-protected pages), and
>this matches the vendor bootloader's own map. The whole span is also
>added to the devicetree and EFI reserved memory at boot time so no
>allocation is placed in memory U-Boot cannot access.
>
>get_effective_memsize() is capped at 0xdf800000 because the top 8 MiB
>of the first DRAM bank contain pages the secure world protects at
>runtime; U-Boot and its heap must stay below them.
>
>Assisted-by: Claude:claude-fable-5
Same as on the first patch.
>Signed-off-by: Lucas Tanure <tanure@linux.com>
>---
> arch/arm/include/asm/arch-meson/boot0.h | 18 +++++
> arch/arm/mach-meson/Kconfig | 10 +++
> arch/arm/mach-meson/Makefile | 1 +
> arch/arm/mach-meson/board-t7.c | 97 +++++++++++++++++++++++++
> 4 files changed, 126 insertions(+)
> create mode 100644 arch/arm/include/asm/arch-meson/boot0.h
> create mode 100644 arch/arm/mach-meson/board-t7.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..3ec085ccd64
>--- /dev/null
>+++ b/arch/arm/include/asm/arch-meson/boot0.h
>@@ -0,0 +1,18 @@
>+/* SPDX-License-Identifier: GPL-2.0+ */
>+/*
>+ * (C) Copyright 2026 Lucas Tanure <tanure@linux.com>
>+ */
>+
>+#ifndef __MESON_BOOT0_H
>+#define __MESON_BOOT0_H
>+
>+/*
>+ * The T7-family secure firmware writes the SCS device keys into the
>+ * first page of the loaded BL33 image (2048 bytes for the BL33 key
>+ * followed by 2048 bytes for the kernel key). Keep that page reserved
>+ * so the keys do not overwrite U-Boot's entry code.
>+ */
>+ b reset
>+ .space 4096
>+
>+#endif /* __MESON_BOOT0_H */
>diff --git a/arch/arm/mach-meson/Kconfig b/arch/arm/mach-meson/Kconfig
>index c687ef822a2..40aafc0b922 100644
>--- a/arch/arm/mach-meson/Kconfig
>+++ b/arch/arm/mach-meson/Kconfig
>@@ -67,6 +67,15 @@ config MESON_A1
> help
> Select this if your SoC is an A113L
>
>+config MESON_T7
>+ bool "T7"
>+ select MESON64_COMMON
>+ select ENABLE_ARM_SOC_BOOT0_HOOK
>+ imply OF_UPSTREAM
>+ help
>+ Select this if your SoC is from the Amlogic T7 family, like
>+ the A311D2 found on the Khadas VIM4 board.
>+
I would shorten this to:
help
Select this if your SoC is an A311D2
to match other SoCs' help message.
> endchoice
>
> config SYS_SOC
>@@ -91,6 +100,7 @@ config SYS_BOARD
> default "q200" if MESON_GXM
> default "s400" if MESON_AXG
> default "u200" if MESON_G12A
>+ default "vim4" if MESON_T7
> default ""
> help
> This option contains information about board name.
>diff --git a/arch/arm/mach-meson/Makefile b/arch/arm/mach-meson/Makefile
>index 08a24d4b24f..dc2bc0ceecb 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_T7) += board-t7.o
>diff --git a/arch/arm/mach-meson/board-t7.c b/arch/arm/mach-meson/board-t7.c
>new file mode 100644
>index 00000000000..a6ccec25c0e
>--- /dev/null
>+++ b/arch/arm/mach-meson/board-t7.c
>@@ -0,0 +1,97 @@
>+// SPDX-License-Identifier: GPL-2.0+
>+/*
>+ * (C) Copyright 2026 Lucas Tanure <tanure@linux.com>
>+ */
>+
>+#include <init.h>
>+#include <asm/arch/boot.h>
>+#include <asm/arch/mem.h>
>+#include <asm/armv8/mmu.h>
>+#include <asm/global_data.h>
>+#include <asm/io.h>
>+#include <linux/bitops.h>
>+#include <linux/compiler.h>
>+#include <linux/errno.h>
>+#include <linux/kernel.h>
>+
>+DECLARE_GLOBAL_DATA_PTR;
>+
>+#define T7_WDT_CTRL 0xfe002100
>+#define T7_WDT_CTRL_EN BIT(18)
>+
These should probably go in a header file? E.g. asm/arch/t7.h?
>+int board_init(void)
>+{
>+ /*
>+ * The secure firmware boots BL33 with the watchdog running,
>+ * disable it.
>+ */
>+ writel(readl(T7_WDT_CTRL) & ~T7_WDT_CTRL_EN, T7_WDT_CTRL);
In the future it might make sense to write a proper watchdog driver.
Though I'm also guilty for doing it this way in U-Boot SPL gxbb/gxl (I
think eventually I'll remove this handling there and have U-Boot
proper manage the watchdog).
Then you can drop this board_init() function entirely. With that said
I won't feel bad if you keep it that way for now.
>+
>+ return 0;
>+}
>+
>+/*
>+ * The secure world owns 0x05000000 - 0x09000000: it contains the BL31
>+ * and BL32 runtime zones (also described as reserved-memory in the
>+ * upstream devicetree) and further firmware-protected pages, and is
>+ * left unmapped in t7_mem_map below. Reserve the whole span so nothing
>+ * (EFI allocations, boot-time relocations) is ever placed in memory
>+ * U-Boot cannot access.
>+ */
>+#define T7_SECMON_RSVMEM_START 0x05000000UL
>+#define T7_SECMON_RSVMEM_SIZE 0x04000000UL
>+
This too, should probably go in a header file.
>+void meson_init_reserved_memory(__maybe_unused void *fdt)
>+{
Why __maybe_unused ?
>+ meson_board_add_reserved_memory(fdt, T7_SECMON_RSVMEM_START,
>+ T7_SECMON_RSVMEM_SIZE);
>+}
>+
>+int meson_get_boot_device(void)
>+{
>+ return -ENOSYS;
>+}
>+
>+phys_size_t get_effective_memsize(void)
>+{
>+ /*
>+ * The top 8 MiB of the first DRAM bank contain pages the secure
>+ * world protects at runtime, keep U-Boot below them.
>+ */
>+ return min(gd->ram_size, (phys_size_t)0xdf800000);
>+}
>+
>+static struct mm_region t7_mem_map[] = {
>+ {
>+ /* DRAM below the secure monitor reserved zone */
>+ .virt = 0x00000000UL,
>+ .phys = 0x00000000UL,
>+ .size = 0x05100000UL,
>+ .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
>+ PTE_BLOCK_INNER_SHARE
>+ }, {
>+ /*
>+ * DRAM between the secure monitor reserved zone and the
>+ * end of the first bank. 0x05100000 - 0x09000000 is
>+ * protected by the secure world and must not be mapped.
>+ */
>+ .virt = 0x09000000UL,
>+ .phys = 0x09000000UL,
>+ .size = 0xd7000000UL,
>+ .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
>+ PTE_BLOCK_INNER_SHARE
>+ }, {
>+ /* Peripherals, GIC, ... */
>+ .virt = 0xe0000000UL,
>+ .phys = 0xe0000000UL,
>+ .size = 0x20000000UL,
>+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
>+ PTE_BLOCK_NON_SHARE |
>+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
>+ }, {
>+ /* List terminator */
>+ 0,
>+ }
>+};
>+
>+struct mm_region *mem_map = t7_mem_map;
>--
>2.55.0
>
>
>
>-=-=-=-=-=-=-=-=-=-=-=-
>Groups.io Links: You receive all messages sent to this group.
>View/Reply Online (#3015): https://groups.io/g/u-boot-amlogic/message/3015
>Mute This Topic: https://groups.io/mt/120681747/8399868
>Group Owner: u-boot-amlogic+owner@groups.io
>Unsubscribe: https://groups.io/g/u-boot-amlogic/unsub [funderscore@postmarketos.org]
>-=-=-=-=-=-=-=-=-=-=-=-
>
>
Best regards,
Ferass
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/4] board: amlogic: add Khadas VIM4 support
2026-08-06 10:18 [PATCH 0/4] Add Amlogic T7 (A311D2) and Khadas VIM4 support Lucas Tanure
2026-08-06 10:18 ` [PATCH 1/4] serial: meson: add Amlogic S4 UART support Lucas Tanure
2026-08-06 10:18 ` [PATCH 2/4] arm: meson: add Amlogic T7 SoC family support Lucas Tanure
@ 2026-08-06 10:18 ` Lucas Tanure
2026-08-10 14:30 ` Ferass El Hafidi
2026-08-06 10:18 ` [PATCH 4/4] doc: board: amlogic: add Khadas VIM4 documentation Lucas Tanure
` (2 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Lucas Tanure @ 2026-08-06 10:18 UTC (permalink / raw)
To: u-boot
Cc: neil.armstrong, trini, ilias.apalodimas, funderscore,
u-boot-amlogic, Lucas Tanure
Add initial support for the Khadas VIM4 board (Amlogic A311D2, T7
family): UART console, DRAM (first bank), PSCI reset through BL31 and
the secure monitor. Storage, network and USB support come later.
The image is position independent with TEXT_BASE=0, so the same
u-boot.bin can be chainloaded from the vendor U-Boot for development
or packaged as BL33 into the vendor boot image.
The console runs at 921600 baud, the serial console convention on the
VIM4 (this is also how BL2 configures uart_a).
Assisted-by: Claude:claude-fable-5
Signed-off-by: Lucas Tanure <tanure@linux.com>
---
.../amlogic-t7-a311d2-khadas-vim4-u-boot.dtsi | 22 +++++++++++++++
board/amlogic/vim4/MAINTAINERS | 7 +++++
board/amlogic/vim4/Makefile | 4 +++
board/amlogic/vim4/vim4.c | 14 ++++++++++
configs/khadas-vim4_defconfig | 27 +++++++++++++++++++
5 files changed, 74 insertions(+)
create mode 100644 arch/arm/dts/amlogic-t7-a311d2-khadas-vim4-u-boot.dtsi
create mode 100644 board/amlogic/vim4/MAINTAINERS
create mode 100644 board/amlogic/vim4/Makefile
create mode 100644 board/amlogic/vim4/vim4.c
create mode 100644 configs/khadas-vim4_defconfig
diff --git a/arch/arm/dts/amlogic-t7-a311d2-khadas-vim4-u-boot.dtsi b/arch/arm/dts/amlogic-t7-a311d2-khadas-vim4-u-boot.dtsi
new file mode 100644
index 00000000000..dde2cd804e3
--- /dev/null
+++ b/arch/arm/dts/amlogic-t7-a311d2-khadas-vim4-u-boot.dtsi
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2026 Lucas Tanure <tanure@linux.com>
+ */
+
+/ {
+ chosen {
+ stdout-path = "serial0:921600n8";
+ };
+
+ soc {
+ bootph-all;
+ };
+};
+
+&uart_a {
+ bootph-all;
+};
+
+&xtal {
+ bootph-all;
+};
diff --git a/board/amlogic/vim4/MAINTAINERS b/board/amlogic/vim4/MAINTAINERS
new file mode 100644
index 00000000000..5e1ec98b571
--- /dev/null
+++ b/board/amlogic/vim4/MAINTAINERS
@@ -0,0 +1,7 @@
+VIM4
+M: Lucas Tanure <tanure@linux.com>
+S: Maintained
+L: u-boot-amlogic@groups.io
+F: board/amlogic/vim4/
+F: configs/khadas-vim4_defconfig
+F: arch/arm/dts/amlogic-t7-a311d2-khadas-vim4-u-boot.dtsi
diff --git a/board/amlogic/vim4/Makefile b/board/amlogic/vim4/Makefile
new file mode 100644
index 00000000000..0cc4078c549
--- /dev/null
+++ b/board/amlogic/vim4/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0+
+# (C) Copyright 2026 Lucas Tanure <tanure@linux.com>
+
+obj-y := vim4.o
diff --git a/board/amlogic/vim4/vim4.c b/board/amlogic/vim4/vim4.c
new file mode 100644
index 00000000000..5db3deefe0e
--- /dev/null
+++ b/board/amlogic/vim4/vim4.c
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2026 Lucas Tanure <tanure@linux.com>
+ */
+
+#include <init.h>
+#include <asm/arch/eth.h>
+
+int misc_init_r(void)
+{
+ meson_generate_serial_ethaddr();
+
+ return 0;
+}
diff --git a/configs/khadas-vim4_defconfig b/configs/khadas-vim4_defconfig
new file mode 100644
index 00000000000..10a64c07a88
--- /dev/null
+++ b/configs/khadas-vim4_defconfig
@@ -0,0 +1,27 @@
+CONFIG_ARM=y
+CONFIG_POSITION_INDEPENDENT=y
+CONFIG_ARCH_MESON=y
+CONFIG_TEXT_BASE=0x00000000
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x2000
+CONFIG_DM_GPIO=y
+CONFIG_DEFAULT_DEVICE_TREE="amlogic/amlogic-t7-a311d2-khadas-vim4"
+CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_MESON_T7=y
+CONFIG_SYS_LOAD_ADDR=0x10000000
+CONFIG_DEBUG_UART_BASE=0xfe078000
+CONFIG_DEBUG_UART_CLOCK=24000000
+CONFIG_IDENT_STRING=" khadas-vim4"
+CONFIG_DEBUG_UART=y
+CONFIG_OF_BOARD_SETUP=y
+# CONFIG_DISPLAY_CPUINFO is not set
+# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_SYS_PROMPT="kvim4> "
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_IMI is not set
+CONFIG_CMD_CACHE=y
+CONFIG_OF_CONTROL=y
+CONFIG_BAUDRATE=921600
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_SKIP_INIT=y
+CONFIG_MESON_SERIAL=y
--
2.55.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 3/4] board: amlogic: add Khadas VIM4 support
2026-08-06 10:18 ` [PATCH 3/4] board: amlogic: add Khadas VIM4 support Lucas Tanure
@ 2026-08-10 14:30 ` Ferass El Hafidi
0 siblings, 0 replies; 10+ messages in thread
From: Ferass El Hafidi @ 2026-08-10 14:30 UTC (permalink / raw)
To: u-boot-amlogic, tanure, u-boot
Cc: neil.armstrong, trini, ilias.apalodimas, funderscore,
u-boot-amlogic, Lucas Tanure
On Thu, 06 Aug 2026 10:18, "Lucas Tanure via groups.io" <tanure=linux.com@groups.io> wrote:
>Add initial support for the Khadas VIM4 board (Amlogic A311D2, T7
>family): UART console, DRAM (first bank), PSCI reset through BL31 and
>the secure monitor. Storage, network and USB support come later.
>
>The image is position independent with TEXT_BASE=0, so the same
>u-boot.bin can be chainloaded from the vendor U-Boot for development
>or packaged as BL33 into the vendor boot image.
>
>The console runs at 921600 baud, the serial console convention on the
>VIM4 (this is also how BL2 configures uart_a).
>
>Assisted-by: Claude:claude-fable-5
>Signed-off-by: Lucas Tanure <tanure@linux.com>
>---
> .../amlogic-t7-a311d2-khadas-vim4-u-boot.dtsi | 22 +++++++++++++++
> board/amlogic/vim4/MAINTAINERS | 7 +++++
> board/amlogic/vim4/Makefile | 4 +++
> board/amlogic/vim4/vim4.c | 14 ++++++++++
> configs/khadas-vim4_defconfig | 27 +++++++++++++++++++
> 5 files changed, 74 insertions(+)
> create mode 100644 arch/arm/dts/amlogic-t7-a311d2-khadas-vim4-u-boot.dtsi
> create mode 100644 board/amlogic/vim4/MAINTAINERS
> create mode 100644 board/amlogic/vim4/Makefile
> create mode 100644 board/amlogic/vim4/vim4.c
> create mode 100644 configs/khadas-vim4_defconfig
>
>diff --git a/arch/arm/dts/amlogic-t7-a311d2-khadas-vim4-u-boot.dtsi b/arch/arm/dts/amlogic-t7-a311d2-khadas-vim4-u-boot.dtsi
>new file mode 100644
>index 00000000000..dde2cd804e3
>--- /dev/null
>+++ b/arch/arm/dts/amlogic-t7-a311d2-khadas-vim4-u-boot.dtsi
>@@ -0,0 +1,22 @@
>+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
>+/*
>+ * Copyright (c) 2026 Lucas Tanure <tanure@linux.com>
>+ */
>+
>+/ {
>+ chosen {
>+ stdout-path = "serial0:921600n8";
>+ };
>+
>+ soc {
>+ bootph-all;
>+ };
>+};
>+
>+&uart_a {
>+ bootph-all;
>+};
>+
>+&xtal {
>+ bootph-all;
>+};
Maybe this should go in a common amlogic-t7-u-boot dts instead of
something board-specific?
>diff --git a/board/amlogic/vim4/MAINTAINERS b/board/amlogic/vim4/MAINTAINERS
>new file mode 100644
>index 00000000000..5e1ec98b571
>--- /dev/null
>+++ b/board/amlogic/vim4/MAINTAINERS
>@@ -0,0 +1,7 @@
>+VIM4
>+M: Lucas Tanure <tanure@linux.com>
>+S: Maintained
>+L: u-boot-amlogic@groups.io
>+F: board/amlogic/vim4/
>+F: configs/khadas-vim4_defconfig
>+F: arch/arm/dts/amlogic-t7-a311d2-khadas-vim4-u-boot.dtsi
>diff --git a/board/amlogic/vim4/Makefile b/board/amlogic/vim4/Makefile
>new file mode 100644
>index 00000000000..0cc4078c549
>--- /dev/null
>+++ b/board/amlogic/vim4/Makefile
>@@ -0,0 +1,4 @@
>+# SPDX-License-Identifier: GPL-2.0+
>+# (C) Copyright 2026 Lucas Tanure <tanure@linux.com>
>+
>+obj-y := vim4.o
>diff --git a/board/amlogic/vim4/vim4.c b/board/amlogic/vim4/vim4.c
>new file mode 100644
>index 00000000000..5db3deefe0e
>--- /dev/null
>+++ b/board/amlogic/vim4/vim4.c
>@@ -0,0 +1,14 @@
>+// SPDX-License-Identifier: GPL-2.0+
>+/*
>+ * (C) Copyright 2026 Lucas Tanure <tanure@linux.com>
>+ */
>+
>+#include <init.h>
>+#include <asm/arch/eth.h>
>+
>+int misc_init_r(void)
>+{
>+ meson_generate_serial_ethaddr();
>+
>+ return 0;
>+}
>diff --git a/configs/khadas-vim4_defconfig b/configs/khadas-vim4_defconfig
>new file mode 100644
>index 00000000000..10a64c07a88
>--- /dev/null
>+++ b/configs/khadas-vim4_defconfig
>@@ -0,0 +1,27 @@
>+CONFIG_ARM=y
>+CONFIG_POSITION_INDEPENDENT=y
>+CONFIG_ARCH_MESON=y
>+CONFIG_TEXT_BASE=0x00000000
>+CONFIG_NR_DRAM_BANKS=1
>+CONFIG_ENV_SIZE=0x2000
>+CONFIG_DM_GPIO=y
>+CONFIG_DEFAULT_DEVICE_TREE="amlogic/amlogic-t7-a311d2-khadas-vim4"
>+CONFIG_OF_LIBFDT_OVERLAY=y
>+CONFIG_MESON_T7=y
>+CONFIG_SYS_LOAD_ADDR=0x10000000
>+CONFIG_DEBUG_UART_BASE=0xfe078000
>+CONFIG_DEBUG_UART_CLOCK=24000000
>+CONFIG_IDENT_STRING=" khadas-vim4"
>+CONFIG_DEBUG_UART=y
>+CONFIG_OF_BOARD_SETUP=y
>+# CONFIG_DISPLAY_CPUINFO is not set
>+# CONFIG_DISPLAY_BOARDINFO is not set
>+CONFIG_SYS_PROMPT="kvim4> "
Leave this unset
>+# CONFIG_CMD_BDI is not set
>+# CONFIG_CMD_IMI is not set
>+CONFIG_CMD_CACHE=y
>+CONFIG_OF_CONTROL=y
>+CONFIG_BAUDRATE=921600
>+CONFIG_DEBUG_UART_ANNOUNCE=y
>+CONFIG_DEBUG_UART_SKIP_INIT=y
>+CONFIG_MESON_SERIAL=y
>--
>2.55.0
Best regards,
Ferass
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 4/4] doc: board: amlogic: add Khadas VIM4 documentation
2026-08-06 10:18 [PATCH 0/4] Add Amlogic T7 (A311D2) and Khadas VIM4 support Lucas Tanure
` (2 preceding siblings ...)
2026-08-06 10:18 ` [PATCH 3/4] board: amlogic: add Khadas VIM4 support Lucas Tanure
@ 2026-08-06 10:18 ` Lucas Tanure
2026-08-10 8:13 ` [PATCH 0/4] Add Amlogic T7 (A311D2) and Khadas VIM4 support neil.armstrong
2026-08-10 14:12 ` Ferass El Hafidi
5 siblings, 0 replies; 10+ messages in thread
From: Lucas Tanure @ 2026-08-06 10:18 UTC (permalink / raw)
To: u-boot
Cc: neil.armstrong, trini, ilias.apalodimas, funderscore,
u-boot-amlogic, Lucas Tanure
Document building U-Boot for the Khadas VIM4, chainloading it from the
vendor U-Boot for development, and packaging the boot image with the
vendor tooling, and add the A311D2 to the support matrix.
Notably, the SD card image layout differs from older Amlogic SoCs:
sector 0 is a checksummed BootROM header (a partition table may
coexist in its MBR slots), so when writing the bootloader the first
sector must be written along with it.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Lucas Tanure <tanure@linux.com>
---
board/amlogic/vim4/MAINTAINERS | 1 +
doc/board/amlogic/index.rst | 119 ++++++++++++++---------------
doc/board/amlogic/khadas-vim4.rst | 122 ++++++++++++++++++++++++++++++
3 files changed, 183 insertions(+), 59 deletions(-)
create mode 100644 doc/board/amlogic/khadas-vim4.rst
diff --git a/board/amlogic/vim4/MAINTAINERS b/board/amlogic/vim4/MAINTAINERS
index 5e1ec98b571..b2e5717e846 100644
--- a/board/amlogic/vim4/MAINTAINERS
+++ b/board/amlogic/vim4/MAINTAINERS
@@ -5,3 +5,4 @@ L: u-boot-amlogic@groups.io
F: board/amlogic/vim4/
F: configs/khadas-vim4_defconfig
F: arch/arm/dts/amlogic-t7-a311d2-khadas-vim4-u-boot.dtsi
+F: doc/board/amlogic/khadas-vim4.rst
diff --git a/doc/board/amlogic/index.rst b/doc/board/amlogic/index.rst
index 23380ac33f2..0785d495d38 100644
--- a/doc/board/amlogic/index.rst
+++ b/doc/board/amlogic/index.rst
@@ -10,65 +10,65 @@ An up-do-date matrix is also available on: http://linux-meson.com
This matrix concerns the actual source code version.
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| SoCs | S905 | S805X | S912 | A113X | S905X2 | S922X | S905X3 |
-| | | S905X | S905D | | S905D2 | A311D | S905D3 |
-| | | S905W | | | S905Y2 | | |
-+===================+===========+==========+==========+==========+==========+==========+==========+
-| UART | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| Pinctrl/GPIO | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| Clock Control | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| PWM | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| Reset Control | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| Infrared Decoder | No | No | No | No | No | No | No |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| Ethernet | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| Multi-core | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| Fuse access | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| SPI (FC) | **Yes** | **Yes** | **Yes** | **Yes** |**Yes** | **Yes** | No |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| SPI (CC) | No | No | No | No | No | No | No |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| I2C | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| USB | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| USB OTG | No | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| eMMC | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| SDCard | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| NAND | No | No | No | No | No | No | No |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| ADC | **Yes** | **Yes** | **Yes** | **Yes** | No | No | No |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| CVBS Output | **Yes** | **Yes** | **Yes** | *N/A* | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| HDMI Output | **Yes** | **Yes** | **Yes** | *N/A* | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| CEC | No | No | No | *N/A* | No | No | No |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| Thermal Sensor | No | No | No | No | No | No | No |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| LCD/LVDS Output | No | *N/A* | No | No | No | No | No |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| MIPI DSI Output | *N/A* | *N/A* | *N/A* | No | No | No | No |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| SoC Rev/Info | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| PCIe (+NVMe) | *N/A* | *N/A* | *N/A* | **Yes** | **Yes** | **Yes** | **Yes** |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
-| Watchdog | *N/A* | **Yes** | *N/A* | *N/A* | *N/A* | *N/A* | *N/A* |
-+-------------------+-----------+----------+----------+----------+----------+----------+----------+
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| SoCs | S905 | S805X | S912 | A113X | S905X2 | S922X | S905X3 | A311D2 |
+| | | S905X | S905D | | S905D2 | A311D | S905D3 | |
+| | | S905W | | | S905Y2 | | | |
++===================+===========+==========+==========+==========+==========+==========+==========+==========+
+| UART | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| Pinctrl/GPIO | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| Clock Control | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| PWM | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| Reset Control | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| Infrared Decoder | No | No | No | No | No | No | No | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| Ethernet | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| Multi-core | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| Fuse access | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| SPI (FC) | **Yes** | **Yes** | **Yes** | **Yes** |**Yes** | **Yes** | No | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| SPI (CC) | No | No | No | No | No | No | No | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| I2C | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| USB | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| USB OTG | No | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| eMMC | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| SDCard | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| NAND | No | No | No | No | No | No | No | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| ADC | **Yes** | **Yes** | **Yes** | **Yes** | No | No | No | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| CVBS Output | **Yes** | **Yes** | **Yes** | *N/A* | **Yes** | **Yes** | **Yes** | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| HDMI Output | **Yes** | **Yes** | **Yes** | *N/A* | **Yes** | **Yes** | **Yes** | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| CEC | No | No | No | *N/A* | No | No | No | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| Thermal Sensor | No | No | No | No | No | No | No | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| LCD/LVDS Output | No | *N/A* | No | No | No | No | No | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| MIPI DSI Output | *N/A* | *N/A* | *N/A* | No | No | No | No | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| SoC Rev/Info | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| PCIe (+NVMe) | *N/A* | *N/A* | *N/A* | **Yes** | **Yes** | **Yes** | **Yes** | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
+| Watchdog | *N/A* | **Yes** | *N/A* | *N/A* | *N/A* | *N/A* | *N/A* | No |
++-------------------+-----------+----------+----------+----------+----------+----------+----------+----------+
Boot Documentation
------------------
@@ -102,6 +102,7 @@ Board Documentation
khadas-vim2
khadas-vim3
khadas-vim3l
+ khadas-vim4
libretech-ac
libretech-cc
nanopi-k2
diff --git a/doc/board/amlogic/khadas-vim4.rst b/doc/board/amlogic/khadas-vim4.rst
new file mode 100644
index 00000000000..a42a5610877
--- /dev/null
+++ b/doc/board/amlogic/khadas-vim4.rst
@@ -0,0 +1,122 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+U-Boot for Khadas VIM4 (A311D2)
+===============================
+
+Khadas VIM4 is a Single Board Computer manufactured by Shenzhen Wesion
+Technology Co. Ltd with the following specifications:
+
+ - Amlogic A311D2 (T7 family) Arm Cortex-A53 quad-core + Cortex-A73 quad-core SoC
+ - 8GB LPDDR4X SDRAM
+ - Gigabit Ethernet
+ - HDMI 2.1 display output, HDMI input
+ - 40-pin GPIO header
+ - 1 x USB 3.0 Host, 1 x USB 2.0 Host/OTG
+ - 32GB eMMC, microSD
+ - M.2 socket
+ - 32MB SPI-NOR flash with the OOWOW recovery system
+ - Infrared receiver
+
+Schematics are available on the manufacturer website.
+
+Current U-Boot support covers the UART console, DRAM and PSCI reset,
+booting either chainloaded from the vendor U-Boot or as BL33 from
+power-on, packaged into the vendor boot image. Storage, network and
+USB are not supported yet.
+
+The serial console runs at 921600 baud, the Khadas convention for this
+board (this is also the rate the vendor firmware configures).
+
+U-Boot Compilation
+------------------
+
+.. code-block:: bash
+
+ $ export CROSS_COMPILE=aarch64-linux-gnu-
+ $ make khadas-vim4_defconfig
+ $ make
+
+Chainloading from the vendor U-Boot
+-----------------------------------
+
+The resulting u-boot.bin is position independent and can be run directly
+from the vendor U-Boot prompt, for example over TFTP:
+
+.. code-block:: none
+
+ kvim4# dhcp
+ kvim4# setenv serverip <tftp server address>
+ kvim4# tftpboot 0x01080000 u-boot.bin
+ kvim4# go 0x01080000
+
+Note: use load addresses in the vendor kernel load area, like 0x01080000
+above. Other areas, e.g. 0x08000000, are not mapped by the vendor U-Boot
+and loading there makes it crash.
+
+Boot image packaging
+--------------------
+
+There is no open-source tool yet that can assemble a bootable image for
+the T7 family: the BootROM and BL2 only accept an image signed by the
+Amlogic tooling shipped in the vendor U-Boot tree, with u-boot.bin
+taking the BL33 slot. The vendor tree and its packaging flow are
+available from https://github.com/khadas/u-boot (branch
+khadas-vims-v2019.01, see fip/mk_script.sh) or through the Khadas Fenix
+build system, https://github.com/khadas/fenix.
+
+To generate an SD card image, first build the vendor package once (for
+example with Fenix: select VIM4 and U-Boot 2019.01, then "make uboot");
+this compiles the vendor tree and leaves all the signed stages and
+tools in <vendor tree>/fip/_tmp. Then replace the BL33 payload with the
+mainline u-boot.bin and rebuild the device FIP:
+
+.. code-block:: bash
+
+ $ VENDOR=/path/to/khadas-u-boot
+ $ T7=$VENDOR/fip/t7
+ $ TMP=$VENDOR/fip/_tmp
+
+ # wrap and LZ4-compress u-boot.bin as the BL33 payload (1.5 MiB slot)
+ $ $T7/aml_encrypt_t7 --bl3sig --input u-boot.bin --output bl33.lz4 \
+ --compress lz4 --level v3 --type bl33
+ $ dd if=bl33.lz4 of=bl33.body bs=1 skip=1824
+ $ dd if=/dev/zero of=bl33-payload.bin bs=1572864 count=1
+ $ dd if=bl33.body of=bl33-payload.bin conv=notrunc
+
+ # rebuild the device FIP with the new BL33
+ $ $T7/binary-tool/acpu-imagetool create-device-fip \
+ --infile-template-chipset-fip-header=$TMP/device-fip-header.bin \
+ --infile-bl30-payload=$TMP/bl30-payload.bin \
+ --infile-bl33-payload=bl33-payload.bin \
+ --infile-blob-bl40=$TMP/blob-bl40.bin.signed \
+ --infile-blob-bl31=$TMP/blob-bl31.bin.signed \
+ --infile-blob-bl32=$TMP/blob-bl32.bin.signed \
+ --outfile-device-fip=device-fip.bin.signed
+
+ # all payload slots are fixed-size: patch the new device FIP into
+ # the vendor SD image at its fixed offset
+ $ cp $TMP/u-boot.bin.sd.bin.signed .
+ $ dd if=device-fip.bin.signed of=u-boot.bin.sd.bin.signed \
+ bs=512 seek=1313 conv=notrunc
+
+The resulting image for SD cards is u-boot.bin.sd.bin.signed.
+
+Unlike older Amlogic SoCs, sector 0 of the T7 SD image is a checksummed
+BootROM header, not only a partition table: the image must be written
+from sector 0 so the header is written too. A partition table may
+coexist in the MBR slots of the same sector, as the vendor SD images
+do:
+
+.. code-block:: bash
+
+ $ dd if=u-boot.bin.sd.bin.signed of=/dev/<sd card> bs=512 conv=fsync
+
+The BootROM tries SD before eMMC, so a valid SD card image always takes
+precedence. If no valid boot image is found, the board falls back to the
+OOWOW recovery system in SPI-NOR flash.
+
+Note that the BootROM only considers the SD card on cold boots: after a
+warm reset (e.g. the U-Boot "reset" command) it goes straight to eMMC
+and then SPI-NOR. Power-cycle the board to boot from SD again, or write
+the eMMC variant of the image (u-boot.bin.signed) to the eMMC boot area
+to make it the default for both boot paths.
--
2.55.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 0/4] Add Amlogic T7 (A311D2) and Khadas VIM4 support
2026-08-06 10:18 [PATCH 0/4] Add Amlogic T7 (A311D2) and Khadas VIM4 support Lucas Tanure
` (3 preceding siblings ...)
2026-08-06 10:18 ` [PATCH 4/4] doc: board: amlogic: add Khadas VIM4 documentation Lucas Tanure
@ 2026-08-10 8:13 ` neil.armstrong
2026-08-10 14:12 ` Ferass El Hafidi
5 siblings, 0 replies; 10+ messages in thread
From: neil.armstrong @ 2026-08-10 8:13 UTC (permalink / raw)
To: Lucas Tanure, u-boot; +Cc: trini, ilias.apalodimas, funderscore, u-boot-amlogic
Hi Lucas,
On 8/6/26 12:18, Lucas Tanure wrote:
> This series adds initial mainline support for the Amlogic T7 SoC
> family and the Khadas VIM4 board (A311D2):
> - S4-generation UART support
> - the T7 platform code
> - VIM4 board and defconfig
> - VIM4 documentation
>
> Tested on a Khadas VIM4 board, both chainloaded from the vendor U-Boot
> (tftpboot) and cold-booted from an SD card.
>
> Lucas Tanure (4):
> serial: meson: add Amlogic S4 UART support
> arm: meson: add Amlogic T7 SoC family support
> board: amlogic: add Khadas VIM4 support
> doc: board: amlogic: add Khadas VIM4 documentation
Overall this looks good, I'll review all the changes closely,
Neil
>
> .../amlogic-t7-a311d2-khadas-vim4-u-boot.dtsi | 22 ++++
> arch/arm/include/asm/arch-meson/boot0.h | 18 +++
> arch/arm/mach-meson/Kconfig | 10 ++
> arch/arm/mach-meson/Makefile | 1 +
> arch/arm/mach-meson/board-t7.c | 97 ++++++++++++++
> board/amlogic/vim4/MAINTAINERS | 8 ++
> board/amlogic/vim4/Makefile | 4 +
> board/amlogic/vim4/vim4.c | 14 ++
> configs/khadas-vim4_defconfig | 27 ++++
> doc/board/amlogic/index.rst | 119 ++++++++---------
> doc/board/amlogic/khadas-vim4.rst | 122 ++++++++++++++++++
> drivers/serial/serial_meson.c | 51 ++++++--
> 12 files changed, 421 insertions(+), 72 deletions(-)
> create mode 100644 arch/arm/dts/amlogic-t7-a311d2-khadas-vim4-u-boot.dtsi
> create mode 100644 arch/arm/include/asm/arch-meson/boot0.h
> create mode 100644 arch/arm/mach-meson/board-t7.c
> create mode 100644 board/amlogic/vim4/MAINTAINERS
> create mode 100644 board/amlogic/vim4/Makefile
> create mode 100644 board/amlogic/vim4/vim4.c
> create mode 100644 configs/khadas-vim4_defconfig
> create mode 100644 doc/board/amlogic/khadas-vim4.rst
>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 0/4] Add Amlogic T7 (A311D2) and Khadas VIM4 support
2026-08-06 10:18 [PATCH 0/4] Add Amlogic T7 (A311D2) and Khadas VIM4 support Lucas Tanure
` (4 preceding siblings ...)
2026-08-10 8:13 ` [PATCH 0/4] Add Amlogic T7 (A311D2) and Khadas VIM4 support neil.armstrong
@ 2026-08-10 14:12 ` Ferass El Hafidi
5 siblings, 0 replies; 10+ messages in thread
From: Ferass El Hafidi @ 2026-08-10 14:12 UTC (permalink / raw)
To: u-boot-amlogic, tanure, u-boot
Cc: neil.armstrong, trini, ilias.apalodimas, funderscore,
u-boot-amlogic, Lucas Tanure
On Thu, 06 Aug 2026 10:18, "Lucas Tanure via groups.io" <tanure=linux.com@groups.io> wrote:
>This series adds initial mainline support for the Amlogic T7 SoC
>family and the Khadas VIM4 board (A311D2):
> - S4-generation UART support
> - the T7 platform code
> - VIM4 board and defconfig
> - VIM4 documentation
>
>Tested on a Khadas VIM4 board, both chainloaded from the vendor U-Boot
>(tftpboot) and cold-booted from an SD card.
>
>Lucas Tanure (4):
> serial: meson: add Amlogic S4 UART support
> arm: meson: add Amlogic T7 SoC family support
> board: amlogic: add Khadas VIM4 support
> doc: board: amlogic: add Khadas VIM4 documentation
>
You made a typo on my email address, I'm funderscore@postmarketos.org,
not funderscore@postmasteros.org ;) I still received your patchset
though (via u-boot-amlogic/u-boot ML), this is just for future patch
revisions.
Best regards,
Ferass
^ permalink raw reply [flat|nested] 10+ messages in thread