All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] net: mvmdio: add xSMI support
@ 2017-06-07  8:38 ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: davem, jason, andrew, gregory.clement, sebastian.hesselbarth, f.fainelli
  Cc: Antoine Tenart, thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

Hello,

This series aims to add the xSMI support (also called xMDIO) to the
mvmdio driver. The xSMI interface complies with the IEEE 802.3 clause 45
and is used by 10GbE devices. On 7k and 8k (as of now), such an
interface is found and is used by Ethernet controllers.

Patches 1-3 are cosmetic cleanups.

Patches 4-6 are prerequisites to the xSMI support.

Patches 7-9 add the xSMI support to the mvmdio driver, and a node is
added both in the cp110 slave and master device trees.

This was tested on an Armada 8040 mcbin, as well as on both the
Armada 7040 DB and the Armada 8040 DB to ensure the SMI interface
was still working.

Thanks,
Antoine

Antoine Tenart (9):
  net: mvmdio: reorder headers alphabetically
  net: mvmdio: use tabs for defines
  net: mvmdio: use GENMASK for masks
  net: mvmdio: move the read valid check into its own function
  net: mvmdio: introduce an ops structure
  net: mvmdio: put the poll intervals in the private structure
  net: mvmdio: add xmdio support
  dt-bindings: orion-mdio: document the new xmdio compatible
  arm64: marvell: dts: add xmdio nodes for 7k/8k

 .../devicetree/bindings/net/marvell-orion-mdio.txt |   8 +-
 .../boot/dts/marvell/armada-cp110-master.dtsi      |   7 +
 .../arm64/boot/dts/marvell/armada-cp110-slave.dtsi |   7 +
 drivers/net/ethernet/marvell/Kconfig               |   6 +-
 drivers/net/ethernet/marvell/mvmdio.c              | 200 +++++++++++++++++----
 5 files changed, 184 insertions(+), 44 deletions(-)

-- 
2.9.4

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

* [PATCH 0/9] net: mvmdio: add xSMI support
@ 2017-06-07  8:38 ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

This series aims to add the xSMI support (also called xMDIO) to the
mvmdio driver. The xSMI interface complies with the IEEE 802.3 clause 45
and is used by 10GbE devices. On 7k and 8k (as of now), such an
interface is found and is used by Ethernet controllers.

Patches 1-3 are cosmetic cleanups.

Patches 4-6 are prerequisites to the xSMI support.

Patches 7-9 add the xSMI support to the mvmdio driver, and a node is
added both in the cp110 slave and master device trees.

This was tested on an Armada 8040 mcbin, as well as on both the
Armada 7040 DB and the Armada 8040 DB to ensure the SMI interface
was still working.

Thanks,
Antoine

Antoine Tenart (9):
  net: mvmdio: reorder headers alphabetically
  net: mvmdio: use tabs for defines
  net: mvmdio: use GENMASK for masks
  net: mvmdio: move the read valid check into its own function
  net: mvmdio: introduce an ops structure
  net: mvmdio: put the poll intervals in the private structure
  net: mvmdio: add xmdio support
  dt-bindings: orion-mdio: document the new xmdio compatible
  arm64: marvell: dts: add xmdio nodes for 7k/8k

 .../devicetree/bindings/net/marvell-orion-mdio.txt |   8 +-
 .../boot/dts/marvell/armada-cp110-master.dtsi      |   7 +
 .../arm64/boot/dts/marvell/armada-cp110-slave.dtsi |   7 +
 drivers/net/ethernet/marvell/Kconfig               |   6 +-
 drivers/net/ethernet/marvell/mvmdio.c              | 200 +++++++++++++++++----
 5 files changed, 184 insertions(+), 44 deletions(-)

-- 
2.9.4

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

* [PATCH 1/9] net: mvmdio: reorder headers alphabetically
  2017-06-07  8:38 ` Antoine Tenart
@ 2017-06-07  8:38   ` Antoine Tenart
  -1 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: davem, jason, andrew, gregory.clement, sebastian.hesselbarth, f.fainelli
  Cc: thomas.petazzoni, netdev, Antoine Tenart, linux, mw, linux-arm-kernel

Cosmetic fix reordering headers alphabetically.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvmdio.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 90a60b98c28e..109a2bff334d 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -17,16 +17,16 @@
  * warranty of any kind, whether express or implied.
  */
 
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/of_mdio.h>
 #include <linux/phy.h>
-#include <linux/interrupt.h>
 #include <linux/platform_device.h>
-#include <linux/delay.h>
-#include <linux/io.h>
-#include <linux/clk.h>
-#include <linux/of_mdio.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
 
-- 
2.9.4

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

* [PATCH 1/9] net: mvmdio: reorder headers alphabetically
@ 2017-06-07  8:38   ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Cosmetic fix reordering headers alphabetically.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvmdio.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 90a60b98c28e..109a2bff334d 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -17,16 +17,16 @@
  * warranty of any kind, whether express or implied.
  */
 
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/of_mdio.h>
 #include <linux/phy.h>
-#include <linux/interrupt.h>
 #include <linux/platform_device.h>
-#include <linux/delay.h>
-#include <linux/io.h>
-#include <linux/clk.h>
-#include <linux/of_mdio.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
 
-- 
2.9.4

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

* [PATCH 2/9] net: mvmdio: use tabs for defines
  2017-06-07  8:38 ` Antoine Tenart
@ 2017-06-07  8:38   ` Antoine Tenart
  -1 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: davem, jason, andrew, gregory.clement, sebastian.hesselbarth, f.fainelli
  Cc: Antoine Tenart, thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

Cosmetic patch replacing spaces by tabs for defined values.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvmdio.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 109a2bff334d..17b518b13ae3 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -30,25 +30,25 @@
 #include <linux/sched.h>
 #include <linux/wait.h>
 
-#define MVMDIO_SMI_DATA_SHIFT              0
-#define MVMDIO_SMI_PHY_ADDR_SHIFT          16
-#define MVMDIO_SMI_PHY_REG_SHIFT           21
-#define MVMDIO_SMI_READ_OPERATION          BIT(26)
-#define MVMDIO_SMI_WRITE_OPERATION         0
-#define MVMDIO_SMI_READ_VALID              BIT(27)
-#define MVMDIO_SMI_BUSY                    BIT(28)
-#define MVMDIO_ERR_INT_CAUSE		   0x007C
-#define  MVMDIO_ERR_INT_SMI_DONE	   0x00000010
-#define MVMDIO_ERR_INT_MASK		   0x0080
+#define MVMDIO_SMI_DATA_SHIFT		0
+#define MVMDIO_SMI_PHY_ADDR_SHIFT	16
+#define MVMDIO_SMI_PHY_REG_SHIFT	21
+#define MVMDIO_SMI_READ_OPERATION	BIT(26)
+#define MVMDIO_SMI_WRITE_OPERATION	0
+#define MVMDIO_SMI_READ_VALID		BIT(27)
+#define MVMDIO_SMI_BUSY			BIT(28)
+#define MVMDIO_ERR_INT_CAUSE		0x007C
+#define  MVMDIO_ERR_INT_SMI_DONE	0x00000010
+#define MVMDIO_ERR_INT_MASK		0x0080
 
 /*
  * SMI Timeout measurements:
  * - Kirkwood 88F6281 (Globalscale Dreamplug): 45us to 95us (Interrupt)
  * - Armada 370       (Globalscale Mirabox):   41us to 43us (Polled)
  */
-#define MVMDIO_SMI_TIMEOUT		   1000 /* 1000us = 1ms */
-#define MVMDIO_SMI_POLL_INTERVAL_MIN	   45
-#define MVMDIO_SMI_POLL_INTERVAL_MAX	   55
+#define MVMDIO_SMI_TIMEOUT		1000 /* 1000us = 1ms */
+#define MVMDIO_SMI_POLL_INTERVAL_MIN	45
+#define MVMDIO_SMI_POLL_INTERVAL_MAX	55
 
 struct orion_mdio_dev {
 	struct mutex lock;
-- 
2.9.4

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

* [PATCH 2/9] net: mvmdio: use tabs for defines
@ 2017-06-07  8:38   ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Cosmetic patch replacing spaces by tabs for defined values.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvmdio.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 109a2bff334d..17b518b13ae3 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -30,25 +30,25 @@
 #include <linux/sched.h>
 #include <linux/wait.h>
 
-#define MVMDIO_SMI_DATA_SHIFT              0
-#define MVMDIO_SMI_PHY_ADDR_SHIFT          16
-#define MVMDIO_SMI_PHY_REG_SHIFT           21
-#define MVMDIO_SMI_READ_OPERATION          BIT(26)
-#define MVMDIO_SMI_WRITE_OPERATION         0
-#define MVMDIO_SMI_READ_VALID              BIT(27)
-#define MVMDIO_SMI_BUSY                    BIT(28)
-#define MVMDIO_ERR_INT_CAUSE		   0x007C
-#define  MVMDIO_ERR_INT_SMI_DONE	   0x00000010
-#define MVMDIO_ERR_INT_MASK		   0x0080
+#define MVMDIO_SMI_DATA_SHIFT		0
+#define MVMDIO_SMI_PHY_ADDR_SHIFT	16
+#define MVMDIO_SMI_PHY_REG_SHIFT	21
+#define MVMDIO_SMI_READ_OPERATION	BIT(26)
+#define MVMDIO_SMI_WRITE_OPERATION	0
+#define MVMDIO_SMI_READ_VALID		BIT(27)
+#define MVMDIO_SMI_BUSY			BIT(28)
+#define MVMDIO_ERR_INT_CAUSE		0x007C
+#define  MVMDIO_ERR_INT_SMI_DONE	0x00000010
+#define MVMDIO_ERR_INT_MASK		0x0080
 
 /*
  * SMI Timeout measurements:
  * - Kirkwood 88F6281 (Globalscale Dreamplug): 45us to 95us (Interrupt)
  * - Armada 370       (Globalscale Mirabox):   41us to 43us (Polled)
  */
-#define MVMDIO_SMI_TIMEOUT		   1000 /* 1000us = 1ms */
-#define MVMDIO_SMI_POLL_INTERVAL_MIN	   45
-#define MVMDIO_SMI_POLL_INTERVAL_MAX	   55
+#define MVMDIO_SMI_TIMEOUT		1000 /* 1000us = 1ms */
+#define MVMDIO_SMI_POLL_INTERVAL_MIN	45
+#define MVMDIO_SMI_POLL_INTERVAL_MAX	55
 
 struct orion_mdio_dev {
 	struct mutex lock;
-- 
2.9.4

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

* [PATCH 3/9] net: mvmdio: use GENMASK for masks
  2017-06-07  8:38 ` Antoine Tenart
@ 2017-06-07  8:38   ` Antoine Tenart
  -1 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: davem, jason, andrew, gregory.clement, sebastian.hesselbarth, f.fainelli
  Cc: Antoine Tenart, thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

Cosmetic patch to use the GENMASK helper for masks.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvmdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 17b518b13ae3..96af8d57d9e5 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -138,7 +138,7 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
 		goto out;
 	}
 
-	ret = val & 0xFFFF;
+	ret = val & GENMASK(15,0);
 out:
 	mutex_unlock(&dev->lock);
 	return ret;
-- 
2.9.4

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

* [PATCH 3/9] net: mvmdio: use GENMASK for masks
@ 2017-06-07  8:38   ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Cosmetic patch to use the GENMASK helper for masks.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvmdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 17b518b13ae3..96af8d57d9e5 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -138,7 +138,7 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
 		goto out;
 	}
 
-	ret = val & 0xFFFF;
+	ret = val & GENMASK(15,0);
 out:
 	mutex_unlock(&dev->lock);
 	return ret;
-- 
2.9.4

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

* [PATCH 4/9] net: mvmdio: move the read valid check into its own function
  2017-06-07  8:38 ` Antoine Tenart
@ 2017-06-07  8:38   ` Antoine Tenart
  -1 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: davem, jason, andrew, gregory.clement, sebastian.hesselbarth, f.fainelli
  Cc: Antoine Tenart, thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

Move the read valid check in its own function. This is needed as a
requirement to factorize the driver to add the xMDIO support in the
future.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvmdio.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 96af8d57d9e5..56bbe3990590 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -69,6 +69,11 @@ static int orion_mdio_smi_is_done(struct orion_mdio_dev *dev)
 	return !(readl(dev->regs) & MVMDIO_SMI_BUSY);
 }
 
+static int orion_mdio_smi_is_read_valid(struct orion_mdio_dev *dev)
+{
+	return !(readl(dev->regs) & MVMDIO_SMI_READ_VALID);
+}
+
 /* Wait for the SMI unit to be ready for another operation
  */
 static int orion_mdio_wait_ready(struct mii_bus *bus)
