amba/serial: amba-pl011: Bring back zx29 UART support
cover amba/serial: amba-pl011: Bring back zx29 UART support
This is based on code removed in commit 89d4f98ae90d ("ARM: remove zte zx platform"). It was previously discussed and reviewed on the linux-arm-kernel mailing list as part of my patchset to add initial support for ZTE's zx297520v3 router board. I am sending the two UART driver patches to linux-serial. The rest goes through the soc list.
Note that the first patch (LLDEBUG) uses a Kconfig symbol introduced by my platform patch, which was sent to the soc mailing list. I don't know what the correct way to handle this is. I can delay/resend this patchset after the soc changes are merged.
---
Stefan Dösinger (2):
ARM: zte: Add support for zx29 low level debug amba/serial: amba-pl011: Bring back zx29 UART support
arch/arm/Kconfig.debug | 12 ++++++++++++ arch/arm/include/debug/pl01x.S | 9 +++++++++ drivers/tty/serial/amba-pl011.c | 42 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+)
---
base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
change-id: 20260513-zx29uart-ef44af731390
Best regards,
Signature · 1 line
Stefan Dösinger <[email protected]>
PATCH 1/2 ARM: zte: Add support for zx29 low level debug
This is based on the removed zx29 code. A separate (more complicated) patch will re-add the register map to the pl011 serial driver.
---
Patch changelog:
v8: Adjust UART01x_FR_BUSY to match the different ZX UART registers (Sashiko). I am unsure about UART01x_FR_TXFF and my boards do not expose flow control pins to allow me to test if it works.
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 | 9 +++++++++ 2 files changed, 21 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 +9 -0
@@ -8,6 +8,15 @@ */ #include <linux/amba/serial.h> +#ifdef CONFIG_DEBUG_ZTE_ZX +#undef UART01x_DR +#undef UART01x_FR +#undef UART01x_FR_BUSY +#define UART01x_DR 0x04 +#define UART01x_FR 0x14 +#define UART01x_FR_BUSY (1<<8) +#endif + #ifdef CONFIG_DEBUG_UART_PHYS .macro addruart, rp, rv, tmp ldr \rp, =CONFIG_DEBUG_UART_PHYS
Signature · 1 line
2.53.0
PATCH 2/2 amba/serial: amba-pl011: 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.
---
Changes since v4:
Use ZTE's JEDEC ID instead of 0xfe for the DT-Provided AMBA ID.
--- drivers/tty/serial/amba-pl011.c | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
drivers/tty/serial/amba-pl011.c +42 -0
@@ -240,6 +240,38 @@ static struct vendor_data vendor_nvidia = { .get_fifosize = get_fifosize_nvidia, }; +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 {
@@ -3180,6 +3212,16 @@ static const struct amba_id pl011_ids[] = { .mask = 0x000fffff, .data = &vendor_nvidia, }, + { + /* This is an invented ID. The actual hardware that contains + * these ZTE UARTs (zx29 boards) has no AMBA PIDs stored. ZTE + * JEDEC ID (ignoring banks) and the "011" part number as used + * by ARM. + */ + .id = 0x0008c011, + .mask = 0x000fffff, + .data = &vendor_zte, + }, { 0, 0 }, };
Signature · 1 line
2.53.0