Skip to contentSkip to conversation

net: mdio: add ipq8064 mdio driver

PATCH Superseded Ansuel Smith 3 participants 6 messages Feb 20, 2020 – Feb 21, 2020

Subsystems (5)

v3 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 net: mdio: add ipq8064 mdio driver

Currently ipq806x soc use generi bitbang driver to comunicate with the gmac ethernet interface. Add a dedicated driver created by chunkeey to fix this.

Christian Lamparter <[email protected]>

---
 drivers/net/phy/Kconfig        |   8 ++
 drivers/net/phy/Makefile       |   1 +
 drivers/net/phy/mdio-ipq8064.c | 163 +++++++++++++++++++++++++++++++++
 3 files changed, 172 insertions(+)
 create mode 100644 drivers/net/phy/mdio-ipq8064.c
drivers/net/phy/Kconfig +8 -0
index 9dabe03a668c..ec2a5493a7e8 100644
@@ -157,6 +157,14 @@ config MDIO_I2C
 
 	  This is library mode.
 
+config MDIO_IPQ8064
+	tristate "Qualcomm IPQ8064 MDIO interface support"
+	depends on HAS_IOMEM && OF_MDIO
+	depends on MFD_SYSCON
+	help
+	  This driver supports the MDIO interface found in the network
+	  interface units of the IPQ8064 SoC
+
 config MDIO_MOXART
 	tristate "MOXA ART MDIO interface support"
 	depends on ARCH_MOXART || COMPILE_TEST
drivers/net/phy/Makefile +1 -0
index fe5badf13b65..8f02bd2089f3 100644
@@ -36,6 +36,7 @@ obj-$(CONFIG_MDIO_CAVIUM)	+= mdio-cavium.o
 obj-$(CONFIG_MDIO_GPIO)		+= mdio-gpio.o
 obj-$(CONFIG_MDIO_HISI_FEMAC)	+= mdio-hisi-femac.o
 obj-$(CONFIG_MDIO_I2C)		+= mdio-i2c.o
+obj-$(CONFIG_MDIO_IPQ8064)	+= mdio-ipq8064.o
 obj-$(CONFIG_MDIO_MOXART)	+= mdio-moxart.o
 obj-$(CONFIG_MDIO_MSCC_MIIM)	+= mdio-mscc-miim.o
 obj-$(CONFIG_MDIO_OCTEON)	+= mdio-octeon.o
drivers/net/phy/mdio-ipq8064.c new file +163 -0

163 lines not on this page · raw message

Signature · 1 line
2.25.0
#1 lore raw

PATCH v3 2/2 Documentation: devictree: Add ipq806x mdio bindings

Add documentations for ipq806x mdio driver.

---
 .../bindings/net/qcom,ipq8064-mdio.yaml       | 55 +++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/qcom,ipq8064-mdio.yaml
Documentation/devicetree/bindings/net/qcom,ipq8064-mdio.yaml new file +55 -0
new file mode 100644
index 000000000000..d2254a5ff2ad
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/qcom,ipq8064-mdio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm ipq806x MDIO bus controller
+
+maintainers:
+  - Ansuel Smith <[email protected]>
+
+description: |+
+  The ipq806x soc have a MDIO dedicated controller that is
+  used to comunicate with the gmac phy conntected.
+  Child nodes of this MDIO bus controller node are standard
+  Ethernet PHY device nodes as described in
+  Documentation/devicetree/bindings/net/phy.txt
+
+allOf:
+  - $ref: "mdio.yaml#"
+
+properties:
+  compatible:
+    const: qcom,ipq8064-mdio
+  reg:
+    maxItems: 1
+    description: address and length of the register set for the device
+  clocks:
+    maxItems: 1
+    description: A reference to the clock supplying the MDIO bus controller
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - "#address-cells"
+  - "#size-cells"
+
+examples:
+  - |
+    mdio0: mdio@37000000 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        compatible = "qcom,ipq8064-mdio", "syscon";
+        reg = <0x37000000 0x200000>;
+        resets = <&gcc GMAC_CORE1_RESET>;
+        reset-names = "stmmaceth";
+        clocks = <&gcc GMAC_CORE1_CLK>;
+
+        switch@10 {
+            compatible = "qca,qca8337";
+            ...
+        }
+    };
Signature · 1 line
2.25.0
#3 lore raw
In reply to Ansuel Smith
Quoted 74 lines · Ansuel Smith

Currently ipq806x soc use generi bitbang driver to comunicate with the gmac ethernet interface. Add a dedicated driver created by chunkeey to fix this.

Christian Lamparter <[email protected]>

---
 drivers/net/phy/Kconfig        |   8 ++
 drivers/net/phy/Makefile       |   1 +
 drivers/net/phy/mdio-ipq8064.c | 163 +++++++++++++++++++++++++++++++++
 3 files changed, 172 insertions(+)
 create mode 100644 drivers/net/phy/mdio-ipq8064.c
drivers/net/phy/Kconfig +8 -0
index 9dabe03a668c..ec2a5493a7e8 100644
@@ -157,6 +157,14 @@ config MDIO_I2C
 
 	  This is library mode.
 
+config MDIO_IPQ8064
+	tristate "Qualcomm IPQ8064 MDIO interface support"
+	depends on HAS_IOMEM && OF_MDIO
+	depends on MFD_SYSCON
+	help
+	  This driver supports the MDIO interface found in the network
+	  interface units of the IPQ8064 SoC
+
 config MDIO_MOXART
 	tristate "MOXA ART MDIO interface support"
 	depends on ARCH_MOXART || COMPILE_TEST
drivers/net/phy/Makefile +1 -0
index fe5badf13b65..8f02bd2089f3 100644
@@ -36,6 +36,7 @@ obj-$(CONFIG_MDIO_CAVIUM)	+= mdio-cavium.o
 obj-$(CONFIG_MDIO_GPIO)		+= mdio-gpio.o
 obj-$(CONFIG_MDIO_HISI_FEMAC)	+= mdio-hisi-femac.o
 obj-$(CONFIG_MDIO_I2C)		+= mdio-i2c.o
+obj-$(CONFIG_MDIO_IPQ8064)	+= mdio-ipq8064.o
 obj-$(CONFIG_MDIO_MOXART)	+= mdio-moxart.o
 obj-$(CONFIG_MDIO_MSCC_MIIM)	+= mdio-mscc-miim.o
 obj-$(CONFIG_MDIO_OCTEON)	+= mdio-octeon.o
drivers/net/phy/mdio-ipq8064.c new file +24 -0
new file mode 100644
index 000000000000..e974a6f5d5ef
@@ -0,0 +1,163 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Qualcomm IPQ8064 MDIO interface driver
+//
+// Copyright (C) 2019 Christian Lamparter <[email protected]>
+
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/of_mdio.h>
+#include <linux/phy.h>
+#include <linux/platform_device.h>
+#include <linux/mfd/syscon.h>
+
+/* MII address register definitions */
+#define MII_ADDR_REG_ADDR                       0x10
+#define MII_BUSY                                BIT(0)
+#define MII_WRITE                               BIT(1)
+#define MII_CLKRANGE_60_100M                    (0 << 2)
+#define MII_CLKRANGE_100_150M                   (1 << 2)
+#define MII_CLKRANGE_20_35M                     (2 << 2)
+#define MII_CLKRANGE_35_60M                     (3 << 2)
+#define MII_CLKRANGE_150_250M                   (4 << 2)

drivers/net/phy/mdio-ipq8064.c line 34

Quoted 10 lines
drivers/net/phy/mdio-ipq8064.c new file +10 -0
+#define MII_CLKRANGE_250_300M                   (5 << 2)
+#define MII_CLKRANGE_MASK			GENMASK(4, 2)
+#define MII_REG_SHIFT				6
+#define MII_REG_MASK				GENMASK(10, 6)
+#define MII_ADDR_SHIFT				11
+#define MII_ADDR_MASK				GENMASK(15, 11)
+
+#define MII_DATA_REG_ADDR                       0x14
+
+#define MII_MDIO_DELAY                          (1000)

Maybe name this MII_MDIO_DELAY_USEC to show that it is in microseconds?

drivers/net/phy/mdio-ipq8064.c line 35

Quoted 1 line
drivers/net/phy/mdio-ipq8064.c new file +1 -0
+#define MII_MDIO_RETRY                          (10)

Maybe name this MII_MDIO_RETRY_MSEC to show that it is in milliseconds?

drivers/net/phy/mdio-ipq8064.c line 48

