From 5392ad2fd9ed082e40dac86174e6a737d177c143 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Wed, 29 Jan 2025 22:54:50 +0100 Subject: [PATCH 1/4] remoteproc: renesas: Synchronize caches across cores Explicitly flush icache on the CR52 core before jumping to the next stage software to make sure it does not contain any invalid content. Explicitly flash and invalidate dcache on the CA76 core both over the trampoline buffer and over the CR52 firmware, and then trigger full system synchronization, to make sure the data surely land in DRAM, from where the CR52 can surely pick them up. Signed-off-by: Marek Vasut --- arch/arm/mach-renesas/include/mach/boot0.h | 12 +++++++++++- drivers/remoteproc/renesas_apmu.c | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-renesas/include/mach/boot0.h b/arch/arm/mach-renesas/include/mach/boot0.h index fc68ffc0945..b71c157149e 100644 --- a/arch/arm/mach-renesas/include/mach/boot0.h +++ b/arch/arm/mach-renesas/include/mach/boot0.h @@ -34,7 +34,7 @@ _start: .inst 0xe380070a /* orr r0, r0, #0x280000 */ /* APMU_RVBARPLC0 = (address of 'b reset' below) | CA_CORE0_VLD_RVBARP */ - .inst 0xe28f3088 /* add r3, pc, #0x88 */ + .inst 0xe28f30a8 /* add r3, pc, #0xa8 */ .inst 0xe3833001 /* orr r3, r3, #1 */ .inst 0xe5843038 /* str r3, [r4, #56] @ 0x38 */ @@ -75,12 +75,22 @@ _start: .inst 0xe20230ff /* and r3, r2, #255 @ 0xff */ .inst 0xe3530011 /* cmp r3, #17 */ .inst 0x1afffffb /* bne 78 */ + /* Invalidate icache before jump to follow up software */ + .inst 0xe3a00000 /* mov r0, #0 */ + .inst 0xee070f15 /* mcr 15, 0, r0, cr7, cr5, {0} */ + .inst 0xf57ff04f /* dsb sy */ + .inst 0xf57ff06f /* isb sy */ + /* Jump to follow up software */ .inst 0xe1a02922 /* lsr r2, r2, #18 */ .inst 0xe1a02902 /* lsl r2, r2, #18 */ .inst 0xe1a0f002 /* mov pc, r2 */ .inst 0xeafffffe /* b 94 */ .inst 0xe1a00000 /* nop @ (mov r0, r0) */ .inst 0xe1a00000 /* nop @ (mov r0, r0) */ + .inst 0xe1a00000 /* nop @ (mov r0, r0) */ + .inst 0xe1a00000 /* nop @ (mov r0, r0) */ + .inst 0xe1a00000 /* nop @ (mov r0, r0) */ + .inst 0xe1a00000 /* nop @ (mov r0, r0) */ /* Offset 0xa0 */ #endif b reset diff --git a/drivers/remoteproc/renesas_apmu.c b/drivers/remoteproc/renesas_apmu.c index 32d138e6487..1a50cd3289b 100644 --- a/drivers/remoteproc/renesas_apmu.c +++ b/drivers/remoteproc/renesas_apmu.c @@ -68,6 +68,13 @@ static int renesas_apmu_rproc_load(struct udevice *dev, ulong addr, ulong size) flush_dcache_range(trampolineaddr, trampolineaddr + sizeof(renesas_apmu_rproc_trampoline)); + invalidate_dcache_range(trampolineaddr, + trampolineaddr + + sizeof(renesas_apmu_rproc_trampoline)); + flush_dcache_range(addr, addr + size); + invalidate_dcache_range(addr, addr + size); + asm volatile("dsb sy\n"); + asm volatile("isb sy\n"); /* CR52 boot address set */ writel(trampolineaddr | APMU_CRBARP_CR_VLD_BARP, From 8a2ffd5a852e5ace1fe618ce08a0e1fdda65de51 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Fri, 31 Jan 2025 02:19:57 +0100 Subject: [PATCH 2/4] arm64: renesas: Add R-Car S4 Starter Kit support Add support for the R-Car S4 Starter Kit with R8A779F4 SoC support. This implementation natively uses OF_UPSTREAM to pull in most recent DT. The defconfig is derived from S4 Spider, with reduced UART baud rate to 921600 Bdps. The DT alias to rswitch is removed as the alias should point to rswitch ports, not to rswitch itself, see [1]. [1] https://lore.kernel.org/linux-arm-kernel/20250118111344.361617-5-marek.vasut+renesas@mailbox.org/ Signed-off-by: Marek Vasut --- arch/arm/dts/r8a779f4-s4sk-u-boot.dtsi | 42 +++++++++++++ arch/arm/mach-renesas/Kconfig.rcar4 | 7 +++ board/renesas/s4sk/Kconfig | 15 +++++ board/renesas/s4sk/MAINTAINERS | 7 +++ board/renesas/s4sk/Makefile | 7 +++ board/renesas/s4sk/s4sk.c | 85 ++++++++++++++++++++++++++ configs/r8a779f0_spider_defconfig | 27 +------- configs/r8a779f4_s4sk_defconfig | 11 ++++ configs/renesas_rcar4_s4.config | 23 +++++++ doc/board/renesas/renesas.rst | 6 ++ include/configs/s4sk.h | 13 ++++ 11 files changed, 219 insertions(+), 24 deletions(-) create mode 100644 arch/arm/dts/r8a779f4-s4sk-u-boot.dtsi create mode 100644 board/renesas/s4sk/Kconfig create mode 100644 board/renesas/s4sk/MAINTAINERS create mode 100644 board/renesas/s4sk/Makefile create mode 100644 board/renesas/s4sk/s4sk.c create mode 100644 configs/r8a779f4_s4sk_defconfig create mode 100644 configs/renesas_rcar4_s4.config create mode 100644 include/configs/s4sk.h diff --git a/arch/arm/dts/r8a779f4-s4sk-u-boot.dtsi b/arch/arm/dts/r8a779f4-s4sk-u-boot.dtsi new file mode 100644 index 00000000000..c2c743ba501 --- /dev/null +++ b/arch/arm/dts/r8a779f4-s4sk-u-boot.dtsi @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Device Tree Source extras for U-Boot for the S4SK board + * + * Copyright (C) 2024-2025 Renesas Electronics Corp. + */ + +#include "r8a779f0-u-boot.dtsi" + +/ { + aliases { + spi0 = &rpc; + /delete-property/ ethernet0; + }; +}; + +&pfc { + qspi0_pins: qspi0 { + groups = "qspi0_ctrl", "qspi0_data4"; + function = "qspi0"; + }; +}; + +&rpc { + pinctrl-0 = <&qspi0_pins>; + pinctrl-names = "default"; + + #address-cells = <1>; + #size-cells = <0>; + spi-max-frequency = <40000000>; + status = "okay"; + + spi-flash@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "s25fs512s", "jedec,spi-nor"; + reg = <0>; + spi-tx-bus-width = <1>; + spi-rx-bus-width = <1>; + spi-max-frequency = <40000000>; + }; +}; diff --git a/arch/arm/mach-renesas/Kconfig.rcar4 b/arch/arm/mach-renesas/Kconfig.rcar4 index c2812fd75e4..c42bb9765ef 100644 --- a/arch/arm/mach-renesas/Kconfig.rcar4 +++ b/arch/arm/mach-renesas/Kconfig.rcar4 @@ -54,6 +54,12 @@ config TARGET_SPIDER help Support for Renesas R-Car Gen4 Spider platform +config TARGET_S4SK + bool "S4SK board" + imply R8A779F0 + help + Support for Renesas R-Car Gen4 S4SK platform + config TARGET_WHITEHAWK bool "White Hawk board" imply R8A779G0 @@ -70,6 +76,7 @@ endchoice source "board/renesas/falcon/Kconfig" source "board/renesas/spider/Kconfig" +source "board/renesas/s4sk/Kconfig" source "board/renesas/whitehawk/Kconfig" source "board/renesas/grayhawk/Kconfig" diff --git a/board/renesas/s4sk/Kconfig b/board/renesas/s4sk/Kconfig new file mode 100644 index 00000000000..57013d22b8c --- /dev/null +++ b/board/renesas/s4sk/Kconfig @@ -0,0 +1,15 @@ +if TARGET_S4SK + +config SYS_SOC + default "renesas" + +config SYS_BOARD + default "s4sk" + +config SYS_VENDOR + default "renesas" + +config SYS_CONFIG_NAME + default "s4sk" + +endif diff --git a/board/renesas/s4sk/MAINTAINERS b/board/renesas/s4sk/MAINTAINERS new file mode 100644 index 00000000000..e64da079160 --- /dev/null +++ b/board/renesas/s4sk/MAINTAINERS @@ -0,0 +1,7 @@ +S4SK BOARD +M: Marek Vasut +S: Maintained +F: arch/arm/dts/r8a779f4* +F: board/renesas/s4sk/ +F: configs/r8a779f4_s4sk_defconfig +F: include/configs/s4sk.h diff --git a/board/renesas/s4sk/Makefile b/board/renesas/s4sk/Makefile new file mode 100644 index 00000000000..f03e52386f2 --- /dev/null +++ b/board/renesas/s4sk/Makefile @@ -0,0 +1,7 @@ +# +# Copyright (C) 2025 Renesas Electronics Corp. +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y := s4sk.o diff --git a/board/renesas/s4sk/s4sk.c b/board/renesas/s4sk/s4sk.c new file mode 100644 index 00000000000..d2beb71c684 --- /dev/null +++ b/board/renesas/s4sk/s4sk.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2025 Marek Vasut + */ + +#include +#include +#include +#include + +#define S4SK_FPGA_I2C_BUS "i2c5" +#define S4SK_FPGA_I2C_DEV_ADDR 0x70 +#define S4SK_FPGA_I2C_DEV_WIDTH 2 +#define S4SK_FPGA_I2C_MAC_COUNT 4 +#define S4SK_FPGA_I2C_MAC_OFFSET 0x58 +#define S4SK_FPGA_I2C_MAC_WIDTH 8 + +int board_late_init(void) +{ + /* + * Extract AVB and TSN0,1,2 MAC addresses from FPGA via I2C. + * + * In case a matching ethaddr/ethNaddr environment variable + * is not set, set it, otherwise do not override it. This + * allows users to set their own MAC addresses via ethaddr + * and ethNaddr environment variables. + * + * The ethaddr/ethNaddr mapping follows Linux kernel DT aliases + * ethernetN property assignment: + * - ethaddr ..... TSN0 (IC104 connector) + * - eth1addr .... TSN1 (IC101 connector) + * - eth2addr .... TSN2 (Expansion connector) + * - eth3addr .... AVB (CN1 connector) + */ + ofnode i2c_node = ofnode_path(S4SK_FPGA_I2C_BUS); + struct udevice *bus, *dev; + unsigned char enetaddr[6]; + unsigned char macs[32]; /* Four MAC addresses in FPGA in total. */ + int i, idx, j, ret; + + ret = uclass_get_device_by_ofnode(UCLASS_I2C, i2c_node, &bus); + if (ret < 0) { + printf("s4sk: cannot find i2c bus (%d)\n", ret); + return 0; + } + + ret = i2c_get_chip(bus, S4SK_FPGA_I2C_DEV_ADDR, + S4SK_FPGA_I2C_DEV_WIDTH, &dev); + if (ret < 0) { + printf("s4sk: cannot find i2c chip (%d)\n", ret); + return 0; + } + + ret = dm_i2c_read(dev, S4SK_FPGA_I2C_MAC_OFFSET, macs, sizeof(macs)); + if (ret < 0) { + printf("s4sk: failed to read MAC addresses via i2c (%d)\n", ret); + return 0; + } + + for (i = 0; i < S4SK_FPGA_I2C_MAC_COUNT; i++) { + /* + * Remap TSN0,1,2 to ethaddr,eth1addr,eth2addr and + * AVB to eth3addr to match Linux /aliases ethernetN + * assignment, which starts with ethernet0 for TSN. + */ + idx = (i + 3) % 4; + ret = eth_env_get_enetaddr_by_index("eth", idx, enetaddr); + if (ret) /* ethaddr is already set */ + continue; + + /* Byte-wise reverse the MAC address */ + for (j = 0; j < sizeof(enetaddr); j++) + enetaddr[j] = macs[i * S4SK_FPGA_I2C_MAC_WIDTH + (5 - j)]; + + if (!is_valid_ethaddr(enetaddr)) { + printf("s4sk: MAC address %d in FPGA not valid (%pM)\n", + i, enetaddr); + continue; + } + + eth_env_set_enetaddr_by_index("eth", idx, enetaddr); + } + + return 0; +} diff --git a/configs/r8a779f0_spider_defconfig b/configs/r8a779f0_spider_defconfig index 7274038a202..6b16ff55480 100644 --- a/configs/r8a779f0_spider_defconfig +++ b/configs/r8a779f0_spider_defconfig @@ -1,32 +1,11 @@ -#include +#include CONFIG_ARM=y CONFIG_ARCH_RENESAS=y CONFIG_RCAR_GEN4=y -CONFIG_ENV_SIZE=0x40000 -CONFIG_ENV_OFFSET=0xD00000 -CONFIG_ENV_SECT_SIZE=0x40000 -CONFIG_DEFAULT_DEVICE_TREE="renesas/r8a779f0-spider" CONFIG_TARGET_SPIDER=y -CONFIG_SYS_CLK_FREQ=20000000 -CONFIG_SYS_BOOT_GET_CMDLINE=y -CONFIG_SYS_BARGSIZE=2048 +CONFIG_DEFAULT_DEVICE_TREE="renesas/r8a779f0-spider" CONFIG_BOOTCOMMAND="tftp 0x48080000 Image && tftp 0x48000000 Image-r8a779f0-spider.dtb && booti 0x48080000 - 0x48000000" CONFIG_DEFAULT_FDT_FILE="r8a779f0-spider.dtb" -CONFIG_SYS_CBSIZE=2048 -CONFIG_CMD_PART=y -CONFIG_CMD_UFS=y -CONFIG_ENV_IS_IN_SPI_FLASH=y -CONFIG_LBA48=y -CONFIG_SYS_64BIT_LBA=y -CONFIG_CLK_GPIO=y -CONFIG_DM_PCA953X=y -CONFIG_PHYLIB_10G=y -CONFIG_PHY_MARVELL_10G=y -CONFIG_RENESAS_ETHER_SWITCH=y -CONFIG_PHY_R8A779F0_ETHERNET_SERDES=y -CONFIG_SCSI=y CONFIG_BAUDRATE=1843200 -CONFIG_UFS=y -CONFIG_UFS_RENESAS=y -CONFIG_FS_FAT_MAX_CLUSTSIZE=131072 +CONFIG_DM_PCA953X=y diff --git a/configs/r8a779f4_s4sk_defconfig b/configs/r8a779f4_s4sk_defconfig new file mode 100644 index 00000000000..1b353492d04 --- /dev/null +++ b/configs/r8a779f4_s4sk_defconfig @@ -0,0 +1,11 @@ +#include + +CONFIG_ARM=y +CONFIG_ARCH_RENESAS=y +CONFIG_RCAR_GEN4=y +CONFIG_TARGET_S4SK=y +CONFIG_DEFAULT_DEVICE_TREE="renesas/r8a779f4-s4sk" +CONFIG_BOOTCOMMAND="tftp 0x48080000 Image && tftp 0x48000000 Image-r8a779f4-s4sk.dtb && booti 0x48080000 - 0x48000000" +CONFIG_DEFAULT_FDT_FILE="r8a779f4-s4sk.dtb" +CONFIG_BAUDRATE=921600 +CONFIG_BOARD_LATE_INIT=y diff --git a/configs/renesas_rcar4_s4.config b/configs/renesas_rcar4_s4.config new file mode 100644 index 00000000000..866e5759e63 --- /dev/null +++ b/configs/renesas_rcar4_s4.config @@ -0,0 +1,23 @@ +#include + +CONFIG_CLK_GPIO=y +CONFIG_CMD_PART=y +CONFIG_CMD_UFS=y +CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_ENV_OFFSET=0xD00000 +CONFIG_ENV_SECT_SIZE=0x40000 +CONFIG_ENV_SIZE=0x40000 +CONFIG_FS_FAT_MAX_CLUSTSIZE=131072 +CONFIG_LBA48=y +CONFIG_PHYLIB_10G=y +CONFIG_PHY_MARVELL_10G=y +CONFIG_PHY_R8A779F0_ETHERNET_SERDES=y +CONFIG_RENESAS_ETHER_SWITCH=y +CONFIG_SCSI=y +CONFIG_SYS_64BIT_LBA=y +CONFIG_SYS_BARGSIZE=2048 +CONFIG_SYS_BOOT_GET_CMDLINE=y +CONFIG_SYS_CBSIZE=2048 +CONFIG_SYS_CLK_FREQ=20000000 +CONFIG_UFS=y +CONFIG_UFS_RENESAS=y diff --git a/doc/board/renesas/renesas.rst b/doc/board/renesas/renesas.rst index 7d961e862e4..0a38ff42eae 100644 --- a/doc/board/renesas/renesas.rst +++ b/doc/board/renesas/renesas.rst @@ -168,6 +168,12 @@ Renesas is a SoC solutions provider for automotive and industrial applications. - arm64 - r8a779f0_spider_defconfig + * - + - S4SK + - R8A779F4 (S4) + - arm64 + - r8a779f4_s4sk_defconfig + * - - White Hawk - R8A779G0 (V4H) diff --git a/include/configs/s4sk.h b/include/configs/s4sk.h new file mode 100644 index 00000000000..a1707359a39 --- /dev/null +++ b/include/configs/s4sk.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * This file is S4SK board configuration. + * + * Copyright (C) 2024-2025 Renesas Electronics Corp. + */ + +#ifndef __S4SK_H +#define __S4SK_H + +#include "rcar-gen4-common.h" + +#endif /* __S4SK_H */ From b1001835f17717c665f28b9f1f82d2e12002f0d7 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 18 Jan 2025 07:16:17 +0100 Subject: [PATCH 3/4] net: miiphybb: Convert ifdef DEBUG to debug() Replace ifdeffery with plain debug() function call. No functional change. Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/phy/miiphybb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/phy/miiphybb.c b/drivers/net/phy/miiphybb.c index 171c1719b5b..5497b838225 100644 --- a/drivers/net/phy/miiphybb.c +++ b/drivers/net/phy/miiphybb.c @@ -183,9 +183,7 @@ int bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg) bus->set_mdc(bus, 1); bus->delay(bus); -#ifdef DEBUG - printf("miiphy_read(0x%x) @ 0x%x = 0x%04x\n", reg, addr, rdreg); -#endif + debug("miiphy_read(0x%x) @ 0x%x = 0x%04x\n", reg, addr, rdreg); return rdreg; } From 30a8c830e92e748a13d881bfe4ded4f7c48c8619 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 25 Jan 2025 13:28:30 +0100 Subject: [PATCH 4/4] net: miiphybb: Update debug() print Update the debug() print, use __func__ to always print matching function name, and also print bus name in case there are multiple busses. Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/phy/miiphybb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/phy/miiphybb.c b/drivers/net/phy/miiphybb.c index 5497b838225..9f5f9b12c9f 100644 --- a/drivers/net/phy/miiphybb.c +++ b/drivers/net/phy/miiphybb.c @@ -183,7 +183,7 @@ int bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg) bus->set_mdc(bus, 1); bus->delay(bus); - debug("miiphy_read(0x%x) @ 0x%x = 0x%04x\n", reg, addr, rdreg); + debug("%s[%s](0x%x) @ 0x%x = 0x%04x\n", __func__, miidev->name, reg, addr, rdreg); return rdreg; }