]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
net: macb: Add support for phy reset using gpio
authorPunnaiah Choudary Kalluri <punnaiah.choudary.kalluri@xilinx.com>
Thu, 8 Mar 2018 12:50:42 +0000 (18:20 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Fri, 16 Mar 2018 09:25:52 +0000 (10:25 +0100)
Added phy reset functionality using the gpio. This patch assumes that the phy
reset involves an active high/low pulse for certain duration. So, it expects
device tree parameters for reset pulse duration and reset active low or active
high state.

The flags, when requesting gpio for phy reset, should have direction
reflected in bit 0 (as out) and active low/high reflected in bit 1.
Currently these flags are wrong in the driver. Correct this to use
the GPIOF_OUT_INIT_* definitions already available.

Signed-off-by: Punnaiah Choudary Kalluri <punnaia@xilinx.com>
Signed-off-by: Harini Katakam <harinik@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/net/ethernet/cadence/macb_main.c

index eb896046f383ed1d9fbb7401b04182f513b923dd..9b59af533c37ec7130be8cda173fe8d6faf26fc2 100644 (file)
@@ -2742,6 +2742,39 @@ static void macb_configure_caps(struct macb *bp,
        dev_dbg(&bp->pdev->dev, "Cadence caps 0x%08x\n", bp->caps);
 }
 
+#if defined(CONFIG_OF)
+static void macb_reset_phy(struct platform_device *pdev)
+{
+       int err, phy_reset, msec = 1;
+       bool active_low;
+       struct device_node *np = pdev->dev.of_node;
+
+       if (!np)
+               return;
+
+       of_property_read_u32(np, "phy-reset-duration", &msec);
+       active_low = of_property_read_bool(np, "phy-reset-active-low");
+
+       phy_reset = of_get_named_gpio(np, "phy-reset-gpio", 0);
+       if (!gpio_is_valid(phy_reset))
+               return;
+
+       err = devm_gpio_request_one(&pdev->dev, phy_reset,
+                                   active_low ? GPIOF_OUT_INIT_LOW :
+                                   GPIOF_OUT_INIT_HIGH, "phy-reset");
+       if (err) {
+               dev_err(&pdev->dev, "failed to get phy-reset-gpio: %d\n", err);
+               return;
+       }
+       msleep(msec);
+       gpio_set_value(phy_reset, active_low);
+}
+#else /* CONFIG_OF */
+static void macb_reset_phy(struct platform_device *pdev)
+{
+}
+#endif /* CONFIG_OF */
+
 static void macb_probe_queues(void __iomem *mem,
                              bool native_io,
                              unsigned int *queue_mask,
@@ -3536,6 +3569,8 @@ static int macb_probe(struct platform_device *pdev)
                bp->phy_interface = err;
        }
 
+       macb_reset_phy(pdev);
+
        /* IP specific init */
        err = init(pdev);
        if (err)