From: Kyle Hendry <kylehendrydev@gmail.com>
To: Florian Fainelli <florian.fainelli@broadcom.com>,
Andrew Lunn <andrew@lunn.ch>, Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Russell King <linux@armlinux.org.uk>
Cc: Kyle Hendry <kylehendrydev@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] net: dsa: b53: mmap: Implement phy_enable for BCM63268 gphy
Date: Wed, 5 Feb 2025 20:30:48 -0800 [thread overview]
Message-ID: <20250206043055.177004-5-kylehendrydev@gmail.com> (raw)
In-Reply-To: <20250206043055.177004-1-kylehendrydev@gmail.com>
Add register defines for gphy control register. When gphy is
enabled, disable low power mode.
Signed-off-by: Kyle Hendry <kylehendrydev@gmail.com>
---
drivers/net/dsa/b53/b53_mmap.c | 34 ++++++++++++++++++++++++++++++++++
drivers/net/dsa/b53/b53_regs.h | 7 +++++++
2 files changed, 41 insertions(+)
diff --git a/drivers/net/dsa/b53/b53_mmap.c b/drivers/net/dsa/b53/b53_mmap.c
index 8157f9871133..ac0b8fc7eb4e 100644
--- a/drivers/net/dsa/b53/b53_mmap.c
+++ b/drivers/net/dsa/b53/b53_mmap.c
@@ -230,6 +230,38 @@ static int b53_mmap_phy_write16(struct b53_device *dev, int addr, int reg,
return -EIO;
}
+static void bcm63268_gphy_set(struct b53_device *dev, bool enable)
+{
+ struct b53_mmap_priv *priv = dev->priv;
+ void __iomem *gphy_ctrl = priv->gphy_ctrl;
+ u32 val;
+
+ val = ioread32be(gphy_ctrl);
+
+ if (enable)
+ val &= ~(GPHY_CTRL_IDDQ_BIAS | GPHY_CTRL_LOW_PWR);
+ else
+ val |= GPHY_CTRL_IDDQ_BIAS | GPHY_CTRL_LOW_PWR;
+
+ iowrite32be(val, gphy_ctrl);
+}
+
+static void b53_mmap_phy_enable(struct b53_device *dev, int port)
+{
+ struct b53_mmap_priv *priv = dev->priv;
+
+ if ((dev->internal_gphy_mask & BIT(port)) && priv->gphy_ctrl)
+ bcm63268_gphy_set(dev, true);
+}
+
+static void b53_mmap_phy_disable(struct b53_device *dev, int port)
+{
+ struct b53_mmap_priv *priv = dev->priv;
+
+ if ((dev->internal_gphy_mask & BIT(port)) && priv->gphy_ctrl)
+ bcm63268_gphy_set(dev, false);
+}
+
static const struct b53_io_ops b53_mmap_ops = {
.read8 = b53_mmap_read8,
.read16 = b53_mmap_read16,
@@ -243,6 +275,8 @@ static const struct b53_io_ops b53_mmap_ops = {
.write64 = b53_mmap_write64,
.phy_read16 = b53_mmap_phy_read16,
.phy_write16 = b53_mmap_phy_write16,
+ .phy_enable = b53_mmap_phy_enable,
+ .phy_disable = b53_mmap_phy_disable,
};
static int b53_mmap_probe_of(struct platform_device *pdev,
diff --git a/drivers/net/dsa/b53/b53_regs.h b/drivers/net/dsa/b53/b53_regs.h
index bfbcb66bef66..9607b28bbb86 100644
--- a/drivers/net/dsa/b53/b53_regs.h
+++ b/drivers/net/dsa/b53/b53_regs.h
@@ -525,4 +525,11 @@
/* CFP Control Register with ports map (8 bit) */
#define B53_CFP_CTRL 0x00
+/*************************************************************************
+ * Gigabit PHY Control Register
+ *************************************************************************/
+
+#define GPHY_CTRL_IDDQ_BIAS BIT(0)
+#define GPHY_CTRL_LOW_PWR BIT(3)
+
#endif /* !__B53_REGS_H */
--
2.43.0
next prev parent reply other threads:[~2025-02-06 4:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-06 4:30 [PATCH 0/4] net: dsa: b53: Enable internal GPHY on BCM63268 Kyle Hendry
2025-02-06 4:30 ` [PATCH 1/4] net: dsa: b53: Indicate which BCM63268 port is GPHY Kyle Hendry
2025-02-06 4:30 ` [PATCH 2/4] net: dsa: b53: mmap: Add gphy control register as a resource Kyle Hendry
2025-02-06 4:30 ` [PATCH 3/4] net: dsa: b53: Add phy_enable(), phy_disable() methods Kyle Hendry
2025-02-06 4:30 ` Kyle Hendry [this message]
2025-02-06 18:15 ` [PATCH 0/4] net: dsa: b53: Enable internal GPHY on BCM63268 Florian Fainelli
2025-02-06 20:17 ` Andrew Lunn
2025-02-07 1:41 ` Kyle Hendry
2025-02-07 16:44 ` Vladimir Oltean
2025-02-07 16:44 ` Florian Fainelli
2025-02-09 23:30 ` Andrew Lunn
2025-02-10 17:25 ` Florian Fainelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250206043055.177004-5-kylehendrydev@gmail.com \
--to=kylehendrydev@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.