[U-Boot] [PATCH 0/6] arm64: versal: Misc patches

Hi, I am sending some patches in series to make sure that they are applied in the proper order. They can be applied an reviewed independently.
Thanks, Michal
Michal Simek (3): arm64: versal: Disable showing information about console arm64: versal: Remove one level of indentation in board_early_init_r() arm64: versal: Move IOU_SWITCH_DIVISOR0 to Kconfig
Siva Durga Prasad Paladugu (3): arm64: versal: Define distro boot commnads for qspi ospi and mmc arm64: versal: Define board_late_init for versal arm64: versal: Add mini configuration for Versal
arch/arm/Kconfig | 1 + arch/arm/dts/Makefile | 1 + arch/arm/dts/versal-mini.dts | 36 ++++++ arch/arm/mach-versal/Kconfig | 6 + arch/arm/mach-versal/include/mach/hardware.h | 23 ++++ board/xilinx/versal/board.c | 169 ++++++++++++++++++++++----- configs/xilinx_versal_mini_defconfig | 53 +++++++++ configs/xilinx_versal_mini_emmc0_defconfig | 2 + configs/xilinx_versal_mini_emmc1_defconfig | 2 + include/configs/xilinx_versal.h | 26 ++++- 10 files changed, 291 insertions(+), 28 deletions(-) create mode 100644 arch/arm/dts/versal-mini.dts create mode 100644 configs/xilinx_versal_mini_defconfig

There is no need to see this info. It is just wasting of space/time. It saves 308Bytes.
Signed-off-by: Michal Simek michal.simek@xilinx.com ---
configs/xilinx_versal_mini_emmc0_defconfig | 1 + configs/xilinx_versal_mini_emmc1_defconfig | 1 + 2 files changed, 2 insertions(+)
diff --git a/configs/xilinx_versal_mini_emmc0_defconfig b/configs/xilinx_versal_mini_emmc0_defconfig index 412bf945a45d..d647d6839bcc 100644 --- a/configs/xilinx_versal_mini_emmc0_defconfig +++ b/configs/xilinx_versal_mini_emmc0_defconfig @@ -6,6 +6,7 @@ CONFIG_ENV_SIZE=0x80 CONFIG_SYS_MALLOC_LEN=0x80000 CONFIG_COUNTER_FREQUENCY=2720000 CONFIG_NR_DRAM_BANKS=1 +CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_CPUINFO is not set CONFIG_BOARD_EARLY_INIT_R=y # CONFIG_CMDLINE_EDITING is not set diff --git a/configs/xilinx_versal_mini_emmc1_defconfig b/configs/xilinx_versal_mini_emmc1_defconfig index b8960db858d4..4a8331123598 100644 --- a/configs/xilinx_versal_mini_emmc1_defconfig +++ b/configs/xilinx_versal_mini_emmc1_defconfig @@ -6,6 +6,7 @@ CONFIG_ENV_SIZE=0x80 CONFIG_SYS_MALLOC_LEN=0x80000 CONFIG_COUNTER_FREQUENCY=2720000 CONFIG_NR_DRAM_BANKS=1 +CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_CPUINFO is not set CONFIG_BOARD_EARLY_INIT_R=y # CONFIG_CMDLINE_EDITING is not set

From: Siva Durga Prasad Paladugu siva.durga.paladugu@xilinx.com
This patch adds distro boot commands for qspi, ospi and mmc. The distro boot commands now reads the script from flash offset of 63.5MB for qspi and ospi and executes it. For mmc its same as generic distro boot command. As either one of the qspi or ospi can exist on hardware, defined a single distroboot command as xspi that works for both.
Setup default location via script_offset_f to 63.5MB to match the most xilinx reference boards for qspi, ospi for now. 512kB allocated space for script size (script_size_f) should be more than enough to cover custom boot logic.
Signed-off-by: Siva Durga Prasad Paladugu siva.durga.paladugu@xilinx.com Signed-off-by: Michal Simek michal.simek@xilinx.com ---
include/configs/xilinx_versal.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/include/configs/xilinx_versal.h b/include/configs/xilinx_versal.h index bfe4c43449ac..2cc36e793b61 100644 --- a/include/configs/xilinx_versal.h +++ b/include/configs/xilinx_versal.h @@ -73,9 +73,33 @@ "pxefile_addr_r=0x10000000\0" \ "kernel_addr_r=0x18000000\0" \ "scriptaddr=0x02000000\0" \ - "ramdisk_addr_r=0x02100000\0" + "ramdisk_addr_r=0x02100000\0" \ + "script_offset_f=0x3f80000\0" \ + "script_size_f=0x80000\0" + +#if defined(CONFIG_MMC_SDHCI_ZYNQ) +# define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0) func(MMC, mmc, 1) +#else +# define BOOT_TARGET_DEVICES_MMC(func) +#endif + +#if defined(CONFIG_ZYNQMP_GQSPI) || defined(CONFIG_CADENCE_OSPI_VERSAL) +# define BOOT_TARGET_DEVICES_XSPI(func) func(XSPI, xspi, 0) +#else +# define BOOT_TARGET_DEVICES_XSPI(func) +#endif + +#define BOOTENV_DEV_XSPI(devtypeu, devtypel, instance) \ + "bootcmd_xspi0=sf probe 0 0 0 && " \ + "sf read $scriptaddr $script_offset_f $script_size_f && " \ + "source ${scriptaddr}; echo SCRIPT FAILED: continuing...;\0" + +#define BOOTENV_DEV_NAME_XSPI(devtypeu, devtypel, instance) \ + "xspi "
#define BOOT_TARGET_DEVICES(func) \ + BOOT_TARGET_DEVICES_MMC(func) \ + BOOT_TARGET_DEVICES_XSPI(func) \ func(PXE, pxe, na) \ func(DHCP, dhcp, na)

