]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: dsa: b53: mmap: Implement bcm63268 gphy power control
authorKyle Hendry <kylehendrydev@gmail.com>
Thu, 14 Aug 2025 00:25:28 +0000 (17:25 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 15 Aug 2025 00:53:58 +0000 (17:53 -0700)
Add check for gphy in enable/disable phy calls and set power bits
in gphy control register.

Signed-off-by: Kyle Hendry <kylehendrydev@gmail.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20250814002530.5866-3-kylehendrydev@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/b53/b53_mmap.c

index 87e1338765c271ac87ba7dfa8a6b0106e30da3cb..f4a59d8fbdd604e74305a3a04be780308ff365cb 100644 (file)
 #include "b53_priv.h"
 
 #define BCM63XX_EPHY_REG 0x3C
+#define BCM63268_GPHY_REG 0x54
+
+#define GPHY_CTRL_LOW_PWR      BIT(3)
+#define GPHY_CTRL_IDDQ_BIAS    BIT(0)
 
 struct b53_phy_info {
        u32 gphy_port_mask;
@@ -292,13 +296,30 @@ static int bcm63xx_ephy_set(struct b53_device *dev, int port, bool enable)
        return regmap_update_bits(gpio_ctrl, BCM63XX_EPHY_REG, mask, val);
 }
 
+static int bcm63268_gphy_set(struct b53_device *dev, bool enable)
+{
+       struct b53_mmap_priv *priv = dev->priv;
+       struct regmap *gpio_ctrl = priv->gpio_ctrl;
+       u32 mask = GPHY_CTRL_IDDQ_BIAS | GPHY_CTRL_LOW_PWR;
+       u32 val = 0;
+
+       if (!enable)
+               val = mask;
+
+       return regmap_update_bits(gpio_ctrl, BCM63268_GPHY_REG, mask, val);
+}
+
 static void b53_mmap_phy_enable(struct b53_device *dev, int port)
 {
        struct b53_mmap_priv *priv = dev->priv;
        int ret = 0;
 
-       if (priv->phy_info && (BIT(port) & priv->phy_info->ephy_port_mask))
-               ret = bcm63xx_ephy_set(dev, port, true);
+       if (priv->phy_info) {
+               if (BIT(port) & priv->phy_info->ephy_port_mask)
+                       ret = bcm63xx_ephy_set(dev, port, true);
+               else if (BIT(port) & priv->phy_info->gphy_port_mask)
+                       ret = bcm63268_gphy_set(dev, true);
+       }
 
        if (!ret)
                priv->phys_enabled |= BIT(port);
@@ -309,8 +330,12 @@ static void b53_mmap_phy_disable(struct b53_device *dev, int port)
        struct b53_mmap_priv *priv = dev->priv;
        int ret = 0;
 
-       if (priv->phy_info && (BIT(port) & priv->phy_info->ephy_port_mask))
-               ret = bcm63xx_ephy_set(dev, port, false);
+       if (priv->phy_info) {
+               if (BIT(port) & priv->phy_info->ephy_port_mask)
+                       ret = bcm63xx_ephy_set(dev, port, false);
+               else if (BIT(port) & priv->phy_info->gphy_port_mask)
+                       ret = bcm63268_gphy_set(dev, false);
+       }
 
        if (!ret)
                priv->phys_enabled &= ~BIT(port);