Quoted 13 lines
drivers/net/phy/mdio-ipq8064.c new file +13 -0
+
+struct ipq8064_mdio {
+	struct regmap *base; /* NSS_GMAC0_BASE */
+};
+
+static int
+ipq8064_mdio_wait_busy(struct ipq8064_mdio *priv)
+{
+	u32 busy;
+
+	return regmap_read_poll_timeout(priv->base, MII_ADDR_REG_ADDR, busy,
+				   !(busy & MII_BUSY), MII_MDIO_DELAY,
+				   MII_MDIO_RETRY * USEC_PER_MSEC);

Thanks.

drivers/net/phy/mdio-ipq8064.c line 61

Quoted 13 lines
drivers/net/phy/mdio-ipq8064.c new file +13 -0
+}
+
+static int
+ipq8064_mdio_read(struct mii_bus *bus, int phy_addr, int reg_offset)
+{
+	struct ipq8064_mdio *priv = bus->priv;
+	u32 miiaddr = MII_BUSY | MII_CLKRANGE_250_300M;
+	u32 ret_val;
+	int err;
+
+	/* Reject clause 45 */
+	if (reg_offset & MII_ADDR_C45)
+		return -EOPNOTSUPP;

Thanks.

Quoted 14 lines
drivers/net/phy/mdio-ipq8064.c new file +14 -0
+
+	miiaddr |= ((phy_addr << MII_ADDR_SHIFT) & MII_ADDR_MASK) |
+		   ((reg_offset << MII_REG_SHIFT) & MII_REG_MASK);
+
+	regmap_write(priv->base, MII_ADDR_REG_ADDR, miiaddr);
+	usleep_range(10, 20);
+
+	err = ipq8064_mdio_wait_busy(priv);
+	if (err)
+		return err;
+
+	regmap_read(priv->base, MII_DATA_REG_ADDR, &ret_val);
+	return (int)ret_val;
+}

drivers/net/phy/mdio-ipq8064.c line 85

Quoted 10 lines
drivers/net/phy/mdio-ipq8064.c new file +10 -0
+
+static int
+ipq8064_mdio_write(struct mii_bus *bus, int phy_addr, int reg_offset, u16 data)
+{
+	struct ipq8064_mdio *priv = bus->priv;
+	u32 miiaddr = MII_WRITE | MII_BUSY | MII_CLKRANGE_250_300M;
+
+	/* Reject clause 45 */
+	if (reg_offset & MII_ADDR_C45)
+		return -EOPNOTSUPP;

Thanks.

Quoted 29 lines
drivers/net/phy/mdio-ipq8064.c new file +29 -0
+
+	regmap_write(priv->base, MII_DATA_REG_ADDR, data);
+
+	miiaddr |= ((phy_addr << MII_ADDR_SHIFT) & MII_ADDR_MASK) |
+		   ((reg_offset << MII_REG_SHIFT) & MII_REG_MASK);
+
+	regmap_write(priv->base, MII_ADDR_REG_ADDR, miiaddr);
+	usleep_range(10, 20);
+
+	return ipq8064_mdio_wait_busy(priv);
+}
+
+static int
+ipq8064_mdio_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct ipq8064_mdio *priv;
+	struct mii_bus *bus;
+	int ret;
+
+	bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv));
+	if (!bus)
+		return -ENOMEM;
+
+	bus->name = "ipq8064_mdio_bus";
+	bus->read = ipq8064_mdio_read;
+	bus->write = ipq8064_mdio_write;
+	snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(&pdev->dev));
+	bus->parent = &pdev->dev;

drivers/net/phy/mdio-ipq8064.c line 124

Quoted 10 lines
drivers/net/phy/mdio-ipq8064.c new file +10 -0
+
+	priv = bus->priv;
+	priv->base = syscon_node_to_regmap(np);
+	if (IS_ERR_OR_NULL(priv->base)) {
+		priv->base = syscon_regmap_lookup_by_phandle(np, "master");
+		if (IS_ERR_OR_NULL(priv->base)) {
+			dev_err(&pdev->dev, "master phandle not found\n");
+			return -EINVAL;
+		}
+	}

I'm curious why you've kept this as-is given my comments?

If you don't agree with them, it would be helpful to reply to the review email giving the reasons why.

Thanks.

Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up
#4 lore raw

R: [PATCH v3 1/2] net: mdio: add ipq8064 mdio driver

Quoted 206 lines · Ansuel Smith
Quoted 10 lines

Currently ipq806x soc use generi bitbang driver to comunicate with the gmac ethernet interface. Add a dedicated driver created by chunkeey to fix this.

Christian Lamparter <[email protected]>

---
 drivers/net/phy/Kconfig        |   8 ++
 drivers/net/phy/Makefile       |   1 +
 drivers/net/phy/mdio-ipq8064.c | 163

+++++++++++++++++++++++++++++++++

