kernel: backport NVMEM late fixes from v6.2
[openwrt/openwrt.git] / target / linux / generic / backport-5.10 / 734-v5.16-0002-net-bgmac-support-MDIO-described-in-DT.patch
1 From 45c9d966688e7fad7f24bfc450547d91e4304d0b Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Sat, 2 Oct 2021 19:58:12 +0200
4 Subject: [PATCH] net: bgmac: support MDIO described in DT
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Check ethernet controller DT node for "mdio" subnode and use it with
10 of_mdiobus_register() when present. That allows specifying MDIO and its
11 PHY devices in a standard DT based way.
12
13 This is required for BCM53573 SoC support. That family is sometimes
14 called Northstar (by marketing?) but is quite different from it. It uses
15 different CPU(s) and many different hw blocks.
16
17 One of shared blocks in BCM53573 is Ethernet controller. Switch however
18 is not SRAB accessible (as it Northstar) but is MDIO attached.
19
20 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
21 Signed-off-by: David S. Miller <davem@davemloft.net>
22 ---
23 drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c | 6 +++++-
24 1 file changed, 5 insertions(+), 1 deletion(-)
25
26 --- a/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
27 +++ b/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c
28 @@ -10,6 +10,7 @@
29
30 #include <linux/bcma/bcma.h>
31 #include <linux/brcmphy.h>
32 +#include <linux/of_mdio.h>
33 #include "bgmac.h"
34
35 static bool bcma_mdio_wait_value(struct bcma_device *core, u16 reg, u32 mask,
36 @@ -211,6 +212,7 @@ struct mii_bus *bcma_mdio_mii_register(s
37 {
38 struct bcma_device *core = bgmac->bcma.core;
39 struct mii_bus *mii_bus;
40 + struct device_node *np;
41 int err;
42
43 mii_bus = mdiobus_alloc();
44 @@ -229,7 +231,9 @@ struct mii_bus *bcma_mdio_mii_register(s
45 mii_bus->parent = &core->dev;
46 mii_bus->phy_mask = ~(1 << bgmac->phyaddr);
47
48 - err = mdiobus_register(mii_bus);
49 + np = of_get_child_by_name(core->dev.of_node, "mdio");
50 +
51 + err = of_mdiobus_register(mii_bus, np);
52 if (err) {
53 dev_err(&core->dev, "Registration of mii bus failed\n");
54 goto err_free_bus;