All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] net: mdio-ipq4019: add Clause 45 support
@ 2020-09-20 14:16 Robert Marko
  2020-09-20 14:16 ` [PATCH v4 1/2] net: mdio-ipq4019: change defines to upper case Robert Marko
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Robert Marko @ 2020-09-20 14:16 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, kuba, netdev, linux-kernel,
	linux-arm-msm
  Cc: Robert Marko

This patch series adds support for Clause 45 to the driver.

While at it also change some defines to upper case to match rest of the driver.

Changes since v1:
* Drop clock patches, these need further investigation and
no user for non default configuration has been found

Robert Marko (2):
  net: mdio-ipq4019: change defines to upper case
  net: mdio-ipq4019: add Clause 45 support

 drivers/net/phy/mdio-ipq4019.c | 109 ++++++++++++++++++++++++++++-----
 1 file changed, 92 insertions(+), 17 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v4 1/2] net: mdio-ipq4019: change defines to upper case
  2020-09-20 14:16 [PATCH v4 0/2] net: mdio-ipq4019: add Clause 45 support Robert Marko
@ 2020-09-20 14:16 ` Robert Marko
  2020-09-20 14:16 ` [PATCH v4 2/2] net: mdio-ipq4019: add Clause 45 support Robert Marko
  2020-09-21 21:48 ` [PATCH v4 0/2] " David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: Robert Marko @ 2020-09-20 14:16 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, kuba, netdev, linux-kernel,
	linux-arm-msm
  Cc: Robert Marko, Luka Perkov, Florian Fainelli

In the commit adding the IPQ4019 MDIO driver, defines for timeout and sleep partially used lower case.
Lets change it to upper case in line with the rest of driver defines.

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Cc: Luka Perkov <luka.perkov@sartura.hr>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/mdio-ipq4019.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/mdio-ipq4019.c b/drivers/net/phy/mdio-ipq4019.c
index 1ce81ff2f41d..64b169e5a699 100644
--- a/drivers/net/phy/mdio-ipq4019.c
+++ b/drivers/net/phy/mdio-ipq4019.c
@@ -21,8 +21,8 @@
 #define MDIO_CMD_ACCESS_CODE_READ	0
 #define MDIO_CMD_ACCESS_CODE_WRITE	1
 
-#define ipq4019_MDIO_TIMEOUT	10000
-#define ipq4019_MDIO_SLEEP		10
+#define IPQ4019_MDIO_TIMEOUT	10000
+#define IPQ4019_MDIO_SLEEP		10
 
 struct ipq4019_mdio_data {
 	void __iomem	*membase;
@@ -35,7 +35,7 @@ static int ipq4019_mdio_wait_busy(struct mii_bus *bus)
 
 	return readl_poll_timeout(priv->membase + MDIO_CMD_REG, busy,
 				  (busy & MDIO_CMD_ACCESS_BUSY) == 0,
-				  ipq4019_MDIO_SLEEP, ipq4019_MDIO_TIMEOUT);
+				  IPQ4019_MDIO_SLEEP, IPQ4019_MDIO_TIMEOUT);
 }
 
 static int ipq4019_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v4 2/2] net: mdio-ipq4019: add Clause 45 support
  2020-09-20 14:16 [PATCH v4 0/2] net: mdio-ipq4019: add Clause 45 support Robert Marko
  2020-09-20 14:16 ` [PATCH v4 1/2] net: mdio-ipq4019: change defines to upper case Robert Marko
@ 2020-09-20 14:16 ` Robert Marko
  2020-09-20 14:18   ` Andrew Lunn
  2020-09-21 21:48 ` [PATCH v4 0/2] " David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Robert Marko @ 2020-09-20 14:16 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, kuba, netdev, linux-kernel,
	linux-arm-msm
  Cc: Robert Marko, Luka Perkov

While up-streaming the IPQ4019 driver it was thought that the controller had no Clause 45 support,
but it actually does and its activated by writing a bit to the mode register.

So lets add it as newer SoC-s use the same controller and Clause 45 compliant PHY-s.

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Cc: Luka Perkov <luka.perkov@sartura.hr>
---
Changes since v3:
* Rename MDIO_MODE_BIT to MDIO_MODE_C45

Changes since v2:
* Fix missed reverse christmas tree

Changes since v1:
* Maintain reverse christmas tree

 drivers/net/phy/mdio-ipq4019.c | 103 ++++++++++++++++++++++++++++-----
 1 file changed, 89 insertions(+), 14 deletions(-)

diff --git a/drivers/net/phy/mdio-ipq4019.c b/drivers/net/phy/mdio-ipq4019.c
index 64b169e5a699..25c25ea6da66 100644
--- a/drivers/net/phy/mdio-ipq4019.c
+++ b/drivers/net/phy/mdio-ipq4019.c
@@ -12,6 +12,7 @@
 #include <linux/phy.h>
 #include <linux/platform_device.h>
 
