common: Drop linux/delay.h from common header
[oweals/u-boot.git] / drivers / net / bcm-sf2-eth.c
index eab4c1f9003258d3926318d69b60f8c061e53c76..2998d57c72f799705483b294fe53c62b284f7283 100644 (file)
@@ -1,13 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2014 Broadcom Corporation.
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <log.h>
 #include <malloc.h>
 #include <net.h>
 #include <config.h>
+#include <linux/delay.h>
 
 #include <phy.h>
 #include <miiphy.h>
@@ -40,7 +41,7 @@ static int bcm_sf2_eth_init(struct eth_device *dev)
 
        rc = eth->mac_init(dev);
        if (rc) {
-               error("%s: Couldn't cofigure MAC!\n", __func__);
+               pr_err("%s: Couldn't cofigure MAC!\n", __func__);
                return rc;
        }
 
@@ -51,7 +52,7 @@ static int bcm_sf2_eth_init(struct eth_device *dev)
        eth->port_num = 0;
        debug("Connecting PHY 0...\n");
        phydev = phy_connect(miiphy_get_dev_by_name(dev->name),
-                            0, dev, eth->phy_interface);
+                            -1, dev, eth->phy_interface);
        if (phydev != NULL) {
                eth->port[0] = phydev;
                eth->port_num += 1;
@@ -90,7 +91,7 @@ static int bcm_sf2_eth_send(struct eth_device *dev, void *packet, int length)
                debug(".");
                i++;
                if (i > 20) {
-                       error("%s: Tx timeout: retried 20 times\n", __func__);
+                       pr_err("%s: Tx timeout: retried 20 times\n", __func__);
                        rc = -1;
                        break;
                }
@@ -117,7 +118,7 @@ static int bcm_sf2_eth_receive(struct eth_device *dev)
                        debug("\nNO More Rx\n");
                        break;
                } else if ((rcvlen == 0) || (rcvlen > RX_BUF_SIZE)) {
-                       error("%s: Wrong Ethernet packet size (%d B), skip!\n",
+                       pr_err("%s: Wrong Ethernet packet size (%d B), skip!\n",
                              __func__, rcvlen);
                        break;
                } else {
@@ -166,9 +167,9 @@ static int bcm_sf2_eth_open(struct eth_device *dev, bd_t *bt)
         */
        for (i = 0; i < eth->port_num; i++) {
                if (phy_startup(eth->port[i])) {
-                       error("%s: PHY %d startup failed!\n", __func__, i);
+                       pr_err("%s: PHY %d startup failed!\n", __func__, i);
                        if (i == CONFIG_BCM_SF2_ETH_DEFAULT_PORT) {
-                               error("%s: No default port %d!\n", __func__, i);
+                               pr_err("%s: No default port %d!\n", __func__, i);
                                return -1;
                        }
                }
@@ -205,13 +206,13 @@ int bcm_sf2_eth_register(bd_t *bis, u8 dev_num)
 
        dev = (struct eth_device *)malloc(sizeof(struct eth_device));
        if (dev == NULL) {
-               error("%s: Not enough memory!\n", __func__);
+               pr_err("%s: Not enough memory!\n", __func__);
                return -1;
        }
 
        eth = (struct eth_info *)malloc(sizeof(struct eth_info));
        if (eth == NULL) {
-               error("%s: Not enough memory!\n", __func__);
+               pr_err("%s: Not enough memory!\n", __func__);
                return -1;
        }
 
@@ -234,7 +235,7 @@ int bcm_sf2_eth_register(bd_t *bis, u8 dev_num)
        if (gmac_add(dev)) {
                free(eth);
                free(dev);
-               error("%s: Adding GMAC failed!\n", __func__);
+               pr_err("%s: Adding GMAC failed!\n", __func__);
                return -1;
        }
 #else
@@ -244,7 +245,18 @@ int bcm_sf2_eth_register(bd_t *bis, u8 dev_num)
        eth_register(dev);
 
 #ifdef CONFIG_CMD_MII
-       miiphy_register(dev->name, eth->miiphy_read, eth->miiphy_write);
+       int retval;
+       struct mii_dev *mdiodev = mdio_alloc();
+
+       if (!mdiodev)
+               return -ENOMEM;
+       strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
+       mdiodev->read = eth->miiphy_read;
+       mdiodev->write = eth->miiphy_write;
+
+       retval = mdio_register(mdiodev);
+       if (retval < 0)
+               return retval;
 #endif
 
        /* Initialization */
@@ -252,7 +264,7 @@ int bcm_sf2_eth_register(bd_t *bis, u8 dev_num)
 
        rc = bcm_sf2_eth_init(dev);
        if (rc != 0) {
-               error("%s: configuration failed!\n", __func__);
+               pr_err("%s: configuration failed!\n", __func__);
                return -1;
        }