@@ -113,7 +118,6 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
 			   int regnum)
 {
 	struct orion_mdio_dev *dev = bus->priv;
-	u32 val;
 	int ret;
 
 	mutex_lock(&dev->lock);
@@ -131,14 +135,13 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
 	if (ret < 0)
 		goto out;
 
-	val = readl(dev->regs);
-	if (!(val & MVMDIO_SMI_READ_VALID)) {
+	if (orion_mdio_smi_is_read_valid(dev)) {
 		dev_err(bus->parent, "SMI bus read not valid\n");
 		ret = -ENODEV;
 		goto out;
 	}
 
-	ret = val & GENMASK(15,0);
+	ret = readl(dev->regs) & GENMASK(15,0);
 out:
 	mutex_unlock(&dev->lock);
 	return ret;
-- 
2.9.4

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

* [PATCH 4/9] net: mvmdio: move the read valid check into its own function
@ 2017-06-07  8:38   ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Move the read valid check in its own function. This is needed as a
requirement to factorize the driver to add the xMDIO support in the
future.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvmdio.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 96af8d57d9e5..56bbe3990590 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -69,6 +69,11 @@ static int orion_mdio_smi_is_done(struct orion_mdio_dev *dev)
 	return !(readl(dev->regs) & MVMDIO_SMI_BUSY);
 }
 
+static int orion_mdio_smi_is_read_valid(struct orion_mdio_dev *dev)
+{
+	return !(readl(dev->regs) & MVMDIO_SMI_READ_VALID);
+}
+
 /* Wait for the SMI unit to be ready for another operation
  */
 static int orion_mdio_wait_ready(struct mii_bus *bus)
@@ -113,7 +118,6 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
 			   int regnum)
 {
 	struct orion_mdio_dev *dev = bus->priv;
-	u32 val;
 	int ret;
 
 	mutex_lock(&dev->lock);
@@ -131,14 +135,13 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
 	if (ret < 0)
 		goto out;
 
-	val = readl(dev->regs);
-	if (!(val & MVMDIO_SMI_READ_VALID)) {
+	if (orion_mdio_smi_is_read_valid(dev)) {
 		dev_err(bus->parent, "SMI bus read not valid\n");
 		ret = -ENODEV;
 		goto out;
 	}
 
-	ret = val & GENMASK(15,0);
+	ret = readl(dev->regs) & GENMASK(15,0);
 out:
 	mutex_unlock(&dev->lock);
 	return ret;
-- 
2.9.4

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

* [PATCH 5/9] net: mvmdio: introduce an ops structure
  2017-06-07  8:38 ` Antoine Tenart
@ 2017-06-07  8:38   ` Antoine Tenart
  -1 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: davem, jason, andrew, gregory.clement, sebastian.hesselbarth, f.fainelli
  Cc: Antoine Tenart, thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

Introduce an ops structure to add an indirection on functions accessing
the registers. This is needed to add the xMDIO support later.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvmdio.c | 65 +++++++++++++++++++++++++++--------
 1 file changed, 51 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 56bbe3990590..8a71ef93a61b 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -62,6 +62,15 @@ struct orion_mdio_dev {
 	 */
 	int err_interrupt;
 	wait_queue_head_t smi_busy_wait;
+	struct orion_mdio_ops *ops;
+};
+
+struct orion_mdio_ops {
+	int (*is_done)(struct orion_mdio_dev *);
+	int (*is_read_valid)(struct orion_mdio_dev *);
+	void (*start_read)(struct orion_mdio_dev *, int, int);
+	u16 (*read)(struct orion_mdio_dev *);
+	void (*write)(struct orion_mdio_dev *, int, int, u16);
 };
 
 static int orion_mdio_smi_is_done(struct orion_mdio_dev *dev)
@@ -74,6 +83,30 @@ static int orion_mdio_smi_is_read_valid(struct orion_mdio_dev *dev)
 	return !(readl(dev->regs) & MVMDIO_SMI_READ_VALID);
 }
 
+static void orion_mdio_start_read_op(struct orion_mdio_dev *dev, int mii_id,
+				     int regnum)
+{
+	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
+		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
+		MVMDIO_SMI_READ_OPERATION),
+	       dev->regs);
+}
+
+static u16 orion_mdio_read_op(struct orion_mdio_dev *dev)
+{
+	return readl(dev->regs) & GENMASK(15,0);
+}
+
+static void orion_mdio_write_op(struct orion_mdio_dev *dev, int mii_id,
+				int regnum, u16 value)
+{
+	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
+		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
+		MVMDIO_SMI_WRITE_OPERATION            |
+		(value << MVMDIO_SMI_DATA_SHIFT)),
+	       dev->regs);
+}
+
 /* Wait for the SMI unit to be ready for another operation
  */
 static int orion_mdio_wait_ready(struct mii_bus *bus)
@@ -84,7 +117,7 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
 	int timedout = 0;
 
 	while (1) {
-	        if (orion_mdio_smi_is_done(dev))
+	        if (dev->ops->is_done(dev))
 			return 0;
 	        else if (timedout)
 			break;
@@ -103,8 +136,7 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
 			if (timeout < 2)
 				timeout = 2;
 			wait_event_timeout(dev->smi_busy_wait,
-				           orion_mdio_smi_is_done(dev),
-				           timeout);
+				           dev->ops->is_done(dev), timeout);
 
 			++timedout;
 	        }
@@ -126,22 +158,19 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
 	if (ret < 0)
 		goto out;
 
-	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
-		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
-		MVMDIO_SMI_READ_OPERATION),
-	       dev->regs);
+	dev->ops->start_read(dev, mii_id, regnum);
 
 	ret = orion_mdio_wait_ready(bus);
 	if (ret < 0)
 		goto out;
 
-	if (orion_mdio_smi_is_read_valid(dev)) {
+	if (dev->ops->is_read_valid(dev)) {
 		dev_err(bus->parent, "SMI bus read not valid\n");
 		ret = -ENODEV;
 		goto out;
 	}
 
-	ret = readl(dev->regs) & GENMASK(15,0);
+	ret = dev->ops->read(dev);
 out:
 	mutex_unlock(&dev->lock);
 	return ret;
@@ -159,11 +188,7 @@ static int orion_mdio_write(struct mii_bus *bus, int mii_id,
 	if (ret < 0)
 		goto out;
 
-	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
-		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
-		MVMDIO_SMI_WRITE_OPERATION            |
-		(value << MVMDIO_SMI_DATA_SHIFT)),
-	       dev->regs);
+	dev->ops->write(dev, mii_id, regnum, value);
 
 out:
 	mutex_unlock(&dev->lock);
@@ -190,6 +215,7 @@ static int orion_mdio_probe(struct platform_device *pdev)
 	struct resource *r;
 	struct mii_bus *bus;
 	struct orion_mdio_dev *dev;
+	struct orion_mdio_ops *ops;
 	int i, ret;
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -249,6 +275,17 @@ static int orion_mdio_probe(struct platform_device *pdev)
 
 	mutex_init(&dev->lock);
 
+	ops = devm_kzalloc(&pdev->dev, sizeof(*ops), GFP_KERNEL);
+	if (!ops)
+		return -ENOMEM;
+
+	ops->is_done = orion_mdio_smi_is_done;
+	ops->is_read_valid = orion_mdio_smi_is_read_valid;
+	ops->start_read = orion_mdio_start_read_op;
+	ops->read = orion_mdio_read_op;
+	ops->write = orion_mdio_write_op;
+	dev->ops = ops;
+
 	if (pdev->dev.of_node)
 		ret = of_mdiobus_register(bus, pdev->dev.of_node);
 	else
-- 
2.9.4

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

* [PATCH 5/9] net: mvmdio: introduce an ops structure
@ 2017-06-07  8:38   ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Introduce an ops structure to add an indirection on functions accessing
the registers. This is needed to add the xMDIO support later.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvmdio.c | 65 +++++++++++++++++++++++++++--------
 1 file changed, 51 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 56bbe3990590..8a71ef93a61b 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -62,6 +62,15 @@ struct orion_mdio_dev {
 	 */
 	int err_interrupt;
 	wait_queue_head_t smi_busy_wait;
+	struct orion_mdio_ops *ops;
+};
+
+struct orion_mdio_ops {
+	int (*is_done)(struct orion_mdio_dev *);
+	int (*is_read_valid)(struct orion_mdio_dev *);
+	void (*start_read)(struct orion_mdio_dev *, int, int);
+	u16 (*read)(struct orion_mdio_dev *);
+	void (*write)(struct orion_mdio_dev *, int, int, u16);
 };
 
 static int orion_mdio_smi_is_done(struct orion_mdio_dev *dev)
@@ -74,6 +83,30 @@ static int orion_mdio_smi_is_read_valid(struct orion_mdio_dev *dev)
 	return !(readl(dev->regs) & MVMDIO_SMI_READ_VALID);
 }
 
+static void orion_mdio_start_read_op(struct orion_mdio_dev *dev, int mii_id,
+				     int regnum)
+{
+	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
+		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
+		MVMDIO_SMI_READ_OPERATION),
+	       dev->regs);
+}
+
+static u16 orion_mdio_read_op(struct orion_mdio_dev *dev)
+{
+	return readl(dev->regs) & GENMASK(15,0);
+}
+
+static void orion_mdio_write_op(struct orion_mdio_dev *dev, int mii_id,
+				int regnum, u16 value)
+{
+	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
+		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
+		MVMDIO_SMI_WRITE_OPERATION            |
+		(value << MVMDIO_SMI_DATA_SHIFT)),
+	       dev->regs);
+}
+
 /* Wait for the SMI unit to be ready for another operation
  */
 static int orion_mdio_wait_ready(struct mii_bus *bus)
@@ -84,7 +117,7 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
 	int timedout = 0;
 
 	while (1) {
-	        if (orion_mdio_smi_is_done(dev))
+	        if (dev->ops->is_done(dev))
 			return 0;
 	        else if (timedout)
 			break;
@@ -103,8 +136,7 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
 			if (timeout < 2)
 				timeout = 2;
 			wait_event_timeout(dev->smi_busy_wait,
-				           orion_mdio_smi_is_done(dev),
-				           timeout);
+				           dev->ops->is_done(dev), timeout);
 
 			++timedout;
 	        }
@@ -126,22 +158,19 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
 	if (ret < 0)
 		goto out;
 
-	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
-		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
-		MVMDIO_SMI_READ_OPERATION),
-	       dev->regs);
+	dev->ops->start_read(dev, mii_id, regnum);
 
 	ret = orion_mdio_wait_ready(bus);
 	if (ret < 0)
 		goto out;
 
-	if (orion_mdio_smi_is_read_valid(dev)) {
+	if (dev->ops->is_read_valid(dev)) {
 		dev_err(bus->parent, "SMI bus read not valid\n");
 		ret = -ENODEV;
 		goto out;
 	}
 
-	ret = readl(dev->regs) & GENMASK(15,0);
+	ret = dev->ops->read(dev);
 out:
 	mutex_unlock(&dev->lock);
 	return ret;
@@ -159,11 +188,7 @@ static int orion_mdio_write(struct mii_bus *bus, int mii_id,
 	if (ret < 0)
 		goto out;
 
-	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
-		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
-		MVMDIO_SMI_WRITE_OPERATION            |
-		(value << MVMDIO_SMI_DATA_SHIFT)),
-	       dev->regs);
+	dev->ops->write(dev, mii_id, regnum, value);
 
 out:
 	mutex_unlock(&dev->lock);
@@ -190,6 +215,7 @@ static int orion_mdio_probe(struct platform_device *pdev)
 	struct resource *r;
 	struct mii_bus *bus;
 	struct orion_mdio_dev *dev;
+	struct orion_mdio_ops *ops;
 	int i, ret;
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -249,6 +275,17 @@ static int orion_mdio_probe(struct platform_device *pdev)
 
 	mutex_init(&dev->lock);
 
+	ops = devm_kzalloc(&pdev->dev, sizeof(*ops), GFP_KERNEL);
+	if (!ops)
+		return -ENOMEM;
+
+	ops->is_done = orion_mdio_smi_is_done;
+	ops->is_read_valid = orion_mdio_smi_is_read_valid;
+	ops->start_read = orion_mdio_start_read_op;
+	ops->read = orion_mdio_read_op;
+	ops->write = orion_mdio_write_op;
+	dev->ops = ops;
+
 	if (pdev->dev.of_node)
 		ret = of_mdiobus_register(bus, pdev->dev.of_node);
 	else
-- 
2.9.4

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

* [PATCH 6/9] net: mvmdio: put the poll intervals in the private structure
  2017-06-07  8:38 ` Antoine Tenart
@ 2017-06-07  8:38   ` Antoine Tenart
  -1 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: davem, jason, andrew, gregory.clement, sebastian.hesselbarth, f.fainelli
  Cc: Antoine Tenart, thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