+#define MDIO_MODE_REG				0x40
 #define MDIO_ADDR_REG				0x44
 #define MDIO_DATA_WRITE_REG			0x48
 #define MDIO_DATA_READ_REG			0x4c
@@ -20,6 +21,12 @@
 #define MDIO_CMD_ACCESS_START		BIT(8)
 #define MDIO_CMD_ACCESS_CODE_READ	0
 #define MDIO_CMD_ACCESS_CODE_WRITE	1
+#define MDIO_CMD_ACCESS_CODE_C45_ADDR	0
+#define MDIO_CMD_ACCESS_CODE_C45_WRITE	1
+#define MDIO_CMD_ACCESS_CODE_C45_READ	2
+
+/* 0 = Clause 22, 1 = Clause 45 */
+#define MDIO_MODE_C45				BIT(8)
 
 #define IPQ4019_MDIO_TIMEOUT	10000
 #define IPQ4019_MDIO_SLEEP		10
@@ -41,19 +48,44 @@ static int ipq4019_mdio_wait_busy(struct mii_bus *bus)
 static int ipq4019_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
 {
 	struct ipq4019_mdio_data *priv = bus->priv;
+	unsigned int data;
 	unsigned int cmd;
 
-	/* Reject clause 45 */
-	if (regnum & MII_ADDR_C45)
-		return -EOPNOTSUPP;
-
 	if (ipq4019_mdio_wait_busy(bus))
 		return -ETIMEDOUT;
 
-	/* issue the phy address and reg */
-	writel((mii_id << 8) | regnum, priv->membase + MDIO_ADDR_REG);
+	/* Clause 45 support */
+	if (regnum & MII_ADDR_C45) {
+		unsigned int mmd = (regnum >> 16) & 0x1F;
+		unsigned int reg = regnum & 0xFFFF;
+
+		/* Enter Clause 45 mode */
+		data = readl(priv->membase + MDIO_MODE_REG);
+
+		data |= MDIO_MODE_C45;
+
+		writel(data, priv->membase + MDIO_MODE_REG);
+
+		/* issue the phy address and mmd */
+		writel((mii_id << 8) | mmd, priv->membase + MDIO_ADDR_REG);
+
+		/* issue reg */
+		writel(reg, priv->membase + MDIO_DATA_WRITE_REG);
+
+		cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_C45_ADDR;
+	} else {
+		/* Enter Clause 22 mode */
+		data = readl(priv->membase + MDIO_MODE_REG);
 
-	cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_READ;
+		data &= ~MDIO_MODE_C45;
+
+		writel(data, priv->membase + MDIO_MODE_REG);
+
+		/* issue the phy address and reg */
+		writel((mii_id << 8) | regnum, priv->membase + MDIO_ADDR_REG);
+
+		cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_READ;
+	}
 
 	/* issue read command */
 	writel(cmd, priv->membase + MDIO_CMD_REG);
@@ -62,6 +94,15 @@ static int ipq4019_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
 	if (ipq4019_mdio_wait_busy(bus))
 		return -ETIMEDOUT;
 
+	if (regnum & MII_ADDR_C45) {
+		cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_C45_READ;
+
+		writel(cmd, priv->membase + MDIO_CMD_REG);
+
+		if (ipq4019_mdio_wait_busy(bus))
+			return -ETIMEDOUT;
+	}
+
 	/* Read and return data */
 	return readl(priv->membase + MDIO_DATA_READ_REG);
 }
@@ -70,23 +111,57 @@ static int ipq4019_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
 							 u16 value)
 {
 	struct ipq4019_mdio_data *priv = bus->priv;
+	unsigned int data;
 	unsigned int cmd;
 
-	/* Reject clause 45 */
-	if (regnum & MII_ADDR_C45)
-		return -EOPNOTSUPP;
-
 	if (ipq4019_mdio_wait_busy(bus))
 		return -ETIMEDOUT;
 
-	/* issue the phy address and reg */
-	writel((mii_id << 8) | regnum, priv->membase + MDIO_ADDR_REG);
+	/* Clause 45 support */
+	if (regnum & MII_ADDR_C45) {
+		unsigned int mmd = (regnum >> 16) & 0x1F;
+		unsigned int reg = regnum & 0xFFFF;
+
+		/* Enter Clause 45 mode */
+		data = readl(priv->membase + MDIO_MODE_REG);
+
+		data |= MDIO_MODE_C45;
+
+		writel(data, priv->membase + MDIO_MODE_REG);
+
+		/* issue the phy address and mmd */
+		writel((mii_id << 8) | mmd, priv->membase + MDIO_ADDR_REG);
+
+		/* issue reg */
+		writel(reg, priv->membase + MDIO_DATA_WRITE_REG);
+
+		cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_C45_ADDR;
+
+		writel(cmd, priv->membase + MDIO_CMD_REG);
+
+		if (ipq4019_mdio_wait_busy(bus))
+			return -ETIMEDOUT;
+	} else {
+		/* Enter Clause 22 mode */
+		data = readl(priv->membase + MDIO_MODE_REG);
+
+		data &= ~MDIO_MODE_C45;
+
+		writel(data, priv->membase + MDIO_MODE_REG);
+
+		/* issue the phy address and reg */
+		writel((mii_id << 8) | regnum, priv->membase + MDIO_ADDR_REG);
+	}
 
 	/* issue write data */
 	writel(value, priv->membase + MDIO_DATA_WRITE_REG);
 
-	cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_WRITE;
 	/* issue write command */
+	if (regnum & MII_ADDR_C45)
+		cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_C45_WRITE;
+	else
+		cmd = MDIO_CMD_ACCESS_START | MDIO_CMD_ACCESS_CODE_WRITE;
+
 	writel(cmd, priv->membase + MDIO_CMD_REG);
 
 	/* Wait write complete */
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v4 2/2] net: mdio-ipq4019: add Clause 45 support
  2020-09-20 14:16 ` [PATCH v4 2/2] net: mdio-ipq4019: add Clause 45 support Robert Marko
@ 2020-09-20 14:18   ` Andrew Lunn
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2020-09-20 14:18 UTC (permalink / raw)
  To: Robert Marko
  Cc: hkallweit1, linux, davem, kuba, netdev, linux-kernel,
	linux-arm-msm, Luka Perkov

