generic: ar8216: add support for reset control
authorChuanhong Guo <gch981213@gmail.com>
Sun, 19 Jul 2020 14:07:51 +0000 (22:07 +0800)
committerChuanhong Guo <gch981213@gmail.com>
Sat, 19 Sep 2020 13:55:20 +0000 (21:55 +0800)
This allows a full hardware reset of builtin switch found in ar724x
and later SoCs.
It's only added for mdio-device probing because this can only be used
by builtin switches, and all builtin switches are probed using
mdio-device method.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
target/linux/generic/files/drivers/net/phy/ar8216.c

index 18a455b21abfc9810125fb12c908067087d14114..447286f315b3228a75017cdff6a0a0502479206b 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/of_device.h>
 #include <linux/of_mdio.h>
 #include <linux/of_net.h>
+#include <linux/reset.h>
 #include <linux/bitops.h>
 #include <net/genetlink.h>
 #include <linux/switch.h>
@@ -2782,6 +2783,7 @@ ar8xxx_mdiodev_probe(struct mdio_device *mdiodev)
        const struct of_device_id *match;
        struct ar8xxx_priv *priv;
        struct switch_dev *swdev;
+       struct reset_control *switch_reset;
        struct device_node *mdio_node;
        int ret;
 
@@ -2789,6 +2791,14 @@ ar8xxx_mdiodev_probe(struct mdio_device *mdiodev)
        if (!match)
                return -EINVAL;
 
+       switch_reset = devm_reset_control_get_optional(&mdiodev->dev, "switch");
+       if (switch_reset) {
+               reset_control_assert(switch_reset);
+               msleep(50);
+               reset_control_deassert(switch_reset);
+               msleep(200);
+       }
+
        priv = ar8xxx_create();
        if (priv == NULL)
                return -ENOMEM;