]> git.sur5r.net Git - u-boot/blobdiff - drivers/net/sh_eth.c
sf: add paired dev info for winbond w25q16jv
[u-boot] / drivers / net / sh_eth.c
index 1864c894b796ad1209c4ce134f339db830657cdc..2e1123c488a37ee8eed544a20f65abf872adcf55 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * sh_eth.c - Driver for Renesas ethernet controller.
  *
@@ -5,12 +6,11 @@
  * Copyright (c) 2008, 2011, 2014 2014 Nobuhiro Iwamatsu
  * Copyright (c) 2007 Carlos Munoz <carlos@kenati.com>
  * Copyright (C) 2013, 2014 Renesas Electronics Corporation
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <config.h>
 #include <common.h>
+#include <environment.h>
 #include <malloc.h>
 #include <net.h>
 #include <netdev.h>
@@ -675,7 +675,7 @@ struct sh_ether_priv {
        struct sh_eth_dev       shdev;
 
        struct mii_dev          *bus;
-       void __iomem            *iobase;
+       phys_addr_t             iobase;
        struct clk              clk;
        struct gpio_desc        reset_gpio;
 };
@@ -810,24 +810,31 @@ static int sh_ether_probe(struct udevice *udev)
        struct eth_pdata *pdata = dev_get_platdata(udev);
        struct sh_ether_priv *priv = dev_get_priv(udev);
        struct sh_eth_dev *eth = &priv->shdev;
+       struct ofnode_phandle_args phandle_args;
        struct mii_dev *mdiodev;
-       void __iomem *iobase;
        int ret;
 
-       iobase = map_physmem(pdata->iobase, 0x1000, MAP_NOCACHE);
-       priv->iobase = iobase;
+       priv->iobase = pdata->iobase;
 
        ret = clk_get_by_index(udev, 0, &priv->clk);
        if (ret < 0)
-               goto err_mdio_alloc;
+               return ret;
 
-       gpio_request_by_name(udev, "reset-gpios", 0, &priv->reset_gpio,
-                            GPIOD_IS_OUT);
+       ret = dev_read_phandle_with_args(udev, "phy-handle", NULL, 0, 0, &phandle_args);
+       if (!ret) {
+               gpio_request_by_name_nodev(phandle_args.node, "reset-gpios", 0,
+                                          &priv->reset_gpio, GPIOD_IS_OUT);
+       }
+
+       if (!dm_gpio_is_valid(&priv->reset_gpio)) {
+               gpio_request_by_name(udev, "reset-gpios", 0, &priv->reset_gpio,
+                                    GPIOD_IS_OUT);
+       }
 
        mdiodev = mdio_alloc();
        if (!mdiodev) {
                ret = -ENOMEM;
-               goto err_mdio_alloc;
+               return ret;
        }
 
        mdiodev->read = bb_miiphy_read;
@@ -850,8 +857,6 @@ static int sh_ether_probe(struct udevice *udev)
 
 err_mdio_register:
        mdio_free(mdiodev);
-err_mdio_alloc:
-       unmap_physmem(priv->iobase, MAP_NOCACHE);
        return ret;
 }
 
@@ -868,8 +873,6 @@ static int sh_ether_remove(struct udevice *udev)
        if (dm_gpio_is_valid(&priv->reset_gpio))
                dm_gpio_free(udev, &priv->reset_gpio);
 
-       unmap_physmem(priv->iobase, MAP_NOCACHE);
-
        return 0;
 }
 
@@ -911,7 +914,10 @@ int sh_ether_ofdata_to_platdata(struct udevice *dev)
 }
 
 static const struct udevice_id sh_ether_ids[] = {
+       { .compatible = "renesas,ether-r8a7790" },
        { .compatible = "renesas,ether-r8a7791" },
+       { .compatible = "renesas,ether-r8a7793" },
+       { .compatible = "renesas,ether-r8a7794" },
        { }
 };