ath79: ag71xx: assert a switch reset if defined in dts.
authorChuanhong Guo <gch981213@gmail.com>
Tue, 24 Jul 2018 13:19:04 +0000 (21:19 +0800)
committerJohn Crispin <john@phrozen.org>
Mon, 30 Jul 2018 08:43:35 +0000 (10:43 +0200)
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c

index f91144da6ebb3706de43b8ce463c6e53ca6206eb..173c16a53dfd41b9f78a4fc4355f25ad9acd3230 100644 (file)
@@ -1218,6 +1218,7 @@ ag71xx_ar7240_probe(struct mdio_device *mdiodev)
        struct mii_bus *mii = mdiodev->bus;
        struct ar7240sw *as;
        struct switch_dev *swdev;
+       struct reset_control *switch_reset;
        u32 ctrl;
        int phy_if_mode, err, i;
 
@@ -1231,6 +1232,14 @@ ag71xx_ar7240_probe(struct mdio_device *mdiodev)
 
        swdev = &as->swdev;
 
+       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);
+       }
+
        ctrl = ar7240sw_reg_read(mii, AR7240_REG_MASK_CTRL);
        as->ver = (ctrl >> AR7240_MASK_CTRL_VERSION_S) &
                  AR7240_MASK_CTRL_VERSION_M;