Put the two poll intervals (min and max) in the driver's private
structure. This is needed to add the xmdio support later.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvmdio.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 8a71ef93a61b..3cb3dd3331d8 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -63,6 +63,9 @@ struct orion_mdio_dev {
 	int err_interrupt;
 	wait_queue_head_t smi_busy_wait;
 	struct orion_mdio_ops *ops;
+
+	unsigned int poll_interval_min;
+	unsigned int poll_interval_max;
 };
 
 struct orion_mdio_ops {
@@ -123,8 +126,8 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
 			break;
 
 	        if (dev->err_interrupt <= 0) {
-			usleep_range(MVMDIO_SMI_POLL_INTERVAL_MIN,
-				     MVMDIO_SMI_POLL_INTERVAL_MAX);
+			usleep_range(dev->poll_interval_min,
+				     dev->poll_interval_max);
 
 			if (time_is_before_jiffies(end))
 				++timedout;
@@ -279,6 +282,8 @@ static int orion_mdio_probe(struct platform_device *pdev)
 	if (!ops)
 		return -ENOMEM;
 
+	dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
+	dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
 	ops->is_done = orion_mdio_smi_is_done;
 	ops->is_read_valid = orion_mdio_smi_is_read_valid;
 	ops->start_read = orion_mdio_start_read_op;
-- 
2.9.4

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

* [PATCH 6/9] net: mvmdio: put the poll intervals in the private structure
@ 2017-06-07  8:38   ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Put the two poll intervals (min and max) in the driver's private
structure. This is needed to add the xmdio support later.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvmdio.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 8a71ef93a61b..3cb3dd3331d8 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -63,6 +63,9 @@ struct orion_mdio_dev {
 	int err_interrupt;
 	wait_queue_head_t smi_busy_wait;
 	struct orion_mdio_ops *ops;
+
+	unsigned int poll_interval_min;
+	unsigned int poll_interval_max;
 };
 
 struct orion_mdio_ops {
@@ -123,8 +126,8 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
 			break;
 
 	        if (dev->err_interrupt <= 0) {
-			usleep_range(MVMDIO_SMI_POLL_INTERVAL_MIN,
-				     MVMDIO_SMI_POLL_INTERVAL_MAX);
+			usleep_range(dev->poll_interval_min,
+				     dev->poll_interval_max);
 
 			if (time_is_before_jiffies(end))
 				++timedout;
@@ -279,6 +282,8 @@ static int orion_mdio_probe(struct platform_device *pdev)
 	if (!ops)
 		return -ENOMEM;
 
+	dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
+	dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
 	ops->is_done = orion_mdio_smi_is_done;
 	ops->is_read_valid = orion_mdio_smi_is_read_valid;
 	ops->start_read = orion_mdio_start_read_op;
-- 
2.9.4

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

* [PATCH 7/9] net: mvmdio: add xmdio support
  2017-06-07  8:38 ` Antoine Tenart
@ 2017-06-07  8:38   ` Antoine Tenart
  -1 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: davem, jason, andrew, gregory.clement, sebastian.hesselbarth, f.fainelli
  Cc: Antoine Tenart, thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

This patch adds the xMDIO interface support in the mvmdio driver. This
interface is used in Ethernet controllers on Marvell 370, 7k and 8k (as
of now). The xSMI interface supported by this driver complies with the
IEEE 802.3 clause 45 (while the SMI interface complies with the clause
22). The xSMI interface is used by 10GbE devices.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/Kconfig  |   6 +-
 drivers/net/ethernet/marvell/mvmdio.c | 121 ++++++++++++++++++++++++++++------
 2 files changed, 104 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/marvell/Kconfig b/drivers/net/ethernet/marvell/Kconfig
index da6fb825afea..205bb7e683b7 100644
--- a/drivers/net/ethernet/marvell/Kconfig
+++ b/drivers/net/ethernet/marvell/Kconfig
@@ -35,9 +35,9 @@ config MVMDIO
 	depends on HAS_IOMEM
 	select PHYLIB
 	---help---
-	  This driver supports the MDIO interface found in the network
-	  interface units of the Marvell EBU SoCs (Kirkwood, Orion5x,
-	  Dove, Armada 370 and Armada XP).
+	  This driver supports the MDIO and xMDIO interfaces found in
+	  the network interface units of the Marvell EBU SoCs (Kirkwood,
+	  Orion5x, Dove, Armada 370, Armada XP, Armada 7k and Armada 8k).
 
 	  This driver is used by the MV643XX_ETH and MVNETA drivers.
 
diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 3cb3dd3331d8..13b198aca5c1 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -41,6 +41,15 @@
 #define  MVMDIO_ERR_INT_SMI_DONE	0x00000010
 #define MVMDIO_ERR_INT_MASK		0x0080
 
+#define MVMDIO_XSMI_MGNT_REG		0x0
+#define  MVMDIO_XSMI_READ_VALID		BIT(29)
+#define  MVMDIO_XSMI_BUSY		BIT(30)
+#define MVMDIO_XSMI_ADDR_REG		0x8
+#define  MVMDIO_XSMI_PHYADDR_SHIFT	16
+#define  MVMDIO_XSMI_DEVADDR_SHIFT	21
+#define  MVMDIO_XSMI_READ_OPERATION	(0x7 << 26)
+#define  MVMDIO_XSMI_WRITE_OPERATION	(0x5 << 27)
+
 /*
  * SMI Timeout measurements:
  * - Kirkwood 88F6281 (Globalscale Dreamplug): 45us to 95us (Interrupt)
@@ -50,6 +59,9 @@
 #define MVMDIO_SMI_POLL_INTERVAL_MIN	45
 #define MVMDIO_SMI_POLL_INTERVAL_MAX	55
 
+#define MVMDIO_XSMI_POLL_INTERVAL_MIN	150
+#define MVMDIO_XSMI_POLL_INTERVAL_MAX	160
+
 struct orion_mdio_dev {
 	struct mutex lock;
 	void __iomem *regs;
@@ -76,18 +88,19 @@ struct orion_mdio_ops {
 	void (*write)(struct orion_mdio_dev *, int, int, u16);
 };
 
-static int orion_mdio_smi_is_done(struct orion_mdio_dev *dev)
+/* smi */
+static int smi_is_done(struct orion_mdio_dev *dev)
 {
 	return !(readl(dev->regs) & MVMDIO_SMI_BUSY);
 }
 
-static int orion_mdio_smi_is_read_valid(struct orion_mdio_dev *dev)
+static int smi_is_read_valid(struct orion_mdio_dev *dev)
 {
 	return !(readl(dev->regs) & MVMDIO_SMI_READ_VALID);
 }
 
-static void orion_mdio_start_read_op(struct orion_mdio_dev *dev, int mii_id,
-				     int regnum)
+static void smi_start_read_op(struct orion_mdio_dev *dev, int mii_id,
+			      int regnum)
 {
 	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
 		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
@@ -95,13 +108,13 @@ static void orion_mdio_start_read_op(struct orion_mdio_dev *dev, int mii_id,
 	       dev->regs);
 }
 
-static u16 orion_mdio_read_op(struct orion_mdio_dev *dev)
+static u16 smi_read_op(struct orion_mdio_dev *dev)
 {
 	return readl(dev->regs) & GENMASK(15,0);
 }
 
-static void orion_mdio_write_op(struct orion_mdio_dev *dev, int mii_id,
-				int regnum, u16 value)
+static void smi_write_op(struct orion_mdio_dev *dev, int mii_id,
+			 int regnum, u16 value)
 {
 	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
 		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
@@ -110,6 +123,47 @@ static void orion_mdio_write_op(struct orion_mdio_dev *dev, int mii_id,
 	       dev->regs);
 }
 
+/* xsmi */
+static int xsmi_is_done(struct orion_mdio_dev *dev)
+{
+	return !(readl(dev->regs + MVMDIO_XSMI_MGNT_REG) & MVMDIO_XSMI_BUSY);
+}
+
+static int xsmi_is_read_valid(struct orion_mdio_dev *dev)
+{
+	return !(readl(dev->regs + MVMDIO_XSMI_MGNT_REG) &
+		 MVMDIO_XSMI_READ_VALID);
+}
+
+static void xsmi_start_read_op(struct orion_mdio_dev *dev, int mii_id,
+			      int regnum)
+{
+	u16 dev_addr = regnum >> 16;
+
+	writel(regnum & GENMASK(15,0), dev->regs + MVMDIO_XSMI_ADDR_REG);
+	writel((mii_id << MVMDIO_XSMI_PHYADDR_SHIFT) |
+	       (dev_addr << MVMDIO_XSMI_DEVADDR_SHIFT) |
+	       MVMDIO_XSMI_READ_OPERATION,
+	       dev->regs + MVMDIO_XSMI_MGNT_REG);
+}
+
+static u16 xsmi_read_op(struct orion_mdio_dev *dev)
+{
+	return readl(dev->regs + MVMDIO_XSMI_MGNT_REG) & GENMASK(15,0);
+}
+
+static void xsmi_write_op(struct orion_mdio_dev *dev, int mii_id,
+			 int regnum, u16 value)
+{
+	u16 dev_addr = regnum >> 16;
+
+	writel(regnum & GENMASK(15,0), dev->regs + MVMDIO_XSMI_ADDR_REG);
+	writel((mii_id << MVMDIO_XSMI_PHYADDR_SHIFT) |
+	       (dev_addr << MVMDIO_XSMI_DEVADDR_SHIFT) |
+	       MVMDIO_XSMI_WRITE_OPERATION | value,
+	       dev->regs + MVMDIO_XSMI_MGNT_REG);
+}
+
 /* Wait for the SMI unit to be ready for another operation
  */
 static int orion_mdio_wait_ready(struct mii_bus *bus)
@@ -213,12 +267,47 @@ static irqreturn_t orion_mdio_err_irq(int irq, void *dev_id)
 	return IRQ_NONE;
 }
 
+static int orion_mdio_populate_ops(struct platform_device *pdev,
+				   struct orion_mdio_dev *dev)
+{
+	struct orion_mdio_ops *ops;
+	struct device_node *np = pdev->dev.of_node;
+
+	ops = devm_kzalloc(&pdev->dev, sizeof(*ops), GFP_KERNEL);
+	if (!ops)
+		return -ENOMEM;
+
+	if (of_device_is_compatible(np, "marvell,orion-mdio")) {
+		ops->is_done = smi_is_done;
+		ops->is_read_valid = smi_is_read_valid;
+		ops->start_read = smi_start_read_op;
+		ops->read = smi_read_op;
+		ops->write = smi_write_op;
+
+		dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
+		dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
+	} else if (of_device_is_compatible(np, "marvell,xmdio")) {
+		ops->is_done = xsmi_is_done;
+		ops->is_read_valid = xsmi_is_read_valid;
+		ops->start_read = xsmi_start_read_op;
+		ops->read = xsmi_read_op;
+		ops->write = xsmi_write_op;
+
+		dev->poll_interval_min = MVMDIO_XSMI_POLL_INTERVAL_MIN;
+		dev->poll_interval_max = MVMDIO_XSMI_POLL_INTERVAL_MAX;
+	} else {
+		return -EINVAL;
+	}
+
+	dev->ops = ops;
+	return 0;
+}
+
 static int orion_mdio_probe(struct platform_device *pdev)
 {
 	struct resource *r;
 	struct mii_bus *bus;
 	struct orion_mdio_dev *dev;
-	struct orion_mdio_ops *ops;
 	int i, ret;
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -278,18 +367,9 @@ static int orion_mdio_probe(struct platform_device *pdev)
 
 	mutex_init(&dev->lock);
 
-	ops = devm_kzalloc(&pdev->dev, sizeof(*ops), GFP_KERNEL);
-	if (!ops)
-		return -ENOMEM;
-
-	dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
-	dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
-	ops->is_done = orion_mdio_smi_is_done;
-	ops->is_read_valid = orion_mdio_smi_is_read_valid;
-	ops->start_read = orion_mdio_start_read_op;
-	ops->read = orion_mdio_read_op;
-	ops->write = orion_mdio_write_op;
-	dev->ops = ops;
+	ret = orion_mdio_populate_ops(pdev, dev);
+	if (ret)
+		return ret;
 
 	if (pdev->dev.of_node)
 		ret = of_mdiobus_register(bus, pdev->dev.of_node);
@@ -340,6 +420,7 @@ static int orion_mdio_remove(struct platform_device *pdev)
 
 static const struct of_device_id orion_mdio_match[] = {
 	{ .compatible = "marvell,orion-mdio" },
+	{ .compatible = "marvell,xmdio" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, orion_mdio_match);
-- 
2.9.4

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

* [PATCH 7/9] net: mvmdio: add xmdio support
@ 2017-06-07  8:38   ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds the xMDIO interface support in the mvmdio driver. This
interface is used in Ethernet controllers on Marvell 370, 7k and 8k (as
of now). The xSMI interface supported by this driver complies with the
IEEE 802.3 clause 45 (while the SMI interface complies with the clause
22). The xSMI interface is used by 10GbE devices.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/Kconfig  |   6 +-
 drivers/net/ethernet/marvell/mvmdio.c | 121 ++++++++++++++++++++++++++++------
 2 files changed, 104 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/marvell/Kconfig b/drivers/net/ethernet/marvell/Kconfig
index da6fb825afea..205bb7e683b7 100644
--- a/drivers/net/ethernet/marvell/Kconfig
+++ b/drivers/net/ethernet/marvell/Kconfig
@@ -35,9 +35,9 @@ config MVMDIO
 	depends on HAS_IOMEM
 	select PHYLIB
 	---help---
-	  This driver supports the MDIO interface found in the network
-	  interface units of the Marvell EBU SoCs (Kirkwood, Orion5x,
-	  Dove, Armada 370 and Armada XP).
+	  This driver supports the MDIO and xMDIO interfaces found in
+	  the network interface units of the Marvell EBU SoCs (Kirkwood,
+	  Orion5x, Dove, Armada 370, Armada XP, Armada 7k and Armada 8k).
 
 	  This driver is used by the MV643XX_ETH and MVNETA drivers.
 
diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 3cb3dd3331d8..13b198aca5c1 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -41,6 +41,15 @@
 #define  MVMDIO_ERR_INT_SMI_DONE	0x00000010
 #define MVMDIO_ERR_INT_MASK		0x0080
 
+#define MVMDIO_XSMI_MGNT_REG		0x0
+#define  MVMDIO_XSMI_READ_VALID		BIT(29)
+#define  MVMDIO_XSMI_BUSY		BIT(30)
+#define MVMDIO_XSMI_ADDR_REG		0x8
+#define  MVMDIO_XSMI_PHYADDR_SHIFT	16
+#define  MVMDIO_XSMI_DEVADDR_SHIFT	21
+#define  MVMDIO_XSMI_READ_OPERATION	(0x7 << 26)
+#define  MVMDIO_XSMI_WRITE_OPERATION	(0x5 << 27)
+
 /*
  * SMI Timeout measurements:
  * - Kirkwood 88F6281 (Globalscale Dreamplug): 45us to 95us (Interrupt)
@@ -50,6 +59,9 @@
 #define MVMDIO_SMI_POLL_INTERVAL_MIN	45
 #define MVMDIO_SMI_POLL_INTERVAL_MAX	55
 
+#define MVMDIO_XSMI_POLL_INTERVAL_MIN	150
+#define MVMDIO_XSMI_POLL_INTERVAL_MAX	160
+
 struct orion_mdio_dev {
 	struct mutex lock;
 	void __iomem *regs;
@@ -76,18 +88,19 @@ struct orion_mdio_ops {
 	void (*write)(struct orion_mdio_dev *, int, int, u16);
 };
 
-static int orion_mdio_smi_is_done(struct orion_mdio_dev *dev)
+/* smi */
+static int smi_is_done(struct orion_mdio_dev *dev)
 {
 	return !(readl(dev->regs) & MVMDIO_SMI_BUSY);
 }
 
-static int orion_mdio_smi_is_read_valid(struct orion_mdio_dev *dev)
+static int smi_is_read_valid(struct orion_mdio_dev *dev)
 {
 	return !(readl(dev->regs) & MVMDIO_SMI_READ_VALID);
 }
 
-static void orion_mdio_start_read_op(struct orion_mdio_dev *dev, int mii_id,
-				     int regnum)
+static void smi_start_read_op(struct orion_mdio_dev *dev, int mii_id,
+			      int regnum)
 {
 	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
 		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
@@ -95,13 +108,13 @@ static void orion_mdio_start_read_op(struct orion_mdio_dev *dev, int mii_id,
 	       dev->regs);
 }
 
-static u16 orion_mdio_read_op(struct orion_mdio_dev *dev)
+static u16 smi_read_op(struct orion_mdio_dev *dev)
 {
 	return readl(dev->regs) & GENMASK(15,0);
 }
 
-static void orion_mdio_write_op(struct orion_mdio_dev *dev, int mii_id,
-				int regnum, u16 value)
+static void smi_write_op(struct orion_mdio_dev *dev, int mii_id,
+			 int regnum, u16 value)
 {
 	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
 		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
@@ -110,6 +123,47 @@ static void orion_mdio_write_op(struct orion_mdio_dev *dev, int mii_id,
 	       dev->regs);
 }
 
+/* xsmi */
+static int xsmi_is_done(struct orion_mdio_dev *dev)
+{
+	return !(readl(dev->regs + MVMDIO_XSMI_MGNT_REG) & MVMDIO_XSMI_BUSY);
+}
+
+static int xsmi_is_read_valid(struct orion_mdio_dev *dev)
+{
+	return !(readl(dev->regs + MVMDIO_XSMI_MGNT_REG) &
+		 MVMDIO_XSMI_READ_VALID);
+}
+
+static void xsmi_start_read_op(struct orion_mdio_dev *dev, int mii_id,
+			      int regnum)
+{
+	u16 dev_addr = regnum >> 16;
+
+	writel(regnum & GENMASK(15,0), dev->regs + MVMDIO_XSMI_ADDR_REG);
+	writel((mii_id << MVMDIO_XSMI_PHYADDR_SHIFT) |
+	       (dev_addr << MVMDIO_XSMI_DEVADDR_SHIFT) |
+	       MVMDIO_XSMI_READ_OPERATION,
+	       dev->regs + MVMDIO_XSMI_MGNT_REG);
+}
+
+static u16 xsmi_read_op(struct orion_mdio_dev *dev)
+{
+	return readl(dev->regs + MVMDIO_XSMI_MGNT_REG) & GENMASK(15,0);
+}
+
+static void xsmi_write_op(struct orion_mdio_dev *dev, int mii_id,
+			 int regnum, u16 value)
+{
+	u16 dev_addr = regnum >> 16;
+
+	writel(regnum & GENMASK(15,0), dev->regs + MVMDIO_XSMI_ADDR_REG);
+	writel((mii_id << MVMDIO_XSMI_PHYADDR_SHIFT) |
+	       (dev_addr << MVMDIO_XSMI_DEVADDR_SHIFT) |
+	       MVMDIO_XSMI_WRITE_OPERATION | value,
+	       dev->regs + MVMDIO_XSMI_MGNT_REG);
+}
+
 /* Wait for the SMI unit to be ready for another operation
  */
 static int orion_mdio_wait_ready(struct mii_bus *bus)
@@ -213,12 +267,47 @@ static irqreturn_t orion_mdio_err_irq(int irq, void *dev_id)
 	return IRQ_NONE;
 }
 
+static int orion_mdio_populate_ops(struct platform_device *pdev,
+				   struct orion_mdio_dev *dev)
+{
+	struct orion_mdio_ops *ops;
+	struct device_node *np = pdev->dev.of_node;
+
+	ops = devm_kzalloc(&pdev->dev, sizeof(*ops), GFP_KERNEL);
+	if (!ops)
+		return -ENOMEM;
+
+	if (of_device_is_compatible(np, "marvell,orion-mdio")) {
+		ops->is_done = smi_is_done;
+		ops->is_read_valid = smi_is_read_valid;
+		ops->start_read = smi_start_read_op;
+		ops->read = smi_read_op;
+		ops->write = smi_write_op;
+
+		dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
+		dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
+	} else if (of_device_is_compatible(np, "marvell,xmdio")) {
+		ops->is_done = xsmi_is_done;
+		ops->is_read_valid = xsmi_is_read_valid;
+		ops->start_read = xsmi_start_read_op;
+		ops->read = xsmi_read_op;
+		ops->write = xsmi_write_op;
+
+		dev->poll_interval_min = MVMDIO_XSMI_POLL_INTERVAL_MIN;
+		dev->poll_interval_max = MVMDIO_XSMI_POLL_INTERVAL_MAX;
+	} else {
+		return -EINVAL;
+	}
+
+	dev->ops = ops;
+	return 0;
+}
+
 static int orion_mdio_probe(struct platform_device *pdev)
 {
 	struct resource *r;
 	struct mii_bus *bus;
 	struct orion_mdio_dev *dev;
-	struct orion_mdio_ops *ops;
 	int i, ret;
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -278,18 +367,9 @@ static int orion_mdio_probe(struct platform_device *pdev)
 
 	mutex_init(&dev->lock);
 
-	ops = devm_kzalloc(&pdev->dev, sizeof(*ops), GFP_KERNEL);
-	if (!ops)
-		return -ENOMEM;
-
-	dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
-	dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
-	ops->is_done = orion_mdio_smi_is_done;
-	ops->is_read_valid = orion_mdio_smi_is_read_valid;
-	ops->start_read = orion_mdio_start_read_op;
-	ops->read = orion_mdio_read_op;
-	ops->write = orion_mdio_write_op;
-	dev->ops = ops;
+	ret = orion_mdio_populate_ops(pdev, dev);
+	if (ret)
+		return ret;
 
 	if (pdev->dev.of_node)
 		ret = of_mdiobus_register(bus, pdev->dev.of_node);
@@ -340,6 +420,7 @@ static int orion_mdio_remove(struct platform_device *pdev)
 
 static const struct of_device_id orion_mdio_match[] = {
 	{ .compatible = "marvell,orion-mdio" },
+	{ .compatible = "marvell,xmdio" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, orion_mdio_match);
-- 
2.9.4

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

* [PATCH 8/9] dt-bindings: orion-mdio: document the new xmdio compatible
  2017-06-07  8:38 ` Antoine Tenart
@ 2017-06-07  8:38   ` Antoine Tenart
  -1 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: davem, jason, andrew, gregory.clement, sebastian.hesselbarth, f.fainelli
  Cc: Antoine Tenart, thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

A new compatible for Marvell xMDIO interfaces was added into the Marvell
MDIO driver. Document this new compatible.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 Documentation/devicetree/bindings/net/marvell-orion-mdio.txt | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/marvell-orion-mdio.txt b/Documentation/devicetree/bindings/net/marvell-orion-mdio.txt
index ccdabdcc8618..315036ff8fed 100644
--- a/Documentation/devicetree/bindings/net/marvell-orion-mdio.txt
+++ b/Documentation/devicetree/bindings/net/marvell-orion-mdio.txt
@@ -1,12 +1,12 @@
 * Marvell MDIO Ethernet Controller interface
 
 The Ethernet controllers of the Marvel Kirkwood, Dove, Orion5x,
-MV78xx0, Armada 370 and Armada XP have an identical unit that provides
-an interface with the MDIO bus. This driver handles this MDIO
-interface.
+MV78xx0, Armada 370, Armada XP, Armada 7k and Armada 8k have an
+identical unit that provides an interface with the MDIO bus or to
+the xMDIO bus. This driver handles these interfaces.
 
 Required properties:
-- compatible: "marvell,orion-mdio"
+- compatible: "marvell,orion-mdio" or "marvell,xmdio"
 - reg: address and length of the MDIO registers.  When an interrupt is
   not present, the length is the size of the SMI register (4 bytes)
   otherwise it must be 0x84 bytes to cover the interrupt control
-- 
2.9.4

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

* [PATCH 8/9] dt-bindings: orion-mdio: document the new xmdio compatible
@ 2017-06-07  8:38   ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

A new compatible for Marvell xMDIO interfaces was added into the Marvell
MDIO driver. Document this new compatible.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 Documentation/devicetree/bindings/net/marvell-orion-mdio.txt | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/marvell-orion-mdio.txt b/Documentation/devicetree/bindings/net/marvell-orion-mdio.txt
index ccdabdcc8618..315036ff8fed 100644
--- a/Documentation/devicetree/bindings/net/marvell-orion-mdio.txt
+++ b/Documentation/devicetree/bindings/net/marvell-orion-mdio.txt
@@ -1,12 +1,12 @@
 * Marvell MDIO Ethernet Controller interface
 
 The Ethernet controllers of the Marvel Kirkwood, Dove, Orion5x,
-MV78xx0, Armada 370 and Armada XP have an identical unit that provides
-an interface with the MDIO bus. This driver handles this MDIO
-interface.
+MV78xx0, Armada 370, Armada XP, Armada 7k and Armada 8k have an
+identical unit that provides an interface with the MDIO bus or to
+the xMDIO bus. This driver handles these interfaces.
 
 Required properties:
-- compatible: "marvell,orion-mdio"
+- compatible: "marvell,orion-mdio" or "marvell,xmdio"
 - reg: address and length of the MDIO registers.  When an interrupt is
   not present, the length is the size of the SMI register (4 bytes)
   otherwise it must be 0x84 bytes to cover the interrupt control
-- 
2.9.4

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

* [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k
  2017-06-07  8:38 ` Antoine Tenart
@ 2017-06-07  8:38   ` Antoine Tenart
  -1 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: davem, jason, andrew, gregory.clement, sebastian.hesselbarth, f.fainelli
  Cc: Antoine Tenart, thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

Add the description of the xMDIO bus for the Marvell Armada 7k and
Marvell Armada 8k; for both CP110 slave and master. This bus is found
on Marvell Ethernet controllers and provides an interface with the
xMDIO bus.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi | 7 +++++++
 arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi  | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
index 037ed30d75a7..95953743455e 100644
--- a/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
@@ -98,6 +98,13 @@
 				clocks = <&cpm_syscon0 1 9>, <&cpm_syscon0 1 5>;
 			};
 
+			cpm_xmdio: mdio@12a600 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "marvell,xmdio";
+				reg = <0x12a600 0x10>;
+			};
+
 			cpm_icu: interrupt-controller@1e0000 {
 				compatible = "marvell,cp110-icu"; 
 				reg = <0x1e0000 0x10>;
diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
index 2a99ff8fca2a..594356243ddb 100644
--- a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
@@ -103,6 +103,13 @@
 				clocks = <&cps_syscon0 1 9>, <&cps_syscon0 1 5>;
 			};
 
+			cps_xmdio: mdio@12a600 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "marvell,xmdio";
+				reg = <0x12a600 0x10>;
+			};
+
 			cps_icu: interrupt-controller@1e0000 {
 				compatible = "marvell,cp110-icu";
 				reg = <0x1e0000 0x10>;
-- 
2.9.4

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

* [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k
@ 2017-06-07  8:38   ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Add the description of the xMDIO bus for the Marvell Armada 7k and
Marvell Armada 8k; for both CP110 slave and master. This bus is found
on Marvell Ethernet controllers and provides an interface with the
xMDIO bus.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi | 7 +++++++
 arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi  | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
index 037ed30d75a7..95953743455e 100644
--- a/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
@@ -98,6 +98,13 @@
 				clocks = <&cpm_syscon0 1 9>, <&cpm_syscon0 1 5>;
 			};
 
+			cpm_xmdio: mdio at 12a600 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "marvell,xmdio";
+				reg = <0x12a600 0x10>;
+			};
+
 			cpm_icu: interrupt-controller at 1e0000 {
 				compatible = "marvell,cp110-icu"; 
 				reg = <0x1e0000 0x10>;
diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
index 2a99ff8fca2a..594356243ddb 100644
--- a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
@@ -103,6 +103,13 @@
 				clocks = <&cps_syscon0 1 9>, <&cps_syscon0 1 5>;
 			};
 
+			cps_xmdio: mdio at 12a600 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "marvell,xmdio";
+				reg = <0x12a600 0x10>;
+			};
+
 			cps_icu: interrupt-controller at 1e0000 {
 				compatible = "marvell,cp110-icu";
 				reg = <0x1e0000 0x10>;
-- 
2.9.4

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

* Re: [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k
  2017-06-07  8:38   ` Antoine Tenart
@ 2017-06-07  8:43     ` Gregory CLEMENT
  -1 siblings, 0 replies; 56+ messages in thread
From: Gregory CLEMENT @ 2017-06-07  8:43 UTC (permalink / raw)
  To: davem
  Cc: Antoine Tenart, jason, andrew, sebastian.hesselbarth, f.fainelli,
	thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

Hi Dave,
 
 On mer., juin 07 2017, Antoine Tenart <antoine.tenart@free-electrons.com> wrote:

> Add the description of the xMDIO bus for the Marvell Armada 7k and
> Marvell Armada 8k; for both CP110 slave and master. This bus is found
> on Marvell Ethernet controllers and provides an interface with the
> xMDIO bus.
>

If you agrees with this series please don't apply this patch. I will
take care of it. We have many changes in the dt directory for the next
release and I want that all the change are in the same place to take
care of the merge conflict.

Thanks,

Gregory

> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> ---
>  arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi | 7 +++++++
>  arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi  | 7 +++++++
>  2 files changed, 14 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
> index 037ed30d75a7..95953743455e 100644
> --- a/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
> +++ b/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
> @@ -98,6 +98,13 @@
>  				clocks = <&cpm_syscon0 1 9>, <&cpm_syscon0 1 5>;
>  			};
>  
> +			cpm_xmdio: mdio@12a600 {
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				compatible = "marvell,xmdio";
> +				reg = <0x12a600 0x10>;
> +			};
> +
>  			cpm_icu: interrupt-controller@1e0000 {
>  				compatible = "marvell,cp110-icu"; 
>  				reg = <0x1e0000 0x10>;
> diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> index 2a99ff8fca2a..594356243ddb 100644
> --- a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> +++ b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> @@ -103,6 +103,13 @@
>  				clocks = <&cps_syscon0 1 9>, <&cps_syscon0 1 5>;
>  			};
>  
> +			cps_xmdio: mdio@12a600 {
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				compatible = "marvell,xmdio";
> +				reg = <0x12a600 0x10>;
> +			};
> +
>  			cps_icu: interrupt-controller@1e0000 {
>  				compatible = "marvell,cp110-icu";
>  				reg = <0x1e0000 0x10>;
> -- 
> 2.9.4
>

-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k
@ 2017-06-07  8:43     ` Gregory CLEMENT
  0 siblings, 0 replies; 56+ messages in thread
From: Gregory CLEMENT @ 2017-06-07  8:43 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Dave,
 
 On mer., juin 07 2017, Antoine Tenart <antoine.tenart@free-electrons.com> wrote:

> Add the description of the xMDIO bus for the Marvell Armada 7k and
> Marvell Armada 8k; for both CP110 slave and master. This bus is found
> on Marvell Ethernet controllers and provides an interface with the
> xMDIO bus.
>

If you agrees with this series please don't apply this patch. I will
take care of it. We have many changes in the dt directory for the next
release and I want that all the change are in the same place to take
care of the merge conflict.

Thanks,

Gregory

> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> ---
>  arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi | 7 +++++++
>  arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi  | 7 +++++++
>  2 files changed, 14 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
> index 037ed30d75a7..95953743455e 100644
> --- a/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
> +++ b/arch/arm64/boot/dts/marvell/armada-cp110-master.dtsi
> @@ -98,6 +98,13 @@
>  				clocks = <&cpm_syscon0 1 9>, <&cpm_syscon0 1 5>;
>  			};
>  
> +			cpm_xmdio: mdio at 12a600 {
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				compatible = "marvell,xmdio";
> +				reg = <0x12a600 0x10>;
> +			};
> +
>  			cpm_icu: interrupt-controller at 1e0000 {
>  				compatible = "marvell,cp110-icu"; 
>  				reg = <0x1e0000 0x10>;
> diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> index 2a99ff8fca2a..594356243ddb 100644
> --- a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> +++ b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> @@ -103,6 +103,13 @@
>  				clocks = <&cps_syscon0 1 9>, <&cps_syscon0 1 5>;
>  			};
>  
> +			cps_xmdio: mdio at 12a600 {
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				compatible = "marvell,xmdio";
> +				reg = <0x12a600 0x10>;
> +			};
> +
>  			cps_icu: interrupt-controller at 1e0000 {
>  				compatible = "marvell,cp110-icu";
>  				reg = <0x1e0000 0x10>;
> -- 
> 2.9.4
>

-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* Re: [PATCH 4/9] net: mvmdio: move the read valid check into its own function
  2017-06-07  8:38   ` Antoine Tenart
@ 2017-06-07 10:00     ` Sergei Shtylyov
  -1 siblings, 0 replies; 56+ messages in thread
From: Sergei Shtylyov @ 2017-06-07 10:00 UTC (permalink / raw)
  To: Antoine Tenart, davem, jason, andrew, gregory.clement,
	sebastian.hesselbarth, f.fainelli
  Cc: thomas.petazzoni, netdev, mw, linux, linux-arm-kernel

Hello!

On 6/7/2017 11:38 AM, Antoine Tenart wrote:

> Move the read valid check in its own function. This is needed as a
> requirement to factorize the driver to add the xMDIO support in the
> future.
>
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> ---
>  drivers/net/ethernet/marvell/mvmdio.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
> index 96af8d57d9e5..56bbe3990590 100644
> --- a/drivers/net/ethernet/marvell/mvmdio.c
> +++ b/drivers/net/ethernet/marvell/mvmdio.c
> @@ -69,6 +69,11 @@ static int orion_mdio_smi_is_done(struct orion_mdio_dev *dev)
>  	return !(readl(dev->regs) & MVMDIO_SMI_BUSY);
>  }
>
> +static int orion_mdio_smi_is_read_valid(struct orion_mdio_dev *dev)
> +{
> +	return !(readl(dev->regs) & MVMDIO_SMI_READ_VALID);
> +}
> +
>  /* Wait for the SMI unit to be ready for another operation
>   */
>  static int orion_mdio_wait_ready(struct mii_bus *bus)
> @@ -113,7 +118,6 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
>  			   int regnum)
>  {
>  	struct orion_mdio_dev *dev = bus->priv;
> -	u32 val;
>  	int ret;
>
>  	mutex_lock(&dev->lock);
> @@ -131,14 +135,13 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
>  	if (ret < 0)
>  		goto out;
>
> -	val = readl(dev->regs);
> -	if (!(val & MVMDIO_SMI_READ_VALID)) {
> +	if (orion_mdio_smi_is_read_valid(dev)) {
>  		dev_err(bus->parent, "SMI bus read not valid\n");

    I think you reversed the valuid/invalid sense in the new function's name.

>  		ret = -ENODEV;
>  		goto out;
>  	}
>
[...]

MBR, Sergei

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

* [PATCH 4/9] net: mvmdio: move the read valid check into its own function
@ 2017-06-07 10:00     ` Sergei Shtylyov
  0 siblings, 0 replies; 56+ messages in thread
From: Sergei Shtylyov @ 2017-06-07 10:00 UTC (permalink / raw)
  To: linux-arm-kernel

Hello!

On 6/7/2017 11:38 AM, Antoine Tenart wrote:

> Move the read valid check in its own function. This is needed as a
> requirement to factorize the driver to add the xMDIO support in the
> future.
>
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> ---
>  drivers/net/ethernet/marvell/mvmdio.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
> index 96af8d57d9e5..56bbe3990590 100644
> --- a/drivers/net/ethernet/marvell/mvmdio.c
> +++ b/drivers/net/ethernet/marvell/mvmdio.c
> @@ -69,6 +69,11 @@ static int orion_mdio_smi_is_done(struct orion_mdio_dev *dev)
>  	return !(readl(dev->regs) & MVMDIO_SMI_BUSY);
>  }
>
> +static int orion_mdio_smi_is_read_valid(struct orion_mdio_dev *dev)
> +{
> +	return !(readl(dev->regs) & MVMDIO_SMI_READ_VALID);
> +}
> +
>  /* Wait for the SMI unit to be ready for another operation
>   */
>  static int orion_mdio_wait_ready(struct mii_bus *bus)
> @@ -113,7 +118,6 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
>  			   int regnum)
>  {
>  	struct orion_mdio_dev *dev = bus->priv;
> -	u32 val;
>  	int ret;
>
>  	mutex_lock(&dev->lock);
> @@ -131,14 +135,13 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
>  	if (ret < 0)
>  		goto out;
>
> -	val = readl(dev->regs);
> -	if (!(val & MVMDIO_SMI_READ_VALID)) {
> +	if (orion_mdio_smi_is_read_valid(dev)) {
>  		dev_err(bus->parent, "SMI bus read not valid\n");

    I think you reversed the valuid/invalid sense in the new function's name.

>  		ret = -ENODEV;
>  		goto out;
>  	}
>
[...]

MBR, Sergei

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

* Re: [PATCH 7/9] net: mvmdio: add xmdio support
  2017-06-07  8:38   ` Antoine Tenart
@ 2017-06-07 12:12     ` Andrew Lunn
  -1 siblings, 0 replies; 56+ messages in thread
From: Andrew Lunn @ 2017-06-07 12:12 UTC (permalink / raw)
  To: Antoine Tenart
  Cc: davem, jason, gregory.clement, sebastian.hesselbarth, f.fainelli,
	thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

On Wed, Jun 07, 2017 at 10:38:08AM +0200, Antoine Tenart wrote:
> This patch adds the xMDIO interface support in the mvmdio driver. This
> interface is used in Ethernet controllers on Marvell 370, 7k and 8k (as
> of now). The xSMI interface supported by this driver complies with the
> IEEE 802.3 clause 45 (while the SMI interface complies with the clause
> 22). The xSMI interface is used by 10GbE devices.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>

Hi Antoine

I've only take a quick look, but i don't see anywhere you look at the
register address and see if it has MII_ADDR_C45 to determine if a C45
transaction should be done, or a C22. The MDIO bus can have a mix of
C45 and C22 devices on it, and you need to use the correct transaction
type depending on the target device/address.

	  Andrew

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

* [PATCH 7/9] net: mvmdio: add xmdio support
@ 2017-06-07 12:12     ` Andrew Lunn
  0 siblings, 0 replies; 56+ messages in thread
From: Andrew Lunn @ 2017-06-07 12:12 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jun 07, 2017 at 10:38:08AM +0200, Antoine Tenart wrote:
> This patch adds the xMDIO interface support in the mvmdio driver. This
> interface is used in Ethernet controllers on Marvell 370, 7k and 8k (as
> of now). The xSMI interface supported by this driver complies with the
> IEEE 802.3 clause 45 (while the SMI interface complies with the clause
> 22). The xSMI interface is used by 10GbE devices.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>

Hi Antoine

I've only take a quick look, but i don't see anywhere you look at the
register address and see if it has MII_ADDR_C45 to determine if a C45
transaction should be done, or a C22. The MDIO bus can have a mix of
C45 and C22 devices on it, and you need to use the correct transaction
type depending on the target device/address.

	  Andrew

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

* Re: [PATCH 7/9] net: mvmdio: add xmdio support
  2017-06-07 12:12     ` Andrew Lunn
@ 2017-06-07 14:42       ` Antoine Tenart
  -1 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07 14:42 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: thomas.petazzoni, f.fainelli, jason, netdev, Antoine Tenart,
	linux, gregory.clement, mw, davem, linux-arm-kernel,
	sebastian.hesselbarth


[-- Attachment #1.1: Type: text/plain, Size: 1063 bytes --]

Hi Andrew,

On Wed, Jun 07, 2017 at 02:12:05PM +0200, Andrew Lunn wrote:
> On Wed, Jun 07, 2017 at 10:38:08AM +0200, Antoine Tenart wrote:
> > This patch adds the xMDIO interface support in the mvmdio driver. This
> > interface is used in Ethernet controllers on Marvell 370, 7k and 8k (as
> > of now). The xSMI interface supported by this driver complies with the
> > IEEE 802.3 clause 45 (while the SMI interface complies with the clause
> > 22). The xSMI interface is used by 10GbE devices.
> 
> I've only take a quick look, but i don't see anywhere you look at the
> register address and see if it has MII_ADDR_C45 to determine if a C45
> transaction should be done, or a C22. The MDIO bus can have a mix of
> C45 and C22 devices on it, and you need to use the correct transaction
> type depending on the target device/address.

So this could be dynamic and not based on the compatible. I'll try this
and see if it can work.

Thanks!

-- 
Antoine Ténart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 7/9] net: mvmdio: add xmdio support
@ 2017-06-07 14:42       ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07 14:42 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Andrew,

On Wed, Jun 07, 2017 at 02:12:05PM +0200, Andrew Lunn wrote:
> On Wed, Jun 07, 2017 at 10:38:08AM +0200, Antoine Tenart wrote:
> > This patch adds the xMDIO interface support in the mvmdio driver. This
> > interface is used in Ethernet controllers on Marvell 370, 7k and 8k (as
> > of now). The xSMI interface supported by this driver complies with the
> > IEEE 802.3 clause 45 (while the SMI interface complies with the clause
> > 22). The xSMI interface is used by 10GbE devices.
> 
> I've only take a quick look, but i don't see anywhere you look at the
> register address and see if it has MII_ADDR_C45 to determine if a C45
> transaction should be done, or a C22. The MDIO bus can have a mix of
> C45 and C22 devices on it, and you need to use the correct transaction
> type depending on the target device/address.

So this could be dynamic and not based on the compatible. I'll try this
and see if it can work.

Thanks!

-- 
Antoine T?nart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170607/a008eb2c/attachment.sig>

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

* Re: [PATCH 4/9] net: mvmdio: move the read valid check into its own function
  2017-06-07 10:00     ` Sergei Shtylyov
@ 2017-06-07 14:43       ` Antoine Tenart
  -1 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07 14:43 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Antoine Tenart, davem, jason, andrew, gregory.clement,
	sebastian.hesselbarth, f.fainelli, thomas.petazzoni, mw, linux,
	netdev, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 550 bytes --]

Hello,

On Wed, Jun 07, 2017 at 01:00:21PM +0300, Sergei Shtylyov wrote:
> On 6/7/2017 11:38 AM, Antoine Tenart wrote:
> > 
> > -	val = readl(dev->regs);
> > -	if (!(val & MVMDIO_SMI_READ_VALID)) {
> > +	if (orion_mdio_smi_is_read_valid(dev)) {
> >  		dev_err(bus->parent, "SMI bus read not valid\n");
> 
>    I think you reversed the valuid/invalid sense in the new function's name.

Good catch, I'll fix this.

Thanks!
Antoine

-- 
Antoine Ténart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [PATCH 4/9] net: mvmdio: move the read valid check into its own function
@ 2017-06-07 14:43       ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07 14:43 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

On Wed, Jun 07, 2017 at 01:00:21PM +0300, Sergei Shtylyov wrote:
> On 6/7/2017 11:38 AM, Antoine Tenart wrote:
> > 
> > -	val = readl(dev->regs);
> > -	if (!(val & MVMDIO_SMI_READ_VALID)) {
> > +	if (orion_mdio_smi_is_read_valid(dev)) {
> >  		dev_err(bus->parent, "SMI bus read not valid\n");
> 
>    I think you reversed the valuid/invalid sense in the new function's name.

Good catch, I'll fix this.

Thanks!
Antoine

-- 
Antoine T?nart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170607/61219f52/attachment.sig>

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

* Re: [PATCH 7/9] net: mvmdio: add xmdio support
  2017-06-07  8:38   ` Antoine Tenart
@ 2017-06-07 15:48     ` Florian Fainelli
  -1 siblings, 0 replies; 56+ messages in thread
From: Florian Fainelli @ 2017-06-07 15:48 UTC (permalink / raw)
  To: Antoine Tenart, davem, jason, andrew, gregory.clement,
	sebastian.hesselbarth
  Cc: thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> This patch adds the xMDIO interface support in the mvmdio driver. This
> interface is used in Ethernet controllers on Marvell 370, 7k and 8k (as
> of now). The xSMI interface supported by this driver complies with the
> IEEE 802.3 clause 45 (while the SMI interface complies with the clause
> 22). The xSMI interface is used by 10GbE devices.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> ---

> +	if (of_device_is_compatible(np, "marvell,orion-mdio")) {
> +		ops->is_done = smi_is_done;
> +		ops->is_read_valid = smi_is_read_valid;
> +		ops->start_read = smi_start_read_op;
> +		ops->read = smi_read_op;
> +		ops->write = smi_write_op;
> +
> +		dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
> +		dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
> +	} else if (of_device_is_compatible(np, "marvell,xmdio")) {
> +		ops->is_done = xsmi_is_done;
> +		ops->is_read_valid = xsmi_is_read_valid;
> +		ops->start_read = xsmi_start_read_op;
> +		ops->read = xsmi_read_op;
> +		ops->write = xsmi_write_op;
> +
> +		dev->poll_interval_min = MVMDIO_XSMI_POLL_INTERVAL_MIN;
> +		dev->poll_interval_max = MVMDIO_XSMI_POLL_INTERVAL_MAX;
> +	} else {
> +		return -EINVAL;
> +	}

Instead of doing this, you could have the ops structure declared e.g: a
static global variables in the driver and reference them from the
of_device_id .data field, something like:

static struct orion_mdio_ops mdio_ops = {
	...
};

static struct orion_mdio_data mdio_data = {
	.ops = &mdio_ops,
	.poll_intervall_min = ...,
	.poll_interfave_max = ...,
};

static struct orion_mdio_ops xmdio_ops = {
	...
};

static strcut orion_mdio_data xmdio_ data = {
};

and then reference those using of_id->data in the probe function

> +
> +	dev->ops = ops;
> +	return 0;
> +}
> +
>  static int orion_mdio_probe(struct platform_device *pdev)
>  {
>  	struct resource *r;
>  	struct mii_bus *bus;
>  	struct orion_mdio_dev *dev;
> -	struct orion_mdio_ops *ops;
>  	int i, ret;
>  
>  	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -278,18 +367,9 @@ static int orion_mdio_probe(struct platform_device *pdev)
>  
>  	mutex_init(&dev->lock);
>  
> -	ops = devm_kzalloc(&pdev->dev, sizeof(*ops), GFP_KERNEL);
> -	if (!ops)
> -		return -ENOMEM;
> -
> -	dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
> -	dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
> -	ops->is_done = orion_mdio_smi_is_done;
> -	ops->is_read_valid = orion_mdio_smi_is_read_valid;
> -	ops->start_read = orion_mdio_start_read_op;
> -	ops->read = orion_mdio_read_op;
> -	ops->write = orion_mdio_write_op;
> -	dev->ops = ops;
> +	ret = orion_mdio_populate_ops(pdev, dev);
> +	if (ret)
> +		return ret;
>  
>  	if (pdev->dev.of_node)
>  		ret = of_mdiobus_register(bus, pdev->dev.of_node);
> @@ -340,6 +420,7 @@ static int orion_mdio_remove(struct platform_device *pdev)
>  
>  static const struct of_device_id orion_mdio_match[] = {
>  	{ .compatible = "marvell,orion-mdio" },

and do .data = &mdio_data

> +	{ .compatible = "marvell,xmdio" },

and .data = &xmdio_data

>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, orion_mdio_match);
> 

-- 
Florian

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

* [PATCH 7/9] net: mvmdio: add xmdio support
@ 2017-06-07 15:48     ` Florian Fainelli
  0 siblings, 0 replies; 56+ messages in thread
From: Florian Fainelli @ 2017-06-07 15:48 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> This patch adds the xMDIO interface support in the mvmdio driver. This
> interface is used in Ethernet controllers on Marvell 370, 7k and 8k (as
> of now). The xSMI interface supported by this driver complies with the
> IEEE 802.3 clause 45 (while the SMI interface complies with the clause
> 22). The xSMI interface is used by 10GbE devices.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> ---

> +	if (of_device_is_compatible(np, "marvell,orion-mdio")) {
> +		ops->is_done = smi_is_done;
> +		ops->is_read_valid = smi_is_read_valid;
> +		ops->start_read = smi_start_read_op;
> +		ops->read = smi_read_op;
> +		ops->write = smi_write_op;
> +
> +		dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
> +		dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
> +	} else if (of_device_is_compatible(np, "marvell,xmdio")) {
> +		ops->is_done = xsmi_is_done;
> +		ops->is_read_valid = xsmi_is_read_valid;
> +		ops->start_read = xsmi_start_read_op;
> +		ops->read = xsmi_read_op;
> +		ops->write = xsmi_write_op;
> +
> +		dev->poll_interval_min = MVMDIO_XSMI_POLL_INTERVAL_MIN;
> +		dev->poll_interval_max = MVMDIO_XSMI_POLL_INTERVAL_MAX;
> +	} else {
> +		return -EINVAL;
> +	}

Instead of doing this, you could have the ops structure declared e.g: a
static global variables in the driver and reference them from the
of_device_id .data field, something like:

static struct orion_mdio_ops mdio_ops = {
	...
};

static struct orion_mdio_data mdio_data = {
	.ops = &mdio_ops,
	.poll_intervall_min = ...,
	.poll_interfave_max = ...,
};

static struct orion_mdio_ops xmdio_ops = {
	...
};

static strcut orion_mdio_data xmdio_ data = {
};

and then reference those using of_id->data in the probe function

> +
> +	dev->ops = ops;
> +	return 0;
> +}
> +
>  static int orion_mdio_probe(struct platform_device *pdev)
>  {
>  	struct resource *r;
>  	struct mii_bus *bus;
>  	struct orion_mdio_dev *dev;
> -	struct orion_mdio_ops *ops;
>  	int i, ret;
>  
>  	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -278,18 +367,9 @@ static int orion_mdio_probe(struct platform_device *pdev)
>  
>  	mutex_init(&dev->lock);
>  
> -	ops = devm_kzalloc(&pdev->dev, sizeof(*ops), GFP_KERNEL);
> -	if (!ops)
> -		return -ENOMEM;
> -
> -	dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
> -	dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
> -	ops->is_done = orion_mdio_smi_is_done;
> -	ops->is_read_valid = orion_mdio_smi_is_read_valid;
> -	ops->start_read = orion_mdio_start_read_op;
> -	ops->read = orion_mdio_read_op;
> -	ops->write = orion_mdio_write_op;
> -	dev->ops = ops;
> +	ret = orion_mdio_populate_ops(pdev, dev);
> +	if (ret)
> +		return ret;
>  
>  	if (pdev->dev.of_node)
>  		ret = of_mdiobus_register(bus, pdev->dev.of_node);
> @@ -340,6 +420,7 @@ static int orion_mdio_remove(struct platform_device *pdev)
>  
>  static const struct of_device_id orion_mdio_match[] = {
>  	{ .compatible = "marvell,orion-mdio" },

and do .data = &mdio_data

> +	{ .compatible = "marvell,xmdio" },

and .data = &xmdio_data

>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, orion_mdio_match);
> 

-- 
Florian

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

* Re: [PATCH 7/9] net: mvmdio: add xmdio support
  2017-06-07 15:48     ` Florian Fainelli
@ 2017-06-07 15:56       ` Russell King - ARM Linux
  -1 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2017-06-07 15:56 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Antoine Tenart, davem, jason, andrew, gregory.clement,
	sebastian.hesselbarth, thomas.petazzoni, netdev, mw,
	linux-arm-kernel

On Wed, Jun 07, 2017 at 08:48:06AM -0700, Florian Fainelli wrote:
> On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> > This patch adds the xMDIO interface support in the mvmdio driver. This
> > interface is used in Ethernet controllers on Marvell 370, 7k and 8k (as
> > of now). The xSMI interface supported by this driver complies with the
> > IEEE 802.3 clause 45 (while the SMI interface complies with the clause
> > 22). The xSMI interface is used by 10GbE devices.
> > 
> > Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> > ---
> 
> > +	if (of_device_is_compatible(np, "marvell,orion-mdio")) {
> > +		ops->is_done = smi_is_done;
> > +		ops->is_read_valid = smi_is_read_valid;
> > +		ops->start_read = smi_start_read_op;
> > +		ops->read = smi_read_op;
> > +		ops->write = smi_write_op;
> > +
> > +		dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
> > +		dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
> > +	} else if (of_device_is_compatible(np, "marvell,xmdio")) {
> > +		ops->is_done = xsmi_is_done;
> > +		ops->is_read_valid = xsmi_is_read_valid;
> > +		ops->start_read = xsmi_start_read_op;
> > +		ops->read = xsmi_read_op;
> > +		ops->write = xsmi_write_op;
> > +
> > +		dev->poll_interval_min = MVMDIO_XSMI_POLL_INTERVAL_MIN;
> > +		dev->poll_interval_max = MVMDIO_XSMI_POLL_INTERVAL_MAX;
> > +	} else {
> > +		return -EINVAL;
> > +	}
> 
> Instead of doing this, you could have the ops structure declared e.g: a
> static global variables in the driver and reference them from the
> of_device_id .data field, something like:
> 
> static struct orion_mdio_ops mdio_ops = {
> 	...
> };

In this case, don't forget the "const" for static structures containing
only function pointers (so that the function pointers can't be exploited.)

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* [PATCH 7/9] net: mvmdio: add xmdio support
@ 2017-06-07 15:56       ` Russell King - ARM Linux
  0 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2017-06-07 15:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jun 07, 2017 at 08:48:06AM -0700, Florian Fainelli wrote:
> On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> > This patch adds the xMDIO interface support in the mvmdio driver. This
> > interface is used in Ethernet controllers on Marvell 370, 7k and 8k (as
> > of now). The xSMI interface supported by this driver complies with the
> > IEEE 802.3 clause 45 (while the SMI interface complies with the clause
> > 22). The xSMI interface is used by 10GbE devices.
> > 
> > Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> > ---
> 
> > +	if (of_device_is_compatible(np, "marvell,orion-mdio")) {
> > +		ops->is_done = smi_is_done;
> > +		ops->is_read_valid = smi_is_read_valid;
> > +		ops->start_read = smi_start_read_op;
> > +		ops->read = smi_read_op;
> > +		ops->write = smi_write_op;
> > +
> > +		dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
> > +		dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
> > +	} else if (of_device_is_compatible(np, "marvell,xmdio")) {
> > +		ops->is_done = xsmi_is_done;
> > +		ops->is_read_valid = xsmi_is_read_valid;
> > +		ops->start_read = xsmi_start_read_op;
> > +		ops->read = xsmi_read_op;
> > +		ops->write = xsmi_write_op;
> > +
> > +		dev->poll_interval_min = MVMDIO_XSMI_POLL_INTERVAL_MIN;
> > +		dev->poll_interval_max = MVMDIO_XSMI_POLL_INTERVAL_MAX;
> > +	} else {
> > +		return -EINVAL;
> > +	}
> 
> Instead of doing this, you could have the ops structure declared e.g: a
> static global variables in the driver and reference them from the
> of_device_id .data field, something like:
> 
> static struct orion_mdio_ops mdio_ops = {
> 	...
> };

In this case, don't forget the "const" for static structures containing
only function pointers (so that the function pointers can't be exploited.)

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH 7/9] net: mvmdio: add xmdio support
  2017-06-07 15:48     ` Florian Fainelli
@ 2017-06-07 16:13       ` Antoine Tenart
  -1 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07 16:13 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Antoine Tenart, davem, jason, andrew, gregory.clement,
	sebastian.hesselbarth, thomas.petazzoni, mw, linux, netdev,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1433 bytes --]

Hi Florian,

On Wed, Jun 07, 2017 at 08:48:06AM -0700, Florian Fainelli wrote:
> On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> 
> > +	if (of_device_is_compatible(np, "marvell,orion-mdio")) {
> > +		ops->is_done = smi_is_done;
> > +		ops->is_read_valid = smi_is_read_valid;
> > +		ops->start_read = smi_start_read_op;
> > +		ops->read = smi_read_op;
> > +		ops->write = smi_write_op;
> > +
> > +		dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
> > +		dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
> > +	} else if (of_device_is_compatible(np, "marvell,xmdio")) {
> > +		ops->is_done = xsmi_is_done;
> > +		ops->is_read_valid = xsmi_is_read_valid;
> > +		ops->start_read = xsmi_start_read_op;
> > +		ops->read = xsmi_read_op;
> > +		ops->write = xsmi_write_op;
> > +
> > +		dev->poll_interval_min = MVMDIO_XSMI_POLL_INTERVAL_MIN;
> > +		dev->poll_interval_max = MVMDIO_XSMI_POLL_INTERVAL_MAX;
> > +	} else {
> > +		return -EINVAL;
> > +	}
> 
> Instead of doing this, you could have the ops structure declared e.g: a
> static global variables in the driver and reference them from the
> of_device_id .data field, something like:

Good idea, I'll update the series using static global variables for ops
and poll intervals and reference them in the .data field.

Thanks!
Antoine

-- 
Antoine Ténart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [PATCH 7/9] net: mvmdio: add xmdio support
@ 2017-06-07 16:13       ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-07 16:13 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Florian,

On Wed, Jun 07, 2017 at 08:48:06AM -0700, Florian Fainelli wrote:
> On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> 
> > +	if (of_device_is_compatible(np, "marvell,orion-mdio")) {
> > +		ops->is_done = smi_is_done;
> > +		ops->is_read_valid = smi_is_read_valid;
> > +		ops->start_read = smi_start_read_op;
> > +		ops->read = smi_read_op;
> > +		ops->write = smi_write_op;
> > +
> > +		dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
> > +		dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
> > +	} else if (of_device_is_compatible(np, "marvell,xmdio")) {
> > +		ops->is_done = xsmi_is_done;
> > +		ops->is_read_valid = xsmi_is_read_valid;
> > +		ops->start_read = xsmi_start_read_op;
> > +		ops->read = xsmi_read_op;
> > +		ops->write = xsmi_write_op;
> > +
> > +		dev->poll_interval_min = MVMDIO_XSMI_POLL_INTERVAL_MIN;
> > +		dev->poll_interval_max = MVMDIO_XSMI_POLL_INTERVAL_MAX;
> > +	} else {
> > +		return -EINVAL;
> > +	}
> 
> Instead of doing this, you could have the ops structure declared e.g: a
> static global variables in the driver and reference them from the
> of_device_id .data field, something like:

Good idea, I'll update the series using static global variables for ops
and poll intervals and reference them in the .data field.

Thanks!
Antoine

-- 
Antoine T?nart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170607/b292725a/attachment-0001.sig>

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

* Re: [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k
  2017-06-07  8:43     ` Gregory CLEMENT
@ 2017-06-07 19:09       ` David Miller
  -1 siblings, 0 replies; 56+ messages in thread
From: David Miller @ 2017-06-07 19:09 UTC (permalink / raw)
  To: gregory.clement
  Cc: antoine.tenart, jason, andrew, sebastian.hesselbarth, f.fainelli,
	thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

From: Gregory CLEMENT <gregory.clement@free-electrons.com>
Date: Wed, 07 Jun 2017 10:43:49 +0200

> If you agrees with this series please don't apply this patch. I will
> take care of it. We have many changes in the dt directory for the next
> release and I want that all the change are in the same place to take
> care of the merge conflict.

Ok, I will elide this patch when/if I apply the series to net-next.

Thanks.

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

* [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k
@ 2017-06-07 19:09       ` David Miller
  0 siblings, 0 replies; 56+ messages in thread
From: David Miller @ 2017-06-07 19:09 UTC (permalink / raw)
  To: linux-arm-kernel

From: Gregory CLEMENT <gregory.clement@free-electrons.com>
Date: Wed, 07 Jun 2017 10:43:49 +0200

> If you agrees with this series please don't apply this patch. I will
> take care of it. We have many changes in the dt directory for the next
> release and I want that all the change are in the same place to take
> care of the merge conflict.

Ok, I will elide this patch when/if I apply the series to net-next.

Thanks.

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

* Re: [PATCH 1/9] net: mvmdio: reorder headers alphabetically
  2017-06-07  8:38   ` Antoine Tenart
@ 2017-06-07 19:24     ` Florian Fainelli
  -1 siblings, 0 replies; 56+ messages in thread
From: Florian Fainelli @ 2017-06-07 19:24 UTC (permalink / raw)
  To: Antoine Tenart, davem, jason, andrew, gregory.clement,
	sebastian.hesselbarth
  Cc: thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> Cosmetic fix reordering headers alphabetically.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* [PATCH 1/9] net: mvmdio: reorder headers alphabetically
@ 2017-06-07 19:24     ` Florian Fainelli
  0 siblings, 0 replies; 56+ messages in thread
From: Florian Fainelli @ 2017-06-07 19:24 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> Cosmetic fix reordering headers alphabetically.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH 2/9] net: mvmdio: use tabs for defines
  2017-06-07  8:38   ` Antoine Tenart
@ 2017-06-07 19:24     ` Florian Fainelli
  -1 siblings, 0 replies; 56+ messages in thread
From: Florian Fainelli @ 2017-06-07 19:24 UTC (permalink / raw)
  To: Antoine Tenart, davem, jason, andrew, gregory.clement,
	sebastian.hesselbarth
  Cc: thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> Cosmetic patch replacing spaces by tabs for defined values.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* [PATCH 2/9] net: mvmdio: use tabs for defines
@ 2017-06-07 19:24     ` Florian Fainelli
  0 siblings, 0 replies; 56+ messages in thread
From: Florian Fainelli @ 2017-06-07 19:24 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> Cosmetic patch replacing spaces by tabs for defined values.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH 3/9] net: mvmdio: use GENMASK for masks
  2017-06-07  8:38   ` Antoine Tenart
@ 2017-06-07 19:24     ` Florian Fainelli
  -1 siblings, 0 replies; 56+ messages in thread
From: Florian Fainelli @ 2017-06-07 19:24 UTC (permalink / raw)
  To: Antoine Tenart, davem, jason, andrew, gregory.clement,
	sebastian.hesselbarth
  Cc: thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> Cosmetic patch to use the GENMASK helper for masks.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* [PATCH 3/9] net: mvmdio: use GENMASK for masks
@ 2017-06-07 19:24     ` Florian Fainelli
  0 siblings, 0 replies; 56+ messages in thread
From: Florian Fainelli @ 2017-06-07 19:24 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> Cosmetic patch to use the GENMASK helper for masks.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH 6/9] net: mvmdio: put the poll intervals in the private structure
  2017-06-07  8:38   ` Antoine Tenart
@ 2017-06-07 19:25     ` Florian Fainelli
  -1 siblings, 0 replies; 56+ messages in thread
From: Florian Fainelli @ 2017-06-07 19:25 UTC (permalink / raw)
  To: Antoine Tenart, davem, jason, andrew, gregory.clement,
	sebastian.hesselbarth
  Cc: thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> Put the two poll intervals (min and max) in the driver's private
> structure. This is needed to add the xmdio support later.
>
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* [PATCH 6/9] net: mvmdio: put the poll intervals in the private structure
@ 2017-06-07 19:25     ` Florian Fainelli
  0 siblings, 0 replies; 56+ messages in thread
From: Florian Fainelli @ 2017-06-07 19:25 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> Put the two poll intervals (min and max) in the driver's private
> structure. This is needed to add the xmdio support later.
>
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH 5/9] net: mvmdio: introduce an ops structure
  2017-06-07  8:38   ` Antoine Tenart
@ 2017-06-07 19:28     ` Florian Fainelli
  -1 siblings, 0 replies; 56+ messages in thread
From: Florian Fainelli @ 2017-06-07 19:28 UTC (permalink / raw)
  To: Antoine Tenart, davem, jason, andrew, gregory.clement,
	sebastian.hesselbarth
  Cc: thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> Introduce an ops structure to add an indirection on functions accessing
> the registers. This is needed to add the xMDIO support later.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> ---
>  drivers/net/ethernet/marvell/mvmdio.c | 65 +++++++++++++++++++++++++++--------
>  1 file changed, 51 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
> index 56bbe3990590..8a71ef93a61b 100644
> --- a/drivers/net/ethernet/marvell/mvmdio.c
> +++ b/drivers/net/ethernet/marvell/mvmdio.c
> @@ -62,6 +62,15 @@ struct orion_mdio_dev {
>  	 */
>  	int err_interrupt;
>  	wait_queue_head_t smi_busy_wait;
> +	struct orion_mdio_ops *ops;
> +};
> +
> +struct orion_mdio_ops {
> +	int (*is_done)(struct orion_mdio_dev *);
> +	int (*is_read_valid)(struct orion_mdio_dev *);
> +	void (*start_read)(struct orion_mdio_dev *, int, int);
> +	u16 (*read)(struct orion_mdio_dev *);
> +	void (*write)(struct orion_mdio_dev *, int, int, u16);
>  };
>  
>  static int orion_mdio_smi_is_done(struct orion_mdio_dev *dev)
> @@ -74,6 +83,30 @@ static int orion_mdio_smi_is_read_valid(struct orion_mdio_dev *dev)
>  	return !(readl(dev->regs) & MVMDIO_SMI_READ_VALID);
>  }
>  
> +static void orion_mdio_start_read_op(struct orion_mdio_dev *dev, int mii_id,
> +				     int regnum)
> +{
> +	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
> +		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
> +		MVMDIO_SMI_READ_OPERATION),
> +	       dev->regs);
> +}
> +
> +static u16 orion_mdio_read_op(struct orion_mdio_dev *dev)
> +{
> +	return readl(dev->regs) & GENMASK(15,0);
> +}
> +
> +static void orion_mdio_write_op(struct orion_mdio_dev *dev, int mii_id,
> +				int regnum, u16 value)
> +{
> +	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
> +		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
> +		MVMDIO_SMI_WRITE_OPERATION            |
> +		(value << MVMDIO_SMI_DATA_SHIFT)),
> +	       dev->regs);
> +}
> +
>  /* Wait for the SMI unit to be ready for another operation
>   */
>  static int orion_mdio_wait_ready(struct mii_bus *bus)
> @@ -84,7 +117,7 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
>  	int timedout = 0;
>  
>  	while (1) {
> -	        if (orion_mdio_smi_is_done(dev))
> +	        if (dev->ops->is_done(dev))

Nit: you could actually keep this function (and all of them that have a
corresponding dev->ops function pointer) and just make it a static
inline that calls into dev->ops->is_done()

That would limit the delta to review, and it would still be within the
namespace of the driver (orion_mdio_*).

Your call.

>  			return 0;
>  	        else if (timedout)
>  			break;
> @@ -103,8 +136,7 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
>  			if (timeout < 2)
>  				timeout = 2;
>  			wait_event_timeout(dev->smi_busy_wait,
> -				           orion_mdio_smi_is_done(dev),
> -				           timeout);
> +				           dev->ops->is_done(dev), timeout);
>  
>  			++timedout;
>  	        }
> @@ -126,22 +158,19 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
>  	if (ret < 0)
>  		goto out;
>  
> -	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
> -		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
> -		MVMDIO_SMI_READ_OPERATION),
> -	       dev->regs);
> +	dev->ops->start_read(dev, mii_id, regnum);
>  
>  	ret = orion_mdio_wait_ready(bus);
>  	if (ret < 0)
>  		goto out;
>  
> -	if (orion_mdio_smi_is_read_valid(dev)) {
> +	if (dev->ops->is_read_valid(dev)) {
>  		dev_err(bus->parent, "SMI bus read not valid\n");
>  		ret = -ENODEV;
>  		goto out;
>  	}
>  
> -	ret = readl(dev->regs) & GENMASK(15,0);
> +	ret = dev->ops->read(dev);
>  out:
>  	mutex_unlock(&dev->lock);
>  	return ret;
> @@ -159,11 +188,7 @@ static int orion_mdio_write(struct mii_bus *bus, int mii_id,
>  	if (ret < 0)
>  		goto out;
>  
> -	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
> -		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
> -		MVMDIO_SMI_WRITE_OPERATION            |
> -		(value << MVMDIO_SMI_DATA_SHIFT)),
> -	       dev->regs);
> +	dev->ops->write(dev, mii_id, regnum, value);
>  
>  out:
>  	mutex_unlock(&dev->lock);
> @@ -190,6 +215,7 @@ static int orion_mdio_probe(struct platform_device *pdev)
>  	struct resource *r;
>  	struct mii_bus *bus;
>  	struct orion_mdio_dev *dev;
> +	struct orion_mdio_ops *ops;
>  	int i, ret;
>  
>  	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -249,6 +275,17 @@ static int orion_mdio_probe(struct platform_device *pdev)
>  
>  	mutex_init(&dev->lock);
>  
> +	ops = devm_kzalloc(&pdev->dev, sizeof(*ops), GFP_KERNEL);
> +	if (!ops)
> +		return -ENOMEM;
> +
> +	ops->is_done = orion_mdio_smi_is_done;
> +	ops->is_read_valid = orion_mdio_smi_is_read_valid;
> +	ops->start_read = orion_mdio_start_read_op;
> +	ops->read = orion_mdio_read_op;
> +	ops->write = orion_mdio_write_op;
> +	dev->ops = ops;
> +
>  	if (pdev->dev.of_node)
>  		ret = of_mdiobus_register(bus, pdev->dev.of_node);
>  	else
> 


