net: dm: fec: Support phy-reset-post-delay property
[oweals/u-boot.git] / drivers / net / ravb.c
index 999894f0f6d5806beb7bf41ea4a8381093816a7e..749562db960e59a8e7df3a0c8c7a6372b9b21e68 100644 (file)
@@ -318,12 +318,13 @@ static int ravb_phy_config(struct udevice *dev)
 
        eth->phydev = phydev;
 
-       /* 10BASE is not supported for Ethernet AVB MAC */
-       phydev->supported &= ~(SUPPORTED_10baseT_Full
-                              | SUPPORTED_10baseT_Half);
+       phydev->supported &= SUPPORTED_100baseT_Full |
+                            SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg |
+                            SUPPORTED_TP | SUPPORTED_MII | SUPPORTED_Pause |
+                            SUPPORTED_Asym_Pause;
+
        if (pdata->max_speed != 1000) {
-               phydev->supported &= ~(SUPPORTED_1000baseT_Half
-                                      | SUPPORTED_1000baseT_Full);
+               phydev->supported &= ~SUPPORTED_1000baseT_Full;
                reg = phy_read(phydev, -1, MII_CTRL1000);
                reg &= ~(BIT(9) | BIT(8));
                phy_write(phydev, -1, MII_CTRL1000, reg);
@@ -437,7 +438,7 @@ static int ravb_start(struct udevice *dev)
 
        ret = ravb_reset(dev);
        if (ret)
-               goto err;
+               return ret;
 
        ravb_base_desc_init(eth);
        ravb_tx_desc_init(eth);
@@ -445,16 +446,12 @@ static int ravb_start(struct udevice *dev)
 
        ret = ravb_config(dev);
        if (ret)
-               goto err;
+               return ret;
 
        /* Setting the control will start the AVB-DMAC process. */
        writel(CCC_OPC_OPERATION, eth->iobase + RAVB_REG_CCC);
 
        return 0;
-
-err:
-       clk_disable(&eth->clk);
-       return ret;
 }
 
 static void ravb_stop(struct udevice *dev)
@@ -469,6 +466,7 @@ static int ravb_probe(struct udevice *dev)
 {
        struct eth_pdata *pdata = dev_get_platdata(dev);
        struct ravb_priv *eth = dev_get_priv(dev);
+       struct ofnode_phandle_args phandle_args;
        struct mii_dev *mdiodev;
        void __iomem *iobase;
        int ret;
@@ -480,8 +478,16 @@ static int ravb_probe(struct udevice *dev)
        if (ret < 0)
                goto err_mdio_alloc;
 
-       gpio_request_by_name(dev, "reset-gpios", 0, &eth->reset_gpio,
-                            GPIOD_IS_OUT);
+       ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, &phandle_args);
+       if (!ret) {
+               gpio_request_by_name_nodev(phandle_args.node, "reset-gpios", 0,
+                                          &eth->reset_gpio, GPIOD_IS_OUT);
+       }
+
+       if (!dm_gpio_is_valid(&eth->reset_gpio)) {
+               gpio_request_by_name(dev, "reset-gpios", 0, &eth->reset_gpio,
+                                    GPIOD_IS_OUT);
+       }
 
        mdiodev = mdio_alloc();
        if (!mdiodev) {