From faf96b20ee6e2784273ca95203c4d44629739b71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Moj=C3=ADk?= Date: Wed, 6 Dec 2023 15:35:56 +0100 Subject: net: mv88e6xxx: fix missing SMI address initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mv88e6xxx driver does not currently initialize the smi_addr field, but instead keeps the default zero value. This leads to driver being unusable on devices where the switch is not on address zero of the mdio bus. Fix this problem by reading the SMI address from device tree. Signed-off-by: Marek Mojík Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- drivers/net/mv88e6xxx.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/mv88e6xxx.c b/drivers/net/mv88e6xxx.c index c073f81..8fbbc1c 100644 --- a/drivers/net/mv88e6xxx.c +++ b/drivers/net/mv88e6xxx.c @@ -745,6 +745,7 @@ static int mv88e6xxx_probe(struct udevice *dev) { struct dsa_pdata *dsa_pdata = dev_get_uclass_plat(dev); struct mv88e6xxx_priv *priv = dev_get_priv(dev); + fdt_addr_t smi_addr; int val, ret; if (ofnode_valid(dev_ofnode(dev)) && @@ -753,6 +754,13 @@ static int mv88e6xxx_probe(struct udevice *dev) return -ENODEV; } + smi_addr = dev_read_addr(dev); + if (smi_addr == FDT_ADDR_T_NONE) { + dev_err(dev, "Missing SMI address\n"); + return -EINVAL; + } + priv->smi_addr = smi_addr; + /* probe internal mdio bus */ ret = mv88e6xxx_probe_mdio(dev); if (ret) -- cgit v1.1 From f56591d326f11b35321c19495bf97049fd26fd8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Moj=C3=ADk?= Date: Tue, 19 Dec 2023 10:55:55 +0100 Subject: arm: mvebu: turris_omnia: Enable networking via ethernet switch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Turris Omnia contains the Marvell 88E6176 ethernet switch. Add config options and device tree to enable the support. Signed-off-by: Marek Mojík Signed-off-by: Marek Behún --- arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi | 51 ++++++++++++++++++++++++ configs/turris_omnia_defconfig | 2 + 2 files changed, 53 insertions(+) diff --git a/arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi b/arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi index 509d6ca..c63a331 100644 --- a/arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi +++ b/arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi @@ -35,6 +35,57 @@ }; }; +&mdio { + switch@10 { + mdio { + #address-cells = <1>; + #size-cells = <0>; + + sw_phy0: ethernet-phy@0 { + reg = <0x0>; + }; + + sw_phy1: ethernet-phy@1 { + reg = <0x1>; + }; + + sw_phy2: ethernet-phy@2 { + reg = <0x2>; + }; + + sw_phy3: ethernet-phy@3 { + reg = <0x3>; + }; + + sw_phy4: ethernet-phy@4 { + reg = <0x4>; + }; + }; + ports { + ports@0 { + phy-handle = <&sw_phy0>; + phy-mode = "internal"; + }; + ports@1 { + phy-handle = <&sw_phy1>; + phy-mode = "internal"; + }; + ports@2 { + phy-handle = <&sw_phy2>; + phy-mode = "internal"; + }; + ports@3 { + phy-handle = <&sw_phy3>; + phy-mode = "internal"; + }; + ports@4 { + phy-handle = <&sw_phy4>; + phy-mode = "internal"; + }; + }; + }; +}; + #ifdef CONFIG_ENV_IS_IN_SPI_FLASH &spi0 { flash@0 { diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig index f045dd7..2914840 100644 --- a/configs/turris_omnia_defconfig +++ b/configs/turris_omnia_defconfig @@ -95,7 +95,9 @@ CONFIG_SPI_FLASH_WINBOND=y CONFIG_SPI_FLASH_MTD=y CONFIG_PHY_MARVELL=y CONFIG_PHY_FIXED=y +CONFIG_DM_DSA=y CONFIG_PHY_GIGE=y +CONFIG_MV88E6XXX=y CONFIG_MVNETA=y CONFIG_MII=y CONFIG_MVMDIO=y -- cgit v1.1 From 52f7530e2d0f432d6978affc12732c756b522b85 Mon Sep 17 00:00:00 2001 From: Josua Mayer Date: Fri, 2 Feb 2024 16:13:32 +0100 Subject: arm: dts: armada-38x-solidrun-microsom: configure i2c0 bus SolidRun Armada-388 SoM has an i2c bus supporting on-som eeprom, and peripherals on a carrier. armada-38x.dtsi disables this bus by default, it should be enabled by som or carrier dts. Linux has moved i2c0 from helios-4 board dts to som dtsi, including status, pinctrl and clock speed. Copy these settings from mainline. This fixes accessing i2c bus from u-boot commandline. Signed-off-by: Josua Mayer --- arch/arm/dts/armada-38x-solidrun-microsom.dtsi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/dts/armada-38x-solidrun-microsom.dtsi b/arch/arm/dts/armada-38x-solidrun-microsom.dtsi index f6ae784..1540162 100644 --- a/arch/arm/dts/armada-38x-solidrun-microsom.dtsi +++ b/arch/arm/dts/armada-38x-solidrun-microsom.dtsi @@ -99,6 +99,11 @@ }; &i2c0 { + clock-frequency = <400000>; + pinctrl-0 = <&i2c0_pins>; + pinctrl-names = "default"; + status = "okay"; + eeprom@53 { compatible = "atmel,24c02"; reg = <0x53>; -- cgit v1.1 From 18c73e30e1aa412a47ab460eb2ccb8fb9551e8ad Mon Sep 17 00:00:00 2001 From: Josua Mayer Date: Fri, 2 Feb 2024 16:13:33 +0100 Subject: arm: mvebu: helios4_defconfig: enable setexpr command Update the helios4 defconfig to enable the 'setexpr' command, which is a default and useful for various complex boot-scripts. Signed-off-by: Josua Mayer --- configs/helios4_defconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/helios4_defconfig b/configs/helios4_defconfig index f4f5db6..72d1d77 100644 --- a/configs/helios4_defconfig +++ b/configs/helios4_defconfig @@ -43,7 +43,6 @@ CONFIG_CMD_MMC=y CONFIG_CMD_PCI=y CONFIG_CMD_SPI=y CONFIG_CMD_USB=y -# CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y -- cgit v1.1 From e58704070621eda667557c6cb4690c46b18ae012 Mon Sep 17 00:00:00 2001 From: Josua Mayer Date: Fri, 2 Feb 2024 16:13:34 +0100 Subject: board: helios-4: add config fragment for spi booting Add a config fragment with required differences for booting from spi flash instead of sd-card (default). Settings for environment location are based on vendor u-boot: https://github.com/kobol-io/u-boot/blob/helios4/include/configs/helios4.h#L59 The fragment can be applied on top of helios4_defconfig by make: make helios4_defconfig spiboot.config Signed-off-by: Josua Mayer --- board/kobol/helios4/spiboot.config | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 board/kobol/helios4/spiboot.config diff --git a/board/kobol/helios4/spiboot.config b/board/kobol/helios4/spiboot.config new file mode 100644 index 0000000..5ffb7d2 --- /dev/null +++ b/board/kobol/helios4/spiboot.config @@ -0,0 +1,4 @@ +CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI=y +# CONFIG_MVEBU_SPL_BOOT_DEVICE_MMC is not set +CONFIG_ENV_OFFSET=0x100000 +CONFIG_ENV_SECT_SIZE=0x10000 -- cgit v1.1 From d61b485dbd766970816ae9da09004dc4b30f8395 Mon Sep 17 00:00:00 2001 From: Max Resch Date: Thu, 15 Feb 2024 17:57:57 +0100 Subject: rng: Add Turris Mox rTWM RNG driver A RNG driver for Armada 3720 boards running the Turris Mox rWTM firmware from CZ.NIC in the secure processor. Signed-off-by: Max Resch Reviewed-by: Stefan Roese --- drivers/rng/Kconfig | 8 +++ drivers/rng/Makefile | 1 + drivers/rng/turris_rwtm_rng.c | 123 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 drivers/rng/turris_rwtm_rng.c diff --git a/drivers/rng/Kconfig b/drivers/rng/Kconfig index a89c899..cd72852 100644 --- a/drivers/rng/Kconfig +++ b/drivers/rng/Kconfig @@ -105,4 +105,12 @@ config RNG_JH7110 help Enable True Random Number Generator in StarFive JH7110 SoCs. +config RNG_TURRIS_RWTM + bool "Turris Mox TRNG in Secure Processor" + depends on DM_RNG && ARMADA_3700 + help + Use TRNG in Turris Mox Secure Processor Firmware. Can be used + on other Armada-3700 devices (like EspressoBin) if Secure + Firmware from CZ.NIC is used. + endif diff --git a/drivers/rng/Makefile b/drivers/rng/Makefile index 7e64c4c..ecae1a3 100644 --- a/drivers/rng/Makefile +++ b/drivers/rng/Makefile @@ -17,3 +17,4 @@ obj-$(CONFIG_RNG_SMCCC_TRNG) += smccc_trng.o obj-$(CONFIG_RNG_ARM_RNDR) += arm_rndr.o obj-$(CONFIG_TPM_RNG) += tpm_rng.o obj-$(CONFIG_RNG_JH7110) += jh7110_rng.o +obj-$(CONFIG_RNG_TURRIS_RWTM) += turris_rwtm_rng.o diff --git a/drivers/rng/turris_rwtm_rng.c b/drivers/rng/turris_rwtm_rng.c new file mode 100644 index 0000000..ca808c4 --- /dev/null +++ b/drivers/rng/turris_rwtm_rng.c @@ -0,0 +1,123 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause +/* + * Copyright (c) 2024, Max Resch + */ + +#include +#include +#include +#include +#include +#include + +/* size of entropy buffer */ +#define RNG_BUFFER_SIZE 128U + +struct turris_rwtm_rng_priv { + phys_addr_t buffer; +}; + +static int turris_rwtm_rng_fill_entropy(phys_addr_t entropy, size_t size) +{ + u32 args[3] = { 1, (u32)entropy, size }; + int ret; + + /* flush data cache */ + flush_dcache_range(entropy, entropy + size); + + /* + * get entropy + * args[0] = 1 copies BYTES array in args[1] of length args[2] + */ + ret = mbox_do_cmd(MBOX_CMD_GET_RANDOM, args, 3, NULL, 0); + if (ret < 0) + return ret; + + /* invalidate data cache */ + invalidate_dcache_range(entropy, entropy + size); + + return 0; +} + +static int turris_rwtm_rng_random_read(struct udevice *dev, void *data, size_t count) +{ + struct turris_rwtm_rng_priv *priv = dev_get_priv(dev); + phys_addr_t phys; + size_t size; + int ret; + + phys = priv->buffer; + + while (count) { + size = min_t(size_t, RNG_BUFFER_SIZE, count); + + ret = turris_rwtm_rng_fill_entropy(phys, size); + if (ret < 0) + return ret; + + memcpy(data, (void *)phys, size); + count -= size; + data = (u8 *)data + size; + } + + return 0; +} + +static int turris_rwtm_rng_probe(struct udevice *dev) +{ + struct turris_rwtm_rng_priv *priv = dev_get_priv(dev); + u32 args[] = { 0 }; + int ret; + + /* + * check if the random command is supported + * args[0] = 0 would copy 16 DWORDS entropy to out but we ignore them + */ + ret = mbox_do_cmd(MBOX_CMD_GET_RANDOM, args, ARRAY_SIZE(args), NULL, 0); + if (ret < 0) + return ret; + + /* entropy buffer */ + priv->buffer = 0; + + /* buffer address need to be aligned */ + dma_alloc_coherent(RNG_BUFFER_SIZE, (unsigned long *)&priv->buffer); + if (!priv->buffer) + return -ENOMEM; + + return 0; +} + +static int turris_rwtm_rng_remove(struct udevice *dev) +{ + struct turris_rwtm_rng_priv *priv = dev_get_priv(dev); + phys_addr_t phys = priv->buffer; + + dma_free_coherent((void *)phys); + + return 0; +} + +static const struct dm_rng_ops turris_rwtm_rng_ops = { + .read = turris_rwtm_rng_random_read, +}; + +/* + * only Turris MOX firmware has the RNG but allow all probable devices to be + * probed the default firmware will just reject the probe + */ +static const struct udevice_id turris_rwtm_rng_match[] = { + { .compatible = "cznic,turris-mox-rwtm" }, + { .compatible = "marvell,armada-3700-rwtm-firmware" }, + {}, +}; + +U_BOOT_DRIVER(turris_rwtm_rng) = { + .name = "turris-rwtm-rng", + .id = UCLASS_RNG, + .of_match = turris_rwtm_rng_match, + .ops = &turris_rwtm_rng_ops, + .probe = turris_rwtm_rng_probe, + .remove = turris_rwtm_rng_remove, + .priv_auto = sizeof(struct turris_rwtm_rng_priv), +}; -- cgit v1.1