-- 
Florian

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

* [PATCH 5/9] net: mvmdio: introduce an ops structure
@ 2017-06-07 19:28     ` Florian Fainelli
  0 siblings, 0 replies; 56+ messages in thread
From: Florian Fainelli @ 2017-06-07 19:28 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> Introduce an ops structure to add an indirection on functions accessing
> the registers. This is needed to add the xMDIO support later.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> ---
>  drivers/net/ethernet/marvell/mvmdio.c | 65 +++++++++++++++++++++++++++--------
>  1 file changed, 51 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
> index 56bbe3990590..8a71ef93a61b 100644
> --- a/drivers/net/ethernet/marvell/mvmdio.c
> +++ b/drivers/net/ethernet/marvell/mvmdio.c
> @@ -62,6 +62,15 @@ struct orion_mdio_dev {
>  	 */
>  	int err_interrupt;
>  	wait_queue_head_t smi_busy_wait;
> +	struct orion_mdio_ops *ops;
> +};
> +
> +struct orion_mdio_ops {
> +	int (*is_done)(struct orion_mdio_dev *);
> +	int (*is_read_valid)(struct orion_mdio_dev *);
> +	void (*start_read)(struct orion_mdio_dev *, int, int);
> +	u16 (*read)(struct orion_mdio_dev *);
> +	void (*write)(struct orion_mdio_dev *, int, int, u16);
>  };
>  
>  static int orion_mdio_smi_is_done(struct orion_mdio_dev *dev)
> @@ -74,6 +83,30 @@ static int orion_mdio_smi_is_read_valid(struct orion_mdio_dev *dev)
>  	return !(readl(dev->regs) & MVMDIO_SMI_READ_VALID);
>  }
>  
> +static void orion_mdio_start_read_op(struct orion_mdio_dev *dev, int mii_id,
> +				     int regnum)
> +{
> +	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
> +		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
> +		MVMDIO_SMI_READ_OPERATION),
> +	       dev->regs);
> +}
> +
> +static u16 orion_mdio_read_op(struct orion_mdio_dev *dev)
> +{
> +	return readl(dev->regs) & GENMASK(15,0);
> +}
> +
> +static void orion_mdio_write_op(struct orion_mdio_dev *dev, int mii_id,
> +				int regnum, u16 value)
> +{
> +	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
> +		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
> +		MVMDIO_SMI_WRITE_OPERATION            |
> +		(value << MVMDIO_SMI_DATA_SHIFT)),
> +	       dev->regs);
> +}
> +
>  /* Wait for the SMI unit to be ready for another operation
>   */
>  static int orion_mdio_wait_ready(struct mii_bus *bus)
> @@ -84,7 +117,7 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
>  	int timedout = 0;
>  
>  	while (1) {
> -	        if (orion_mdio_smi_is_done(dev))
> +	        if (dev->ops->is_done(dev))

Nit: you could actually keep this function (and all of them that have a
corresponding dev->ops function pointer) and just make it a static
inline that calls into dev->ops->is_done()

That would limit the delta to review, and it would still be within the
namespace of the driver (orion_mdio_*).

Your call.

>  			return 0;
>  	        else if (timedout)
>  			break;
> @@ -103,8 +136,7 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
>  			if (timeout < 2)
>  				timeout = 2;
>  			wait_event_timeout(dev->smi_busy_wait,
> -				           orion_mdio_smi_is_done(dev),
> -				           timeout);
> +				           dev->ops->is_done(dev), timeout);
>  
>  			++timedout;
>  	        }
> @@ -126,22 +158,19 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
>  	if (ret < 0)
>  		goto out;
>  
> -	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
> -		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
> -		MVMDIO_SMI_READ_OPERATION),
> -	       dev->regs);
> +	dev->ops->start_read(dev, mii_id, regnum);
>  
>  	ret = orion_mdio_wait_ready(bus);
>  	if (ret < 0)
>  		goto out;
>  
> -	if (orion_mdio_smi_is_read_valid(dev)) {
> +	if (dev->ops->is_read_valid(dev)) {
>  		dev_err(bus->parent, "SMI bus read not valid\n");
>  		ret = -ENODEV;
>  		goto out;
>  	}
>  
> -	ret = readl(dev->regs) & GENMASK(15,0);
> +	ret = dev->ops->read(dev);
>  out:
>  	mutex_unlock(&dev->lock);
>  	return ret;
> @@ -159,11 +188,7 @@ static int orion_mdio_write(struct mii_bus *bus, int mii_id,
>  	if (ret < 0)
>  		goto out;
>  
> -	writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
> -		(regnum << MVMDIO_SMI_PHY_REG_SHIFT)  |
> -		MVMDIO_SMI_WRITE_OPERATION            |
> -		(value << MVMDIO_SMI_DATA_SHIFT)),
> -	       dev->regs);
> +	dev->ops->write(dev, mii_id, regnum, value);
>  
>  out:
>  	mutex_unlock(&dev->lock);
> @@ -190,6 +215,7 @@ static int orion_mdio_probe(struct platform_device *pdev)
>  	struct resource *r;
>  	struct mii_bus *bus;
>  	struct orion_mdio_dev *dev;
> +	struct orion_mdio_ops *ops;
>  	int i, ret;
>  
>  	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -249,6 +275,17 @@ static int orion_mdio_probe(struct platform_device *pdev)
>  
>  	mutex_init(&dev->lock);
>  
> +	ops = devm_kzalloc(&pdev->dev, sizeof(*ops), GFP_KERNEL);
> +	if (!ops)
> +		return -ENOMEM;
> +
> +	ops->is_done = orion_mdio_smi_is_done;
> +	ops->is_read_valid = orion_mdio_smi_is_read_valid;
> +	ops->start_read = orion_mdio_start_read_op;
> +	ops->read = orion_mdio_read_op;
> +	ops->write = orion_mdio_write_op;
> +	dev->ops = ops;
> +
>  	if (pdev->dev.of_node)
>  		ret = of_mdiobus_register(bus, pdev->dev.of_node);
>  	else
> 


-- 
Florian

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

* Re: [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k
  2017-06-07  8:38   ` Antoine Tenart
@ 2017-06-08  8:45     ` Antoine Tenart
  -1 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-08  8:45 UTC (permalink / raw)
  To: davem, jason, andrew, gregory.clement, sebastian.hesselbarth, f.fainelli
  Cc: Antoine Tenart, thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 995 bytes --]

Hi Gregory,

On Wed, Jun 07, 2017 at 10:38:10AM +0200, Antoine Tenart wrote:
> diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> index 2a99ff8fca2a..594356243ddb 100644
> --- a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> +++ b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> @@ -103,6 +103,13 @@
>  				clocks = <&cps_syscon0 1 9>, <&cps_syscon0 1 5>;
>  			};
>  
> +			cps_xmdio: mdio@12a600 {
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				compatible = "marvell,xmdio";
> +				reg = <0x12a600 0x10>;
> +			};
> +

Russell pointed out on IRC the mdio/xmdio interfaces aren't wired to
anything on the mcbin. We could either disable these interfaces by
default, or add explicit disables in the mcbin device tree.

What's your thoughts on this?

Thanks!
Antoine

-- 
Antoine Ténart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k
@ 2017-06-08  8:45     ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-08  8:45 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Gregory,

On Wed, Jun 07, 2017 at 10:38:10AM +0200, Antoine Tenart wrote:
> diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> index 2a99ff8fca2a..594356243ddb 100644
> --- a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> +++ b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> @@ -103,6 +103,13 @@
>  				clocks = <&cps_syscon0 1 9>, <&cps_syscon0 1 5>;
>  			};
>  
> +			cps_xmdio: mdio at 12a600 {
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +				compatible = "marvell,xmdio";
> +				reg = <0x12a600 0x10>;
> +			};
> +

Russell pointed out on IRC the mdio/xmdio interfaces aren't wired to
anything on the mcbin. We could either disable these interfaces by
default, or add explicit disables in the mcbin device tree.

What's your thoughts on this?

Thanks!
Antoine

-- 
Antoine T?nart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170608/d6e8a142/attachment-0001.sig>

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

* Re: [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k
  2017-06-08  8:45     ` Antoine Tenart
@ 2017-06-08  8:51       ` Antoine Tenart
  -1 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-08  8:51 UTC (permalink / raw)
  To: davem, jason, andrew, gregory.clement, sebastian.hesselbarth, f.fainelli
  Cc: Antoine Tenart, thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 975 bytes --]

On Thu, Jun 08, 2017 at 10:45:15AM +0200, Antoine Tenart wrote:
> On Wed, Jun 07, 2017 at 10:38:10AM +0200, Antoine Tenart wrote:
> > diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> > index 2a99ff8fca2a..594356243ddb 100644
> > --- a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> > +++ b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> > @@ -103,6 +103,13 @@
> >  				clocks = <&cps_syscon0 1 9>, <&cps_syscon0 1 5>;
> >  			};
> >  
> > +			cps_xmdio: mdio@12a600 {
> > +				#address-cells = <1>;
> > +				#size-cells = <0>;
> > +				compatible = "marvell,xmdio";
> > +				reg = <0x12a600 0x10>;
> > +			};
> > +
> 
> Russell pointed out on IRC the mdio/xmdio interfaces aren't wired to
> anything on the mcbin.

The ones found in the cp110 slave *

Antoine

-- 
Antoine Ténart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k
@ 2017-06-08  8:51       ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-08  8:51 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jun 08, 2017 at 10:45:15AM +0200, Antoine Tenart wrote:
> On Wed, Jun 07, 2017 at 10:38:10AM +0200, Antoine Tenart wrote:
> > diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> > index 2a99ff8fca2a..594356243ddb 100644
> > --- a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> > +++ b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> > @@ -103,6 +103,13 @@
> >  				clocks = <&cps_syscon0 1 9>, <&cps_syscon0 1 5>;
> >  			};
> >  
> > +			cps_xmdio: mdio at 12a600 {
> > +				#address-cells = <1>;
> > +				#size-cells = <0>;
> > +				compatible = "marvell,xmdio";
> > +				reg = <0x12a600 0x10>;
> > +			};
> > +
> 
> Russell pointed out on IRC the mdio/xmdio interfaces aren't wired to
> anything on the mcbin.

The ones found in the cp110 slave *

Antoine

-- 
Antoine T?nart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170608/0eb19b16/attachment-0001.sig>

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

* Re: [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k
  2017-06-08  8:45     ` Antoine Tenart
