diff mbox series

[2/2] ARM: bcm: Support BCM6846 debug UART

Message ID 20240917-bcm-arm-bcm6846-v1-2-236e29661f4c@linaro.org (mailing list archive)
State New, archived
Headers show
Series ARM: bcm: Make BCM6846 bootable on mainline | expand

Commit Message

Linus Walleij Sept. 17, 2024, 7:18 p.m. UTC
The debug UART on the BCM6846 is in a different place than
on the other BCM platforms.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/arm/Kconfig.debug            | 12 +++++++++---
 arch/arm/mach-bcm/Makefile        |  1 +
 arch/arm/mach-bcm/board_bcm6846.c | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 3 deletions(-)

Comments

William Zhang Sept. 19, 2024, 1:26 a.m. UTC | #1
Hi Linus,

On 09/17/2024 12:18 PM, Linus Walleij wrote:
> The debug UART on the BCM6846 is in a different place than
> on the other BCM platforms.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>   arch/arm/Kconfig.debug            | 12 +++++++++---
>   arch/arm/mach-bcm/Makefile        |  1 +
>   arch/arm/mach-bcm/board_bcm6846.c | 34 ++++++++++++++++++++++++++++++++++
>   3 files changed, 44 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
> index 7f47b4f335c3..86989257b968 100644
> --- a/arch/arm/Kconfig.debug
> +++ b/arch/arm/Kconfig.debug
> @@ -242,6 +242,10 @@ choice
>               depends on ARCH_BCM_5301X || ARCH_BCM_NSP
>               select DEBUG_UART_8250
>
> +     config DEBUG_BCM6846
> +             bool "Kernel low-level debugging on BCM6846 UART0"
> +             depends on ARCH_BCMBCA
> +
>       config DEBUG_BCM_HR2
>               bool "Kernel low-level debugging on Hurricane 2 UART2"
>               depends on ARCH_BCM_HR2
> @@ -1526,7 +1530,7 @@ config DEBUG_LL_INCLUDE
>       default "debug/vf.S" if DEBUG_VF_UART
>       default "debug/vt8500.S" if DEBUG_VT8500_UART0
>       default "debug/zynq.S" if DEBUG_ZYNQ_UART0 || DEBUG_ZYNQ_UART1
> -     default "debug/bcm63xx.S" if DEBUG_BCM63XX_UART
> +     default "debug/bcm63xx.S" if DEBUG_BCM63XX_UART || DEBUG_BCM6846
>       default "debug/digicolor.S" if DEBUG_DIGICOLOR_UA0
>       default "debug/brcmstb.S" if DEBUG_BRCMSTB_UART
>       default "mach/debug-macro.S"
> @@ -1640,6 +1644,7 @@ config DEBUG_UART_PHYS
>       default 0xfe531000 if DEBUG_STIH41X_SBC_ASC1
>       default 0xfed32000 if DEBUG_STIH41X_ASC2
>       default 0xff690000 if DEBUG_RK32_UART2
> +     default 0xff800640 if DEBUG_BCM6846
>       default 0xffc02000 if DEBUG_SOCFPGA_UART0
>       default 0xffc02100 if DEBUG_SOCFPGA_ARRIA10_UART1
>       default 0xffc03000 if DEBUG_SOCFPGA_CYCLONE5_UART1
> @@ -1664,7 +1669,7 @@ config DEBUG_UART_PHYS
>               DEBUG_RMOBILE_SCIFA0 || DEBUG_RMOBILE_SCIFA1 || \
>               DEBUG_RMOBILE_SCIFA4 || \
>               DEBUG_S3C64XX_UART || \
> -             DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \
> +             DEBUG_BCM63XX_UART || DEBUG_BCM6846 || DEBUG_ASM9260_UART || \
>               DEBUG_DIGICOLOR_UA0 || \
>               DEBUG_AT91_UART || DEBUG_STM32_UART || \
>               DEBUG_STIH41X_ASC2 || DEBUG_STIH41X_SBC_ASC1 || \
> @@ -1734,6 +1739,7 @@ config DEBUG_UART_VIRT
>       default 0xfe018000 if DEBUG_MMP_UART3
>       default 0xfe100000 if DEBUG_IMX23_UART || DEBUG_IMX28_UART
>       default 0xfe300000 if DEBUG_BCM_KONA_UART
> +     default 0xfe300640 if DEBUG_BCM6846
>       default 0xfeb00000 if DEBUG_HI3620_UART || DEBUG_HIX5HD2_UART
>       default 0xfeb24000 if DEBUG_RK3X_UART0
>       default 0xfeb26000 if DEBUG_RK3X_UART1
> @@ -1765,7 +1771,7 @@ config DEBUG_UART_VIRT
>               DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_MESON_UARTAO || \
>               DEBUG_QCOM_UARTDM || \
>               DEBUG_S3C64XX_UART || \
> -             DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \
> +             DEBUG_BCM63XX_UART || DEBUG_BCM6846 || DEBUG_ASM9260_UART || \
>               DEBUG_DIGICOLOR_UA0 || \
>               DEBUG_AT91_UART || DEBUG_STM32_UART || \
>               DEBUG_STIH41X_ASC2 || DEBUG_STIH41X_SBC_ASC1 || \
> diff --git a/arch/arm/mach-bcm/Makefile b/arch/arm/mach-bcm/Makefile
> index 2e523f29ec3b..22699a7e18ec 100644
> --- a/arch/arm/mach-bcm/Makefile
> +++ b/arch/arm/mach-bcm/Makefile
> @@ -58,5 +58,6 @@ endif
>
>   # BCMBCA
>   ifeq ($(CONFIG_ARCH_BCMBCA),y)
> +obj-y                                += board_bcm6846.o
>   obj-$(CONFIG_SMP)           += bcm63xx_smp.o bcm63xx_pmb.o
>   endif
> diff --git a/arch/arm/mach-bcm/board_bcm6846.c b/arch/arm/mach-bcm/board_bcm6846.c
> new file mode 100644
> index 000000000000..7a086c7a1e71
> --- /dev/null
> +++ b/arch/arm/mach-bcm/board_bcm6846.c
This code will be the same for all the bcmbca A7 chips. And more
importantly, Broadcom's goal is to use
multi_v7 common config for all A7 chips without introducing any
machine or board specific implementation.
Is it possible this can be done through common code? It looks like the
only difference is the UART address.

> @@ -0,0 +1,34 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +// Copyright (C) 2024 Linus Walleij <linus.walleij@linaro.org>
> +
> +#include <asm/mach/arch.h>
> +#include <asm/mach/map.h>
> +
> +#ifdef CONFIG_DEBUG_BCM6846
> +/* This is needed for LL-debug/earlyprintk/debug-macro.S */
> +static struct map_desc bcm6846_io_desc[] __initdata = {
> +     {
> +             .virtual = CONFIG_DEBUG_UART_VIRT,
> +             .pfn = __phys_to_pfn(CONFIG_DEBUG_UART_PHYS),
> +             .length = SZ_4K,
> +             .type = MT_DEVICE,
> +     },
> +};
> +
> +static void __init bcm6846_map_io(void)
> +{
> +     iotable_init(bcm6846_io_desc, ARRAY_SIZE(bcm6846_io_desc));
> +}
> +#else
> +#define bcm6846_map_io NULL
> +#endif
> +
> +static const char * const bcm6846_dt_compat[] = {
> +     "brcm,bcm6846",
> +     NULL,
> +};
> +
> +DT_MACHINE_START(BCM6846_DT, "BCM6846 Application Processor")
> +     .map_io = bcm6846_map_io,
> +     .dt_compat = bcm6846_dt_compat,
> +MACHINE_END
>
Linus Walleij Sept. 20, 2024, 1:33 p.m. UTC | #2
On Thu, Sep 19, 2024 at 3:26 AM William Zhang
<william.zhang@broadcom.com> wrote:

> >   ifeq ($(CONFIG_ARCH_BCMBCA),y)
> > +obj-y                                += board_bcm6846.o
> >   obj-$(CONFIG_SMP)           += bcm63xx_smp.o bcm63xx_pmb.o
> >   endif
> > diff --git a/arch/arm/mach-bcm/board_bcm6846.c b/arch/arm/mach-bcm/board_bcm6846.c
> > new file mode 100644
> > index 000000000000..7a086c7a1e71
> > --- /dev/null
> > +++ b/arch/arm/mach-bcm/board_bcm6846.c
> This code will be the same for all the bcmbca A7 chips.

Do you mean I should rename the config options to DEBUG_BCMBCA
and match on compatible brcm,bcmbca simply? (I guess yes.)

> And more
> importantly, Broadcom's goal is to use
> multi_v7 common config for all A7 chips without introducing any
> machine or board specific implementation.
> Is it possible this can be done through common code? It looks like the
> only difference is the UART address.

DEBUG_LL can never coexist with multi_v7 or any other multi-config.

To get low-level debugging one always have to make an SoC-specific
build.

We have discussed the issue many times over the years and never
found any good generic solution. (Solutions suggested included even a
binary driver encoded in the device tree...)

The consensus is, that if you're debugging, that should be fine: it would
never be used for a product configuration anyway. That is also why I
have #ifdefs for the specific UART in the code.

I guess if we want to be really picky I can define a new symbol like:

config ARCH_BCMBCA_DEBUG
    depends on ARCH_BCMBCA
    depends on DEBUG_LL

$(CONFIG_ARCH_BCMBCA_DEBUG) = board_bcmbca_debug.o

then this only even get compiled if and only if doing LL-debug.

Yours,
Linus Walleij
William Zhang Sept. 21, 2024, 1:46 a.m. UTC | #3
On Fri, Sep 20, 2024 at 6:33 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> On Thu, Sep 19, 2024 at 3:26 AM William Zhang
> <william.zhang@broadcom.com> wrote:
>
> > >   ifeq ($(CONFIG_ARCH_BCMBCA),y)
> > > +obj-y                                += board_bcm6846.o
> > >   obj-$(CONFIG_SMP)           += bcm63xx_smp.o bcm63xx_pmb.o
> > >   endif
> > > diff --git a/arch/arm/mach-bcm/board_bcm6846.c b/arch/arm/mach-bcm/board_bcm6846.c
> > > new file mode 100644
> > > index 000000000000..7a086c7a1e71
> > > --- /dev/null
> > > +++ b/arch/arm/mach-bcm/board_bcm6846.c
> > This code will be the same for all the bcmbca A7 chips.
>
> Do you mean I should rename the config options to DEBUG_BCMBCA
> and match on compatible brcm,bcmbca simply? (I guess yes.)
>
> > And more
> > importantly, Broadcom's goal is to use
> > multi_v7 common config for all A7 chips without introducing any
> > machine or board specific implementation.
> > Is it possible this can be done through common code? It looks like the
> > only difference is the UART address.
>
> DEBUG_LL can never coexist with multi_v7 or any other multi-config.
>
> To get low-level debugging one always have to make an SoC-specific
> build.
>
> We have discussed the issue many times over the years and never
> found any good generic solution. (Solutions suggested included even a
> binary driver encoded in the device tree...)
>
> The consensus is, that if you're debugging, that should be fine: it would
> never be used for a product configuration anyway. That is also why I
> have #ifdefs for the specific UART in the code.
>
> I guess if we want to be really picky I can define a new symbol like:
>
> config ARCH_BCMBCA_DEBUG
>     depends on ARCH_BCMBCA
>     depends on DEBUG_LL
>
> $(CONFIG_ARCH_BCMBCA_DEBUG) = board_bcmbca_debug.o
>
> then this only even get compiled if and only if doing LL-debug.
>
Yeah I think this is a better approach and only ties this machine specific
setup for low level debug only.  The goal is to use generic arch code
and not to create machine specific code per SoC as much as possible.

> Yours,
> Linus Walleij
diff mbox series

Patch

diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 7f47b4f335c3..86989257b968 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -242,6 +242,10 @@  choice
 		depends on ARCH_BCM_5301X || ARCH_BCM_NSP
 		select DEBUG_UART_8250
 
+	config DEBUG_BCM6846
+		bool "Kernel low-level debugging on BCM6846 UART0"
+		depends on ARCH_BCMBCA
+
 	config DEBUG_BCM_HR2
 		bool "Kernel low-level debugging on Hurricane 2 UART2"
 		depends on ARCH_BCM_HR2
@@ -1526,7 +1530,7 @@  config DEBUG_LL_INCLUDE
 	default "debug/vf.S" if DEBUG_VF_UART
 	default "debug/vt8500.S" if DEBUG_VT8500_UART0
 	default "debug/zynq.S" if DEBUG_ZYNQ_UART0 || DEBUG_ZYNQ_UART1
-	default "debug/bcm63xx.S" if DEBUG_BCM63XX_UART
+	default "debug/bcm63xx.S" if DEBUG_BCM63XX_UART || DEBUG_BCM6846
 	default "debug/digicolor.S" if DEBUG_DIGICOLOR_UA0
 	default "debug/brcmstb.S" if DEBUG_BRCMSTB_UART
 	default "mach/debug-macro.S"
@@ -1640,6 +1644,7 @@  config DEBUG_UART_PHYS
 	default 0xfe531000 if DEBUG_STIH41X_SBC_ASC1
 	default 0xfed32000 if DEBUG_STIH41X_ASC2
 	default 0xff690000 if DEBUG_RK32_UART2
+	default 0xff800640 if DEBUG_BCM6846
 	default 0xffc02000 if DEBUG_SOCFPGA_UART0
 	default 0xffc02100 if DEBUG_SOCFPGA_ARRIA10_UART1
 	default 0xffc03000 if DEBUG_SOCFPGA_CYCLONE5_UART1
@@ -1664,7 +1669,7 @@  config DEBUG_UART_PHYS
 		DEBUG_RMOBILE_SCIFA0 || DEBUG_RMOBILE_SCIFA1 || \
 		DEBUG_RMOBILE_SCIFA4 || \
 		DEBUG_S3C64XX_UART || \
-		DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \
+		DEBUG_BCM63XX_UART || DEBUG_BCM6846 || DEBUG_ASM9260_UART || \
 		DEBUG_DIGICOLOR_UA0 || \
 		DEBUG_AT91_UART || DEBUG_STM32_UART || \
 		DEBUG_STIH41X_ASC2 || DEBUG_STIH41X_SBC_ASC1 || \
@@ -1734,6 +1739,7 @@  config DEBUG_UART_VIRT
 	default 0xfe018000 if DEBUG_MMP_UART3
 	default 0xfe100000 if DEBUG_IMX23_UART || DEBUG_IMX28_UART
 	default 0xfe300000 if DEBUG_BCM_KONA_UART
+	default 0xfe300640 if DEBUG_BCM6846
 	default 0xfeb00000 if DEBUG_HI3620_UART || DEBUG_HIX5HD2_UART
 	default 0xfeb24000 if DEBUG_RK3X_UART0
 	default 0xfeb26000 if DEBUG_RK3X_UART1
@@ -1765,7 +1771,7 @@  config DEBUG_UART_VIRT
 		DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_MESON_UARTAO || \
 		DEBUG_QCOM_UARTDM || \
 		DEBUG_S3C64XX_UART || \
-		DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \
+		DEBUG_BCM63XX_UART || DEBUG_BCM6846 || DEBUG_ASM9260_UART || \
 		DEBUG_DIGICOLOR_UA0 || \
 		DEBUG_AT91_UART || DEBUG_STM32_UART || \
 		DEBUG_STIH41X_ASC2 || DEBUG_STIH41X_SBC_ASC1 || \
diff --git a/arch/arm/mach-bcm/Makefile b/arch/arm/mach-bcm/Makefile
index 2e523f29ec3b..22699a7e18ec 100644
--- a/arch/arm/mach-bcm/Makefile
+++ b/arch/arm/mach-bcm/Makefile
@@ -58,5 +58,6 @@  endif
 
 # BCMBCA
 ifeq ($(CONFIG_ARCH_BCMBCA),y)
+obj-y				+= board_bcm6846.o
 obj-$(CONFIG_SMP)		+= bcm63xx_smp.o bcm63xx_pmb.o
 endif
diff --git a/arch/arm/mach-bcm/board_bcm6846.c b/arch/arm/mach-bcm/board_bcm6846.c
new file mode 100644
index 000000000000..7a086c7a1e71
--- /dev/null
+++ b/arch/arm/mach-bcm/board_bcm6846.c
@@ -0,0 +1,34 @@ 
+// SPDX-License-Identifier: GPL-2.0-only
+// Copyright (C) 2024 Linus Walleij <linus.walleij@linaro.org>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+
+#ifdef CONFIG_DEBUG_BCM6846
+/* This is needed for LL-debug/earlyprintk/debug-macro.S */
+static struct map_desc bcm6846_io_desc[] __initdata = {
+	{
+		.virtual = CONFIG_DEBUG_UART_VIRT,
+		.pfn = __phys_to_pfn(CONFIG_DEBUG_UART_PHYS),
+		.length = SZ_4K,
+		.type = MT_DEVICE,
+	},
+};
+
+static void __init bcm6846_map_io(void)
+{
+	iotable_init(bcm6846_io_desc, ARRAY_SIZE(bcm6846_io_desc));
+}
+#else
+#define bcm6846_map_io NULL
+#endif
+
+static const char * const bcm6846_dt_compat[] = {
+	"brcm,bcm6846",
+	NULL,
+};
+
+DT_MACHINE_START(BCM6846_DT, "BCM6846 Application Processor")
+	.map_io = bcm6846_map_io,
+	.dt_compat = bcm6846_dt_compat,
+MACHINE_END