From: Siva Durga Prasad Paladugu siva.durga.paladugu@xilinx.com
Define board_late_init which performs bootmode detection and prepares corresponding distro boot commaand sequence.
Signed-off-by: Siva Durga Prasad Paladugu siva.durga.paladugu@xilinx.com Signed-off-by: Michal Simek michal.simek@xilinx.com ---
arch/arm/Kconfig | 1 + arch/arm/mach-versal/include/mach/hardware.h | 23 ++++++ board/xilinx/versal/board.c | 111 +++++++++++++++++++++++++++ configs/xilinx_versal_mini_emmc0_defconfig | 1 + configs/xilinx_versal_mini_emmc1_defconfig | 1 + 5 files changed, 137 insertions(+)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index f0edb10003ba..bc0a5b4fe9a3 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -892,6 +892,7 @@ config ARCH_VERSAL select DM_MMC if MMC select DM_SERIAL select OF_CONTROL + imply BOARD_LATE_INIT
config ARCH_VF610 bool "Freescale Vybrid" diff --git a/arch/arm/mach-versal/include/mach/hardware.h b/arch/arm/mach-versal/include/mach/hardware.h index 23fbc3d8f536..e26beab2e9cd 100644 --- a/arch/arm/mach-versal/include/mach/hardware.h +++ b/arch/arm/mach-versal/include/mach/hardware.h @@ -51,3 +51,26 @@ struct rpu_regs { };
#define rpu_base ((struct rpu_regs *)VERSAL_RPU_BASEADDR) + +#define VERSAL_CRP_BASEADDR 0xF1260000 + +struct crp_regs { + u32 reserved0[128]; + u32 boot_mode_usr; +}; + +#define crp_base ((struct crp_regs *)VERSAL_CRP_BASEADDR) + +/* Bootmode setting values */ +#define BOOT_MODES_MASK 0x0000000F +#define QSPI_MODE_24BIT 0x00000001 +#define QSPI_MODE_32BIT 0x00000002 +#define SD_MODE 0x00000003 /* sd 0 */ +#define SD_MODE1 0x00000005 /* sd 1 */ +#define EMMC_MODE 0x00000006 +#define USB_MODE 0x00000007 +#define OSPI_MODE 0x00000008 +#define SD1_LSHFT_MODE 0x0000000E /* SD1 Level shifter */ +#define JTAG_MODE 0x00000000 +#define BOOT_MODE_USE_ALT 0x100 +#define BOOT_MODE_ALT_SHIFT 12 diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c index 2b3a40b73a5f..fd6c8d8cb737 100644 --- a/board/xilinx/versal/board.c +++ b/board/xilinx/versal/board.c @@ -9,6 +9,8 @@ #include <malloc.h> #include <asm/io.h> #include <asm/arch/hardware.h> +#include <dm/device.h> +#include <dm/uclass.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -61,6 +63,115 @@ int board_early_init_r(void) return 0; }
+int board_late_init(void) +{ + u32 reg = 0; + u8 bootmode; + struct udevice *dev; + int bootseq = -1; + int bootseq_len = 0; + int env_targets_len = 0; + const char *mode; + char *new_targets; + char *env_targets; + + if (!(gd->flags & GD_FLG_ENV_DEFAULT)) { + debug("Saved variables - Skipping\n"); + return 0; + } + + reg = readl(&crp_base->boot_mode_usr); + + if (reg >> BOOT_MODE_ALT_SHIFT) + reg >>= BOOT_MODE_ALT_SHIFT; + + bootmode = reg & BOOT_MODES_MASK; + + puts("Bootmode: "); + switch (bootmode) { + case JTAG_MODE: + puts("JTAG_MODE\n"); + mode = "pxe dhcp"; + break; + case QSPI_MODE_24BIT: + puts("QSPI_MODE_24\n"); + mode = "xspi0"; + break; + case QSPI_MODE_32BIT: + puts("QSPI_MODE_32\n"); + mode = "xspi0"; + break; + case OSPI_MODE: + puts("OSPI_MODE\n"); + mode = "xspi0"; + break; + case EMMC_MODE: + puts("EMMC_MODE\n"); + mode = "mmc0"; + break; + case SD_MODE: + puts("SD_MODE\n"); + if (uclass_get_device_by_name(UCLASS_MMC, + "sdhci@f1040000", &dev)) { + puts("Boot from SD0 but without SD0 enabled!\n"); + return -1; + } + debug("mmc0 device found at %p, seq %d\n", dev, dev->seq); + + mode = "mmc"; + bootseq = dev->seq; + break; + case SD1_LSHFT_MODE: + puts("LVL_SHFT_"); + /* fall through */ + case SD_MODE1: + puts("SD_MODE1\n"); + if (uclass_get_device_by_name(UCLASS_MMC, + "sdhci@f1050000", &dev)) { + puts("Boot from SD1 but without SD1 enabled!\n"); + return -1; + } + debug("mmc1 device found at %p, seq %d\n", dev, dev->seq); + + mode = "mmc"; + bootseq = dev->seq; + break; + default: + mode = ""; + printf("Invalid Boot Mode:0x%x\n", bootmode); + break; + } + + if (bootseq >= 0) { + bootseq_len = snprintf(NULL, 0, "%i", bootseq); + debug("Bootseq len: %x\n", bootseq_len); + } + + /* + * One terminating char + one byte for space between mode + * and default boot_targets + */ + env_targets = env_get("boot_targets"); + if (env_targets) + env_targets_len = strlen(env_targets); + + new_targets = calloc(1, strlen(mode) + env_targets_len + 2 + + bootseq_len); + if (!new_targets) + return -ENOMEM; + + if (bootseq >= 0) + sprintf(new_targets, "%s%x %s", mode, bootseq, + env_targets ? env_targets : ""); + else + sprintf(new_targets, "%s %s", mode, + env_targets ? env_targets : ""); + + env_set("boot_targets", new_targets); + + return 0; +} + int dram_init_banksize(void) { fdtdec_setup_memory_banksize(); diff --git a/configs/xilinx_versal_mini_emmc0_defconfig b/configs/xilinx_versal_mini_emmc0_defconfig index d647d6839bcc..3af399cf5ad1 100644 --- a/configs/xilinx_versal_mini_emmc0_defconfig +++ b/configs/xilinx_versal_mini_emmc0_defconfig @@ -7,6 +7,7 @@ CONFIG_SYS_MALLOC_LEN=0x80000 CONFIG_COUNTER_FREQUENCY=2720000 CONFIG_NR_DRAM_BANKS=1 CONFIG_SYS_CONSOLE_INFO_QUIET=y +# CONFIG_BOARD_LATE_INIT is not set # CONFIG_DISPLAY_CPUINFO is not set CONFIG_BOARD_EARLY_INIT_R=y # CONFIG_CMDLINE_EDITING is not set diff --git a/configs/xilinx_versal_mini_emmc1_defconfig b/configs/xilinx_versal_mini_emmc1_defconfig index 4a8331123598..e2ffa294d040 100644 --- a/configs/xilinx_versal_mini_emmc1_defconfig +++ b/configs/xilinx_versal_mini_emmc1_defconfig @@ -7,6 +7,7 @@ CONFIG_SYS_MALLOC_LEN=0x80000 CONFIG_COUNTER_FREQUENCY=2720000 CONFIG_NR_DRAM_BANKS=1 CONFIG_SYS_CONSOLE_INFO_QUIET=y +# CONFIG_BOARD_LATE_INIT is not set # CONFIG_DISPLAY_CPUINFO is not set CONFIG_BOARD_EARLY_INIT_R=y # CONFIG_CMDLINE_EDITING is not set

Simplify code indentation.
Signed-off-by: Michal Simek michal.simek@xilinx.com ---
board/xilinx/versal/board.c | 57 +++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 28 deletions(-)
diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c index fd6c8d8cb737..b49a4f473a72 100644 --- a/board/xilinx/versal/board.c +++ b/board/xilinx/versal/board.c @@ -23,42 +23,43 @@ int board_init(void)
int board_early_init_r(void) { - if (current_el() == 3) { - u32 val; + u32 val;
- writel(IOU_SWITCH_CTRL_CLKACT_BIT | - (0x20 << IOU_SWITCH_CTRL_DIVISOR0_SHIFT), - &crlapb_base->iou_switch_ctrl); + if (current_el() != 3) + return 0;
- /* Global timer init - Program time stamp reference clk */ - val = readl(&crlapb_base->timestamp_ref_ctrl); - val |= CRL_APB_TIMESTAMP_REF_CTRL_CLKACT_BIT; - writel(val, &crlapb_base->timestamp_ref_ctrl); + writel(IOU_SWITCH_CTRL_CLKACT_BIT | + (0x20 << IOU_SWITCH_CTRL_DIVISOR0_SHIFT), + &crlapb_base->iou_switch_ctrl);
- debug("ref ctrl 0x%x\n", - readl(&crlapb_base->timestamp_ref_ctrl)); + /* Global timer init - Program time stamp reference clk */ + val = readl(&crlapb_base->timestamp_ref_ctrl); + val |= CRL_APB_TIMESTAMP_REF_CTRL_CLKACT_BIT; + writel(val, &crlapb_base->timestamp_ref_ctrl);
- /* Clear reset of timestamp reg */ - writel(0, &crlapb_base->rst_timestamp); + debug("ref ctrl 0x%x\n", + readl(&crlapb_base->timestamp_ref_ctrl));
- /* - * Program freq register in System counter and - * enable system counter. - */ - writel(COUNTER_FREQUENCY, - &iou_scntr_secure->base_frequency_id_register); + /* Clear reset of timestamp reg */ + writel(0, &crlapb_base->rst_timestamp);
- debug("counter val 0x%x\n", - readl(&iou_scntr_secure->base_frequency_id_register)); + /* + * Program freq register in System counter and + * enable system counter. + */ + writel(COUNTER_FREQUENCY, + &iou_scntr_secure->base_frequency_id_register);
- writel(IOU_SCNTRS_CONTROL_EN, - &iou_scntr_secure->counter_control_register); + debug("counter val 0x%x\n", + readl(&iou_scntr_secure->base_frequency_id_register));
- debug("scntrs control 0x%x\n", - readl(&iou_scntr_secure->counter_control_register)); - debug("timer 0x%llx\n", get_ticks()); - debug("timer 0x%llx\n", get_ticks()); - } + writel(IOU_SCNTRS_CONTROL_EN, + &iou_scntr_secure->counter_control_register); + + debug("scntrs control 0x%x\n", + readl(&iou_scntr_secure->counter_control_register)); + debug("timer 0x%llx\n", get_ticks()); + debug("timer 0x%llx\n", get_ticks());
return 0; }

Move hardcoded IOU_SWITCH_DIVISOR0 to Kconfig to be able to set it up for different platforms.
Signed-off-by: Michal Simek michal.simek@xilinx.com ---
arch/arm/mach-versal/Kconfig | 6 ++++++ board/xilinx/versal/board.c | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-versal/Kconfig b/arch/arm/mach-versal/Kconfig index f291800bc971..26d175637101 100644 --- a/arch/arm/mach-versal/Kconfig +++ b/arch/arm/mach-versal/Kconfig @@ -41,6 +41,12 @@ config VERSAL_OF_BOARD_DTB_ADDR default 0x1000 depends on OF_BOARD
+config IOU_SWITCH_DIVISOR0 + hex "IOU switch divisor0" + default 0x20 + help + Setup time clock divisor for input clock. + config SYS_MEM_RSVD_FOR_MMU bool "Reserve memory for MMU Table" help diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c index b49a4f473a72..b5ddd0c5ad24 100644 --- a/board/xilinx/versal/board.c +++ b/board/xilinx/versal/board.c @@ -28,8 +28,11 @@ int board_early_init_r(void) if (current_el() != 3) return 0;
+ debug("iou_switch ctrl div0 %x\n", + readl(&crlapb_base->iou_switch_ctrl)); + writel(IOU_SWITCH_CTRL_CLKACT_BIT | - (0x20 << IOU_SWITCH_CTRL_DIVISOR0_SHIFT), + (CONFIG_IOU_SWITCH_DIVISOR0 << IOU_SWITCH_CTRL_DIVISOR0_SHIFT), &crlapb_base->iou_switch_ctrl);
/* Global timer init - Program time stamp reference clk */

From: Siva Durga Prasad Paladugu siva.durga.paladugu@xilinx.com
This patch adds new mini target for versal. This configuration is very minimal in size which runs from OCM. It contains support for mtest which can be used for running DDR memory tests.
Signed-off-by: Siva Durga Prasad Paladugu siva.durga.paladugu@xilinx.com Signed-off-by: Michal Simek michal.simek@xilinx.com ---
arch/arm/dts/Makefile | 1 + arch/arm/dts/versal-mini.dts | 36 ++++++++++++++++++++++++ configs/xilinx_versal_mini_defconfig | 53 ++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 arch/arm/dts/versal-mini.dts create mode 100644 configs/xilinx_versal_mini_defconfig
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 4d8bb32d1cef..a8a0d0615dc6 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -186,6 +186,7 @@ dtb-$(CONFIG_ARCH_ZYNQMP) += \ zynqmp-zc1751-xm018-dc4.dtb \ zynqmp-zc1751-xm019-dc5.dtb dtb-$(CONFIG_ARCH_VERSAL) += \ + versal-mini.dtb \ versal-mini-emmc0.dtb \ versal-mini-emmc1.dtb dtb-$(CONFIG_ARCH_ZYNQMP_R5) += \ diff --git a/arch/arm/dts/versal-mini.dts b/arch/arm/dts/versal-mini.dts new file mode 100644 index 000000000000..6a83981cc2a4 --- /dev/null +++ b/arch/arm/dts/versal-mini.dts @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * dts file for Xilinx Versal Mini Configuration + * + * (C) Copyright 2019, Xilinx, Inc. + * + * Siva Durga Prasad Paladugu siva.durga.paladugu@xilinx.com + */ + +/dts-v1/; + +/ { + model = "Versal MINI"; + compatible = "xlnx,versal"; + #address-cells = <2>; + #size-cells = <2>; + + aliases { + serial0 = &dcc; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + memory@0 { + device_type = "memory"; + reg = <0x0 0xfffc0000 0x0 0x40000>, <0x0 0x0 0x0 0x80000000>; + }; + + dcc: dcc { + compatible = "arm,dcc"; + status = "okay"; + u-boot,dm-pre-reloc; + }; +}; diff --git a/configs/xilinx_versal_mini_defconfig b/configs/xilinx_versal_mini_defconfig new file mode 100644 index 000000000000..d6cd8cd50e12 --- /dev/null +++ b/configs/xilinx_versal_mini_defconfig @@ -0,0 +1,53 @@ +CONFIG_ARM=y +CONFIG_SYS_CONFIG_NAME="xilinx_versal_mini_qspi" +CONFIG_ARCH_VERSAL=y +CONFIG_SYS_TEXT_BASE=0xFFFC0000 +CONFIG_ENV_SIZE=0x80 +CONFIG_SYS_MALLOC_LEN=0x2000 +CONFIG_SYS_MEM_RSVD_FOR_MMU=y +CONFIG_COUNTER_FREQUENCY=2720000 +CONFIG_NR_DRAM_BANKS=1 +# CONFIG_IMAGE_FORMAT_LEGACY is not set +CONFIG_SYS_CONSOLE_INFO_QUIET=y +# CONFIG_BOARD_LATE_INIT is not set +# CONFIG_DISPLAY_CPUINFO is not set +CONFIG_BOARD_EARLY_INIT_R=y +# CONFIG_CMDLINE_EDITING is not set +# CONFIG_AUTO_COMPLETE is not set +# CONFIG_SYS_LONGHELP is not set +CONFIG_SYS_PROMPT="Versal> " +# CONFIG_AUTOBOOT is not set +# CONFIG_CMD_BDI is not set +# CONFIG_CMD_CONSOLE is not set +# CONFIG_CMD_BOOTD is not set +# CONFIG_CMD_BOOTM is not set +# CONFIG_CMD_BOOTI is not set +# CONFIG_CMD_ELF is not set +# CONFIG_CMD_FDT is not set +# CONFIG_CMD_GO is not set +# CONFIG_CMD_RUN is not set +# CONFIG_CMD_IMI is not set +# CONFIG_CMD_XIMG is not set +# CONFIG_CMD_EXPORTENV is not set +# CONFIG_CMD_IMPORTENV is not set +# CONFIG_CMD_EDITENV is not set +# CONFIG_CMD_SAVEENV is not set +# CONFIG_CMD_ENV_EXISTS is not set +# CONFIG_CMD_CRC32 is not set +CONFIG_CMD_MEMTEST=y +CONFIG_SYS_ALT_MEMTEST=y +# CONFIG_CMD_FLASH is not set +# CONFIG_CMD_LOADB is not set +# CONFIG_CMD_LOADS is not set +# CONFIG_CMD_ECHO is not set +# CONFIG_CMD_ITEST is not set +# CONFIG_CMD_SOURCE is not set +# CONFIG_CMD_SETEXPR is not set +# CONFIG_CMD_MISC is not set +# CONFIG_PARTITIONS is not set +CONFIG_DEFAULT_DEVICE_TREE="versal-mini" +# CONFIG_NET is not set +# CONFIG_DM_WARN is not set +# CONFIG_DM_DEVICE_REMOVE is not set +# CONFIG_MMC is not set +# CONFIG_EFI_LOADER is not set
participants (1)
-
Michal Simek