drivers/net/phy/Makefile obj-$(CONFIG_MDIO_CAVIUM) += mdio-

Quoted 27 lines
 3 files changed, 172 insertions(+)
 create mode 100644 drivers/net/phy/mdio-ipq8064.c
drivers/net/phy/Kconfig +8 -0
index 9dabe03a668c..ec2a5493a7e8 100644
@@ -157,6 +157,14 @@ config MDIO_I2C
 
 	  This is library mode.
 
+config MDIO_IPQ8064
+	tristate "Qualcomm IPQ8064 MDIO interface support"
+	depends on HAS_IOMEM && OF_MDIO
+	depends on MFD_SYSCON
+	help
+	  This driver supports the MDIO interface found in the network
+	  interface units of the IPQ8064 SoC
+
 config MDIO_MOXART
 	tristate "MOXA ART MDIO interface support"
 	depends on ARCH_MOXART || COMPILE_TEST
drivers/net/phy/Makefile +0 -0
index fe5badf13b65..8f02bd2089f3 100644
@@ -36,6 +36,7 @@ obj-$(CONFIG_MDIO_CAVIUM)	+= mdio-

cavium.o

drivers/net/phy/mdio-

Quoted 8 lines
drivers/net/phy/Makefile +1 -0
 obj-$(CONFIG_MDIO_GPIO)		+= mdio-gpio.o
 obj-$(CONFIG_MDIO_HISI_FEMAC)	+= mdio-hisi-femac.o
 obj-$(CONFIG_MDIO_I2C)		+= mdio-i2c.o
+obj-$(CONFIG_MDIO_IPQ8064)	+= mdio-ipq8064.o
 obj-$(CONFIG_MDIO_MOXART)	+= mdio-moxart.o
 obj-$(CONFIG_MDIO_MSCC_MIIM)	+= mdio-mscc-miim.o
 obj-$(CONFIG_MDIO_OCTEON)	+= mdio-octeon.o
drivers/net/phy/mdio- renamed from drivers/net/phy/mdio-ipq8064.c +0 -0

ipq8064.c

Quoted 29 lines

new file mode 100644
index 000000000000..e974a6f5d5ef

drivers/net/phy/mdio-ipq8064.c new file +24 -0
@@ -0,0 +1,163 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Qualcomm IPQ8064 MDIO interface driver
+//
+// Copyright (C) 2019 Christian Lamparter <[email protected]>
+
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/of_mdio.h>
+#include <linux/phy.h>
+#include <linux/platform_device.h>
+#include <linux/mfd/syscon.h>
+
+/* MII address register definitions */
+#define MII_ADDR_REG_ADDR                       0x10
+#define MII_BUSY                                BIT(0)
+#define MII_WRITE                               BIT(1)
+#define MII_CLKRANGE_60_100M                    (0 << 2)
+#define MII_CLKRANGE_100_150M                   (1 << 2)
+#define MII_CLKRANGE_20_35M                     (2 << 2)
+#define MII_CLKRANGE_35_60M                     (3 << 2)
+#define MII_CLKRANGE_150_250M                   (4 << 2)

drivers/net/phy/mdio-ipq8064.c line 34

Quoted 10 lines
drivers/net/phy/mdio-ipq8064.c new file +10 -0
+#define MII_CLKRANGE_250_300M                   (5 << 2)
+#define MII_CLKRANGE_MASK			GENMASK(4, 2)
+#define MII_REG_SHIFT				6
+#define MII_REG_MASK				GENMASK(10, 6)
+#define MII_ADDR_SHIFT				11
+#define MII_ADDR_MASK				GENMASK(15, 11)
+
+#define MII_DATA_REG_ADDR                       0x14
+
+#define MII_MDIO_DELAY                          (1000)

Maybe name this MII_MDIO_DELAY_USEC to show that it is in microseconds?

drivers/net/phy/mdio-ipq8064.c line 35

Quoted 1 line
drivers/net/phy/mdio-ipq8064.c new file +1 -0
+#define MII_MDIO_RETRY                          (10)

Maybe name this MII_MDIO_RETRY_MSEC to show that it is in milliseconds?

drivers/net/phy/mdio-ipq8064.c

Quoted 11 lines
drivers/net/phy/mdio-ipq8064.c new file +11 -0
+
+struct ipq8064_mdio {
+	struct regmap *base; /* NSS_GMAC0_BASE */
+};
+
+static int
+ipq8064_mdio_wait_busy(struct ipq8064_mdio *priv)
+{
+	u32 busy;
+
+	return regmap_read_poll_timeout(priv->base,

MII_ADDR_REG_ADDR, busy,

drivers/net/phy/mdio-ipq8064.c line 48

Quoted 2 lines
drivers/net/phy/mdio-ipq8064.c new file +2 -0
+				   !(busy & MII_BUSY), MII_MDIO_DELAY,
+				   MII_MDIO_RETRY * USEC_PER_MSEC);

Thanks.

drivers/net/phy/mdio-ipq8064.c line 61

Quoted 13 lines
drivers/net/phy/mdio-ipq8064.c new file +13 -0
+}
+
+static int
+ipq8064_mdio_read(struct mii_bus *bus, int phy_addr, int reg_offset)
+{
+	struct ipq8064_mdio *priv = bus->priv;
+	u32 miiaddr = MII_BUSY | MII_CLKRANGE_250_300M;
+	u32 ret_val;
+	int err;
+
+	/* Reject clause 45 */
+	if (reg_offset & MII_ADDR_C45)
+		return -EOPNOTSUPP;

Thanks.

Quoted 7 lines
drivers/net/phy/mdio-ipq8064.c new file +7 -0
+
+	miiaddr |= ((phy_addr << MII_ADDR_SHIFT) & MII_ADDR_MASK) |
+		   ((reg_offset << MII_REG_SHIFT) & MII_REG_MASK);
+
+	regmap_write(priv->base, MII_ADDR_REG_ADDR, miiaddr);
+	usleep_range(10, 20);
+

drivers/net/phy/mdio-ipq8064.c

Quoted 10 lines
drivers/net/phy/mdio-ipq8064.c new file +10 -0
+	err = ipq8064_mdio_wait_busy(priv);
+	if (err)
+		return err;
+
+	regmap_read(priv->base, MII_DATA_REG_ADDR, &ret_val);
+	return (int)ret_val;
+}
+
+static int
+ipq8064_mdio_write(struct mii_bus *bus, int phy_addr, int reg_offset,

u16 data)

drivers/net/phy/mdio-ipq8064.c line 85

Quoted 7 lines
drivers/net/phy/mdio-ipq8064.c new file +7 -0
+{
+	struct ipq8064_mdio *priv = bus->priv;
+	u32 miiaddr = MII_WRITE | MII_BUSY | MII_CLKRANGE_250_300M;
+
+	/* Reject clause 45 */
+	if (reg_offset & MII_ADDR_C45)
+		return -EOPNOTSUPP;

Thanks.

Quoted 29 lines
drivers/net/phy/mdio-ipq8064.c new file +28 -0
+
+	regmap_write(priv->base, MII_DATA_REG_ADDR, data);
+
+	miiaddr |= ((phy_addr << MII_ADDR_SHIFT) & MII_ADDR_MASK) |
+		   ((reg_offset << MII_REG_SHIFT) & MII_REG_MASK);
+
+	regmap_write(priv->base, MII_ADDR_REG_ADDR, miiaddr);
+	usleep_range(10, 20);
+
+	return ipq8064_mdio_wait_busy(priv);
+}
+
+static int
+ipq8064_mdio_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct ipq8064_mdio *priv;
+	struct mii_bus *bus;
+	int ret;
+
+	bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv));
+	if (!bus)
+		return -ENOMEM;
+
+	bus->name = "ipq8064_mdio_bus";
+	bus->read = ipq8064_mdio_read;
+	bus->write = ipq8064_mdio_write;
+	snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(&pdev-

dev));

drivers/net/phy/mdio-ipq8064.c

