From a83149509131b3c5cd1811f953cf96c213308eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Thu, 8 Jul 2021 20:18:58 +0200 Subject: [PATCH 1/9] arm: a37xx: pci: Extend validation for PCIe resources and oubound windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remapped address of PCIe outbound window may have set only bits from the mask. Add additional check that remapped address which is calculated from PCIe bus address specified in DTS file is valid. Remove also useless clearing of low 16 bits in win_mask. As win_size is power of two and is at least 0x10000 it means that it always has zero low 16 bits. Signed-off-by: Pali Rohár Reviewed-by: Konstantin Porotchkin Reviewed-by: Stefan Roese --- drivers/pci/pci-aardvark.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/pci/pci-aardvark.c b/drivers/pci/pci-aardvark.c index 96aa039bdc..77ce9d0c8d 100644 --- a/drivers/pci/pci-aardvark.c +++ b/drivers/pci/pci-aardvark.c @@ -609,21 +609,22 @@ static void pcie_advk_set_ob_region(struct pcie_advk *pcie, int *wins, * match with given mask. * So every PCIe window size must be a power of two and every start * address must be aligned to window size. Minimal size is 64 KiB - * because lower 16 bits of mask must be zero. + * because lower 16 bits of mask must be zero. Remapped address + * may have set only bits from the mask. */ while (*wins < OB_WIN_COUNT && size > 0) { /* Calculate the largest aligned window size */ win_size = (1ULL << (fls64(size) - 1)) | (phys_start ? (1ULL << __ffs64(phys_start)) : 0); win_size = 1ULL << __ffs64(win_size); - if (win_size < 0x10000) + win_mask = ~(win_size - 1); + if (win_size < 0x10000 || (bus_start & ~win_mask)) break; dev_dbg(pcie->dev, "Configuring PCIe window %d: [0x%llx-0x%llx] as 0x%x\n", *wins, (u64)phys_start, (u64)phys_start + win_size, actions); - win_mask = ~(win_size - 1) & ~0xffff; pcie_advk_set_ob_win(pcie, *wins, phys_start, bus_start, win_mask, actions); From cbd7ef70bc6523474cca6480364c6248a8e5b5d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Thu, 8 Jul 2021 20:18:59 +0200 Subject: [PATCH 2/9] arm: a37xx: pci: Optimize a3700_fdt_fix_pcie_regions() when fixup offset is zero MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If fixup offset is zero then there is nothing to fix. All calculation in this case just increase addresses by value zero which results in identity. So in this case skip whole fixup re-calculation as it is not needed. This is just an optimization for special case when fix_offset is zero which skips code path which does only identity operations (meaning nothing). No functional changes. Signed-off-by: Pali Rohár Reviewed-by: Konstantin Porotchkin Reviewed-by: Stefan Roese --- arch/arm/mach-mvebu/armada3700/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/mach-mvebu/armada3700/cpu.c b/arch/arm/mach-mvebu/armada3700/cpu.c index 9aec0ce9a4..7702028ba1 100644 --- a/arch/arm/mach-mvebu/armada3700/cpu.c +++ b/arch/arm/mach-mvebu/armada3700/cpu.c @@ -331,6 +331,10 @@ int a3700_fdt_fix_pcie_regions(void *blob) /* Calculate fixup offset from first child address (in last cell) */ fix_offset = base - fdt32_to_cpu(ranges[2]); + /* If fixup offset is zero then there is nothing to fix */ + if (!fix_offset) + return 0; + /* * Fix address (last cell) of each child address and each parent * address From 960d45979a3c35e6161af2583f737612fb38b43b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Thu, 8 Jul 2021 20:19:00 +0200 Subject: [PATCH 3/9] arm: a37xx: pci: Fix typo in comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pali Rohár Reviewed-by: Konstantin Porotchkin Reviewed-by: Stefan Roese --- drivers/pci/pci-aardvark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci-aardvark.c b/drivers/pci/pci-aardvark.c index 77ce9d0c8d..1b9bae7cca 100644 --- a/drivers/pci/pci-aardvark.c +++ b/drivers/pci/pci-aardvark.c @@ -605,7 +605,7 @@ static void pcie_advk_set_ob_region(struct pcie_advk *pcie, int *wins, /* * The n-th PCIe window is configured by tuple (match, remap, mask) - * and an access to address A uses this window it if A matches the + * and an access to address A uses this window if A matches the * match with given mask. * So every PCIe window size must be a power of two and every start * address must be aligned to window size. Minimal size is 64 KiB From 4494ca84318be0b4995ddee98f8a85ab5fa74466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Fri, 9 Jul 2021 16:56:13 +0200 Subject: [PATCH 4/9] arm: mvebu: turris_omnia: force 40 MHz speed on SPI NOR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit e2e95e5e2542 ("spi: Update speed/mode on change") changed the boot time on Turris Omnia from ~2.3s to over 8s, due to SPL loading main U-Boot from SPI NOR at 1 MHz instead of 40 MHz. This is because the SPL code passes the CONFIG_SF_DEFAULT_SPEED option to spi_flash_probe(), and with the above commit spi_flash_probe() starts prefering this parameter instead of the one specified in device-tree. The proper solution here would probably be to fix the SF subsystem to prefer the frequency specified in the device-tree, if it is present, but I am not sure what else will be affected on other boards with such a change. So until then we need a more simple fix. Since the CONFIG_SF_DEFAULT_SPEED option is used by the code, put the correct value there for Turris Omnia. Also put the correct value to CONFIG_SF_DEFAULT_MODE and use 40 MHz when reading environment. Signed-off-by: Marek Behún Cc: Stefan Roese Cc: Tom Rini Cc: Marek Vasut Cc: Jagan Teki Cc: Patrick Delaunay Cc: Pali Rohár Reviewed-by: Stefan Roese --- configs/turris_omnia_defconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig index 57ab384f63..ec2294699f 100644 --- a/configs/turris_omnia_defconfig +++ b/configs/turris_omnia_defconfig @@ -56,7 +56,7 @@ CONFIG_CMD_FS_UUID=y # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_ENV_OVERWRITE=y CONFIG_USE_ENV_SPI_MAX_HZ=y -CONFIG_ENV_SPI_MAX_HZ=50000000 +CONFIG_ENV_SPI_MAX_HZ=40000000 CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_SPL_OF_TRANSLATE=y CONFIG_AHCI_PCI=y @@ -67,6 +67,8 @@ CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_MV=y CONFIG_SPI_FLASH_MACRONIX=y CONFIG_SPI_FLASH_SPANSION=y +CONFIG_SF_DEFAULT_MODE=0x0 +CONFIG_SF_DEFAULT_SPEED=40000000 CONFIG_PHY_MARVELL=y CONFIG_PHY_GIGE=y CONFIG_MVNETA=y From 4d4cbd9d4edaafc3398f1c6de9f17b5514ef1478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Fri, 9 Jul 2021 16:56:14 +0200 Subject: [PATCH 5/9] arm: mvebu: turris_{omnia, mox}: enable MTD command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that the MTD subsystem properly supports OF partitions of a SPI NOR, we can enable the MTD command and start using it instead of the deprecated sf command. Signed-off-by: Marek Behún Cc: Stefan Roese Cc: Pali Rohár Reviewed-by: Stefan Roese --- configs/turris_mox_defconfig | 3 +++ configs/turris_omnia_defconfig | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig index 2c6f4938db..34127dc3e6 100644 --- a/configs/turris_mox_defconfig +++ b/configs/turris_mox_defconfig @@ -31,6 +31,7 @@ CONFIG_CMD_CLK=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y +CONFIG_CMD_MTD=y CONFIG_CMD_PCI=y CONFIG_CMD_SPI=y CONFIG_CMD_USB=y @@ -60,12 +61,14 @@ CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_SDMA=y CONFIG_MMC_SDHCI_XENON=y CONFIG_MTD=y +CONFIG_DM_MTD=y CONFIG_SF_DEFAULT_MODE=0 CONFIG_SF_DEFAULT_SPEED=20000000 CONFIG_SPI_FLASH_MACRONIX=y CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y +CONFIG_SPI_FLASH_MTD=y CONFIG_PHY_MARVELL=y CONFIG_PHY_GIGE=y CONFIG_MVNETA=y diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig index ec2294699f..f860cf5e7d 100644 --- a/configs/turris_omnia_defconfig +++ b/configs/turris_omnia_defconfig @@ -41,6 +41,7 @@ CONFIG_CMD_LZMADEC=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y +CONFIG_CMD_MTD=y CONFIG_CMD_PCI=y CONFIG_CMD_SATA=y CONFIG_CMD_SPI=y @@ -65,8 +66,11 @@ CONFIG_AHCI_MVEBU=y CONFIG_DM_PCA953X=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_MV=y +CONFIG_MTD=y +CONFIG_DM_MTD=y CONFIG_SPI_FLASH_MACRONIX=y CONFIG_SPI_FLASH_SPANSION=y +CONFIG_SPI_FLASH_MTD=y CONFIG_SF_DEFAULT_MODE=0x0 CONFIG_SF_DEFAULT_SPEED=40000000 CONFIG_PHY_MARVELL=y From 4a8ad5849b3c22d657450070a716501de2bf630f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Fri, 9 Jul 2021 17:40:59 +0200 Subject: [PATCH 6/9] arm: mvebu: armada-3720: remove unused config option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The config option CONFIG_DEBUG_UART_CLOCK is not used by Armada 3720's serial driver (it wasn't even before the recent update of that driver). Even if it was used, the value was incorrect (the frequency of the clock is 25 MHz, not 25.8048 MHz). Remove it from config files and set the default value to 0. Signed-off-by: Marek Behún Cc: Stefan Roese Cc: Pali Rohár Reviewed-by: Pali Rohár Reviewed-by: Stefan Roese --- configs/mvebu_db-88f3720_defconfig | 1 - configs/mvebu_espressobin-88f3720_defconfig | 1 - configs/turris_mox_defconfig | 1 - configs/uDPU_defconfig | 1 - drivers/serial/Kconfig | 1 + 5 files changed, 1 insertion(+), 4 deletions(-) diff --git a/configs/mvebu_db-88f3720_defconfig b/configs/mvebu_db-88f3720_defconfig index c9935da102..ff4668e837 100644 --- a/configs/mvebu_db-88f3720_defconfig +++ b/configs/mvebu_db-88f3720_defconfig @@ -11,7 +11,6 @@ CONFIG_ENV_SECT_SIZE=0x10000 CONFIG_DM_GPIO=y CONFIG_DEFAULT_DEVICE_TREE="armada-3720-db" CONFIG_DEBUG_UART_BASE=0xd0012000 -CONFIG_DEBUG_UART_CLOCK=25804800 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y diff --git a/configs/mvebu_espressobin-88f3720_defconfig b/configs/mvebu_espressobin-88f3720_defconfig index 157a4b7cb2..dc199cfe50 100644 --- a/configs/mvebu_espressobin-88f3720_defconfig +++ b/configs/mvebu_espressobin-88f3720_defconfig @@ -11,7 +11,6 @@ CONFIG_ENV_SECT_SIZE=0x10000 CONFIG_DM_GPIO=y CONFIG_DEFAULT_DEVICE_TREE="armada-3720-espressobin" CONFIG_DEBUG_UART_BASE=0xd0012000 -CONFIG_DEBUG_UART_CLOCK=25804800 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig index 34127dc3e6..fd5b6f351e 100644 --- a/configs/turris_mox_defconfig +++ b/configs/turris_mox_defconfig @@ -11,7 +11,6 @@ CONFIG_ENV_SECT_SIZE=0x10000 CONFIG_DM_GPIO=y CONFIG_DEFAULT_DEVICE_TREE="armada-3720-turris-mox" CONFIG_DEBUG_UART_BASE=0xd0012000 -CONFIG_DEBUG_UART_CLOCK=25804800 CONFIG_DEBUG_UART=y CONFIG_OF_BOARD_FIXUP=y CONFIG_DISTRO_DEFAULTS=y diff --git a/configs/uDPU_defconfig b/configs/uDPU_defconfig index cdf6b2274c..649248d74d 100644 --- a/configs/uDPU_defconfig +++ b/configs/uDPU_defconfig @@ -10,7 +10,6 @@ CONFIG_ENV_SECT_SIZE=0x10000 CONFIG_DM_GPIO=y CONFIG_DEFAULT_DEVICE_TREE="armada-3720-uDPU" CONFIG_DEBUG_UART_BASE=0xd0012000 -CONFIG_DEBUG_UART_CLOCK=25804800 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 961e3fb031..93348c0929 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -443,6 +443,7 @@ config DEBUG_UART_CLOCK int "UART input clock" depends on DEBUG_UART default 0 if DEBUG_UART_SANDBOX + default 0 if DEBUG_MVEBU_A3700_UART help The UART input clock determines the speed of the internal UART circuitry. The baud rate is derived from this by dividing the input From aeff1740b6f4896b13e9c300e60078ebd488f37b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Wed, 14 Jul 2021 16:37:27 +0200 Subject: [PATCH 7/9] arm: mvebu: Espressobin: Fix setting $fdtfile env MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensure that 'env default -a' always set correct value to $fdtfile, even when custom user variable is already stored in non-volatile env storage (means that env_get("fdtfile") call returns non-NULL value). As default value is now correctly set like if specified at compile time in CONFIG_EXTRA_ENV_SETTINGS, there is no need to set $fdtfile explicitly via env_set("fdtfile", ...) call. So remove wrong skip based on env_get("fdtfile") and then also unneeded env_set("fdtfile", ...) call. Fixes: c4df0f6f315c ("arm: mvebu: Espressobin: Set default value for $fdtfile env variable") Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese --- board/Marvell/mvebu_armada-37xx/board.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c index c630437c08..5ff940cb35 100644 --- a/board/Marvell/mvebu_armada-37xx/board.c +++ b/board/Marvell/mvebu_armada-37xx/board.c @@ -133,9 +133,6 @@ int board_late_init(void) device_unbind(dev); } - if (env_get("fdtfile")) - return 0; - /* Ensure that 'env default -a' set correct value to $fdtfile */ if (ddr4 && emmc) strcpy(ptr, "fdtfile=marvell/armada-3720-espressobin-v7-emmc.dtb"); @@ -146,10 +143,6 @@ int board_late_init(void) else strcpy(ptr, "fdtfile=marvell/armada-3720-espressobin.dtb"); - /* If $fdtfile was not set explicitly by user then set default value */ - if (!env_get("fdtfile")) - env_set("fdtfile", ptr + sizeof("fdtfile=")); - return 0; } #endif From 42ba56691ccae5a33da13a023a342fef4fa8f086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Wed, 14 Jul 2021 16:37:28 +0200 Subject: [PATCH 8/9] arm: mvebu: Espressobin: Use function mmc_get_op_cond() for detecting eMMC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use function mmc_get_op_cond() instead of mmc_init() for detecting presence of eMMC. Documentation for this function says that it could be used to detect the presence of SD/eMMC when no card detect logic is available. This function is also used by mx6cuboxi board for detecting presence of eMMC. Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese --- board/Marvell/mvebu_armada-37xx/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c index 5ff940cb35..5af3f2f062 100644 --- a/board/Marvell/mvebu_armada-37xx/board.c +++ b/board/Marvell/mvebu_armada-37xx/board.c @@ -124,7 +124,7 @@ int board_late_init(void) /* eMMC is mmc dev num 1 */ mmc_dev = find_mmc_device(1); - emmc = (mmc_dev && mmc_init(mmc_dev) == 0); + emmc = (mmc_dev && mmc_get_op_cond(mmc_dev) == 0); /* if eMMC is not present then remove it from DM */ if (!emmc && mmc_dev) { From a4c577f981569bf34e997cd85618f922409d6b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Wed, 14 Jul 2021 16:37:29 +0200 Subject: [PATCH 9/9] mmc: mmc_get_op_cond: Allow quiet detection of eMMC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new 'quiet' argument to mmc_get_op_cond() function which avoids printing error message when SD/eMMC card is not detected. Espressobin and mx6cuboxi boards use this function for detecting presence of eMMC and therefore it is expected and normal that eMMC does not have to be connected. So error message "Card did not respond to voltage select!" should be skipped in this case as it is not an error. Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese Acked-by: Jaehoon Chung --- board/Marvell/mvebu_armada-37xx/board.c | 2 +- board/solidrun/mx6cuboxi/mx6cuboxi.c | 2 +- drivers/mmc/mmc.c | 7 ++++--- include/mmc.h | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c index 5af3f2f062..2de9c2ac17 100644 --- a/board/Marvell/mvebu_armada-37xx/board.c +++ b/board/Marvell/mvebu_armada-37xx/board.c @@ -124,7 +124,7 @@ int board_late_init(void) /* eMMC is mmc dev num 1 */ mmc_dev = find_mmc_device(1); - emmc = (mmc_dev && mmc_get_op_cond(mmc_dev) == 0); + emmc = (mmc_dev && mmc_get_op_cond(mmc_dev, true) == 0); /* if eMMC is not present then remove it from DM */ if (!emmc && mmc_dev) { diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c index 3eadc38f6f..6207bf8253 100644 --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c @@ -374,7 +374,7 @@ static bool has_emmc(void) mmc = find_mmc_device(2); if (!mmc) return 0; - return (mmc_get_op_cond(mmc) < 0) ? 0 : 1; + return (mmc_get_op_cond(mmc, true) < 0) ? 0 : 1; } int checkboard(void) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 1e83007286..8078a89f18 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -2766,7 +2766,7 @@ static int mmc_power_cycle(struct mmc *mmc) return mmc_power_on(mmc); } -int mmc_get_op_cond(struct mmc *mmc) +int mmc_get_op_cond(struct mmc *mmc, bool quiet) { bool uhs_en = supports_uhs(mmc->cfg->host_caps); int err; @@ -2842,7 +2842,8 @@ retry: if (err) { #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) - pr_err("Card did not respond to voltage select! : %d\n", err); + if (!quiet) + pr_err("Card did not respond to voltage select! : %d\n", err); #endif return -EOPNOTSUPP; } @@ -2882,7 +2883,7 @@ int mmc_start_init(struct mmc *mmc) return -ENOMEDIUM; } - err = mmc_get_op_cond(mmc); + err = mmc_get_op_cond(mmc, false); if (!err) mmc->init_in_progress = 1; diff --git a/include/mmc.h b/include/mmc.h index 6f943e78b7..0bf19de20e 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -900,9 +900,10 @@ int mmc_set_bkops_enable(struct mmc *mmc); * the presence of SD/eMMC when no card detect logic is available. * * @param mmc Pointer to a MMC device struct + * @param quiet Be quiet, do not print error messages when card is not detected. * @return 0 on success, <0 on error. */ -int mmc_get_op_cond(struct mmc *mmc); +int mmc_get_op_cond(struct mmc *mmc, bool quiet); /** * Start device initialization and return immediately; it does not block on