@ 2017-06-08  8:55       ` Gregory CLEMENT
  -1 siblings, 0 replies; 56+ messages in thread
From: Gregory CLEMENT @ 2017-06-08  8:55 UTC (permalink / raw)
  To: Antoine Tenart
  Cc: davem, jason, andrew, sebastian.hesselbarth, f.fainelli,
	thomas.petazzoni, mw, linux, netdev, linux-arm-kernel

Hi Antoine,
 
 On jeu., juin 08 2017, Antoine Tenart <antoine.tenart@free-electrons.com> wrote:

> Hi Gregory,
>
> On Wed, Jun 07, 2017 at 10:38:10AM +0200, Antoine Tenart wrote:
>> diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
>> index 2a99ff8fca2a..594356243ddb 100644
>> --- a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
>> +++ b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
>> @@ -103,6 +103,13 @@
>>  				clocks = <&cps_syscon0 1 9>, <&cps_syscon0 1 5>;
>>  			};
>>  
>> +			cps_xmdio: mdio@12a600 {
>> +				#address-cells = <1>;
>> +				#size-cells = <0>;
>> +				compatible = "marvell,xmdio";
>> +				reg = <0x12a600 0x10>;
>> +			};
>> +
>
> Russell pointed out on IRC the mdio/xmdio interfaces aren't wired to
> anything on the mcbin. We could either disable these interfaces by
> default, or add explicit disables in the mcbin device tree.
>
> What's your thoughts on this?

I prefer that we disable it by default and only enable it on the boards
using it.

Thanks,

Gregory

>
> Thanks!
> Antoine
>
> -- 
> Antoine Ténart, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k
@ 2017-06-08  8:55       ` Gregory CLEMENT
  0 siblings, 0 replies; 56+ messages in thread
