Add support for ZTE zx297520v3
Subsystems (9)
Stefan Dösinger
maintainerv4 cover Add support for ZTE zx297520v3
Hi,
This is a follow-up on my RFC patches from January [0] for ZTE's zx297520v3 chipset. This chipset is popular in cheap LTE-to-wifi routers sold in developing countries. My goal is to run OpenWRT on them. I made more progress in more work on this SoC and it is time to get serious about code review and upstreaming.
Since my version in January I managed to get more hardware running: SPI, I2C, PMIC with real time clock and voltage regulators, Watchdog. LTE is not working yet, but I am able to start the coprocessor that handles it and talk to it via mailbox + shared memory. Wifi is working on a few more devices. Since WiFi, USB and Ethernet are working, the devices can have actual use with OpenWRT even without LTE.
Another hacker created a free software program to talk to the USB loader
[1] and boot U-Boot and Linux without modifying the on disk files. At the moment it needs a proprietary blob, so my documentation is emphasising booting with the on-device U-Boot.
This patchset here is mostly unmodified from the version I sent in January. It is the bare minimum to get an interactive shell working on the UART. Future patches can be found on my git repository [2] for those curious to peek ahead. The first 30 patches are in reasonable shape, but the further you go the more cleanup is necessary. I expect all of the patches go require a few rounds of feedback though.
My plan for upstreaming is largly this:
1) This bare minimum boot patchset
2) Add clock and pinctrl drivers
3) Add standard hardware to the device tree
4) Add zx29 specific drivers one by one: Watchdog, spi, i2c, DMA, PMIC, battery
5) SDIO backend for rtl8xxxu
6) rproc, mailbox and rpmsg
I am willing to maintain support for the SoC within reason. My patches add myself as maintainer. This is a hobby project for me though, keep that in mind if you want to ship a commercial product with these SoCs and upstreaming Linux.
Cheers,
Stefan
0: https://lists.infradead.org/pipermail/linux-arm-kernel/2026-January/1099306.html
1: https://github.com/zx297520v3-mainline/zx297520v3-loader
2: https://gitlab.com/stefandoesinger/zx297520-kernel/
Patch changelog:
v4: rename zx29.yaml to zte.yaml and add board enums
v3: Remove [RFC] tag, add defconfig
v2: checkpatch.pl fixes
---
Stefan Dösinger (8):
ARM: zte: Add zx297520v3 platform support
dt-bindings: arm: Add zx297520v3 board binding
ARM: dts: Add D-Link DWR-932M support
ARM: zte: Add support for zx29 low level debug
ARM: dts: Add an armv7 timer for zx297520v3
ARM: zte: Bring back zx29 UART support
ARM: dts: Declare UART1 on zx297520v3 boards
ARM: defconfig: Add a zx29 defconfig file
Documentation/arch/arm/zte/zx297520v3.rst | 158 +++++++++++++++++++++++++ Documentation/devicetree/bindings/arm/zte.yaml | 25 ++++ MAINTAINERS | 6 + arch/arm/Kconfig | 2 + arch/arm/Kconfig.debug | 12 ++ arch/arm/Makefile | 1 + arch/arm/boot/dts/Makefile | 1 + arch/arm/boot/dts/zte/Makefile | 3 + arch/arm/boot/dts/zte/dlink-dwr-932m.dts | 21 ++++ arch/arm/boot/dts/zte/zx297520v3.dtsi | 83 +++++++++++++ arch/arm/configs/zx29_defconfig | 90 ++++++++++++++ arch/arm/include/debug/pl01x.S | 7 ++ arch/arm/mach-zte/Kconfig | 24 ++++ arch/arm/mach-zte/Makefile | 2 + arch/arm/mach-zte/zx297520v3.c | 19 +++ drivers/tty/serial/amba-pl011.c | 37 ++++++ include/linux/amba/bus.h | 6 + 17 files changed, 497 insertions(+)
---
base-commit: 028ef9c96e96197026887c0f092424679298aae8
change-id: 20260416-send-5c08e095e5c9
Best regards,
Signature · 1 line
Stefan Dösinger <[email protected]>
Stefan Dösinger
maintainerPATCH v4 1/8 ARM: zte: Add zx297520v3 platform support
This SoC is used in low end LTE-to-WiFi routers, for example some D-Link DWR 932 revisions, ZTE K10, ZLT S10 4G, but also models that are branded and sold by ISPs themselves. They are widespread in Africa, China, Russia and Eastern Europe.
This SoC is a relative of the zx296702 and zx296718 that had some upstream support until commit 89d4f98ae90d ("ARM: remove zte zx platform"). My eventual goal is to enable OpenWRT to run on these devices.
--- Documentation/arch/arm/zte/zx297520v3.rst | 158 ++++++++++++++++++++++++++++++ MAINTAINERS | 4 + arch/arm/Kconfig | 2 + arch/arm/Makefile | 1 + arch/arm/mach-zte/Kconfig | 24 +++++ arch/arm/mach-zte/Makefile | 2 + arch/arm/mach-zte/zx297520v3.c | 19 ++++ 7 files changed, 210 insertions(+)
Documentation/arch/arm/zte/zx297520v3.rst new file +158 -0
@@ -0,0 +1,158 @@ +.. SPDX-License-Identifier: GPL-2.0 + +==================================== +Booting Linux on ZTE zx297520v3 SoCs +==================================== + +............................................................................... + +Author: Stefan Dösinger + +Date : 27 Jan 2026 + +1. Hardware description +--------------------------- +Zx297520v3 SoCs use a 64 bit capable Cortex-A53 CPU and GICv3, although they +run in aarch32 mode only. The CPU has support EL3, but no hypervisor (EL2) and +it seems to lack VFP and NEON. + +The SoC is used in a number of cheap LTE to Wifi routers, both battery powered +MiFis and stationary CPEs. In addition to the CPU these devices usually have +64 MB Ram (although some is shared with the LTE chip), 128 MB NAND flash, an +SDIO connected RTL8192-type Wifi chip limited to 2.4 ghz operation, USB 2, +and buttons. Devices with as low as 32 MB or as high as 128 MB ram exist, as +do devices with 8 or 16 MB of NOR flash. + +Some devices, especially the stationary ones, have 100 mbit Ethernet and an +Ethernet switch. + +Usually the devices have LEDs for status indication, although some have SPI or +i2c connected displays + +Some have an SD card slot. If it exists, it is a better choice for the root +file system because it easily outperforms the built-in NAND. + +The LTE interface runs on a separate DSP called ZSP880. It is probably derived +from LSI ZSPs and has an undocumented instruction set. The ZSP communicates +with the main CPU via SRAM and DRAM and a mailbox hardware that can generate +IRQs on either ends. + +There is also a Cortex M0 CPU, which is responsible for early HW initialization +and starting the Cortex A53 CPU. It does not have any essential purpose once +U-Boot is started. A SRAM-Based handover protocol exists to run custom code on +this CPU. + +2. Booting via USB +--------------------------- + +The Boot ROM has support for booting custom code via USB. This mode can be +entered by connecting a Boot PIN to GND or by modifying the third byte on NAND +(set it to anything other than 0x5A aka 'Z'). A free software tool to start +custom uboot and kernels can be found here: + +https://github.com/zx297520v3-mainline/zx297520v3-loader + +If USB download mode is entered but no boot commands are sent through USB, the +device will proceed to boot normally after a few seconds. It is therefore +possible to enable USB boot permanently and still leave the default boot files +in place. + +3. Building for built-in U-Boot +--------------------------- +The devices come with an ancient U-Boot that loads legacy uImages from NAND and +boots them without a chance for the user to interrupt. The images are stored in +files ap_cpuap.bin and ap_recovery.bin on a jffs2 partition named imagefs, +usually mtd4. A file named "fotaflag" switches between the two modes. + +In addition to the uImage header, those files have a 384 byte signature header, +which is used for authenticating the images on some devices. Most devices have +this authentication disabled and it is enough to pad the uImage files with 384 +zero bytes. + +Builtin U-Boot also poorly sets up the CPU. Read the next section for details +on this. It has no support for loading DTBs, so CONFIG_ARM_APPENDED_DTB is +needed. + +So to build an image that boots from NAND the following steps are necessary: + +1) Patch the assembly code from section 3 into arch/arm/kernel/head.S. +2) make zx29_defconfig +3) make [-j x] +4) cat arch/arm/boot/zImage arch/arm/boot/dts/zte/[device].dtb > kernel+dtb +5) mkimage -A arm -O linux -T kernel -C none -a 0x20008000 -d kernel+dtb uimg +6) dd if=/dev/zero bs=1 count=384 of=ap_recovery.bin +7) cat uimg >> ap_recovery.bin +8) Place this file onto imagefs on the device. Delete ap_cpuap.bin if the +free space is not enough. +9) Create the file fotaflag: echo -n FOTA-RECOVERY > fotaflag + +For development, booting ap_recovery.bin is recommended because the normal boot +mode arms the watchdog before starting the kernel. + +4. CPU and GIC Setup +--------------------------- + +Generally CPU and GICv3 need to be set up according to the requirements spelled +out in Documentation/arch/arm64/booting.rst. For zx297520v3 this means: + +1. GICD_CTLR.DS=1 to disable GIC security +2. Enable access to ICC_SRE +3. Disable trapping IRQs into monitor mode +4. Configure EL2 and below to run in insecure mode. +5. Configure timer PPIs to active-low. + +The kernel sources provided by ZTE do not boot either (interrupts do not work +at all). They are incomplete in other aspects too, so it is assumed that there +is some workaround similar to the one described in this document somewhere in +the binary blobs. + +The assembly code below is given as an example of how to achieve this: + +``` +#include <linux/irqchip/arm-gic-v3.h> +#include <asm/assembler.h> +#include <asm/cp15.h> + +@ This allows EL1 to handle ints hat are normally handled by EL2/3. +ldr r3, =0xf2000000 +ldr r4, =#(GICD_CTLR_ARE_NS | GICD_CTLR_DS) +str r4, [r3] + +cps #MON_MODE + +@ Work in non-secure physical address space: SCR_EL3.NS = 1. At least the UART +@ seems to respond only to non-secure addresses. I have taken insipiration from +@ Raspberry pi's armstub7.S here. +@ +@ ARM docs say modify this bit in monitor mode only... +mov r3, #0x131 @ non-secure, Make F, A bits in CPSR writeable + @ Allow hypervisor call. +mcr p15, 0, r3, c1, c1, 0 + +@ AP_PPI_MODE_REG: Configure timer PPIs (10, 11, 13, 14) to active-low. +ldr r3, =0xF22020a8 +ldr r4, =0x50 +str r4, [r3] +ldr r3, =0xF22020ac +ldr r4, =0x14 +str r4, [r3] + +@ Enable EL2 access to ICC_SRE (bit 3, ICC_SRE_EL3.Enable). Enable system reg +@ access to GICv3 registers (bit 0, ICC_SRE_EL3.SRE) for EL1 and EL3. +mrc p15, 6, r3, c12, c12, 5 @ ICC_SRE_EL3 +orr r3, #0x9 @ FIXME: No defines for SRE_EL3 values? +mcr p15, 6, r3, c12, c12, 5 +mrc p15, 0, r3, c12, c12, 5 @ ICC_SRE_EL1 +orr r3, #(ICC_SRE_EL1_SRE) +mcr p15, 0, r3, c12, c12, 5 + +@ Like ICC_SRE_EL3, enable EL1 access to ICC_SRE and system register access +@ for EL2. +mrc p15, 4, r3, c12, c9, 5 @ ICC_SRE_EL2 aka ICC_HSRE +orr r3, r3, #(ICC_SRE_EL2_ENABLE | ICC_SRE_EL2_SRE) +mcr p15, 4, r3, c12, c9, 5 +isb + +@ Back to SVC mode. TODO: Doesn't safe_svcmode_maskall do this for us anyway? +cps #SVC_MODE +```
MAINTAINERS +4 -0
@@ -29200,6 +29200,10 @@ F: include/linux/zswap.h F: mm/zswap.c F: tools/testing/selftests/cgroup/test_zswap.c +ZX29 +M: Stefan Dösinger <[email protected]> +F: arch/arm/mach-zte/ + SENARYTECH AUDIO CODEC DRIVER M: bo liu <[email protected]> S: Maintained
arch/arm/Kconfig +2 -0
@@ -464,6 +464,8 @@ source "arch/arm/mach-versatile/Kconfig" source "arch/arm/mach-vt8500/Kconfig" +source "arch/arm/mach-zte/Kconfig" + source "arch/arm/mach-zynq/Kconfig" # ARMv7-M architecture
arch/arm/Makefile +1 -0
@@ -223,6 +223,7 @@ machine-$(CONFIG_ARCH_SUNXI) += sunxi machine-$(CONFIG_ARCH_TEGRA) += tegra machine-$(CONFIG_ARCH_U8500) += ux500 machine-$(CONFIG_ARCH_VT8500) += vt8500 +machine-$(CONFIG_ARCH_ZTE) += zte machine-$(CONFIG_ARCH_ZYNQ) += zynq machine-$(CONFIG_PLAT_VERSATILE) += versatile machine-$(CONFIG_PLAT_SPEAR) += spear
arch/arm/mach-zte/Kconfig new file +24 -0
@@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0 +menuconfig ARCH_ZTE + bool "ZTE zx family" + depends on ARCH_MULTI_V7 + help + Support for ZTE zx-based family of processors. + +if ARCH_ZTE + +config SOC_ZX297520V3 + default y if ARCH_ZTE + bool "ZX297520v3" + select ARM_GIC_V3 + select ARM_AMBA + select HAVE_ARM_ARCH_TIMER + select PM_GENERIC_DOMAINS if PM + help + Support for ZTE zx297520v3 SoC. It a single core SoC used in cheap LTE to WiFi routers. + These devices can be Identified by the occurrence of the string "zx297520v3" in the boot + output and /proc/cpuinfo of their stock firmware. + + Please read Documentation/arch/arm/zte/zx297520v3.rst on how to boot the kernel. + +endif
arch/arm/mach-zte/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_SOC_ZX297520V3) += zx297520v3.o
arch/arm/mach-zte/zx297520v3.c new file +19 -0
@@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright 2026 Stefan Dösinger +*/ + +#include <asm/mach/arch.h> +#include <asm/mach/map.h> + +#include <linux/of_address.h> +#include <linux/of_platform.h> + +static const char *const zx297520v3_dt_compat[]__initconst = { +"zte,zx297520v3" , +NULL , +}; + +DT_MACHINE_START (ZX ,"ZTE zx297520v3 (Device Tree)" ) + .dt_compat = zx297520v3_dt_compat, +MACHINE_END
Signature · 1 line
2.52.0
Stefan Dösinger
maintainerPATCH v4 2/8 dt-bindings: arm: Add zx297520v3 board binding
In reply to Stefan DösingerAdd a compatible for boards based on the ZTE zx297520v3 SoC.
---
The list of devices is the devices I have access to for testing. There are many more devices based on this board and it is not always easy to identify them. Often they are sold without any branding ("4G home router") or with mobile carrier branding.
--- Documentation/devicetree/bindings/arm/zte.yaml | 25 +++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 26 insertions(+)
Documentation/devicetree/bindings/arm/zte.yaml new file +25 -0
@@ -0,0 +1,25 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/zte.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ZTE zx29 + +maintainers: + - Stefan Dösinger <[email protected]> + +properties: + $nodename: + const: "/" + compatible: + oneOf: + - items: + - enum: + - dlink,dwr932m + - hgsd,r310 + - tecno,tr118 + - zte,k10 + - const: zte,zx297520v3 + +additionalProperties: true
MAINTAINERS +1 -0
@@ -29202,6 +29202,7 @@ F: tools/testing/selftests/cgroup/test_zswap.c ZX29 M: Stefan Dösinger <[email protected]> +F: Documentation/devicetree/bindings/arm/zte.yaml F: arch/arm/mach-zte/ SENARYTECH AUDIO CODEC DRIVER
Signature · 1 line
2.52.0
Stefan Dösinger
maintainerPATCH v4 3/8 ARM: dts: Add D-Link DWR-932M support
In reply to Stefan DösingerThis adds DT bindings for zx297520v3 and one board that consumes it.
--- MAINTAINERS | 1 + arch/arm/boot/dts/Makefile | 1 + arch/arm/boot/dts/zte/Makefile | 3 +++ arch/arm/boot/dts/zte/dlink-dwr-932m.dts | 21 ++++++++++++++++++ arch/arm/boot/dts/zte/zx297520v3.dtsi | 37 ++++++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+)
MAINTAINERS +1 -0
@@ -29203,6 +29203,7 @@ F: tools/testing/selftests/cgroup/test_zswap.c ZX29 M: Stefan Dösinger <[email protected]> F: Documentation/devicetree/bindings/arm/zte.yaml +F: arch/arm/boot/dts/zte F: arch/arm/mach-zte/ SENARYTECH AUDIO CODEC DRIVER
arch/arm/boot/dts/Makefile +1 -0
@@ -39,3 +39,4 @@ subdir-y += unisoc subdir-y += vt8500 subdir-y += xen subdir-y += xilinx +subdir-y += zte
arch/arm/boot/dts/zte/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +dtb-$(CONFIG_SOC_ZX297520V3) += \ + dlink-dwr-932m.dtb
arch/arm/boot/dts/zte/dlink-dwr-932m.dts new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * D-Link DWR-932M Board + * + * (C) Copyright 2026 Stefan Dösinger + * + */ + +/dts-v1/; + +#include "zx297520v3.dtsi" + +/ { + model = "D-Link DWR-932M"; + compatible = "dlink,dwr932m", "zte,zx297520v3"; + + memory@20000000 { + device_type = "memory"; + reg = <0x20000000 0x04000000>; + }; +};
arch/arm/boot/dts/zte/zx297520v3.dtsi new file +37 -0
@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <dt-bindings/interrupt-controller/arm-gic.h> + +/ { + #address-cells = <1>; + #size-cells = <1>; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a53"; + reg = <0>; + }; + }; + + soc { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + interrupt-parent = <&gic>; + ranges; + + gic: interrupt-controller@f2000000 { + compatible = "arm,gic-v3"; + interrupt-controller; + #interrupt-cells = <3>; + #address-cells = <1>; + #size-cells = <1>; + reg = <0xf2000000 0x10000>, + <0xf2040000 0x20000>; + }; + }; +};
Signature · 1 line
2.52.0
Stefan Dösinger
maintainerPATCH v4 4/8 ARM: zte: Add support for zx29 low level debug
In reply to Stefan DösingerThis is based on the removed zx29 code. A separate (more complicated) patch will re-add the register map to the pl011 serial driver.
---
I am unsure about the virtual address. It doesn't seem to matter, as long as it is a valid address. This address is based on the old removed code. Is there a rule-of-thumb physical to virtual mapping I can use to give a sensible default value?
--- arch/arm/Kconfig.debug | 12 ++++++++++++ arch/arm/include/debug/pl01x.S | 7 +++++++ 2 files changed, 19 insertions(+)
arch/arm/Kconfig.debug +12 -0
@@ -1331,6 +1331,16 @@ choice This option selects UART0 on VIA/Wondermedia System-on-a-chip devices, including VT8500, WM8505, WM8650 and WM8850. + config DEBUG_ZTE_ZX + bool "Kernel low-level debugging via zx29 UART" + select DEBUG_UART_PL01X + depends on ARCH_ZTE + help + Say Y here if you are enabling ZTE zx297520v3 SOC and need + debug UART support. This UART is a PL011 with different + register addresses. The UART for boot messages on zx29 boards + is usually UART1 and is operating at 921600 8N1. + config DEBUG_ZYNQ_UART0 bool "Kernel low-level debugging on Xilinx Zynq using UART0" depends on ARCH_ZYNQ
@@ -1545,6 +1555,7 @@ config DEBUG_UART_8250 config DEBUG_UART_PHYS hex "Physical base address of debug UART" + default 0x01408000 if DEBUG_ZTE_ZX default 0x01c28000 if DEBUG_SUNXI_UART0 default 0x01c28400 if DEBUG_SUNXI_UART1 default 0x01d0c000 if DEBUG_DAVINCI_DA8XX_UART1
@@ -1701,6 +1712,7 @@ config DEBUG_UART_VIRT default 0xf31004c0 if DEBUG_MESON_UARTAO default 0xf4090000 if DEBUG_LPC32XX default 0xf4200000 if DEBUG_GEMINI + default 0xf4708000 if DEBUG_ZTE_ZX default 0xf6200000 if DEBUG_PXA_UART1 default 0xf7000000 if DEBUG_SUN9I_UART0 default 0xf7000000 if DEBUG_S3C64XX_UART && DEBUG_S3C_UART0
arch/arm/include/debug/pl01x.S +7 -0
@@ -8,6 +8,13 @@ */ #include <linux/amba/serial.h> +#ifdef CONFIG_DEBUG_ZTE_ZX +#undef UART01x_DR +#undef UART01x_FR +#define UART01x_DR 0x04 +#define UART01x_FR 0x14 +#endif + #ifdef CONFIG_DEBUG_UART_PHYS .macro addruart, rp, rv, tmp ldr \rp, =CONFIG_DEBUG_UART_PHYS
Signature · 1 line
2.52.0
Stefan Dösinger
maintainerPATCH v4 5/8 ARM: dts: Add an armv7 timer for zx297520v3
In reply to Stefan DösingerThe stock kernel does not use this timer, but it seems to work fine. The board has other board-specific timers that would need a driver and I see no reason to bother with them since the arm standard timer works.
The caveat is the non-standard GIC setup needed to handle the timer's level-low PPI. This is the responsibility of the boot loader and documented in Documentation/arch/arm/zte/zx297520v3.rst.
--- arch/arm/boot/dts/zte/zx297520v3.dtsi | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
arch/arm/boot/dts/zte/zx297520v3.dtsi +24 -0
@@ -24,6 +24,15 @@ soc { interrupt-parent = <&gic>; ranges; + /* The GIC has a non-standard way of configuring ints between level-low/level + * high or rising edge/falling edge at 0xf2202070 and onwards. See AP_INT_MODE_BASE + * and AP_PPI_MODE_REG in the ZTE kernel, although the offsets in the kernel source + * seem wrong. + * + * Everything defaults to active-high/rising edge, but the timer is active-low. We + * currently rely on the boot loader to change timer IRQs to active-low for us for + * now. + */ gic: interrupt-controller@f2000000 { compatible = "arm,gic-v3"; interrupt-controller;
@@ -33,5 +42,20 @@ gic: interrupt-controller@f2000000 { reg = <0xf2000000 0x10000>, <0xf2040000 0x20000>; }; + + timer { + compatible = "arm,armv7-timer"; + interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_LOW>, + <GIC_PPI 14 IRQ_TYPE_LEVEL_LOW>, + <GIC_PPI 11 IRQ_TYPE_LEVEL_LOW>, + <GIC_PPI 10 IRQ_TYPE_LEVEL_LOW>; + clock-frequency = <26000000>; + interrupt-parent = <&gic>; + /* I don't think uboot sets CNTVOFF and the stock kernel doesn't use the + * arm timer at all. Since this is a single CPU system I don't think it + * really matters that the offset is random though. + */ + arm,cpu-registers-not-fw-configured; + }; }; };
Signature · 1 line
2.52.0
Stefan Dösinger
maintainerPATCH v4 6/8 ARM: zte: Bring back zx29 UART support
In reply to Stefan DösingerThis is based on code removed in commit 89d4f98ae90d ("ARM: remove zte zx platform"). I did not bring back the zx29-uart .compatible as the arm,primecell-periphid does the job.
--- drivers/tty/serial/amba-pl011.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/amba/bus.h | 6 ++++++ 2 files changed, 43 insertions(+)
drivers/tty/serial/amba-pl011.c +37 -0
@@ -216,6 +216,38 @@ static struct vendor_data vendor_st = { .get_fifosize = get_fifosize_st, }; +static const u16 pl011_zte_offsets[REG_ARRAY_SIZE ] = { + [REG_DR ] =ZX_UART011_DR , + [REG_FR ] =ZX_UART011_FR , + [REG_LCRH_RX ] =ZX_UART011_LCRH , + [REG_LCRH_TX ] =ZX_UART011_LCRH , + [REG_IBRD ] =ZX_UART011_IBRD , + [REG_FBRD ] =ZX_UART011_FBRD , + [REG_CR ] =ZX_UART011_CR , + [REG_IFLS ] =ZX_UART011_IFLS , + [REG_IMSC ] =ZX_UART011_IMSC , + [REG_RIS ] =ZX_UART011_RIS , + [REG_MIS ] =ZX_UART011_MIS , + [REG_ICR ] =ZX_UART011_ICR , + [REG_DMACR ] =ZX_UART011_DMACR , +}; + +static unsigned int get_fifosize_zte (struct amba_device *dev) +{ +return 16 ; +} + +static struct vendor_data vendor_zte = { + .reg_offset = pl011_zte_offsets, + .access_32b = true, + .ifls =UART011_IFLS_RX4_8 |UART011_IFLS_TX4_8 , + .fr_busy = ZX_UART01x_FR_BUSY, + .fr_dsr = ZX_UART01x_FR_DSR, + .fr_cts = ZX_UART01x_FR_CTS, + .fr_ri =ZX_UART011_FR_RI , + .get_fifosize = get_fifosize_zte, +}; +/* Deals with DMA transactions */ struct pl011_dmabuf {
@@ -3081,6 +3113,11 @@ static const struct amba_id pl011_ids[] = { .mask = 0x00ffffff, .data = &vendor_st, }, + { + .id = AMBA_LINUX_ID(0x00, 0x1, 0xffe), + .mask = 0x00ffffff, + .data = &vendor_zte, + }, { 0, 0 }, };
include/linux/amba/bus.h +6 -0
@@ -103,8 +103,14 @@ enum amba_vendor {AMBA_VENDOR_ST =0x80 ,AMBA_VENDOR_QCOM =0x51 ,AMBA_VENDOR_LSI =0xb6 , + AMBA_VENDOR_LINUX = 0xfe, /* This value is not official */ }; +/* This is used to generate pseudo-ID for AMBA device */ +#define AMBA_LINUX_ID (conf, rev, part) \ + (((conf) & 0xff) << 24 | ((rev) & 0xf) << 20 | \ + AMBA_VENDOR_LINUX << 12 | ((part) & 0xfff)) +extern const struct bus_type amba_bustype;#define to_amba_device (d) container_of_const(d, struct amba_device, dev)
Signature · 1 line
2.52.0
Stefan Dösinger
maintainerPATCH v4 7/8 ARM: dts: Declare UART1 on zx297520v3 boards
In reply to Stefan DösingerThis is the UART that sends Uboot messages and is accessible via pins on the boards I have seen so far. UART0 and UART2 exist as well in the SoC and can be used with the right pinmux settings on some boards. They will be added later.
---
The reason why I add the serial1=uart1 alias is to keep console=ttyAMA1 stable regardless of the other enabled UARTs. UART0, as the name implies, has a lower MMIO address, but uart1 is the one that usually has the boot output and console.
--- arch/arm/boot/dts/zte/zx297520v3.dtsi | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/arm/boot/dts/zte/zx297520v3.dtsi +22 -0
@@ -6,6 +6,10 @@ / { #address-cells = <1>; #size-cells = <1>; + aliases { + serial1 = &uart1; + }; + cpus { #address-cells = <1>; #size-cells = <0>;
@@ -57,5 +61,23 @@ timer { */ arm,cpu-registers-not-fw-configured; }; + + /* The UART clock defaults to 26 mhz. It will be replaced when the zx29 clock + * framework is added. + */ + uartclk: uartclk: clock-26000000 { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <26000000>; + }; + + uart1: serial@1408000 { + compatible = "arm,pl011", "arm,primecell"; + arm,primecell-periphid = <0x001feffe>; + reg = <0x01408000 0x1000>; + interrupts = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&uartclk>; + clock-names = "apb_pclk"; + }; }; };
Signature · 1 line
2.52.0
Stefan Dösinger
maintainerPATCH v4 8/8 ARM: defconfig: Add a zx29 defconfig file
In reply to Stefan DösingerThis enables existing drivers that already are (UART) or will be (USB, GPIO) necessary to operate this board even if they aren't declared in the DTS yet.
--- arch/arm/configs/zx29_defconfig | 90 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+)
arch/arm/configs/zx29_defconfig new file +90 -0
@@ -0,0 +1,90 @@ +CONFIG_SYSVIPC=y +CONFIG_BLK_DEV_INITRD=y +# CONFIG_RD_BZIP2 is not set +# CONFIG_RD_LZMA is not set +# CONFIG_RD_XZ is not set +# CONFIG_RD_LZ4 is not set +CONFIG_EXPERT=y +CONFIG_KALLSYMS_ALL=y +CONFIG_MMU=y +CONFIG_ARCH_MULTI_V7=y +CONFIG_ARCH_ZTE=y +CONFIG_SOC_ZX297520V3=y +# FIXME: There is no PSCI on this board, but ARM_GIC_V3 depends on it +CONFIG_ARM_PSCI=y +CONFIG_ARM_APPENDED_DTB=y +CONFIG_CMDLINE="console=ttyAMA1 earlyprintk root=/dev/ram rw" +# CONFIG_SUSPEND is not set +CONFIG_BINFMT_FLAT=y +# CONFIG_UEVENT_HELPER is not set +# CONFIG_STANDALONE is not set +# CONFIG_PREVENT_FIRMWARE_BUILD is not set +# CONFIG_ALLOW_DEV_COREDUMP is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_COUNT=4 +CONFIG_CPU_FREQ=y +CONFIG_CPUFREQ_DT_PLATDEV=y +CONFIG_PM=y +CONFIG_PM_CLK=y +CONFIG_PM_GENERIC_DOMAINS=y +CONFIG_NET=y +CONFIG_PACKET=y +CONFIG_UNIX=y +CONFIG_INET=y +CONFIG_DEVTMPFS=y # FIXME: This is specific to my initrd. Remove before upstream +CONFIG_DEVTMPFS_MOUNT=y +# CONFIG_INPUT_MOUSEDEV is not set +CONFIG_KEYBOARD_GPIO_POLLED=y +CONFIG_GPIOLIB=y +CONFIG_OF_GPIO=y +CONFIG_GPIO_GENERIC_PLATFORM=y +# CONFIG_INPUT_MOUSE is not set +# CONFIG_SERIO is not set +CONFIG_VT_HW_CONSOLE_BINDING=y +CONFIG_SERIAL_AMBA_PL011=y +CONFIG_SERIAL_AMBA_PL011_CONSOLE=y +CONFIG_SERIAL_OF_PLATFORM=y +CONFIG_SERIAL_DEV_BUS=y +CONFIG_SERIAL_DEV_CTRL_TTYPORT=y +# CONFIG_HW_RANDOM is not set +CONFIG_MFD_SYSCON=y +# CONFIG_HID is not set +CONFIG_PINCTRL=y +CONFIG_GENERIC_PINCTRL_GROUPS=y +CONFIG_PINMUX=y +CONFIG_GENERIC_PINMUX_FUNCTIONS=y +CONFIG_PINCONF=y +CONFIG_GENERIC_PINCONF=y +CONFIG_RESET_CONTROLLER=y +CONFIG_POWER_RESET=y +CONFIG_RESET_SIMPLE=y +CONFIG_LEDS_GPIO=y +CONFIG_USB_DWC2=y +CONFIG_USB_GADGET=y +CONFIG_MTD=y +CONFIG_MTD_OF_PARTS=y +CONFIG_MTD_BLKDEVS=y +CONFIG_MTD_BLOCK=y +CONFIG_MTD_SPI_NAND=y +CONFIG_SPI_MASTER=y +CONFIG_MMC=y +CONFIG_MMC_DW=y +CONFIG_MMC_DW_PLTFM=y +CONFIG_STMMAC_ETH=y +CONFIG_STMMAC_PLATFORM=y +CONFIG_MDIO_BUS=y +CONFIG_REGULATOR=y +CONFIG_REGULATOR_FIXED_VOLTAGE=y +CONFIG_SRAM=y +CONFIG_MISC_FILESYSTEMS=y +CONFIG_JFFS2_FS=y +CONFIG_CONFIG_TMPFS=y +# CONFIG_MISC_FILESYSTEMS is not set +CONFIG_PRINTK_TIME=y +CONFIG_EARLY_PRINTK=y +CONFIG_DEBUG_LL=y +CONFIG_DEBUG_ZTE_ZX=y +CONFIG_DEBUG_LL_INCLUDE="debug/pl01x.S" +CONFIG_DEBUG_UART_PL01X=y +CONFIG_DEBUG_UART_PHYS=0x01408000 +CONFIG_DEBUG_UART_VIRT=0xf4708000
Signature · 1 line
2.52.0
Randy Dunlap
reviewerRe: [PATCH v4 1/8] ARM: zte: Add zx297520v3 platform support
In reply to Stefan DösingerQuoted 14 lines · Stefan Dösinger
arch/arm/mach-zte/Kconfig new file +8
-0@@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0 +menuconfig ARCH_ZTE + bool "ZTE zx family" + depends on ARCH_MULTI_V7 + help + Support for ZTE zx-based family of processors. + +if ARCH_ZTE
arch/arm/mach-zte/Kconfig line 18
Quoted 10 lines
arch/arm/mach-zte/Kconfig new file +10
-0+ +config SOC_ZX297520V3 + default y if ARCH_ZTE + bool "ZX297520v3" + select ARM_GIC_V3 + select ARM_AMBA + select HAVE_ARM_ARCH_TIMER + select PM_GENERIC_DOMAINS if PM + help + Support for ZTE zx297520v3 SoC. It a single core SoC used in cheap LTE to WiFi routers.
It is
arch/arm/mach-zte/Kconfig line 19
Quoted 1 line
arch/arm/mach-zte/Kconfig new file +1
-0+ These devices can be Identified by the occurrence of the string "zx297520v3" in the boot
identified
Quoted 3 lines
arch/arm/mach-zte/Kconfig new file +3
-0+ output and /proc/cpuinfo of their stock firmware. + + Please read Documentation/arch/arm/zte/zx297520v3.rst on how to boot the kernel.
Signature · 1 line
~Randy
Arnd Bergmann
maintainerRe: [PATCH v4 7/8] ARM: dts: Declare UART1 on zx297520v3 boards
In reply to Stefan DösingerQuoted 5 lines · Stefan Dösinger
The reason why I add the serial1=uart1 alias is to keep console=ttyAMA1 stable regardless of the other enabled UARTs. UART0, as the name implies, has a lower MMIO address, but uart1 is the one that usually has the boot output and console.
I'm not sure I'm following here. You generally want to either make sure the alias matches whatever number is printed on the product if there are multiple numbered ports, or you just use 'serial0' as the only alias if there is only one port.
arch/arm/boot/dts/zte/zx297520v3.dtsi / { · line 11
Quoted 3 lines
arch/arm/boot/dts/zte/zx297520v3.dtsi +3
-0+ aliases { + serial1 = &uart1; + };
Either way, the alias should go into the board specific file, not the general SoC file, as a board might be using a different set of UARTs.
Quoted 8 lines
arch/arm/boot/dts/zte/zx297520v3.dtsi +8
-0+ + /* The UART clock defaults to 26 mhz. It will be replaced when the zx29 clock + * framework is added. + */ + uartclk: uartclk: clock-26000000 { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <26000000>;
arch/arm/boot/dts/zte/zx297520v3.dtsi timer { · line 81
Quoted 10 lines
arch/arm/boot/dts/zte/zx297520v3.dtsi +10
-0+ }; + + uart1: serial@1408000 { + compatible = "arm,pl011", "arm,primecell"; + arm,primecell-periphid = <0x001feffe>; + reg = <0x01408000 0x1000>; + interrupts = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&uartclk>; + clock-names = "apb_pclk"; + };
Since you know the addresses of the other uart instances, I would suggest you add all of them at the same time.
Arnd
Stefan Dösinger
maintainerRe: [PATCH v4 7/8] ARM: dts: Declare UART1 on zx297520v3 boards
Hi Arnd,
Thanks for your comments.
Quoted 9 lines
Am 17.04.2026 um 11:59 schrieb Arnd Bergmann <[email protected]>:
Quoted 5 lines · Stefan Dösinger
The reason why I add the serial1=uart1 alias is to keep console=ttyAMA1 stable regardless of the other enabled UARTs. UART0, as the name implies, has a lower MMIO address, but uart1 is the one that usually has the boot output and console.
Quoted 4 lines
I'm not sure I'm following here. You generally want to either make sure the alias matches whatever number is printed on the product if there are multiple numbered ports, or you just use 'serial0' as the only alias if there is only one port.
Not all boards have their uart pins labeled, but those that do have the pins that connect to the UART at 0x01408000 named UART1RX/UART1TX. Most boards have only one though. I have seen a picture of only one that has UART0 and UART1. I could not test that board myself yet.
My original reason is one of developer convenience: If I have
uart0=serial@131000{
reg = <0x00131000 0x1000>;
...
status = "disabled";
};
uart1=serial@1408000{
reg = <0x01408000 0x1000>;
...
status = "okay";
};cmdline="... console=ttyAMA{0/1} ..."
changing uart0.status between disabled and okay (e.g. to experiment with uart0 and pinctrl) required changing the command line to match. I found that pretty annoying and the aliases seemed like the best way to avoid this.
Either way I am open to do whatever. I can keep the current naming for the reasons stated above, I can name serial@1408000 "uart0" and leave the others without an alias or I can drop the alias altogether.
Quoted 3 lines
Either way, the alias should go into the board specific file, not the general SoC file, as a board might be using a different set of UARTs.
That works for me, I'll move them. The aliases will most likely be the same for all boards based on this chipset, meaning duplicate code, but matching the alias to the board labels makes sense to me.
Quoted 2 lines
Since you know the addresses of the other uart instances, I would suggest you add all of them at the same time.
Will do.
I'll hold off for a bit before I resend the patches to see if some other comments come up.
Cheers,
Stefan
Rob Herring (Arm)
maintainerRe: [PATCH v4 2/8] dt-bindings: arm: Add zx297520v3 board binding
In reply to Stefan DösingerQuoted 6 lines · Stefan Dösinger
Add a compatible for boards based on the ZTE zx297520v3 SoC.
Signed-off-by Stefan Dösinger <[email protected]>---
Quoted 9 lines
The list of devices is the devices I have access to for testing. There are many more devices based on this board and it is not always easy to identify them. Often they are sold without any branding ("4G home router") or with mobile carrier branding.
--- Documentation/devicetree/bindings/arm/zte.yaml | 25 +++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 26 insertions(+)
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:./Documentation/devicetree/bindings/arm/zte.yaml:19:13: [warning] wrong indentation: expected 14 but found 12 (indentation)
dtschema/dtc warnings/errors:
doc reference errors (make refcheckdocs):
See https://patchwork.kernel.org/project/devicetree/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Stefan Dösinger
maintainerRe: [PATCH v4 2/8] dt-bindings: arm: Add zx297520v3 board binding
Hi Rob,
Am Samstag, 18. April 2026, 00:08:44 Ostafrikanische Zeit schrieben Sie:
Quoted 3 lines
If you already ran 'make
dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
Here is a new PEBKAC issue for your mail template: I ran dt_binding_check, it wrote the warning you pointed out, but I only checked the return value - which indicated success. Which I guess makes sense for a warning, since there seem to be a few preexisting ones. The warning itself was somewhere in the scrollback because I let dt_binding_check check all the files.
So I learned I have to actually look at the output to see if there are any warnings.
Cheers,
Stefan
Krzysztof Kozlowski
maintainerRe: [PATCH v4 2/8] dt-bindings: arm: Add zx297520v3 board binding
Quoted 8 lines · Stefan Dösinger
Hi Rob,
Am Samstag, 18. April 2026, 00:08:44 Ostafrikanische Zeit schrieben Sie:
Quoted 3 lines
If you already ran 'make
dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
Quoted 8 lines
Here is a new PEBKAC issue for your mail template: I ran
dt_binding_check, it wrote the warning you pointed out, but I only checked the return value - which indicated success. Which I guess makes sense for a warning, since there seem to be a few preexisting ones. The warning itself was somewhere in the scrollback because I letdt_binding_checkcheck all the files.So I learned I have to actually look at the output to see if there are any warnings.
Same with every other tool warnings, like compiler warnings...
Best regards,
Krzysztof