From e394ef09bc7389089b410e81fb660ad6ce18223a Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Wed, 6 Aug 2025 02:56:15 +0200 Subject: [PATCH] arm64: renesas: r8a779g3: Disable MicroSD UHS modes on Retronix R-Car V4H Sparrow Hawk EVTA1 The Retronix R-Car V4H Sparrow Hawk old revision EVTA1 does not have MicroSD voltage switch populated on the board, therefore the board supports only 3V3 and non-UHS MicroSD cards. While the EVTB1 board is populated with Winbond W77Q51NW SPI NOR, the EVTA1 board is populated with Spansion S25FS512S SPI NOR, those those SPI NOR IDs to discern the two board revisions and apply the MicroSD related DT changes. The MicroSD related DT changes modify the regulator node, which is now a regulator-fixed and supplies only 3V3, and remove sd-uhs-sdr50 and sd-uhs-sdr104 properties from the MicroSD slot controller node. The MicroSD related DT changes cannot be applied as DTO, because the base DT contains nodes which have to be removed in case of EVTA1, but have to be present in case of EVTB1 and newer revisions of the board. Because the EVTA1 is an old revision of the board that is not generally available, it is better to special case it and keep the base DT compatible with EVTB1 and newer revisions of the board which are actually available. Signed-off-by: Marek Vasut --- board/renesas/sparrowhawk/sparrowhawk.c | 114 ++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/board/renesas/sparrowhawk/sparrowhawk.c b/board/renesas/sparrowhawk/sparrowhawk.c index 8e72b5424d1..871dad8172a 100644 --- a/board/renesas/sparrowhawk/sparrowhawk.c +++ b/board/renesas/sparrowhawk/sparrowhawk.c @@ -6,8 +6,12 @@ #include #include #include +#include +#include #include +#include "../../../drivers/mtd/spi/sf_internal.h" + #if defined(CONFIG_XPL_BUILD) static const struct renesas_dbsc5_board_config @@ -118,6 +122,116 @@ dbsc5_get_board_data(struct udevice *dev, const u32 modemr0) return &renesas_v4h_sparrowhawk_8g_6400_dbsc5_board_config; } +static bool renesas_v4h_sparrowhawk_is_evta1 = false; + +unsigned int spl_spi_get_uboot_offs(struct spi_flash *flash) +{ + const u8 sf_ids_evta1[6] = { 0x01, 0x02, 0x20, 0x4d, 0x00, 0x81 }; + + renesas_v4h_sparrowhawk_is_evta1 = !memcmp(sf_ids_evta1, flash->info->id, + sizeof(sf_ids_evta1)); + + return CONFIG_SYS_SPI_U_BOOT_OFFS; +} + +void spl_perform_fixups(struct spl_image_info *spl_image) +{ + void *blob = spl_image_fdt_addr(spl_image); + int err, offs; + u32 size; + + if (!renesas_v4h_sparrowhawk_is_evta1) + return; + + printf("EVTA1 board detected\n"); + + /* + * MicroSD voltage switch is not populated on Sparrow Hawk EVTA1, + * rewrite MicroSD slot regulator to only support 3V3 and disable + * UHS modes in MicroSD slot node. + */ + if (!blob) + return; + + err = fdt_check_header(blob); + if (err < 0) { + printf("Invalid FDT header: %s\n", fdt_strerror(err)); + return; + } + + size = fdt_totalsize(blob); + err = fdt_open_into(blob, blob, size + 64); + if (err < 0) { + printf("Failed to expand DT\n"); + return; + } + + offs = fdt_path_offset(blob, "/regulator-vcc-sdhi"); + if (offs < 0) { + printf("Failed to locate MicroSD regulator node: %d\n", offs); + return; + } + + err = fdt_setprop_string(blob, offs, "compatible", "regulator-fixed"); + if (err < 0) { + printf("Failed to set fixed MicroSD regulator: %d\n", err); + return; + } + + err = fdt_setprop_u32(blob, offs, "regulator-min-microvolt", 3300000); + if (err < 0) { + printf("Failed to set MicroSD regulator minimum voltage: %d\n", err); + return; + } + + err = fdt_nop_property(blob, offs, "gpios"); + if (err < 0) { + printf("Failed to remove MicroSD regulator gpios: %d\n", err); + return; + } + + err = fdt_nop_property(blob, offs, "gpios-states"); + if (err < 0) { + printf("Failed to remove MicroSD regulator gpio states: %d\n", err); + return; + } + + err = fdt_nop_property(blob, offs, "states"); + if (err < 0) { + printf("Failed to remove MicroSD regulator states: %d\n", err); + return; + } + + offs = fdt_path_offset(blob, "/soc/mmc@ee140000"); + if (offs < 0) { + printf("Failed to locate MicroSD device node: %d\n", offs); + return; + } + + err = fdt_nop_property(blob, offs, "sd-uhs-sdr50"); + if (err < 0) { + printf("Failed to disable SDR50 mode in MicroSD node: %d\n", err); + return; + } + + err = fdt_nop_property(blob, offs, "sd-uhs-sdr104"); + if (err < 0) { + printf("Failed to disable SDR104 mode in MicroSD node: %d\n", err); + return; + } + + err = fdt_setprop_string(blob, offs, "pinctrl-names", "default"); + if (err < 0) { + printf("Failed to set fixed MicroSD pin names: %d\n", err); + return; + } + + err = fdt_nop_property(blob, offs, "pinctrl-1"); + if (err < 0) { + printf("Failed to disable UHS pins in MicroSD node: %d\n", err); + return; + } +} #endif #define RST_MODEMR0 0xe6160000 -- 2.47.2