user_mii_bus of struct realtek_priv is not dereferenced anywhere and it is easy to confuse it with user_mii_bus from struct dsa_switch, remove it. Signed-off-by: Jonas Karlman --- drivers/net/dsa/realtek/realtek.h | 1 - drivers/net/dsa/realtek/rtl83xx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h index a1b2e0b529d5..7f652b245b2e 100644 --- a/drivers/net/dsa/realtek/realtek.h +++ b/drivers/net/dsa/realtek/realtek.h @@ -57,7 +57,6 @@ struct realtek_priv { struct regmap *map; struct regmap *map_nolock; struct mutex map_lock; - struct mii_bus *user_mii_bus; struct mii_bus *bus; int mdio_addr; diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c index 2b9bd4462714..9a05616acea8 100644 --- a/drivers/net/dsa/realtek/rtl83xx.c +++ b/drivers/net/dsa/realtek/rtl83xx.c @@ -102,8 +102,6 @@ int rtl83xx_setup_user_mdio(struct dsa_switch *ds) goto err_put_node; } - priv->user_mii_bus = bus; - err_put_node: of_node_put(mdio_np); -- 2.50.1 The dt-bindings schema for Realtek switches for unmanaged switches contains a restriction on use of a mdio child OF node for MDIO-connected switches, i.e.: if: required: - reg then: not: required: - mdio properties: mdio: false However, the driver currently requires the existence of a mdio child OF node to successfully probe and properly function. Relax the requirement of a mdio child OF node and assign the dsa_switch user_mii_bus to allow a MDIO-connected switch to probe and function when a mdio child OF node is missing. Signed-off-by: Jonas Karlman --- drivers/net/dsa/realtek/rtl83xx.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c index 9a05616acea8..47a09b27c4fa 100644 --- a/drivers/net/dsa/realtek/rtl83xx.c +++ b/drivers/net/dsa/realtek/rtl83xx.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ +#include #include #include #include @@ -64,7 +65,7 @@ static int rtl83xx_user_mdio_write(struct mii_bus *bus, int addr, int regnum, * @ds: DSA switch associated with this user_mii_bus * * Registers the MDIO bus for built-in Ethernet PHYs, and associates it with - * the mandatory 'mdio' child OF node of the switch. + * the optional 'mdio' child OF node of the switch. * * Context: Can sleep. * Return: 0 on success, negative value for failure. @@ -75,11 +76,14 @@ int rtl83xx_setup_user_mdio(struct dsa_switch *ds) struct device_node *mdio_np; struct mii_bus *bus; int ret = 0; + int irq; + int i; mdio_np = of_get_child_by_name(priv->dev->of_node, "mdio"); - if (!mdio_np) { - dev_err(priv->dev, "no MDIO bus node\n"); - return -ENODEV; + if (mdio_np && !of_device_is_available(mdio_np)) { + dev_err(priv->dev, "no available MDIO bus node\n"); + ret = -ENODEV; + goto err_put_node; } bus = devm_mdiobus_alloc(priv->dev); @@ -95,6 +99,20 @@ int rtl83xx_setup_user_mdio(struct dsa_switch *ds) snprintf(bus->id, MII_BUS_ID_SIZE, "%s:user_mii", dev_name(priv->dev)); bus->parent = priv->dev; + if (!mdio_np) { + ds->user_mii_bus = bus; + bus->phy_mask = ~ds->phys_mii_mask; + + if (priv->irqdomain) { + for (i = 0; i < priv->num_ports; i++) { + irq = irq_find_mapping(priv->irqdomain, i); + if (irq < 0) + continue; + bus->irq[i] = irq; + } + } + } + ret = devm_of_mdiobus_register(priv->dev, bus, mdio_np); if (ret) { dev_err(priv->dev, "unable to register MDIO bus %s\n", -- 2.50.1 The Radxa E24C has a Realtek RTL8367RB-VB switch with four usable ports and is connected using a fixed-link to GMAC1 on the RK3528 SoC. Add an ethernet-switch node to describe the RTL8367RB-VB switch. Signed-off-by: Jonas Karlman --- Initial testing with iperf3 showed ~930-940 Mbits/sec in one direction and only around ~1-2 Mbits/sec in the other direction. The RK3528 hardware design guide recommends that timing between TXCLK and data is controlled by MAC, and timing between RXCLK and data is controlled by PHY. Any mix of MAC (rx/tx delay) and switch (rx/tx internal delay) did not seem to resolve this speed issue, however dropping snps,tso seems to fix that issue. Unsure what is best here, should MAC or switch add the delays? Here I just followed DT from vendor downstream tree and added rx/tx internal delay to switch. Vendor downstream DT also adds 'pause' to the fixed-link nodes, and this may be something that should be added here. However, during testing flow control always ended up being disabled so I skipped 'pause' here. Schematics: https://dl.radxa.com/e/e24c/docs/radxa_e24c_v1200_schematic.pdf --- .../boot/dts/rockchip/rk3528-radxa-e24c.dts | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/arch/arm64/boot/dts/rockchip/rk3528-radxa-e24c.dts b/arch/arm64/boot/dts/rockchip/rk3528-radxa-e24c.dts index 225f2b0c5339..26754ff7f4ef 100644 --- a/arch/arm64/boot/dts/rockchip/rk3528-radxa-e24c.dts +++ b/arch/arm64/boot/dts/rockchip/rk3528-radxa-e24c.dts @@ -196,6 +196,7 @@ &cpu3 { }; &gmac1 { + /delete-property/ snps,tso; clock_in_out = "output"; phy-mode = "rgmii-id"; phy-supply = <&avdd_rtl8367rb>; @@ -368,6 +369,60 @@ &mdio1 { reset-delay-us = <25000>; reset-gpios = <&gpio4 RK_PC2 GPIO_ACTIVE_LOW>; reset-post-delay-us = <100000>; + + ethernet-switch@1d { + compatible = "realtek,rtl8365mb"; + reg = <0x1d>; + pinctrl-names = "default"; + pinctrl-0 = <&rtl8367rb_eint>; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + ethernet-port@0 { + reg = <0>; + label = "wan"; + }; + + ethernet-port@1 { + reg = <1>; + label = "lan1"; + }; + + ethernet-port@2 { + reg = <2>; + label = "lan2"; + }; + + ethernet-port@3 { + reg = <3>; + label = "lan3"; + }; + + ethernet-port@6 { + reg = <6>; + ethernet = <&gmac1>; + label = "cpu"; + phy-mode = "rgmii-id"; + rx-internal-delay-ps = <2000>; + tx-internal-delay-ps = <2000>; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + + interrupt-controller { + interrupt-parent = <&gpio1>; + interrupts = ; + interrupt-controller; + #address-cells = <0>; + #interrupt-cells = <1>; + }; + }; }; &pinctrl { -- 2.50.1