]> Git Repo - u-boot.git/blobdiff - drivers/net/pic32_eth.c
Merge tag 'dm-pull-14dec20' of git://git.denx.de/u-boot-dm into next
[u-boot.git] / drivers / net / pic32_eth.c
index 167af8bde5b2770bd2638ff2ee2361580271bf91..9eba55affb199219bcfd135438fc9c45e39cd737 100644 (file)
@@ -1,17 +1,22 @@
+// 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/gpio.h>
+#include <linux/delay.h>
+#include <linux/mii.h>
 
 #include "pic32_eth.h"
 
@@ -64,8 +69,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 +244,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 +326,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 +380,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,7 +531,7 @@ 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;
@@ -535,7 +540,8 @@ static int pic32_eth_probe(struct udevice *dev)
        int offset = 0;
        int phy_addr = -1;
 
-       addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg", &size);
+       addr = fdtdec_get_addr_size(gd->fdt_blob, dev_of_offset(dev), "reg",
+                                   &size);
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
 
@@ -544,7 +550,8 @@ static int pic32_eth_probe(struct udevice *dev)
 
        /* get phy mode */
        pdata->phy_interface = -1;
-       phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+       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) {
@@ -553,14 +560,13 @@ static int pic32_eth_probe(struct udevice *dev)
        }
 
        /* get phy addr */
-       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
                                       "phy-handle");
        if (offset > 0)
                phy_addr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1);
 
        /* phy reset gpio */
-       gpio_request_by_name_nodev(gd->fdt_blob, dev->of_offset,
-                                  "reset-gpios", 0,
+       gpio_request_by_name_nodev(dev_ofnode(dev), "reset-gpios", 0,
                                   &priv->rst_gpio, GPIOD_IS_OUT);
 
        priv->phyif     = pdata->phy_interface;
@@ -600,6 +606,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.030493 seconds and 4 git commands to generate.