On Sun, Sep 20, 2020 at 04:16:53PM +0200, Robert Marko wrote:
> While up-streaming the IPQ4019 driver it was thought that the controller had no Clause 45 support,
> but it actually does and its activated by writing a bit to the mode register.
> 
> So lets add it as newer SoC-s use the same controller and Clause 45 compliant PHY-s.
> 
> Signed-off-by: Robert Marko <robert.marko@sartura.hr>
> Cc: Luka Perkov <luka.perkov@sartura.hr>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4 0/2] net: mdio-ipq4019: add Clause 45 support
  2020-09-20 14:16 [PATCH v4 0/2] net: mdio-ipq4019: add Clause 45 support Robert Marko
  2020-09-20 14:16 ` [PATCH v4 1/2] net: mdio-ipq4019: change defines to upper case Robert Marko
  2020-09-20 14:16 ` [PATCH v4 2/2] net: mdio-ipq4019: add Clause 45 support Robert Marko
@ 2020-09-21 21:48 ` David Miller
  2020-09-22 10:17   ` Robert Marko
  2 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2020-09-21 21:48 UTC (permalink / raw)
  To: robert.marko
  Cc: andrew, hkallweit1, linux, kuba, netdev, linux-kernel, linux-arm-msm

From: Robert Marko <robert.marko@sartura.hr>
Date: Sun, 20 Sep 2020 16:16:51 +0200

> This patch series adds support for Clause 45 to the driver.
> 
> While at it also change some defines to upper case to match rest of the driver.
> 
> Changes since v1:
> * Drop clock patches, these need further investigation and
> no user for non default configuration has been found

Please respin, in the net-next tree the MDIO drivers have been moved
into their own directory.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4 0/2] net: mdio-ipq4019: add Clause 45 support
  2020-09-21 21:48 ` [PATCH v4 0/2] " David Miller
@ 2020-09-22 10:17   ` Robert Marko
  0 siblings, 0 replies; 6+ messages in thread
From: Robert Marko @ 2020-09-22 10:17 UTC (permalink / raw)
  To: David Miller
  Cc: Andrew Lunn, Heiner Kallweit, Russell King - ARM Linux admin,
	kuba, netdev, linux-kernel, linux-arm-msm

On Mon, Sep 21, 2020 at 11:48 PM David Miller <davem@davemloft.net> wrote:
>
> From: Robert Marko <robert.marko@sartura.hr>
> Date: Sun, 20 Sep 2020 16:16:51 +0200
>
> > This patch series adds support for Clause 45 to the driver.
> >
> > While at it also change some defines to upper case to match rest of the driver.
> >
> > Changes since v1:
> > * Drop clock patches, these need further investigation and
> > no user for non default configuration has been found
>
> Please respin, in the net-next tree the MDIO drivers have been moved
> into their own directory.

Done,
I completely missed the commit moving them to MDIO subdirectory.

Regards
Robert

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-09-22 10:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-20 14:16 [PATCH v4 0/2] net: mdio-ipq4019: add Clause 45 support Robert Marko
2020-09-20 14:16 ` [PATCH v4 1/2] net: mdio-ipq4019: change defines to upper case Robert Marko
2020-09-20 14:16 ` [PATCH v4 2/2] net: mdio-ipq4019: add Clause 45 support Robert Marko
2020-09-20 14:18   ` Andrew Lunn
2020-09-21 21:48 ` [PATCH v4 0/2] " David Miller
2020-09-22 10:17   ` Robert Marko

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.