]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: macb: do not set user_io when it does not exist
authorChristian DREHER <christian.dreher@nanoxplore.com>
Tue, 28 Apr 2026 18:04:07 +0000 (20:04 +0200)
committerJerome Forissier <jerome.forissier@arm.com>
Wed, 6 May 2026 09:07:22 +0000 (11:07 +0200)
Cadence Ethernet MAC has a feature named user_io, which provides
some input and some output signals for arbitrary purpose in the SoC.
From the driver code, I understand that, on Atmel SoC, it is used to
drive the PHY mode.

At least on Cadence IP7014 r1p12, this feature is optional, and I am
working on a SoC that does not instantiate it. The presence of this
feature is advertised in DCFG1, this patch merely disables the access
to the user_io register based on this information.

I did not apply this change to the non-gigabit capable versions of
the IP, as I do not have documentation for them, and a new non-gigabit
instance is unlikely to appear. I prefer avoiding regressions on old
systems.

Signed-off-by: Christian DREHER <christian.dreher@nanoxplore.com>
drivers/net/macb.c
drivers/net/macb.h

index 807a038e07115c6d82037ada5a6024f49a367bc7..5cc29ecb2140a1815fc3134e5cfa172ddcb42b63 100644 (file)
@@ -927,26 +927,39 @@ static int _macb_init(struct udevice *dev, const char *name)
                /* Check the multi queue and initialize the queue for tx */
                gmac_init_multi_queues(macb);
 
-               /*
-                * When the GMAC IP with GE feature, this bit is used to
-                * select interface between RGMII and GMII.
-                * When the GMAC IP without GE feature, this bit is used
-                * to select interface between RMII and MII.
+               /* This driver uses the user I/O to select the PHY features,
+                * but some GEM instances come with a fixed configuration and
+                * no USERIO.
                 */
-               if (macb->phy_interface == PHY_INTERFACE_MODE_RGMII ||
-                   macb->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
-                   macb->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID ||
-                   macb->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID)
-                       val = macb->config->usrio->rgmii;
-               else if (macb->phy_interface == PHY_INTERFACE_MODE_RMII)
-                       val = macb->config->usrio->rmii;
-               else if (macb->phy_interface == PHY_INTERFACE_MODE_MII)
-                       val = macb->config->usrio->mii;
-
-               if (macb->config->caps & MACB_CAPS_USRIO_HAS_CLKEN)
-                       val |= macb->config->usrio->clken;
-
-               gem_writel(macb, USRIO, val);
+               if (gem_readl(macb, DCFG1) & GEM_BIT(USERIO)) {
+                       /*
+                        * When the GMAC IP with GE feature, this bit is used to
+                        * select interface between RGMII and GMII.
+                        * When he GMAC IP without GE feature, this bit is used
+                        * to select interface between RMII and MII.
+                        */
+                       switch (macb->phy_interface) {
+                       case PHY_INTERFACE_MODE_RGMII:
+                       case PHY_INTERFACE_MODE_RGMII_ID:
+                       case PHY_INTERFACE_MODE_RGMII_RXID:
+                       case PHY_INTERFACE_MODE_RGMII_TXID:
+                               val = macb->config->usrio->rgmii;
+                               break;
+                       case PHY_INTERFACE_MODE_RMII:
+                               val = macb->config->usrio->rmii;
+                               break;
+                       case PHY_INTERFACE_MODE_MII:
+                               val = macb->config->usrio->mii;
+                               break;
+                       default:
+                               break;
+                       }
+
+                       if (macb->config->caps & MACB_CAPS_USRIO_HAS_CLKEN)
+                               val |= macb->config->usrio->clken;
+
+                       gem_writel(macb, USRIO, val);
+               }
 
                if (macb->phy_interface == PHY_INTERFACE_MODE_SGMII) {
                        unsigned int ncfgr = macb_readl(macb, NCFGR);
index 0eb90574618040d19823fd04ec2192799006a7bc..002d5bd31b21d5cb2a38ce275e01fa53704290f1 100644 (file)
 #define MACB_REV_SIZE                          16
 
 /* Bitfields in DCFG1. */
+#define GEM_USERIO_OFFSET                      9
+#define GEM_USERIO_SIZE                                1
 #define GEM_IRQCOR_OFFSET                      23
 #define GEM_IRQCOR_SIZE                                1
 #define GEM_DBWDEF_OFFSET                      25