[RFC PATCH net-next 5/6] net: dsa: b53: mmap: Clear resets on bcm63xx EPHYs

Kyle Hendry posted 6 patches 3 months, 2 weeks ago
[RFC PATCH net-next 5/6] net: dsa: b53: mmap: Clear resets on bcm63xx EPHYs
Posted by Kyle Hendry 3 months, 2 weeks ago
Make sure the ephy resets aren't being held by setting
lowest bits in ephy control register.

Signed-off-by: Kyle Hendry <kylehendrydev@gmail.com>
---
 drivers/net/dsa/b53/b53_mmap.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/net/dsa/b53/b53_mmap.c b/drivers/net/dsa/b53/b53_mmap.c
index 1bebf5b9826b..a4a2f2965bcc 100644
--- a/drivers/net/dsa/b53/b53_mmap.c
+++ b/drivers/net/dsa/b53/b53_mmap.c
@@ -24,9 +24,12 @@
 #include <linux/mfd/syscon.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/b53.h>
+#include <linux/regmap.h>
 
 #include "b53_priv.h"
 
+#define BCM63XX_EPHY_REG 0x3C
+
 struct b53_phy_info {
 	u32 chip_id;
 	u32 mask;
@@ -253,6 +256,14 @@ static int b53_mmap_phy_write16(struct b53_device *dev, int addr, int reg,
 	return -EIO;
 }
 
+static void bcm63xx_ephy_reset(struct regmap *regmap, int num_ephy)
+{
+	u32 mask = GENMASK((num_ephy - 1), 0);
+
+	/* Set lowest bits to deassert resets */
+	regmap_update_bits(regmap, BCM63XX_EPHY_REG, mask, mask);
+}
+
 static const struct b53_io_ops b53_mmap_ops = {
 	.read8 = b53_mmap_read8,
 	.read16 = b53_mmap_read16,
@@ -345,6 +356,8 @@ static int b53_mmap_probe(struct platform_device *pdev)
 				break;
 			}
 		}
+		if (priv->phy_info)
+			bcm63xx_ephy_reset(priv->gpio_ctrl, priv->phy_info->num_ephy);
 	}
 
 	dev = b53_switch_alloc(&pdev->dev, &b53_mmap_ops, priv);
-- 
2.43.0