From: Gregory CLEMENT @ 2017-06-08  8:55 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Antoine,
 
 On jeu., juin 08 2017, Antoine Tenart <antoine.tenart@free-electrons.com> wrote:

> Hi Gregory,
>
> On Wed, Jun 07, 2017 at 10:38:10AM +0200, Antoine Tenart wrote:
>> diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
>> index 2a99ff8fca2a..594356243ddb 100644
>> --- a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
>> +++ b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
>> @@ -103,6 +103,13 @@
>>  				clocks = <&cps_syscon0 1 9>, <&cps_syscon0 1 5>;
>>  			};
>>  
>> +			cps_xmdio: mdio at 12a600 {
>> +				#address-cells = <1>;
>> +				#size-cells = <0>;
>> +				compatible = "marvell,xmdio";
>> +				reg = <0x12a600 0x10>;
>> +			};
>> +
>
> Russell pointed out on IRC the mdio/xmdio interfaces aren't wired to
> anything on the mcbin. We could either disable these interfaces by
> default, or add explicit disables in the mcbin device tree.
>
> What's your thoughts on this?

I prefer that we disable it by default and only enable it on the boards
using it.

Thanks,

Gregory

>
> Thanks!
> Antoine
>
> -- 
> Antoine T?nart, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* Re: [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k
  2017-06-08  8:55       ` Gregory CLEMENT
@ 2017-06-08  9:03         ` Antoine Tenart
  -1 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-08  9:03 UTC (permalink / raw)
  To: Gregory CLEMENT
  Cc: Antoine Tenart, davem, jason, andrew, sebastian.hesselbarth,
	f.fainelli, thomas.petazzoni, mw, linux, netdev,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1429 bytes --]

Hi Gregory,

On Thu, Jun 08, 2017 at 10:55:01AM +0200, Gregory CLEMENT wrote:
>  On jeu., juin 08 2017, Antoine Tenart <antoine.tenart@free-electrons.com> wrote:
> > On Wed, Jun 07, 2017 at 10:38:10AM +0200, Antoine Tenart wrote:
> >> diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> >> index 2a99ff8fca2a..594356243ddb 100644
> >> --- a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> >> +++ b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> >> @@ -103,6 +103,13 @@
> >>  				clocks = <&cps_syscon0 1 9>, <&cps_syscon0 1 5>;
> >>  			};
> >>  
> >> +			cps_xmdio: mdio@12a600 {
> >> +				#address-cells = <1>;
> >> +				#size-cells = <0>;
> >> +				compatible = "marvell,xmdio";
> >> +				reg = <0x12a600 0x10>;
> >> +			};
> >> +
> >
> > Russell pointed out on IRC the mdio/xmdio interfaces aren't wired to
> > anything on the mcbin. We could either disable these interfaces by
> > default, or add explicit disables in the mcbin device tree.
> >
> > What's your thoughts on this?
> 
> I prefer that we disable it by default and only enable it on the boards
> using it.

OK. I'll add a disabled status property in this patch, and I'll make
another series to fix the existing mdio nodes.

Thanks!
Antoine

-- 
Antoine Ténart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k
@ 2017-06-08  9:03         ` Antoine Tenart
  0 siblings, 0 replies; 56+ messages in thread
From: Antoine Tenart @ 2017-06-08  9:03 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Gregory,

On Thu, Jun 08, 2017 at 10:55:01AM +0200, Gregory CLEMENT wrote:
>  On jeu., juin 08 2017, Antoine Tenart <antoine.tenart@free-electrons.com> wrote:
> > On Wed, Jun 07, 2017 at 10:38:10AM +0200, Antoine Tenart wrote:
> >> diff --git a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> >> index 2a99ff8fca2a..594356243ddb 100644
> >> --- a/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> >> +++ b/arch/arm64/boot/dts/marvell/armada-cp110-slave.dtsi
> >> @@ -103,6 +103,13 @@
> >>  				clocks = <&cps_syscon0 1 9>, <&cps_syscon0 1 5>;
> >>  			};
> >>  
> >> +			cps_xmdio: mdio at 12a600 {
> >> +				#address-cells = <1>;
> >> +				#size-cells = <0>;
> >> +				compatible = "marvell,xmdio";
> >> +				reg = <0x12a600 0x10>;
> >> +			};
> >> +
> >
> > Russell pointed out on IRC the mdio/xmdio interfaces aren't wired to
> > anything on the mcbin. We could either disable these interfaces by
> > default, or add explicit disables in the mcbin device tree.
> >
> > What's your thoughts on this?
> 
> I prefer that we disable it by default and only enable it on the boards
> using it.

OK. I'll add a disabled status property in this patch, and I'll make
another series to fix the existing mdio nodes.

Thanks!
Antoine

-- 
Antoine T?nart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170608/ad114e0f/attachment.sig>

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

end of thread, other threads:[~2017-06-08  9:03 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-07  8:38 [PATCH 0/9] net: mvmdio: add xSMI support Antoine Tenart
2017-06-07  8:38 ` Antoine Tenart
2017-06-07  8:38 ` [PATCH 1/9] net: mvmdio: reorder headers alphabetically Antoine Tenart
2017-06-07  8:38   ` Antoine Tenart
2017-06-07 19:24   ` Florian Fainelli
2017-06-07 19:24     ` Florian Fainelli
2017-06-07  8:38 ` [PATCH 2/9] net: mvmdio: use tabs for defines Antoine Tenart
2017-06-07  8:38   ` Antoine Tenart
2017-06-07 19:24   ` Florian Fainelli
2017-06-07 19:24     ` Florian Fainelli
2017-06-07  8:38 ` [PATCH 3/9] net: mvmdio: use GENMASK for masks Antoine Tenart
2017-06-07  8:38   ` Antoine Tenart
2017-06-07 19:24   ` Florian Fainelli
2017-06-07 19:24     ` Florian Fainelli
2017-06-07  8:38 ` [PATCH 4/9] net: mvmdio: move the read valid check into its own function Antoine Tenart
2017-06-07  8:38   ` Antoine Tenart
2017-06-07 10:00   ` Sergei Shtylyov
2017-06-07 10:00     ` Sergei Shtylyov
2017-06-07 14:43     ` Antoine Tenart
2017-06-07 14:43       ` Antoine Tenart
2017-06-07  8:38 ` [PATCH 5/9] net: mvmdio: introduce an ops structure Antoine Tenart
2017-06-07  8:38   ` Antoine Tenart
2017-06-07 19:28   ` Florian Fainelli
2017-06-07 19:28     ` Florian Fainelli
2017-06-07  8:38 ` [PATCH 6/9] net: mvmdio: put the poll intervals in the private structure Antoine Tenart
2017-06-07  8:38   ` Antoine Tenart
2017-06-07 19:25   ` Florian Fainelli
2017-06-07 19:25     ` Florian Fainelli
2017-06-07  8:38 ` [PATCH 7/9] net: mvmdio: add xmdio support Antoine Tenart
2017-06-07  8:38   ` Antoine Tenart
2017-06-07 12:12   ` Andrew Lunn
2017-06-07 12:12     ` Andrew Lunn
2017-06-07 14:42     ` Antoine Tenart
2017-06-07 14:42       ` Antoine Tenart
2017-06-07 15:48   ` Florian Fainelli
2017-06-07 15:48     ` Florian Fainelli
2017-06-07 15:56     ` Russell King - ARM Linux
2017-06-07 15:56       ` Russell King - ARM Linux
2017-06-07 16:13     ` Antoine Tenart
2017-06-07 16:13       ` Antoine Tenart
2017-06-07  8:38 ` [PATCH 8/9] dt-bindings: orion-mdio: document the new xmdio compatible Antoine Tenart
2017-06-07  8:38   ` Antoine Tenart
2017-06-07  8:38 ` [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k Antoine Tenart
2017-06-07  8:38   ` Antoine Tenart
2017-06-07  8:43   ` Gregory CLEMENT
2017-06-07  8:43     ` Gregory CLEMENT
2017-06-07 19:09     ` David Miller
2017-06-07 19:09       ` David Miller
2017-06-08  8:45   ` Antoine Tenart
2017-06-08  8:45     ` Antoine Tenart
2017-06-08  8:51     ` Antoine Tenart
2017-06-08  8:51       ` Antoine Tenart
2017-06-08  8:55     ` Gregory CLEMENT
2017-06-08  8:55       ` Gregory CLEMENT
2017-06-08  9:03       ` Antoine Tenart
2017-06-08  9:03         ` Antoine Tenart

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.