dm: treewide: Rename auto_alloc_size members to be shorter
[platform/kernel/u-boot.git] / drivers / net / designware.c
index 3b6cf5d..32b3fc8 100644 (file)
 
 #include <common.h>
 #include <clk.h>
+#include <cpu_func.h>
 #include <dm.h>
 #include <errno.h>
+#include <log.h>
 #include <miiphy.h>
 #include <malloc.h>
+#include <net.h>
 #include <pci.h>
 #include <reset.h>
+#include <asm/cache.h>
+#include <dm/device_compat.h>
+#include <dm/devres.h>
 #include <linux/compiler.h>
+#include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
 #include <asm/io.h>
@@ -81,7 +88,7 @@ static int dw_mdio_write(struct mii_dev *bus, int addr, int devad, int reg,
        return ret;
 }
 
-#if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_GPIO)
+#if defined(CONFIG_DM_ETH) && CONFIG_IS_ENABLED(DM_GPIO)
 static int dw_mdio_reset(struct mii_dev *bus)
 {
        struct udevice *dev = bus->priv;
@@ -127,7 +134,7 @@ static int dw_mdio_init(const char *name, void *priv)
        bus->read = dw_mdio_read;
        bus->write = dw_mdio_write;
        snprintf(bus->name, sizeof(bus->name), "%s", name);
-#if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_GPIO)
+#if defined(CONFIG_DM_ETH) && CONFIG_IS_ENABLED(DM_GPIO)
        bus->reset = dw_mdio_reset;
 #endif
 
@@ -480,18 +487,16 @@ static int _dw_free_pkt(struct dw_eth_dev *priv)
 static int dw_phy_init(struct dw_eth_dev *priv, void *dev)
 {
        struct phy_device *phydev;
-       int mask = 0xffffffff, ret;
+       int phy_addr = -1, ret;
 
 #ifdef CONFIG_PHY_ADDR
-       mask = 1 << CONFIG_PHY_ADDR;
+       phy_addr = CONFIG_PHY_ADDR;
 #endif
 
-       phydev = phy_find_by_mask(priv->bus, mask, priv->interface);
+       phydev = phy_connect(priv->bus, phy_addr, dev, priv->interface);
        if (!phydev)
                return -ENODEV;
 
-       phy_connect_dev(phydev, dev);
-
        phydev->supported &= PHY_GBIT_FEATURES;
        if (priv->max_speed) {
                ret = phy_set_supported(phydev, priv->max_speed);
@@ -507,7 +512,7 @@ static int dw_phy_init(struct dw_eth_dev *priv, void *dev)
 }
 
 #ifndef CONFIG_DM_ETH
-static int dw_eth_init(struct eth_device *dev, bd_t *bis)
+static int dw_eth_init(struct eth_device *dev, struct bd_info *bis)
 {
        int ret;
 
@@ -683,7 +688,8 @@ int designware_eth_probe(struct udevice *dev)
        int i, clock_nb;
 
        priv->clock_count = 0;
-       clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells");
+       clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells",
+                                              0);
        if (clock_nb > 0) {
                priv->clocks = devm_kcalloc(dev, clock_nb, sizeof(struct clk),
                                            GFP_KERNEL);
@@ -808,12 +814,12 @@ const struct eth_ops designware_eth_ops = {
 int designware_eth_ofdata_to_platdata(struct udevice *dev)
 {
        struct dw_eth_pdata *dw_pdata = dev_get_platdata(dev);
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
        struct dw_eth_dev *priv = dev_get_priv(dev);
 #endif
        struct eth_pdata *pdata = &dw_pdata->eth_pdata;
        const char *phy_mode;
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
        int reset_flags = GPIOD_IS_OUT;
 #endif
        int ret = 0;
@@ -830,7 +836,7 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev)
 
        pdata->max_speed = dev_read_u32_default(dev, "max-speed", 0);
 
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
        if (dev_read_bool(dev, "snps,reset-active-low"))
                reset_flags |= GPIOD_ACTIVE_LOW;
 
@@ -849,12 +855,12 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev)
 
 static const struct udevice_id designware_eth_ids[] = {
        { .compatible = "allwinner,sun7i-a20-gmac" },
-       { .compatible = "altr,socfpga-stmmac" },
        { .compatible = "amlogic,meson6-dwmac" },
        { .compatible = "amlogic,meson-gx-dwmac" },
        { .compatible = "amlogic,meson-gxbb-dwmac" },
        { .compatible = "amlogic,meson-axg-dwmac" },
        { .compatible = "st,stm32-dwmac" },
+       { .compatible = "snps,arc-dwmac-3.70a" },
        { }
 };
 
@@ -867,8 +873,8 @@ U_BOOT_DRIVER(eth_designware) = {
        .probe  = designware_eth_probe,
        .remove = designware_eth_remove,
        .ops    = &designware_eth_ops,
-       .priv_auto_alloc_size = sizeof(struct dw_eth_dev),
-       .platdata_auto_alloc_size = sizeof(struct dw_eth_pdata),
+       .priv_auto      = sizeof(struct dw_eth_dev),
+       .platdata_auto  = sizeof(struct dw_eth_pdata),
        .flags = DM_FLAG_ALLOC_PRIV_DMA,
 };