From 57805f2270c4a47cbc221e0920c58654f7748f0b Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Thu, 20 Feb 2020 17:36:31 +0100 Subject: [PATCH 01/11] net: bcmgenet: Don't set ID_MODE_DIS when not using RGMII As per Linux's driver, ID_MODE_DIS is only set when the PHY interface is RGMII. Don't enable it for the rest of setups. This has been seen to misconfigure RPi4's PHY when booting Linux. Signed-off-by: Nicolas Saenz Julienne Reviewed-by: Florian Fainelli Signed-off-by: Matthias Brugger --- drivers/net/bcmgenet.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/bcmgenet.c b/drivers/net/bcmgenet.c index 8f4848aec6..e971b556ac 100644 --- a/drivers/net/bcmgenet.c +++ b/drivers/net/bcmgenet.c @@ -448,7 +448,10 @@ static int bcmgenet_adjust_link(struct bcmgenet_eth_priv *priv) } clrsetbits_32(priv->mac_reg + EXT_RGMII_OOB_CTRL, OOB_DISABLE, - RGMII_LINK | RGMII_MODE_EN | ID_MODE_DIS); + RGMII_LINK | RGMII_MODE_EN); + + if (phy_dev->interface == PHY_INTERFACE_MODE_RGMII) + setbits_32(priv->mac_reg + EXT_RGMII_OOB_CTRL, ID_MODE_DIS); writel(speed << CMD_SPEED_SHIFT, (priv->mac_reg + UMAC_CMD)); From 6cbb41432d3af94861568c3cfb057c3d9cbd994b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 22 Mar 2020 21:15:52 -0600 Subject: [PATCH 02/11] arm: dts: bcm283x: Allow UARTs to work before relocation At present the pinctrl nodes are not enabled in pre-relocation U-Boot so the UARTs do not correctly select the pinconfig to enable the UART pins. Fix this so that the U-Boot banner is printed. This fixes serial output on rpi_3b_32b with the following config.txt options: enable_uart=1 gpu_freq=250 Signed-off-by: Simon Glass Fixes: 9821636b64 (bcm2835_pinctrl: Probe pre-reloc) Signed-off-by: Matthias Brugger --- arch/arm/dts/bcm283x-u-boot.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm/dts/bcm283x-u-boot.dtsi b/arch/arm/dts/bcm283x-u-boot.dtsi index 36548dad62..68d03627f4 100644 --- a/arch/arm/dts/bcm283x-u-boot.dtsi +++ b/arch/arm/dts/bcm283x-u-boot.dtsi @@ -19,3 +19,11 @@ &gpio { u-boot,dm-pre-reloc; }; + +&uart0_gpio14 { + u-boot,dm-pre-reloc; +}; + +&uart1_gpio14 { + u-boot,dm-pre-reloc; +}; From 0ed0db985abaa95a326ebfd268785e0b310d9d5d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 22 Mar 2020 21:15:53 -0600 Subject: [PATCH 03/11] arm: bcm283x: serial: Move ofdata reading to probe() method We cannot rely on a parent bus that needs to be probed, until we know that it is probed. That means that code in the ofdata_to_platdata() method cannot rely on the parent bus being probed. Move the ofdata code in the two serial drivers into a probe() method. This fixes serial output on rpi_3b_32b with the following config.txt options: enable_uart=1 gpu_freq=250 Signed-off-by: Simon Glass Signed-off-by: Matthias Brugger --- drivers/serial/serial_bcm283x_mu.c | 21 +++++++++------------ drivers/serial/serial_bcm283x_pl011.c | 12 ++++++++---- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c index a6ffc84b96..febb5ceea2 100644 --- a/drivers/serial/serial_bcm283x_mu.c +++ b/drivers/serial/serial_bcm283x_mu.c @@ -74,16 +74,6 @@ out: return 0; } -static int bcm283x_mu_serial_probe(struct udevice *dev) -{ - struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev); - struct bcm283x_mu_priv *priv = dev_get_priv(dev); - - priv->regs = (struct bcm283x_mu_regs *)plat->base; - - return 0; -} - static int bcm283x_mu_serial_getc(struct udevice *dev) { struct bcm283x_mu_priv *priv = dev_get_priv(dev); @@ -165,15 +155,21 @@ static bool bcm283x_is_serial_muxed(void) return true; } -static int bcm283x_mu_serial_ofdata_to_platdata(struct udevice *dev) +static int bcm283x_mu_serial_probe(struct udevice *dev) { struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev); + struct bcm283x_mu_priv *priv = dev_get_priv(dev); fdt_addr_t addr; /* Don't spawn the device if it's not muxed */ if (!bcm283x_is_serial_muxed()) return -ENODEV; + /* + * Read the ofdata here rather than in an ofdata_to_platdata() method + * since we need the soc simple-bus to be probed so that the 'ranges' + * property is used. + */ addr = devfdt_get_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; @@ -187,6 +183,8 @@ static int bcm283x_mu_serial_ofdata_to_platdata(struct udevice *dev) */ plat->skip_init = true; + priv->regs = (struct bcm283x_mu_regs *)plat->base; + return 0; } #endif @@ -195,7 +193,6 @@ U_BOOT_DRIVER(serial_bcm283x_mu) = { .name = "serial_bcm283x_mu", .id = UCLASS_SERIAL, .of_match = of_match_ptr(bcm283x_mu_serial_id), - .ofdata_to_platdata = of_match_ptr(bcm283x_mu_serial_ofdata_to_platdata), .platdata_auto_alloc_size = sizeof(struct bcm283x_mu_serial_platdata), .probe = bcm283x_mu_serial_probe, .ops = &bcm283x_mu_serial_ops, diff --git a/drivers/serial/serial_bcm283x_pl011.c b/drivers/serial/serial_bcm283x_pl011.c index 7d8ab7b716..923f402fbe 100644 --- a/drivers/serial/serial_bcm283x_pl011.c +++ b/drivers/serial/serial_bcm283x_pl011.c @@ -33,7 +33,7 @@ static bool bcm283x_is_serial_muxed(void) return true; } -static int bcm283x_pl011_serial_ofdata_to_platdata(struct udevice *dev) +static int bcm283x_pl011_serial_probe(struct udevice *dev) { struct pl01x_serial_platdata *plat = dev_get_platdata(dev); int ret; @@ -42,6 +42,11 @@ static int bcm283x_pl011_serial_ofdata_to_platdata(struct udevice *dev) if (!bcm283x_is_serial_muxed()) return -ENODEV; + /* + * Read the ofdata here rather than in an ofdata_to_platdata() method + * since we need the soc simple-bus to be probed so that the 'ranges' + * property is used. + */ ret = pl01x_serial_ofdata_to_platdata(dev); if (ret) return ret; @@ -52,7 +57,7 @@ static int bcm283x_pl011_serial_ofdata_to_platdata(struct udevice *dev) */ plat->skip_init = true; - return 0; + return pl01x_serial_probe(dev); } static int bcm283x_pl011_serial_setbrg(struct udevice *dev, int baudrate) @@ -86,9 +91,8 @@ U_BOOT_DRIVER(bcm283x_pl011_uart) = { .name = "bcm283x_pl011", .id = UCLASS_SERIAL, .of_match = of_match_ptr(bcm283x_pl011_serial_id), - .ofdata_to_platdata = of_match_ptr(bcm283x_pl011_serial_ofdata_to_platdata), + .probe = bcm283x_pl011_serial_probe, .platdata_auto_alloc_size = sizeof(struct pl01x_serial_platdata), - .probe = pl01x_serial_probe, .ops = &bcm283x_pl011_serial_ops, #if !CONFIG_IS_ENABLED(OF_CONTROL) || CONFIG_IS_ENABLED(OF_BOARD) .flags = DM_FLAG_PRE_RELOC, From fac8bfd4f52612fceb2d9784c93ed8f147f209c3 Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Fri, 27 Mar 2020 13:08:00 +0900 Subject: [PATCH 04/11] mmc: sdhci: use phys2bus macro when dma address is accessed Use phys2bus macro when dma address is accessed. Some targets need to use pyhs2bus macro. (e.g, RPI4) After applied it, SDMA mode can be used. Signed-off-by: Jaehoon Chung Reviewed-by: Peng Fan Reviewed-by: Minkyu Kang Signed-off-by: Matthias Brugger --- drivers/mmc/sdhci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 372dc0a820..480fad37ed 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -16,6 +16,7 @@ #include #include #include +#include static void sdhci_reset(struct sdhci_host *host, u8 mask) { @@ -150,7 +151,8 @@ static void sdhci_prepare_dma(struct sdhci_host *host, struct mmc_data *data, mmc_get_dma_dir(data)); if (host->flags & USE_SDMA) { - sdhci_writel(host, host->start_addr, SDHCI_DMA_ADDRESS); + sdhci_writel(host, phys_to_bus((ulong)host->start_addr), + SDHCI_DMA_ADDRESS); } else if (host->flags & (USE_ADMA | USE_ADMA64)) { sdhci_prepare_adma_table(host, data); @@ -204,7 +206,7 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data) start_addr &= ~(SDHCI_DEFAULT_BOUNDARY_SIZE - 1); start_addr += SDHCI_DEFAULT_BOUNDARY_SIZE; - sdhci_writel(host, start_addr, + sdhci_writel(host, phys_to_bus((ulong)start_addr), SDHCI_DMA_ADDRESS); } } From fabb3a43ada899e6ed248c3dee62348114831227 Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Fri, 27 Mar 2020 13:08:01 +0900 Subject: [PATCH 05/11] mmc: sdhci: not return error when SDMA is not supported If Host controller doesn't support SDMA, it doesn't need to return error. Because it can be worked with PIO mode. Signed-off-by: Jaehoon Chung Reviewed-by: Peng Fan Reviewed-by: Minkyu Kang Signed-off-by: Matthias Brugger --- drivers/mmc/sdhci.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 480fad37ed..6e8f6e3d17 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -741,13 +741,12 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, debug("%s, caps: 0x%x\n", __func__, caps); #ifdef CONFIG_MMC_SDHCI_SDMA - if (!(caps & SDHCI_CAN_DO_SDMA)) { + if ((caps & SDHCI_CAN_DO_SDMA)) { + host->flags |= USE_SDMA; + } else { printf("%s: Your controller doesn't support SDMA!!\n", __func__); - return -EINVAL; } - - host->flags |= USE_SDMA; #endif #if CONFIG_IS_ENABLED(MMC_SDHCI_ADMA) if (!(caps & SDHCI_CAN_DO_ADMA2)) { From c6b9fbf7566f84a807a5c116288648085fa529df Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Fri, 27 Mar 2020 13:08:02 +0900 Subject: [PATCH 06/11] configs: rpi_4 : enable SDHCI_SDMA config Enable SDHCI_SDMA configuration. Signed-off-by: Jaehoon Chung Reviewed-by: Peng Fan Reviewed-by: Minkyu Kang Signed-off-by: Matthias Brugger --- configs/rpi_4_32b_defconfig | 1 + configs/rpi_4_defconfig | 1 + 2 files changed, 2 insertions(+) diff --git a/configs/rpi_4_32b_defconfig b/configs/rpi_4_32b_defconfig index 8d262d89b4..52bdd0ab02 100644 --- a/configs/rpi_4_32b_defconfig +++ b/configs/rpi_4_32b_defconfig @@ -24,6 +24,7 @@ CONFIG_DFU_MMC=y CONFIG_DM_KEYBOARD=y CONFIG_DM_MMC=y CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_SDMA=y CONFIG_MMC_SDHCI_BCM2835=y CONFIG_DM_ETH=y CONFIG_BCMGENET=y diff --git a/configs/rpi_4_defconfig b/configs/rpi_4_defconfig index 2a0cea4222..2ce1b6b6ec 100644 --- a/configs/rpi_4_defconfig +++ b/configs/rpi_4_defconfig @@ -24,6 +24,7 @@ CONFIG_DFU_MMC=y CONFIG_DM_KEYBOARD=y CONFIG_DM_MMC=y CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_SDMA=y CONFIG_MMC_SDHCI_BCM2835=y CONFIG_DM_ETH=y CONFIG_BCMGENET=y From cf24c739724f9c40086a73ee648001c79b9cf99c Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Tue, 5 May 2020 12:09:02 +0200 Subject: [PATCH 07/11] configs: rpi_arm64: sync env size with rpi_{3,4}_defconfig Use the same environment size as the configs dedicated for rpi3 and rpi4. This allows to switch between the builds and not to loose the settings stored on the SD card. Signed-off-by: Marek Szyprowski Signed-off-by: Matthias Brugger --- configs/rpi_arm64_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/rpi_arm64_defconfig b/configs/rpi_arm64_defconfig index d2406ca36d..b9bb083a1d 100644 --- a/configs/rpi_arm64_defconfig +++ b/configs/rpi_arm64_defconfig @@ -3,6 +3,7 @@ CONFIG_ARCH_BCM283X=y CONFIG_SYS_TEXT_BASE=0x00080000 CONFIG_TARGET_RPI_ARM64=y CONFIG_SYS_MALLOC_F_LEN=0x2000 +CONFIG_ENV_SIZE=0x4000 CONFIG_NR_DRAM_BANKS=2 CONFIG_DISTRO_DEFAULTS=y CONFIG_OF_BOARD_SETUP=y From 7acdc9aa096d4e2a4c32d887fdbf4cee381a1e92 Mon Sep 17 00:00:00 2001 From: Matthias Brugger Date: Tue, 12 May 2020 12:02:06 +0200 Subject: [PATCH 08/11] mmc: sdhci: Use debug for not supported SDMA info message If CONFIG_MMC_SDHCI_SDMA is enabled but the HW could not support it, we no longer error out. Instead we do not enable it in the host. Change the output from printf to debug as this isn't an error but only additional information now. Signed-off-by: Matthias Brugger Reviewed-by: Peng Fan Signed-off-by: Matthias Brugger --- drivers/mmc/sdhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 6e8f6e3d17..8bb4393ce1 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -744,8 +744,8 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, if ((caps & SDHCI_CAN_DO_SDMA)) { host->flags |= USE_SDMA; } else { - printf("%s: Your controller doesn't support SDMA!!\n", - __func__); + debug("%s: Your controller doesn't support SDMA!!\n", + __func__); } #endif #if CONFIG_IS_ENABLED(MMC_SDHCI_ADMA) From cdabf301db84de7717340b391c97b762890469cd Mon Sep 17 00:00:00 2001 From: Matthias Brugger Date: Tue, 12 May 2020 12:02:07 +0200 Subject: [PATCH 09/11] configs: rpi_arm64: enable SDHCI SDMA support RPi4 supports SDMA on it's SDHCI controller. Enable to option for the combine RPi3/4 config. Signed-off-by: Matthias Brugger Reviewed-by: Peng Fan Signed-off-by: Matthias Brugger --- configs/rpi_arm64_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/rpi_arm64_defconfig b/configs/rpi_arm64_defconfig index b9bb083a1d..66c4a5368c 100644 --- a/configs/rpi_arm64_defconfig +++ b/configs/rpi_arm64_defconfig @@ -23,6 +23,7 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y CONFIG_DM_KEYBOARD=y CONFIG_DM_MMC=y CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_SDMA=y CONFIG_MMC_SDHCI_BCM2835=y CONFIG_DM_ETH=y CONFIG_BCMGENET=y From c6badda85c6f29904aa8f55c508921d38b93cc60 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Wed, 26 Feb 2020 15:37:13 -0600 Subject: [PATCH 10/11] rpi: Kconfig option for initial page reservation While the nearly-universal default for the Raspberry Pi family is to use spin tables and the spin table implementation provided by the Raspberry Pi Foundation, FreeBSD and others may use a PSCI implementation instead. Accommodate these setups by allowing them to configure for more than one page to be reserved in the initial reservation. The default reservation remains as one page. Signed-off-by: Kyle Evans Signed-off-by: Matthias Brugger --- arch/arm/mach-bcm283x/Kconfig | 2 ++ board/raspberrypi/rpi/Kconfig | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 board/raspberrypi/rpi/Kconfig diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig index 00419bf254..e6eb904e7f 100644 --- a/arch/arm/mach-bcm283x/Kconfig +++ b/arch/arm/mach-bcm283x/Kconfig @@ -209,4 +209,6 @@ config SYS_SOC config SYS_CONFIG_NAME default "rpi" +source "board/raspberrypi/rpi/Kconfig" + endmenu diff --git a/board/raspberrypi/rpi/Kconfig b/board/raspberrypi/rpi/Kconfig new file mode 100644 index 0000000000..e40088fde1 --- /dev/null +++ b/board/raspberrypi/rpi/Kconfig @@ -0,0 +1,10 @@ +if SYS_BOARD = "rpi" + +config RPI_EFI_NR_SPIN_PAGES + int "Spin table page count" + default 1 + help + Number of pages to reserve starting at page 0 for spin tables in the EFI + memory map + +endif From 82aef6c6f8a74a0595501bfbb2f6f763c786324f Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Wed, 26 Feb 2020 15:39:10 -0600 Subject: [PATCH 11/11] rpi: use the newly-added RPI_EFI_NR_SPIN_PAGES Some systems may use a slightly larger stub to do PSCI for booting the RPi family. The number of pages has been made configurable so that operating systems building U-Boot for use in these kinds of environments can reserve more memory in the EFI memory map. Signed-off-by: Kyle Evans Signed-off-by: Matthias Brugger --- board/raspberrypi/rpi/rpi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index e367ba3092..0206a093d4 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -489,7 +489,8 @@ int ft_board_setup(void *blob, bd_t *bd) #ifdef CONFIG_EFI_LOADER /* Reserve the spin table */ - efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0); + efi_add_memory_map(0, CONFIG_RPI_EFI_NR_SPIN_PAGES, + EFI_RESERVED_MEMORY_TYPE, 0); #endif return 0;