From 239f424f497dcda32322d3ee990f20d26a5a2f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Wed, 15 Apr 2020 00:59:18 +0200 Subject: [PATCH 1/8] clk: armada-37xx-periph: fix DDR PHY clock divider values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Register value table for DDR PHY clock divider are wrong. They should be 0 or 1 for divide-by-2 or divide-by-4, respectively. Not 1 or 2. Current values do not make sense, since 2 cannot be achieved, because the register is only 1 bit long (mask is set to 1). This fixes clk dump reporting DDR PHY clock rate differently from Linux. Signed-off-by: Marek BehĂșn Reviewed-by: Stefan Roese --- drivers/clk/mvebu/armada-37xx-periph.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/mvebu/armada-37xx-periph.c b/drivers/clk/mvebu/armada-37xx-periph.c index 068e48ea04..855f979b4f 100644 --- a/drivers/clk/mvebu/armada-37xx-periph.c +++ b/drivers/clk/mvebu/armada-37xx-periph.c @@ -89,8 +89,8 @@ static const struct clk_div_table div_table1[] = { }; static const struct clk_div_table div_table2[] = { - { 2, 1 }, - { 4, 2 }, + { 2, 0 }, + { 4, 1 }, { 0, 0 }, }; From 36d61a3d0ae6d5ad0838a5ccb427df12102d02ad Mon Sep 17 00:00:00 2001 From: Joel Johnson Date: Fri, 17 Apr 2020 01:06:53 -0600 Subject: [PATCH 2/8] arm: mvebu: clearfog: adjust SCSI boot duplication Fix duplication resulting from merging of multiple related series. Commits cecf38a75, bd02fd29f, and 201a500de added or adjusted SCSI boot support for ClearFog, but in slightly different locations which didn't result in a merge conflict. Signed-off-by: Joel Johnson Reviewed-by: Stefan Roese --- include/configs/clearfog.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/include/configs/clearfog.h b/include/configs/clearfog.h index 8314956db6..53ff830e81 100644 --- a/include/configs/clearfog.h +++ b/include/configs/clearfog.h @@ -104,12 +104,6 @@ #define BOOT_TARGET_DEVICES_MMC(func) #endif -#ifdef CONFIG_SCSI -#define BOOT_TARGET_DEVICES_SCSI(func) func(SCSI, scsi, 0) -#else -#define BOOT_TARGET_DEVICES_SCSI(func) -#endif - #ifdef CONFIG_USB_STORAGE #define BOOT_TARGET_DEVICES_USB(func) func(USB, usb, 0) #else @@ -152,7 +146,6 @@ */ #define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_DEVICES_MMC(func) \ - BOOT_TARGET_DEVICES_SCSI(func) \ BOOT_TARGET_DEVICES_USB(func) \ BOOT_TARGET_DEVICES_SCSI_BUS0(func) \ BOOT_TARGET_DEVICES_SCSI_BUS1(func) \ From ab2f757eb0513118ac16cab488ea1257ab7d9b83 Mon Sep 17 00:00:00 2001 From: Joel Johnson Date: Fri, 17 Apr 2020 01:19:05 -0600 Subject: [PATCH 3/8] arm: mvebu: correct SPL boot configs for SPI/MMC Update mvebu SPL boot selection mechanism for the move to driver model usage by ensuring that the required driver support for SPI and MMC booting is available in SPL when the respective boot method is selected. Previously, all mvebu boards selected a boot method (implicitly MVEBU_SPL_BOOT_DEVICE_SPI for many) even if SPL booting wasn't used. This changes mvebu boot method selection to depend on SPL usage which resolves the issue with aarch64 boards which don't use SPL getting an implicit boot device selection resulting in unmet dependencies. The 32-bit arm boards do use SPL, but I'm led to conclude that most aren't intentionally using the MVEBU_SPL_BOOT_DEVICE selection since none have SPL_DM_SPI enabled in their defconfig even though they still implicitly select the SPI boot method. This also results in the new addition of SPL_GPIO_SUPPORT to helios4. The mainline dts for helios4 includes the cd-gpios entry for sdhci with identical addresses as the clearfog dts. I don't have a helios4 board to confirm, but based on the current source conclude that the board itself is either wired to pull the signal low for eMMC, or the default MMC boot isn't fully functional in mainline. In either case, as far as I can tell, including the GPIO support will at least cause no regression. Tested on SolidRun ClearFog devices. Signed-off-by: Joel Johnson Reviewed-by: Stefan Roese --- arch/arm/mach-mvebu/Kconfig | 12 ++++++++++++ configs/clearfog_defconfig | 3 --- configs/controlcenterdc_defconfig | 4 ---- configs/db-88f6720_defconfig | 4 ---- configs/db-88f6820-amc_defconfig | 4 ---- configs/db-88f6820-gp_defconfig | 4 ---- configs/db-mv784mp-gp_defconfig | 3 --- configs/ds414_defconfig | 3 --- configs/helios4_defconfig | 1 - configs/maxbcm_defconfig | 3 --- configs/theadorable_debug_defconfig | 3 --- configs/turris_omnia_defconfig | 4 ---- configs/x530_defconfig | 4 ---- include/configs/helios4.h | 5 ----- 14 files changed, 12 insertions(+), 45 deletions(-) diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig index 161dee937f..645990b3ef 100644 --- a/arch/arm/mach-mvebu/Kconfig +++ b/arch/arm/mach-mvebu/Kconfig @@ -232,13 +232,25 @@ config SYS_SOC choice prompt "Boot method" + depends on SPL config MVEBU_SPL_BOOT_DEVICE_SPI bool "SPI NOR flash" + imply ENV_IS_IN_SPI_FLASH + select SPL_DM_SPI + select SPL_SPI_FLASH_SUPPORT + select SPL_SPI_LOAD + select SPL_SPI_SUPPORT config MVEBU_SPL_BOOT_DEVICE_MMC bool "SDIO/MMC card" + imply ENV_IS_IN_MMC + # GPIO needed for eMMC/SD card presence detection + select SPL_DM_GPIO + select SPL_DM_MMC + select SPL_GPIO_SUPPORT select SPL_LIBDISK_SUPPORT + select SPL_MMC_SUPPORT config MVEBU_SPL_BOOT_DEVICE_SATA bool "SATA" diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig index 6db8b8acf6..ada35cb53b 100644 --- a/configs/clearfog_defconfig +++ b/configs/clearfog_defconfig @@ -3,14 +3,12 @@ CONFIG_ARCH_CPU_INIT=y CONFIG_SYS_THUMB_BUILD=y CONFIG_ARCH_MVEBU=y CONFIG_SYS_TEXT_BASE=0x00800000 -CONFIG_SPL_GPIO_SUPPORT=y CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_TARGET_CLEARFOG=y CONFIG_MVEBU_SPL_BOOT_DEVICE_MMC=y CONFIG_DM_GPIO=y -CONFIG_SPL_MMC_SUPPORT=y CONFIG_SPL_SERIAL_SUPPORT=y CONFIG_NR_DRAM_BANKS=2 CONFIG_SPL=y @@ -42,7 +40,6 @@ CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_DEFAULT_DEVICE_TREE="armada-388-clearfog" -CONFIG_ENV_IS_IN_MMC=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_SPL_OF_TRANSLATE=y CONFIG_AHCI_MVEBU=y diff --git a/configs/controlcenterdc_defconfig b/configs/controlcenterdc_defconfig index 51126cbdc3..524dbc2b39 100644 --- a/configs/controlcenterdc_defconfig +++ b/configs/controlcenterdc_defconfig @@ -14,8 +14,6 @@ CONFIG_NR_DRAM_BANKS=2 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xd0012000 CONFIG_DEBUG_UART_CLOCK=250000000 -CONFIG_SPL_SPI_FLASH_SUPPORT=y -CONFIG_SPL_SPI_SUPPORT=y CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_SPL_TEXT_BASE=0x40000030 @@ -28,7 +26,6 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_LAST_STAGE_INIT=y CONFIG_SPL_BOARD_INIT=y CONFIG_SPL_SYS_MALLOC_SIMPLE=y -CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x30000 CONFIG_HUSH_PARSER=y # CONFIG_CMD_ELF is not set @@ -50,7 +47,6 @@ CONFIG_CMD_EXT4=y CONFIG_EFI_PARTITION=y CONFIG_OF_BOARD_FIXUP=y CONFIG_DEFAULT_DEVICE_TREE="armada-38x-controlcenterdc" -CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_USE_ENV_SPI_MAX_HZ=y CONFIG_ENV_SPI_MAX_HZ=50000000 CONFIG_SYS_RELOC_GD_ENV_ADDR=y diff --git a/configs/db-88f6720_defconfig b/configs/db-88f6720_defconfig index 42c427b792..068f76bbe4 100644 --- a/configs/db-88f6720_defconfig +++ b/configs/db-88f6720_defconfig @@ -14,8 +14,6 @@ CONFIG_NR_DRAM_BANKS=2 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xf1012000 CONFIG_DEBUG_UART_CLOCK=250000000 -CONFIG_SPL_SPI_FLASH_SUPPORT=y -CONFIG_SPL_SPI_SUPPORT=y CONFIG_DEBUG_UART=y CONFIG_SPL_TEXT_BASE=0x40004030 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set @@ -25,7 +23,6 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_I2C_SUPPORT=y -CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x20000 CONFIG_CMD_I2C=y CONFIG_CMD_SPI=y @@ -43,7 +40,6 @@ CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y # CONFIG_DOS_PARTITION is not set CONFIG_DEFAULT_DEVICE_TREE="armada-375-db" -CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_USE_ENV_SPI_MAX_HZ=y CONFIG_ENV_SPI_MAX_HZ=50000000 CONFIG_SYS_RELOC_GD_ENV_ADDR=y diff --git a/configs/db-88f6820-amc_defconfig b/configs/db-88f6820-amc_defconfig index 5bf9eb66ad..e231ca4673 100644 --- a/configs/db-88f6820-amc_defconfig +++ b/configs/db-88f6820-amc_defconfig @@ -14,8 +14,6 @@ CONFIG_NR_DRAM_BANKS=2 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xd0012000 CONFIG_DEBUG_UART_CLOCK=200000000 -CONFIG_SPL_SPI_FLASH_SUPPORT=y -CONFIG_SPL_SPI_SUPPORT=y CONFIG_DEBUG_UART=y CONFIG_SPL_TEXT_BASE=0x40000030 CONFIG_FIT=y @@ -26,7 +24,6 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_I2C_SUPPORT=y -CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x24000 # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y @@ -48,7 +45,6 @@ CONFIG_EFI_PARTITION=y # CONFIG_PARTITION_UUIDS is not set # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_DEFAULT_DEVICE_TREE="armada-385-db-88f6820-amc" -CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_USE_ENV_SPI_MAX_HZ=y CONFIG_ENV_SPI_MAX_HZ=50000000 CONFIG_SYS_RELOC_GD_ENV_ADDR=y diff --git a/configs/db-88f6820-gp_defconfig b/configs/db-88f6820-gp_defconfig index 7e3ee5ec1c..c866131025 100644 --- a/configs/db-88f6820-gp_defconfig +++ b/configs/db-88f6820-gp_defconfig @@ -14,8 +14,6 @@ CONFIG_NR_DRAM_BANKS=2 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xd0012000 CONFIG_DEBUG_UART_CLOCK=250000000 -CONFIG_SPL_SPI_FLASH_SUPPORT=y -CONFIG_SPL_SPI_SUPPORT=y CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_SPL_TEXT_BASE=0x40000030 @@ -26,7 +24,6 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y CONFIG_SPL_I2C_SUPPORT=y -CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x24000 CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y @@ -48,7 +45,6 @@ CONFIG_EFI_PARTITION=y # CONFIG_PARTITION_UUIDS is not set # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_DEFAULT_DEVICE_TREE="armada-388-gp" -CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_USE_ENV_SPI_MAX_HZ=y CONFIG_ENV_SPI_MAX_HZ=50000000 CONFIG_SYS_RELOC_GD_ENV_ADDR=y diff --git a/configs/db-mv784mp-gp_defconfig b/configs/db-mv784mp-gp_defconfig index d3a0d0020a..012149a860 100644 --- a/configs/db-mv784mp-gp_defconfig +++ b/configs/db-mv784mp-gp_defconfig @@ -14,8 +14,6 @@ CONFIG_NR_DRAM_BANKS=2 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xd0012000 CONFIG_DEBUG_UART_CLOCK=250000000 -CONFIG_SPL_SPI_FLASH_SUPPORT=y -CONFIG_SPL_SPI_SUPPORT=y CONFIG_DEBUG_UART=y CONFIG_SPL_TEXT_BASE=0x40004030 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set @@ -25,7 +23,6 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_I2C_SUPPORT=y -CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x20000 # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y diff --git a/configs/ds414_defconfig b/configs/ds414_defconfig index 435c896e41..01a3909c8c 100644 --- a/configs/ds414_defconfig +++ b/configs/ds414_defconfig @@ -14,8 +14,6 @@ CONFIG_NR_DRAM_BANKS=2 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xd0012000 CONFIG_DEBUG_UART_CLOCK=250000000 -CONFIG_SPL_SPI_FLASH_SUPPORT=y -CONFIG_SPL_SPI_SUPPORT=y CONFIG_DEBUG_UART=y CONFIG_SPL_TEXT_BASE=0x40004030 CONFIG_BOOTDELAY=3 @@ -26,7 +24,6 @@ CONFIG_PREBOOT="usb start; sf probe" # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_I2C_SUPPORT=y -CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x24000 # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y diff --git a/configs/helios4_defconfig b/configs/helios4_defconfig index 1b8d130ebc..0fe8559507 100644 --- a/configs/helios4_defconfig +++ b/configs/helios4_defconfig @@ -38,7 +38,6 @@ CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_DEFAULT_DEVICE_TREE="armada-388-helios4" -CONFIG_ENV_IS_IN_MMC=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_SPL_OF_TRANSLATE=y CONFIG_SCSI_AHCI=y diff --git a/configs/maxbcm_defconfig b/configs/maxbcm_defconfig index 60a87edac0..9cc9d66393 100644 --- a/configs/maxbcm_defconfig +++ b/configs/maxbcm_defconfig @@ -14,8 +14,6 @@ CONFIG_NR_DRAM_BANKS=2 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xd0012000 CONFIG_DEBUG_UART_CLOCK=250000000 -CONFIG_SPL_SPI_FLASH_SUPPORT=y -CONFIG_SPL_SPI_SUPPORT=y CONFIG_DEBUG_UART=y CONFIG_SPL_TEXT_BASE=0x40004030 CONFIG_BOOTDELAY=3 @@ -24,7 +22,6 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_I2C_SUPPORT=y -CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x20000 CONFIG_CMD_I2C=y CONFIG_CMD_SPI=y diff --git a/configs/theadorable_debug_defconfig b/configs/theadorable_debug_defconfig index fb12e841cb..616c07ab54 100644 --- a/configs/theadorable_debug_defconfig +++ b/configs/theadorable_debug_defconfig @@ -15,8 +15,6 @@ CONFIG_NR_DRAM_BANKS=2 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xd0012000 CONFIG_DEBUG_UART_CLOCK=250000000 -CONFIG_SPL_SPI_FLASH_SUPPORT=y -CONFIG_SPL_SPI_SUPPORT=y CONFIG_DEBUG_UART=y CONFIG_SPL_TEXT_BASE=0x40004030 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set @@ -28,7 +26,6 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_I2C_SUPPORT=y -CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x1a000 CONFIG_HUSH_PARSER=y CONFIG_CMD_BOOTZ=y diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig index f3ed9917d5..29c49686e2 100644 --- a/configs/turris_omnia_defconfig +++ b/configs/turris_omnia_defconfig @@ -17,8 +17,6 @@ CONFIG_NR_DRAM_BANKS=2 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xd0012000 CONFIG_DEBUG_UART_CLOCK=250000000 -CONFIG_SPL_SPI_FLASH_SUPPORT=y -CONFIG_SPL_SPI_SUPPORT=y CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_SPL_TEXT_BASE=0x40000030 @@ -32,7 +30,6 @@ CONFIG_MISC_INIT_R=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_I2C_SUPPORT=y -CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x24000 CONFIG_CMD_MEMTEST=y CONFIG_SYS_ALT_MEMTEST=y @@ -53,7 +50,6 @@ CONFIG_CMD_HASH=y CONFIG_CMD_BTRFS=y # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_DEFAULT_DEVICE_TREE="armada-385-turris-omnia" -CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_USE_ENV_SPI_MAX_HZ=y CONFIG_ENV_SPI_MAX_HZ=50000000 CONFIG_SYS_RELOC_GD_ENV_ADDR=y diff --git a/configs/x530_defconfig b/configs/x530_defconfig index a15b0b46b4..c49211df95 100644 --- a/configs/x530_defconfig +++ b/configs/x530_defconfig @@ -15,8 +15,6 @@ CONFIG_NR_DRAM_BANKS=2 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0xd0012000 CONFIG_DEBUG_UART_CLOCK=250000000 -CONFIG_SPL_SPI_FLASH_SUPPORT=y -CONFIG_SPL_SPI_SUPPORT=y CONFIG_DEBUG_UART=y CONFIG_SPL_TEXT_BASE=0x40000030 CONFIG_FIT=y @@ -26,7 +24,6 @@ CONFIG_SILENT_U_BOOT_ONLY=y CONFIG_SILENT_CONSOLE_UPDATE_ON_RELOC=y CONFIG_MISC_INIT_R=y CONFIG_SPL_BOARD_INIT=y -CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x24000 CONFIG_SPL_WATCHDOG_SUPPORT=y CONFIG_CMD_MEMINFO=y @@ -47,7 +44,6 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_DEFAULT_DEVICE_TREE="armada-385-atl-x530" -CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_ENV_ADDR=0x100000 CONFIG_SPL_OF_TRANSLATE=y CONFIG_BLK=y diff --git a/include/configs/helios4.h b/include/configs/helios4.h index 5a4c9ae066..af595bc7bc 100644 --- a/include/configs/helios4.h +++ b/include/configs/helios4.h @@ -93,16 +93,11 @@ #define CONFIG_SPL_BOOTROM_SAVE (CONFIG_SPL_STACK + 4) #if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SPI_NOR_FLASH -/* SPL related SPI defines */ -#define CONFIG_SPL_SPI_FLASH_SUPPORT -#define CONFIG_SPL_SPI_LOAD -#define CONFIG_SPL_SPI_SUPPORT #define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_SPI_U_BOOT_OFFS #endif #if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SDIO_MMC_CARD /* SPL related MMC defines */ -#define CONFIG_SPL_MMC_SUPPORT #define CONFIG_SYS_MMC_U_BOOT_OFFS (160 << 10) #define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_MMC_U_BOOT_OFFS #ifdef CONFIG_SPL_BUILD From 8ec6db7813fbde251c786777b522b5e11dbf5c6b Mon Sep 17 00:00:00 2001 From: Joel Johnson Date: Fri, 17 Apr 2020 09:38:04 -0600 Subject: [PATCH 4/8] cmd: mvebu: bubt: add A38x support Add support for Armada 38x devices in bubt flashing utility. This is based on (and streamlined from) the support in the SolidRun master-a38x vendor fork. Signed-off-by: Joel Johnson Reviewed-by: Stefan Roese --- cmd/mvebu/bubt.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index 2041a7a29a..d399fb6da4 100644 --- a/cmd/mvebu/bubt.c +++ b/cmd/mvebu/bubt.c @@ -85,7 +85,29 @@ struct mvebu_image_info { u32 encrypt_start_offset; u32 encrypt_size; }; -#endif /* CONFIG_ARMADA_XXX */ +#elif defined(CONFIG_ARMADA_38X) /* A38X */ + +/* Structure of the main header, version 1 (Armada 370/38x/XP) */ +struct a38x_main_hdr_v1 { + u8 blockid; /* 0x0 */ + u8 flags; /* 0x1 */ + u16 reserved2; /* 0x2-0x3 */ + u32 blocksize; /* 0x4-0x7 */ + u8 version; /* 0x8 */ + u8 headersz_msb; /* 0x9 */ + u16 headersz_lsb; /* 0xA-0xB */ + u32 srcaddr; /* 0xC-0xF */ + u32 destaddr; /* 0x10-0x13 */ + u32 execaddr; /* 0x14-0x17 */ + u8 options; /* 0x18 */ + u8 nandblocksize; /* 0x19 */ + u8 nandbadblklocation; /* 0x1A */ + u8 reserved4; /* 0x1B */ + u16 reserved5; /* 0x1C-0x1D */ + u8 ext; /* 0x1E */ + u8 checksum; /* 0x1F */ +}; +#endif struct bubt_dev { char name[8]; @@ -621,7 +643,52 @@ static int check_image_header(void) return 0; } +#elif defined(CONFIG_ARMADA_38X) +static size_t a38x_header_size(const struct a38x_main_hdr_v1 *h) +{ + if (h->version == 1) + return (h->headersz_msb << 16) | le16_to_cpu(h->headersz_lsb); + printf("Error: Invalid A38x image (header version 0x%x unknown)!\n", + h->version); + return 0; +} + +static uint8_t image_checksum8(const void *start, size_t len) +{ + u8 csum = 0; + const u8 *p = start; + + while (len) { + csum += *p; + ++p; + --len; + } + + return csum; +} + +static int check_image_header(void) +{ + u8 checksum; + const struct a38x_main_hdr_v1 *hdr = + (struct a38x_main_hdr_v1 *)get_load_addr(); + const size_t image_size = a38x_header_size(hdr); + + if (!image_size) + return -ENOEXEC; + + checksum = image_checksum8(hdr, image_size); + checksum -= hdr->checksum; + if (checksum != hdr->checksum) { + printf("Error: Bad A38x image checksum. 0x%x != 0x%x\n", + checksum, hdr->checksum); + return -ENOEXEC; + } + + printf("Image checksum...OK!\n"); + return 0; +} #else /* Not ARMADA? */ static int check_image_header(void) { From f41b85ee6a4d5bc469f008e0efb266eb3f54f3d7 Mon Sep 17 00:00:00 2001 From: Joel Johnson Date: Fri, 17 Apr 2020 09:38:05 -0600 Subject: [PATCH 5/8] cmd: mvebu: bubt: correct U-Boot spelling Replace "U-BOOT" text with correct spelling Signed-off-by: Joel Johnson Reviewed-by: Stefan Roese --- cmd/mvebu/bubt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index d399fb6da4..b80b81c82a 100644 --- a/cmd/mvebu/bubt.c +++ b/cmd/mvebu/bubt.c @@ -346,7 +346,7 @@ static int nand_burn_image(size_t image_size) /* Align U-Boot size to currently used blocksize */ image_size = ((image_size + (block_size - 1)) & (~(block_size - 1))); - /* Erase the U-BOOT image space */ + /* Erase the U-Boot image space */ printf("Erasing 0x%x - 0x%x:...", 0, (int)image_size); ret = nand_erase(mtd, 0, image_size); if (ret) { @@ -734,7 +734,7 @@ static int bubt_read_file(struct bubt_dev *src) static int bubt_is_dev_active(struct bubt_dev *dev) { if (!dev->active) { - printf("Device \"%s\" not supported by U-BOOT image\n", + printf("Device \"%s\" not supported by U-Boot image\n", dev->name); return 0; } @@ -822,7 +822,7 @@ int do_bubt_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (!bubt_is_dev_active(src)) return -ENODEV; - printf("Burning U-BOOT image \"%s\" from \"%s\" to \"%s\"\n", + printf("Burning U-Boot image \"%s\" from \"%s\" to \"%s\"\n", net_boot_file_name, src->name, dst->name); image_size = bubt_read_file(src); From 658854a626b56d3ff417453ac842e4486ba5139b Mon Sep 17 00:00:00 2001 From: Joel Johnson Date: Fri, 17 Apr 2020 09:38:06 -0600 Subject: [PATCH 6/8] cmd: mvebu: bubt: verify A38x target device type Ensure that the device to which an image is being written includes header information indicating boot support for the destination device. This is derived from the support in the SolidRun master-a38x vendor fork. Signed-off-by: Joel Johnson Reviewed-by: Stefan Roese --- cmd/mvebu/bubt.c | 52 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index b80b81c82a..be6c5869a9 100644 --- a/cmd/mvebu/bubt.c +++ b/cmd/mvebu/bubt.c @@ -85,7 +85,7 @@ struct mvebu_image_info { u32 encrypt_start_offset; u32 encrypt_size; }; -#elif defined(CONFIG_ARMADA_38X) /* A38X */ +#endif /* Structure of the main header, version 1 (Armada 370/38x/XP) */ struct a38x_main_hdr_v1 { @@ -107,7 +107,23 @@ struct a38x_main_hdr_v1 { u8 ext; /* 0x1E */ u8 checksum; /* 0x1F */ }; -#endif + +struct a38x_boot_mode { + unsigned int id; + const char *name; +}; + +/* The blockid header field values used to indicate boot device of image */ +struct a38x_boot_mode a38x_boot_modes[] = { + { 0x4D, "i2c" }, + { 0x5A, "spi" }, + { 0x69, "uart" }, + { 0x78, "sata" }, + { 0x8B, "nand" }, + { 0x9C, "pex" }, + { 0xAE, "mmc" }, + {}, +}; struct bubt_dev { char name[8]; @@ -697,7 +713,29 @@ static int check_image_header(void) } #endif -static int bubt_verify(size_t image_size) +static int bubt_check_boot_mode(const struct bubt_dev *dst) +{ + if (IS_ENABLED(CONFIG_ARMADA_38X)) { + int mode; + const struct a38x_main_hdr_v1 *hdr = + (struct a38x_main_hdr_v1 *)get_load_addr(); + + for (mode = 0; mode < ARRAY_SIZE(a38x_boot_modes); mode++) { + if (strcmp(a38x_boot_modes[mode].name, dst->name) == 0) + break; + } + + if (a38x_boot_modes[mode].id == hdr->blockid) + return 0; + + puts("Error: A38x image not built for destination device!\n"); + return -ENOEXEC; + } else { + return 0; + } +} + +static int bubt_verify(const struct bubt_dev *dst) { int err; @@ -708,6 +746,12 @@ static int bubt_verify(size_t image_size) return err; } + err = bubt_check_boot_mode(dst); + if (err) { + printf("Error: Image boot mode verification failed\n"); + return err; + } + return 0; } @@ -829,7 +873,7 @@ int do_bubt_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (!image_size) return -EIO; - err = bubt_verify(image_size); + err = bubt_verify(dst); if (err) return err; From 549ba7b440cf22dd196a20816b09c44d1f2b77e4 Mon Sep 17 00:00:00 2001 From: Joel Johnson Date: Fri, 17 Apr 2020 09:38:07 -0600 Subject: [PATCH 7/8] arm: mvebu: clearfog: enable bubt command With support added for Armada 38x, include the bubt command in ClearFog defconfig. Signed-off-by: Joel Johnson Reviewed-by: Stefan Roese --- configs/clearfog_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig index ada35cb53b..1566a4ff82 100644 --- a/configs/clearfog_defconfig +++ b/configs/clearfog_defconfig @@ -31,6 +31,7 @@ CONFIG_SPL_CMD_TLV_EEPROM=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y +CONFIG_CMD_MVEBU_BUBT=y CONFIG_CMD_PCI=y CONFIG_CMD_SPI=y CONFIG_CMD_USB=y From f60a66ef5d7da1980f180cd1cbfd2ce01157e522 Mon Sep 17 00:00:00 2001 From: Joel Johnson Date: Fri, 17 Apr 2020 09:38:08 -0600 Subject: [PATCH 8/8] cmd: mvebu: bubt: show image boot device When a mismatch is found trying to write an image for one boot method to a different boot device, print an error message including the image header marked target boot device type. Signed-off-by: Joel Johnson Reviewed-by: Stefan Roese --- cmd/mvebu/bubt.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index be6c5869a9..dc0ce01c35 100644 --- a/cmd/mvebu/bubt.c +++ b/cmd/mvebu/bubt.c @@ -728,7 +728,17 @@ static int bubt_check_boot_mode(const struct bubt_dev *dst) if (a38x_boot_modes[mode].id == hdr->blockid) return 0; - puts("Error: A38x image not built for destination device!\n"); + for (int i = 0; i < ARRAY_SIZE(a38x_boot_modes); i++) { + if (a38x_boot_modes[i].id == hdr->blockid) { + printf("Error: A38x image meant to be " + "booted from \"%s\", not \"%s\"!\n", + a38x_boot_modes[i].name, dst->name); + return -ENOEXEC; + } + } + + printf("Error: unknown boot device in A38x image header: " + "0x%x\n", hdr->blockid); return -ENOEXEC; } else { return 0;