Skip to contentSkip to conversation

arm: npcm: add low-level debug support for NPCM7XX

PATCH In review Brendan Higgins 2 participants 5 messages Feb 12, 2018 – Feb 13, 2018 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

cover arm: npcm: add low-level debug support for NPCM7XX

Adds low-level debug support for Nuvoton's NPCM7XX architecture.

Change has been tested on Nuvoton's NPCM750 EVB.

#1 lore raw

PATCH 1/2 arm: npcm: add low-level debug support for NPCM7XX

Enable low-level debug support for Nuvoton NPCM7XX family by adding the debug port definitions for the SoC.

---
 arch/arm/Kconfig.debug           | 11 +++++++++++
 arch/arm/include/debug/npcm7xx.S | 30 ++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 arch/arm/include/debug/npcm7xx.S
arch/arm/Kconfig.debug +11 -0
index 447629d89884..d8f925cb8872 100644
@@ -595,6 +595,12 @@ choice
 		  Say Y here if you want kernel low-level debugging support
 		  on Hilscher NetX based platforms.
 
+	config DEBUG_NPCM7XX_UART
+		bool "Kernel low-level debugging messages via Nuvoton NPCMx50 UART"
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on Nuvoton based platforms.
+
 	config DEBUG_NOMADIK_UART
 		bool "Kernel low-level debugging messages via NOMADIK UART"
 		depends on ARCH_NOMADIK
@@ -1444,6 +1450,7 @@ config DEBUG_LL_INCLUDE
 	default "debug/ks8695.S" if DEBUG_KS8695_UART
 	default "debug/msm.S" if DEBUG_QCOM_UARTDM
 	default "debug/netx.S" if DEBUG_NETX_UART
+	default "debug/npcm7xx.S" if DEBUG_NPCM7XX_UART
 	default "debug/omap2plus.S" if DEBUG_OMAP2PLUS_UART
 	default "debug/renesas-scif.S" if DEBUG_R7S72100_SCIF2
 	default "debug/renesas-scif.S" if DEBUG_RCAR_GEN1_SCIF0
@@ -1481,6 +1488,7 @@ config DEBUG_UART_8250
 config DEBUG_UART_PHYS
 	hex "Physical base address of debug UART"
 	default 0x00100a00 if DEBUG_NETX_UART
+	default 0xf0004000 if DEBUG_NPCM7XX_UART
 	default 0x01c20000 if DEBUG_DAVINCI_DMx_UART0
 	default 0x01c28000 if DEBUG_SUNXI_UART0
 	default 0x01c28400 if DEBUG_SUNXI_UART1
@@ -1589,6 +1597,7 @@ config DEBUG_UART_PHYS
 		DEBUG_LL_UART_EFM32 || \
 		DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_MESON_UARTAO || \
 		DEBUG_NETX_UART || \
+		DEBUG_NPCM7XX_UART || \
 		DEBUG_QCOM_UARTDM || DEBUG_R7S72100_SCIF2 || \
 		DEBUG_RCAR_GEN1_SCIF0 || DEBUG_RCAR_GEN1_SCIF2 || \
 		DEBUG_RCAR_GEN2_SCIF0 || DEBUG_RCAR_GEN2_SCIF2 || \
@@ -1605,6 +1614,7 @@ config DEBUG_UART_VIRT
 	default 0xc8821000 if DEBUG_RV1108_UART1
 	default 0xc8912000 if DEBUG_RV1108_UART0
 	default 0xe0000a00 if DEBUG_NETX_UART
+	default 0xf0001000 if DEBUG_NPCM7XX_UART
 	default 0xe0010fe0 if ARCH_RPC
 	default 0xf0000be0 if ARCH_EBSA110
 	default 0xf0010000 if DEBUG_ASM9260_UART
@@ -1695,6 +1705,7 @@ config DEBUG_UART_VIRT
 	depends on DEBUG_LL_UART_8250 || DEBUG_LL_UART_PL01X || \
 		DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_MESON_UARTAO || \
 		DEBUG_NETX_UART || \
+		DEBUG_NPCM7XX_UART || \
 		DEBUG_QCOM_UARTDM || DEBUG_S3C24XX_UART || \
 		DEBUG_S3C64XX_UART || \
 		DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \
arch/arm/include/debug/npcm7xx.S new file +30 -0
new file mode 100644
index 000000000000..d08e14e73d79
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright 2018 Google, Inc.
+// This is heavily based on arch/arm/include/debug/at91.S
+
+#define NPCM7XX_SR	(0x14)	/* Status Register */
+#define NPCM7XX_THR	(0x00)	/* Transmitter Holding Register */
+#define NPCM7XX_TXRDY	(1 << 6)	/* Transmitter Ready */
+#define NPCM7XX_TXEMPTY	(1 << 6)	/* Transmitter Empty */
+
+	.macro	addruart, rp, rv, tmp
+	ldr	\rp, =CONFIG_DEBUG_UART_PHYS	@ System peripherals (phys)
+	ldr	\rv, =CONFIG_DEBUG_UART_VIRT	@ System peripherals (virt)
+	.endm
+
+	.macro	senduart,rd,rx
+	strb	\rd, [\rx, #(NPCM7XX_THR)]	@ Write to Transmit Holding Reg
+	.endm
+
+	.macro	waituart,rd,rx
+1001:	ldr	\rd, [\rx, #(NPCM7XX_SR)]	@ Read Status Register
+	tst	\rd, #NPCM7XX_TXRDY		@ TXRDY = 1 when ready to tx
+	beq	1001b
+	.endm
+
+	.macro	busyuart,rd,rx
+1001:	ldr	\rd, [\rx, #(NPCM7XX_SR)]	@ Read Status Register
+	tst	\rd, #NPCM7XX_TXEMPTY		@ TXEMPTY = 1 when tx complete
+	beq	1001b
+	.endm
+
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
#2 lore raw

Hi Brendan,

Quoted 2 lines · Brendan Higgins

Enable low-level debug support for Nuvoton NPCM7XX family by adding the debug port definitions for the SoC.

When playing with the Poleg boards at the recent OpenBMC hackathon Jeremy discovered that the UART is a normal-ish 8250, with a custom divisor and a few extra bits to be set.

I found that we can us the generic 8250 low level debugging support just fine. This is because u-boot sets up the divisor settings for us (as you've assumed with your version here), and from there it's just reading/writing characters.

Assuming you can reproduce our results, I suggest we drop these patches in favour of adding the correct configuration the Poleg.

Cheers,

Joel

Quoted 109 lines
---
 arch/arm/Kconfig.debug           | 11 +++++++++++
 arch/arm/include/debug/npcm7xx.S | 30 ++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 arch/arm/include/debug/npcm7xx.S
arch/arm/Kconfig.debug +11 -0
index 447629d89884..d8f925cb8872 100644
@@ -595,6 +595,12 @@ choice
                  Say Y here if you want kernel low-level debugging support
                  on Hilscher NetX based platforms.
 
+       config DEBUG_NPCM7XX_UART
+               bool "Kernel low-level debugging messages via Nuvoton NPCMx50 UART"
+               help
+                 Say Y here if you want kernel low-level debugging support
+                 on Nuvoton based platforms.
+
        config DEBUG_NOMADIK_UART
                bool "Kernel low-level debugging messages via NOMADIK UART"
                depends on ARCH_NOMADIK
@@ -1444,6 +1450,7 @@ config DEBUG_LL_INCLUDE
        default "debug/ks8695.S" if DEBUG_KS8695_UART
        default "debug/msm.S" if DEBUG_QCOM_UARTDM
        default "debug/netx.S" if DEBUG_NETX_UART
+       default "debug/npcm7xx.S" if DEBUG_NPCM7XX_UART
        default "debug/omap2plus.S" if DEBUG_OMAP2PLUS_UART
        default "debug/renesas-scif.S" if DEBUG_R7S72100_SCIF2
        default "debug/renesas-scif.S" if DEBUG_RCAR_GEN1_SCIF0
@@ -1481,6 +1488,7 @@ config DEBUG_UART_8250
 config DEBUG_UART_PHYS
        hex "Physical base address of debug UART"
        default 0x00100a00 if DEBUG_NETX_UART
+       default 0xf0004000 if DEBUG_NPCM7XX_UART
        default 0x01c20000 if DEBUG_DAVINCI_DMx_UART0
        default 0x01c28000 if DEBUG_SUNXI_UART0
        default 0x01c28400 if DEBUG_SUNXI_UART1
@@ -1589,6 +1597,7 @@ config DEBUG_UART_PHYS
                DEBUG_LL_UART_EFM32 || \
                DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_MESON_UARTAO || \
                DEBUG_NETX_UART || \
+               DEBUG_NPCM7XX_UART || \
                DEBUG_QCOM_UARTDM || DEBUG_R7S72100_SCIF2 || \
                DEBUG_RCAR_GEN1_SCIF0 || DEBUG_RCAR_GEN1_SCIF2 || \
                DEBUG_RCAR_GEN2_SCIF0 || DEBUG_RCAR_GEN2_SCIF2 || \
@@ -1605,6 +1614,7 @@ config DEBUG_UART_VIRT
        default 0xc8821000 if DEBUG_RV1108_UART1
        default 0xc8912000 if DEBUG_RV1108_UART0
        default 0xe0000a00 if DEBUG_NETX_UART
+       default 0xf0001000 if DEBUG_NPCM7XX_UART
        default 0xe0010fe0 if ARCH_RPC
        default 0xf0000be0 if ARCH_EBSA110
        default 0xf0010000 if DEBUG_ASM9260_UART
@@ -1695,6 +1705,7 @@ config DEBUG_UART_VIRT
        depends on DEBUG_LL_UART_8250 || DEBUG_LL_UART_PL01X || \
                DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_MESON_UARTAO || \
                DEBUG_NETX_UART || \
+               DEBUG_NPCM7XX_UART || \
                DEBUG_QCOM_UARTDM || DEBUG_S3C24XX_UART || \
                DEBUG_S3C64XX_UART || \
                DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \
arch/arm/include/debug/npcm7xx.S new file +30 -1
new file mode 100644
index 000000000000..d08e14e73d79
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright 2018 Google, Inc.
+// This is heavily based on arch/arm/include/debug/at91.S
+
+#define NPCM7XX_SR     (0x14)  /* Status Register */
+#define NPCM7XX_THR    (0x00)  /* Transmitter Holding Register */
+#define NPCM7XX_TXRDY  (1 << 6)        /* Transmitter Ready */
+#define NPCM7XX_TXEMPTY        (1 << 6)        /* Transmitter Empty */
+
+       .macro  addruart, rp, rv, tmp
+       ldr     \rp, =CONFIG_DEBUG_UART_PHYS    @ System peripherals (phys)
+       ldr     \rv, =CONFIG_DEBUG_UART_VIRT    @ System peripherals (virt)
+       .endm
+
+       .macro  senduart,rd,rx
+       strb    \rd, [\rx, #(NPCM7XX_THR)]      @ Write to Transmit Holding Reg
+       .endm
+
+       .macro  waituart,rd,rx
+1001:  ldr     \rd, [\rx, #(NPCM7XX_SR)]       @ Read Status Register
+       tst     \rd, #NPCM7XX_TXRDY             @ TXRDY = 1 when ready to tx
+       beq     1001b
+       .endm
+
+       .macro  busyuart,rd,rx
+1001:  ldr     \rd, [\rx, #(NPCM7XX_SR)]       @ Read Status Register
+       tst     \rd, #NPCM7XX_TXEMPTY           @ TXEMPTY = 1 when tx complete
+       beq     1001b
+       .endm
+
--

2.16.0.rc1.238.g530d649a79-goog

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#3 lore raw
Quoted 11 lines · Joel Stanley

Hi Brendan,

Quoted 2 lines · Brendan Higgins

Enable low-level debug support for Nuvoton NPCM7XX family by adding the debug port definitions for the SoC.

When playing with the Poleg boards at the recent OpenBMC hackathon Jeremy discovered that the UART is a normal-ish 8250, with a custom divisor and a few extra bits to be set.

Quoted 8 lines

I found that we can us the generic 8250 low level debugging support just fine. This is because u-boot sets up the divisor settings for us (as you've assumed with your version here), and from there it's just reading/writing characters.

Assuming you can reproduce our results, I suggest we drop these patches in favour of adding the correct configuration the Poleg.

Sounds good to me. I trust that if you were able to get the 8250 driver working on the Poleg that it does indeed work.

We can talk about configuring it off the Linux mailing lists.

<snip>

Thanks!

#4 lore raw

PATCH 2/2 MAINTAINERS: Add low-level debug files to Nuvoton NPCM section

In reply to Brendan Higgins

Adds low-level debug files for NPCM7XX architecture to the Nuvoton NPCM architecture section.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 2fa95aba0f7f..4eaa66bc0562 100644
@@ -1608,6 +1608,7 @@ L:	openbmc at lists.ozlabs.org (moderated for non-subscribers)
 S:	Supported
 F:	arch/arm/mach-npcm/
 F:	arch/arm/boot/dts/nuvoton-npcm*
+F:	arch/arm/include/debug/npcm7xx.S
 F:	include/dt-bindings/clock/nuvoton,npcm7xx-clks.h
 F:	drivers/*/*npcm*
 F:	Documentation/*/*npcm*
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog