[PATCH 0/5] board: sl28: enable DM_SERIAL and lpuart support

Enable DM_SERIAL for this board. For this to work, we first need to make DM_SERIAL work on LS1028A SoCs, which just means we have to properly call spl_early_init(). After this, clean up the board config by moving the CONFIG_DM_* macros to Kconfig. Now we can switch to DM_SERIAL. As the last patch, provide a configuration option to switch the output to the first serial line on this board, which is not possible because we can enable LPUART support (which needs DM_SERIAL).
Please note, the first patch is not really required but helps a lot in debugging early startup on Layerscape SoCs.
Michael Walle (5): armv8: fsl-layerscape: spl: add debug UART support armv8: fsl-layerscape: spl: call spl_early_init() board: sl28: move DM_* configs to Kconfig board: sl28: enable DM_SERIAL board: sl28: add config to enable console output on SER0
arch/arm/Kconfig | 20 +++++++++++++++++++ arch/arm/cpu/armv8/fsl-layerscape/spl.c | 11 ++++++++++ .../dts/fsl-ls1028a-kontron-sl28-u-boot.dtsi | 12 +++++++++++ board/kontron/sl28/Kconfig | 10 ++++++++++ board/kontron/sl28/Makefile | 2 +- board/kontron/sl28/common.c | 11 ++++++++++ configs/kontron_sl28_defconfig | 17 ---------------- include/configs/kontron_sl28.h | 2 -- 8 files changed, 65 insertions(+), 20 deletions(-) create mode 100644 board/kontron/sl28/common.c

To use the debug UART we have to call debug_uart_init() in the SPL. Do so as soon as possible.
As an example, here is how you can use it on a LS1028A SoC: CONFIG_DEBUG_UART=y CONFIG_DEBUG_UART_BASE=0x21c0500 CONFIG_DEBUG_UART_CLOCK=200000000
Signed-off-by: Michael Walle michael@walle.cc --- arch/arm/cpu/armv8/fsl-layerscape/spl.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/spl.c b/arch/arm/cpu/armv8/fsl-layerscape/spl.c index d5131bcf4b..888c02f6c5 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/spl.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/spl.c @@ -6,6 +6,7 @@ #include <common.h> #include <clock_legacy.h> #include <cpu_func.h> +#include <debug_uart.h> #include <env.h> #include <image.h> #include <init.h> @@ -70,6 +71,8 @@ void board_init_f(ulong dummy) icache_enable(); /* Clear global data */ memset((void *)gd, 0, sizeof(gd_t)); + if (IS_ENABLED(CONFIG_DEBUG_UART)) + debug_uart_init(); board_early_init_f(); timer_init(); #ifdef CONFIG_ARCH_LS2080A

DM_SERIAL needs both the device tree as well as an early heap. Thus, we have to call spl_early_init() to initialize the memory allocator and the setup the device tree.
Signed-off-by: Michael Walle michael@walle.cc --- arch/arm/cpu/armv8/fsl-layerscape/spl.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/spl.c b/arch/arm/cpu/armv8/fsl-layerscape/spl.c index 888c02f6c5..01dd6a30e8 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/spl.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/spl.c @@ -8,6 +8,7 @@ #include <cpu_func.h> #include <debug_uart.h> #include <env.h> +#include <hang.h> #include <image.h> #include <init.h> #include <log.h> @@ -68,12 +69,19 @@ void spl_board_init(void)
void board_init_f(ulong dummy) { + int ret; + icache_enable(); /* Clear global data */ memset((void *)gd, 0, sizeof(gd_t)); if (IS_ENABLED(CONFIG_DEBUG_UART)) debug_uart_init(); board_early_init_f(); + ret = spl_early_init(); + if (ret) { + debug("spl_early_init() failed: %d\n", ret); + hang(); + } timer_init(); #ifdef CONFIG_ARCH_LS2080A env_init();

Move the CONFIG_DM_* from the defconfig to the TARGET_SL28 config.
Signed-off-by: Michael Walle michael@walle.cc --- arch/arm/Kconfig | 19 +++++++++++++++++++ configs/kontron_sl28_defconfig | 17 ----------------- 2 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 3307f2b3fc..d72c2520d1 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1624,6 +1624,25 @@ config TARGET_SL28 select ARMV8_MULTIENTRY select SUPPORT_SPL select BINMAN + select DM + select DM_GPIO + select DM_I2C + select DM_MMC + select DM_SPI_FLASH + select DM_ETH + select DM_MDIO + select DM_PCI + select DM_RNG + select DM_RTC + select DM_SCSI + select DM_SPI + select DM_USB + select SPL_DM if SPL + select SPL_DM_SPI if SPL + select SPL_DM_SPI_FLASH if SPL + select SPL_DM_I2C if SPL + select SPL_DM_MMC if SPL + select SPL_DM_SERIAL if SPL help Support for Kontron SMARC-sAL28 board.
diff --git a/configs/kontron_sl28_defconfig b/configs/kontron_sl28_defconfig index 1c781e091c..98718db5c2 100644 --- a/configs/kontron_sl28_defconfig +++ b/configs/kontron_sl28_defconfig @@ -8,8 +8,6 @@ CONFIG_ENV_SIZE=0x2000 CONFIG_ENV_OFFSET=0x3e0000 CONFIG_ENV_SECT_SIZE=0x10000 CONFIG_SYS_SPI_U_BOOT_OFFS=0x230000 -CONFIG_DM_GPIO=y -CONFIG_SPL_DM_SPI=y CONFIG_SPL_TEXT_BASE=0x18010000 CONFIG_SYS_FSL_SDHC_CLK_DIV=1 CONFIG_SPL_SERIAL_SUPPORT=y @@ -35,7 +33,6 @@ CONFIG_PCI_INIT_R=y CONFIG_SPL_BOARD_INIT=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y -CONFIG_SPL_DM_SPI_FLASH=y CONFIG_SPL_SPI_LOAD=y CONFIG_CMD_ASKENV=y CONFIG_CMD_GREPENV=y @@ -58,52 +55,38 @@ CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_SYS_REDUNDAND_ENVIRONMENT=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_NETCONSOLE=y -CONFIG_DM=y -CONFIG_SPL_DM=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_SCSI_AHCI=y CONFIG_SATA_CEVA=y CONFIG_FSL_CAAM=y CONFIG_SYS_FSL_DDR3=y -CONFIG_DM_I2C=y CONFIG_I2C_SET_DEFAULT_BUS_NUM=y CONFIG_I2C_DEFAULT_BUS_NUMBER=0 CONFIG_I2C_MUX=y -CONFIG_DM_MMC=y CONFIG_MMC_HS400_SUPPORT=y CONFIG_FSL_ESDHC=y CONFIG_FSL_ESDHC_SUPPORT_ADMA2=y -CONFIG_DM_SPI_FLASH=y # CONFIG_SPI_FLASH_UNLOCK_ALL is not set CONFIG_SPI_FLASH_WINBOND=y # CONFIG_SPI_FLASH_USE_4K_SECTORS is not set CONFIG_PHYLIB=y CONFIG_PHY_ATHEROS=y CONFIG_PHY_FIXED=y -CONFIG_DM_ETH=y -CONFIG_DM_MDIO=y CONFIG_DM_DSA=y CONFIG_PHY_GIGE=y CONFIG_E1000=y CONFIG_MSCC_FELIX_SWITCH=y CONFIG_NVME=y CONFIG_PCI=y -CONFIG_DM_PCI=y -CONFIG_DM_PCI_COMPAT=y CONFIG_PCIE_ECAM_GENERIC=y CONFIG_PCIE_LAYERSCAPE_RC=y -CONFIG_DM_RNG=y -CONFIG_DM_RTC=y CONFIG_RTC_RV8803=y CONFIG_SCSI=y -CONFIG_DM_SCSI=y CONFIG_SYS_NS16550=y CONFIG_SPI=y -CONFIG_DM_SPI=y CONFIG_FSL_DSPI=y CONFIG_NXP_FSPI=y CONFIG_USB=y -CONFIG_DM_USB=y # CONFIG_SPL_DM_USB is not set CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y

With all preparations in place, switch over to DM_SERIAL.
Signed-off-by: Michael Walle michael@walle.cc --- arch/arm/Kconfig | 1 + include/configs/kontron_sl28.h | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index d72c2520d1..2ee4f10e39 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1635,6 +1635,7 @@ config TARGET_SL28 select DM_RNG select DM_RTC select DM_SCSI + select DM_SERIAL select DM_SPI select DM_USB select SPL_DM if SPL diff --git a/include/configs/kontron_sl28.h b/include/configs/kontron_sl28.h index 5d818a708d..5f11205802 100644 --- a/include/configs/kontron_sl28.h +++ b/include/configs/kontron_sl28.h @@ -49,8 +49,6 @@ #define CONFIG_MALLOC_F_ADDR CONFIG_SYS_FSL_OCRAM_BASE
/* serial port */ -#define CONFIG_SYS_NS16550_SERIAL -#define CONFIG_SYS_NS16550_REG_SIZE 1 #define CONFIG_SYS_NS16550_CLK (get_bus_freq(0) / 2) #define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }

Sometimes it is desireable to have the console output on the first serial line. Introduce a configuration option for it (in the board scope).
Signed-off-by: Michael Walle michael@walle.cc --- arch/arm/dts/fsl-ls1028a-kontron-sl28-u-boot.dtsi | 12 ++++++++++++ board/kontron/sl28/Kconfig | 10 ++++++++++ board/kontron/sl28/Makefile | 2 +- board/kontron/sl28/common.c | 11 +++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 board/kontron/sl28/common.c
diff --git a/arch/arm/dts/fsl-ls1028a-kontron-sl28-u-boot.dtsi b/arch/arm/dts/fsl-ls1028a-kontron-sl28-u-boot.dtsi index 240178ab4e..b3861ed98c 100644 --- a/arch/arm/dts/fsl-ls1028a-kontron-sl28-u-boot.dtsi +++ b/arch/arm/dts/fsl-ls1028a-kontron-sl28-u-boot.dtsi @@ -133,6 +133,14 @@ }; };
+#ifdef CONFIG_SL28_ENABLE_SER0_CONSOLE +/ { + chosen { + stdout-path = "serial2:115200n8"; + }; +}; +#endif + #ifdef CONFIG_SL28_SPL_LOADS_ATF_BL31 &binman { fit { @@ -250,6 +258,10 @@ u-boot,dm-pre-reloc; };
+&lpuart1 { + u-boot,dm-pre-reloc; +}; + &serial0 { u-boot,dm-pre-reloc; }; diff --git a/board/kontron/sl28/Kconfig b/board/kontron/sl28/Kconfig index 4078ef186b..abcacc3185 100644 --- a/board/kontron/sl28/Kconfig +++ b/board/kontron/sl28/Kconfig @@ -48,4 +48,14 @@ config SL28_BL32_ENTRY_ADDR
endif
+config SL28_ENABLE_SER0_CONSOLE + bool "Enable console output on SER0" + select DM_SERIAL + select SPL_DM_SERIAL + select FSL_LPUART + help + By default the console output of this board is on the second serial + line (SER1). Sometimes it is desirable to enable output on the first + serial line (SER0). For example, if you have a carrier which only + supports the first serial port. endif diff --git a/board/kontron/sl28/Makefile b/board/kontron/sl28/Makefile index 147ef9872b..5d220f0744 100644 --- a/board/kontron/sl28/Makefile +++ b/board/kontron/sl28/Makefile @@ -4,7 +4,7 @@ ifndef CONFIG_SPL_BUILD obj-y += sl28.o cmds.o endif
-obj-y += ddr.o +obj-y += common.o ddr.o
ifdef CONFIG_SPL_BUILD obj-y += spl.o diff --git a/board/kontron/sl28/common.c b/board/kontron/sl28/common.c new file mode 100644 index 0000000000..33c6843c3f --- /dev/null +++ b/board/kontron/sl28/common.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <common.h> +#include <asm/global_data.h> + +DECLARE_GLOBAL_DATA_PTR; + +u32 get_lpuart_clk(void) +{ + return gd->bus_clk / CONFIG_SYS_FSL_LPUART_CLK_DIV; +}
participants (1)
-
Michael Walle