]> Git Repo - u-boot.git/blobdiff - drivers/net/pic32_eth.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[u-boot.git] / drivers / net / pic32_eth.c
index 0b89911f04a2b13c433bd5a626c1a0e6fc823a71..1333a3aa7e44838162e15bd733bf74f7b4acb4da 100644 (file)
@@ -1,17 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (c) 2015 Purna Chandra Mandal <[email protected]>
  *
- * SPDX-License-Identifier:    GPL-2.0+
- *
  */
 #include <common.h>
+#include <cpu_func.h>
 #include <errno.h>
 #include <dm.h>
+#include <log.h>
+#include <malloc.h>
 #include <net.h>
 #include <miiphy.h>
 #include <console.h>
+#include <time.h>
 #include <wait_bit.h>
+#include <asm/global_data.h>
 #include <asm/gpio.h>
+#include <linux/delay.h>
+#include <linux/mii.h>
 
 #include "pic32_eth.h"
 
@@ -64,8 +70,8 @@ static int pic32_mii_init(struct pic32eth_dev *priv)
        writel(ETHCON_ON | ETHCON_TXRTS | ETHCON_RXEN, &ectl_p->con1.clr);
 
        /* wait till busy */
-       wait_for_bit(__func__, &ectl_p->stat.raw, ETHSTAT_BUSY, false,
-                    CONFIG_SYS_HZ, false);
+       wait_for_bit_le32(&ectl_p->stat.raw, ETHSTAT_BUSY, false,
+                         CONFIG_SYS_HZ, false);
 
        /* turn controller ON to access PHY over MII */
        writel(ETHCON_ON, &ectl_p->con1.set);
@@ -239,8 +245,8 @@ static void pic32_ctrl_reset(struct pic32eth_dev *priv)
        writel(ETHCON_ON | ETHCON_TXRTS | ETHCON_RXEN, &ectl_p->con1.clr);
 
        /* wait till busy */
-       wait_for_bit(__func__, &ectl_p->stat.raw, ETHSTAT_BUSY, false,
-                    CONFIG_SYS_HZ, false);
+       wait_for_bit_le32(&ectl_p->stat.raw, ETHSTAT_BUSY, false,
+                         CONFIG_SYS_HZ, false);
        /* decrement received buffcnt to zero. */
        while (readl(&ectl_p->stat.raw) & ETHSTAT_BUFCNT)
                writel(ETHCON_BUFCDEC, &ectl_p->con1.set);
@@ -321,7 +327,7 @@ static void pic32_rx_desc_init(struct pic32eth_dev *priv)
 
 static int pic32_eth_start(struct udevice *dev)
 {
-       struct eth_pdata *pdata = dev_get_platdata(dev);
+       struct eth_pdata *pdata = dev_get_plat(dev);
        struct pic32eth_dev *priv = dev_get_priv(dev);
 
        /* controller */
@@ -375,8 +381,8 @@ static void pic32_eth_stop(struct udevice *dev)
        mdelay(10);
 
        /* wait until everything is down */
-       wait_for_bit(__func__, &ectl_p->stat.raw, ETHSTAT_BUSY, false,
-                    2 * CONFIG_SYS_HZ, false);
+       wait_for_bit_le32(&ectl_p->stat.raw, ETHSTAT_BUSY, false,
+                         2 * CONFIG_SYS_HZ, false);
 
        /* clear any existing interrupt event */
        writel(0xffffffff, &ectl_p->irq.clr);
@@ -526,9 +532,8 @@ static const struct eth_ops pic32_eth_ops = {
 
 static int pic32_eth_probe(struct udevice *dev)
 {
-       struct eth_pdata *pdata = dev_get_platdata(dev);
+       struct eth_pdata *pdata = dev_get_plat(dev);
        struct pic32eth_dev *priv = dev_get_priv(dev);
-       const char *phy_mode;
        void __iomem *iobase;
        fdt_addr_t addr;
        fdt_size_t size;
@@ -544,15 +549,9 @@ static int pic32_eth_probe(struct udevice *dev)
        pdata->iobase = (phys_addr_t)addr;
 
        /* get phy mode */
-       pdata->phy_interface = -1;
-       phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
-                              NULL);
-       if (phy_mode)
-               pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-       if (pdata->phy_interface == -1) {
-               debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+       pdata->phy_interface = dev_read_phy_mode(dev);
+       if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
                return -EINVAL;
-       }
 
        /* get phy addr */
        offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
@@ -601,6 +600,6 @@ U_BOOT_DRIVER(pic32_ethernet) = {
        .probe                  = pic32_eth_probe,
        .remove                 = pic32_eth_remove,
        .ops                    = &pic32_eth_ops,
-       .priv_auto_alloc_size   = sizeof(struct pic32eth_dev),
-       .platdata_auto_alloc_size       = sizeof(struct eth_pdata),
+       .priv_auto      = sizeof(struct pic32eth_dev),
+       .plat_auto      = sizeof(struct eth_pdata),
 };
This page took 0.029682 seconds and 4 git commands to generate.