diff mbox series

[U-Boot,v3,6/7] net: mvpp2: use new MVMDIO driver

Message ID 20190806155144.19301-7-nhed+uboot@starry.com
State New, archived
Delegated to: Joe Hershberger
Headers show
Series Switch MVPP2 to use new MVMDIO | expand

Commit Message

Nevo Hed Aug. 6, 2019, 3:51 p.m. UTC
From: Nevo Hed <nhed+github@starry.com>

An earlier commit in this changeset is taken from Marvells repos but
was based on an MVMDIO implementation that never made it into U-Boot.
With this patch the mvpp2 driver switches to use the new MVMDIO driver
that is based on a more universal mdio-uclass implementation.

Signed-off-by: Nevo Hed <nhed+github@starry.com>
---
 drivers/net/mvpp2.c | 45 ++++++++++-----------------------------------
 1 file changed, 10 insertions(+), 35 deletions(-)

Comments

Joe Hershberger Aug. 14, 2019, 3:59 p.m. UTC | #1
On Tue, Aug 6, 2019 at 10:52 AM <nhed+uboot@starry.com> wrote:
>
> From: Nevo Hed <nhed+github@starry.com>
>
> An earlier commit in this changeset is taken from Marvells repos but
> was based on an MVMDIO implementation that never made it into U-Boot.
> With this patch the mvpp2 driver switches to use the new MVMDIO driver
> that is based on a more universal mdio-uclass implementation.
>
> Signed-off-by: Nevo Hed <nhed+github@starry.com>

You are missing Ramon's review tag in v3.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
diff mbox series

Patch

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 5f908113f2..de1b8fce84 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -32,7 +32,7 @@ 
 #include <linux/mbus.h>
 #include <asm-generic/gpio.h>
 #include <fdt_support.h>
-#include <mdio.h>
+#include <linux/mdio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -936,7 +936,6 @@  struct mvpp2_port {
 
 	/* Per-port registers' base address */
 	void __iomem *base;
-	void __iomem *mdio_base;
 
 	struct mvpp2_rx_queue **rxqs;
 	struct mvpp2_tx_queue **txqs;
@@ -958,7 +957,7 @@  struct mvpp2_port {
 	struct phy_device *phy_dev;
 	phy_interface_t phy_interface;
 	int phyaddr;
-	struct mii_dev *bus;
+	struct udevice *mdio_dev;
 #ifdef CONFIG_DM_GPIO
 	struct gpio_desc phy_reset_gpio;
 	struct gpio_desc phy_tx_disable_gpio;
@@ -4482,8 +4481,8 @@  static void mvpp2_phy_connect(struct udevice *dev, struct mvpp2_port *port)
 	struct phy_device *phy_dev;
 
 	if (!port->init || port->link == 0) {
-		phy_dev = phy_connect(port->bus, port->phyaddr, dev,
-				      port->phy_interface);
+		phy_dev = dm_mdio_phy_connect(port->mdio_dev, port->phyaddr,
+					      dev, port->phy_interface);
 
 		/* If the phy doesn't match with any existing u-boot drivers the
 		 * phy framework will connect it to generic one which
@@ -4708,24 +4707,18 @@  static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
 	int phy_mode = -1;
 	int ret;
 
-	/* Default mdio_base from the same eth base */
-	if (port->priv->hw_version == MVPP21)
-		port->mdio_base = port->priv->lms_base + MVPP21_SMI;
-	else
-		port->mdio_base = port->priv->iface_base + MVPP22_SMI;
-
 	phy_node = fdtdec_lookup_phandle(gd->fdt_blob, port_node, "phy");
 
 	if (phy_node > 0) {
-		ofnode phy_ofnode;
-		fdt_addr_t phy_base;
-
+		int parent;
 		phyaddr = fdtdec_get_int(gd->fdt_blob, phy_node, "reg", 0);
 		if (phyaddr < 0) {
 			dev_err(&pdev->dev, "could not find phy address\n");
 			return -1;
 		}
-		ret = mdio_mii_bus_get_from_phy(phy_node, &port->bus);
+		parent = fdt_parent_offset(gd->fdt_blob, phy_node);
+		ret = uclass_get_device_by_of_offset(UCLASS_MDIO, parent,
+						     &port->mdio_dev);
 		if (ret)
 			return ret;
 	} else {
@@ -5044,7 +5037,7 @@  static int mvpp2_init(struct udevice *dev, struct mvpp2 *priv)
 	return 0;
 }
 
-int mvpp2_recv(struct udevice *dev, int flags, uchar **packetp)
+static int mvpp2_recv(struct udevice *dev, int flags, uchar **packetp)
 {
 	struct mvpp2_port *port = dev_get_priv(dev);
 	struct mvpp2_rx_desc *rx_desc;
@@ -5309,31 +5302,13 @@  static int mvpp2_probe(struct udevice *dev)
 {
 	struct mvpp2_port *port = dev_get_priv(dev);
 	struct mvpp2 *priv = dev_get_priv(dev->parent);
-	struct mii_dev *bus;
 	int err;
 
 	/* Only call the probe function for the parent once */
 	if (!priv->probe_done)
 		err = mvpp2_base_probe(dev->parent);
 
-	port->priv = dev_get_priv(dev->parent);
-
-	/* Create and register the MDIO bus driver */
-	bus = mdio_alloc();
-	if (!bus) {
-		printf("Failed to allocate MDIO bus\n");
-		return -ENOMEM;
-	}
-
-	bus->read = mpp2_mdio_read;
-	bus->write = mpp2_mdio_write;
-	snprintf(bus->name, sizeof(bus->name), dev->name);
-	bus->priv = (void *)port;
-	port->bus = bus;
-
-	err = mdio_register(bus);
-	if (err)
-		return err;
+	port->priv = priv;
 
 	err = phy_info_parse(dev, port);
 	if (err)