Quoted 6 lines
drivers/net/phy/mdio-ipq8064.c new file +6 -0
+	bus->parent = &pdev->dev;
+
+	priv = bus->priv;
+	priv->base = syscon_node_to_regmap(np);
+	if (IS_ERR_OR_NULL(priv->base)) {
+		priv->base = syscon_regmap_lookup_by_phandle(np,

"master");

drivers/net/phy/mdio-ipq8064.c

Quoted 2 lines
drivers/net/phy/mdio-ipq8064.c new file +2 -0
+		if (IS_ERR_OR_NULL(priv->base)) {
+			dev_err(&pdev->dev, "master phandle not

found\n");

drivers/net/phy/mdio-ipq8064.c line 124

Quoted 3 lines
drivers/net/phy/mdio-ipq8064.c new file +3 -0
+			return -EINVAL;
+		}
+	}

I'm curious why you've kept this as-is given my comments?

If you don't agree with them, it would be helpful to reply to the review email giving the reasons why.

Quoted 7 lines

Thanks.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

I hope it's not a problem if I answer here.
I read your command and now I understand what you mean. Since they both never return NULL the IS_ERR_OR_NULL is wrong and only IS_ERR should be used. Correct me if I'm wrong.
About the error propagation, should I return the syscon_regmap_lookup_by_phandle
error or I can keep the EINVAL error?

#5 lore raw

Re: R: [PATCH v3 1/2] net: mdio: add ipq8064 mdio driver

Quoted 37 lines · On Fri, Feb 21, 2020 at 01:49:17AM +0100, [email protected] wrote:
Quoted 28 lines · Ansuel Smith
Quoted 17 lines
drivers/net/phy/mdio-ipq8064.c new file +16 -0
+static int
+ipq8064_mdio_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct ipq8064_mdio *priv;
+	struct mii_bus *bus;
+	int ret;
+
+	bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv));
+	if (!bus)
+		return -ENOMEM;
+
+	bus->name = "ipq8064_mdio_bus";
+	bus->read = ipq8064_mdio_read;
+	bus->write = ipq8064_mdio_write;
+	snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(&pdev-

dev));

drivers/net/phy/mdio-ipq8064.c

Quoted 6 lines
drivers/net/phy/mdio-ipq8064.c new file +6 -0
+	bus->parent = &pdev->dev;
+
+	priv = bus->priv;
+	priv->base = syscon_node_to_regmap(np);
+	if (IS_ERR_OR_NULL(priv->base)) {
+		priv->base = syscon_regmap_lookup_by_phandle(np,

"master");

Review

Quoted 2 lines
(quoted diff) +2 -0
+		if (IS_ERR_OR_NULL(priv->base)) {
+			dev_err(&pdev->dev, "master phandle not

found\n");

Quoted 8 lines

drivers/net/phy/mdio-ipq8064.c line 124

Quoted 3 lines
drivers/net/phy/mdio-ipq8064.c new file +3 -0
+			return -EINVAL;
+		}
+	}

I'm curious why you've kept this as-is given my comments?

If you don't agree with them, it would be helpful to reply to the review email giving the reasons why.

Quoted 6 lines

I read your command and now I understand what you mean. Since they both never return NULL the IS_ERR_OR_NULL is wrong and only IS_ERR should be used. Correct me if I'm wrong.
About the error propagation, should I return the syscon_regmap_lookup_by_phandle
error or I can keep the EINVAL error?

Hi,

You probably want something like:

	priv->base = syscon_node_to_regmap(np);
	if (IS_ERR(priv->base) && priv->base != ERR_PTR(-EPROBE_DEFER))
		priv->base = syscon_regmap_lookup_by_phandle(np, "master");

	if (priv->base == ERR_PTR(-EPROBE_DEFER)) {
		return -EPROBE_DEFER;
	} else if (IS_ERR(priv->base)) {
		dev_err(&pdev->dev, "error getting syscon regmap, error=%pe\n",
			priv->base);
		return PTR_ERR(priv->base);
	}

Please ensure that you test the above, including the case where you should fall through to syscon_regmap_lookup_by_phandle().

Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up
maintainer
#2 lore raw

Re: [PATCH v3 2/2] Documentation: devictree: Add ipq806x mdio bindings

In reply to Ansuel Smith
Quoted 8 lines · Ansuel Smith

Add documentations for ipq806x mdio driver.

---
 .../bindings/net/qcom,ipq8064-mdio.yaml       | 55 +++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/qcom,ipq8064-mdio.yaml

My bot found errors running 'make dt_binding_check' on your patch:

Documentation/devicetree/bindings/display/simple-framebuffer.example.dts:21.16-37.11: Warning (chosen_node_is_root): /example-0/chosen: chosen node must be at root node
Error: Documentation/devicetree/bindings/net/qcom,ipq8064-mdio.example.dts:23.28-29 syntax error
FATAL ERROR: Unable to parse input tree
scripts/Makefile.lib:300: recipe for target 'Documentation/devicetree/bindings/net/qcom,ipq8064-mdio.example.dt.yaml' failed
make[1]: *** [Documentation/devicetree/bindings/net/qcom,ipq8064-mdio.example.dt.yaml] Error 1
Makefile:1263: recipe for target 'dt_binding_check' failed
make: *** [dt_binding_check] Error 2

See https://patchwork.ozlabs.org/patch/1241711
Please check and re-submit.