Commit a4f1a05b authored by Ajay Singh's avatar Ajay Singh Committed by Kalle Valo

wifi: wilc1000: fix incorrect power down sequence

Use the correct register configuration when the WILC chip is down so the
successive interface up operation is successful. The modified registers
values during chip down helps to avoid the "FW not responding" debug
message which sometimes occurs because of temporary bus communication
failure during the next start. Also, make sure on first communication with
the chip that it is indeed woken up.
Reported-by: default avatarMichael Walle <mwalle@kernel.org>
Closes: https://lore.kernel.org/linux-wireless/20221026085415.6jgwrhq4sunqaypm@0002.3ffe.de/Signed-off-by: default avatarAjay Singh <ajay.kathat@microchip.com>
Signed-off-by: default avatarAlexis Lothoré <alexis.lothore@bootlin.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240115-wilc_1000_fixes-v1-4-54d29463a738@bootlin.com
parent 328efda2
...@@ -1198,27 +1198,32 @@ int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif) ...@@ -1198,27 +1198,32 @@ int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif)
acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP);
ret = wilc->hif_func->hif_read_reg(wilc, WILC_GP_REG_0, &reg); ret = wilc->hif_func->hif_read_reg(wilc, GLOBAL_MODE_CONTROL, &reg);
if (ret) { if (ret)
netdev_err(vif->ndev, "Error while reading reg\n");
goto release; goto release;
}
ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_0, reg &= ~WILC_GLOBAL_MODE_ENABLE_WIFI;
(reg | WILC_ABORT_REQ_BIT)); ret = wilc->hif_func->hif_write_reg(wilc, GLOBAL_MODE_CONTROL, reg);
if (ret) { if (ret)
netdev_err(vif->ndev, "Error while writing reg\n"); goto release;
ret = wilc->hif_func->hif_read_reg(wilc, PWR_SEQ_MISC_CTRL, &reg);
if (ret)
goto release;
reg &= ~WILC_PWR_SEQ_ENABLE_WIFI_SLEEP;
ret = wilc->hif_func->hif_write_reg(wilc, PWR_SEQ_MISC_CTRL, reg);
if (ret)
goto release; goto release;
}
ret = wilc->hif_func->hif_read_reg(wilc, WILC_FW_HOST_COMM, &reg); ret = wilc->hif_func->hif_read_reg(wilc, WILC_GP_REG_0, &reg);
if (ret) { if (ret) {
netdev_err(vif->ndev, "Error while reading reg\n"); netdev_err(vif->ndev, "Error while reading reg\n");
goto release; goto release;
} }
reg = BIT(0);
ret = wilc->hif_func->hif_write_reg(wilc, WILC_FW_HOST_COMM, reg); ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_0,
(reg | WILC_ABORT_REQ_BIT));
if (ret) { if (ret) {
netdev_err(vif->ndev, "Error while writing reg\n"); netdev_err(vif->ndev, "Error while writing reg\n");
goto release; goto release;
...@@ -1410,7 +1415,7 @@ static int init_chip(struct net_device *dev) ...@@ -1410,7 +1415,7 @@ static int init_chip(struct net_device *dev)
struct wilc_vif *vif = netdev_priv(dev); struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc = vif->wilc; struct wilc *wilc = vif->wilc;
acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP);
chipid = wilc_get_chipid(wilc, true); chipid = wilc_get_chipid(wilc, true);
...@@ -1440,7 +1445,7 @@ static int init_chip(struct net_device *dev) ...@@ -1440,7 +1445,7 @@ static int init_chip(struct net_device *dev)
} }
release: release:
release_bus(wilc, WILC_BUS_RELEASE_ONLY); release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
return ret; return ret;
} }
......
...@@ -156,6 +156,12 @@ ...@@ -156,6 +156,12 @@
#define WILC_GP_REG_0 0x149c #define WILC_GP_REG_0 0x149c
#define WILC_GP_REG_1 0x14a0 #define WILC_GP_REG_1 0x14a0
#define GLOBAL_MODE_CONTROL 0x1614
#define PWR_SEQ_MISC_CTRL 0x3008
#define WILC_GLOBAL_MODE_ENABLE_WIFI BIT(0)
#define WILC_PWR_SEQ_ENABLE_WIFI_SLEEP BIT(28)
#define WILC_HAVE_SDIO_IRQ_GPIO BIT(0) #define WILC_HAVE_SDIO_IRQ_GPIO BIT(0)
#define WILC_HAVE_USE_PMU BIT(1) #define WILC_HAVE_USE_PMU BIT(1)
#define WILC_HAVE_SLEEP_CLK_SRC_RTC BIT(2) #define WILC_HAVE_SLEEP_CLK_SRC_RTC BIT(2)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment