Skip to content

Commit 20ab626

Browse files
author
Adham Abozaeid
committed
staging: wilc1000: Ignore errors from clockless registers
Some wilc1000 devices can return wrong spi responses when accessing clockless registers while the device is in sleep mode, so responses should be ignored for them. Once the device wakes up, the responses will be reliable. Signed-off-by: Adham Abozaeid <[email protected]>
1 parent 2a244db commit 20ab626

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed

wilc/wilc_spi.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,11 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
541541

542542
rsp = rb[rix++];
543543

544-
if (rsp != cmd) {
544+
/*
545+
* Clockless registers operations might return unexptected responses,
546+
* even if successful.
547+
*/
548+
if (rsp != cmd && !clockless) {
545549
dev_err(&spi->dev,
546550
"Failed cmd response, cmd (%02x), resp (%02x)\n",
547551
cmd, rsp);
@@ -552,7 +556,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
552556
* State response
553557
*/
554558
rsp = rb[rix++];
555-
if (rsp != 0x00) {
559+
if (rsp != 0x00 && !clockless) {
556560
dev_err(&spi->dev, "Failed cmd state response state (%02x)\n",
557561
rsp);
558562
return N_FAIL;
@@ -579,7 +583,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
579583
break;
580584
} while (retry--);
581585

582-
if (retry <= 0) {
586+
if (retry <= 0 && !clockless) {
583587
dev_err(&spi->dev,
584588
"Error, data read response (%02x)\n", rsp);
585589
return N_RESET;

wilc/wilc_wfi_cfgoperations.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,6 +1816,7 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
18161816
dev->type = ARPHRD_IEEE80211_RADIOTAP;
18171817
priv->wdev.iftype = type;
18181818
vif->iftype = WILC_MONITOR_MODE;
1819+
18191820
if (wl->initialized)
18201821
wilc_set_operation_mode(vif, wilc_get_vif_idx(vif),
18211822
WILC_MONITOR_MODE,

wilc/wilc_wlan.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ void chip_allow_sleep(struct wilc *wilc, int source)
754754
void chip_wakeup_wilc1000(struct wilc *wilc, int source)
755755
{
756756
u32 ret = 0;
757-
u32 reg = 0, clk_status_val = 0, trials = 0;
757+
u32 clk_status_val = 0, trials = 0;
758758
u32 wakeup_reg, wakeup_bit;
759759
u32 clk_status_reg, clk_status_bit;
760760
u32 to_host_from_fw_reg, to_host_from_fw_bit;
@@ -782,28 +782,18 @@ void chip_wakeup_wilc1000(struct wilc *wilc, int source)
782782
to_host_from_fw_bit = BIT(0);
783783
}
784784

785-
ret = hif_func->hif_read_reg(wilc, from_host_to_fw_reg, &reg);
785+
786+
/*USE bit 0 to indicate host wakeup*/
787+
ret = hif_func->hif_write_reg(wilc, from_host_to_fw_reg,
788+
from_host_to_fw_bit);
786789
if (!ret)
787790
goto _fail_;
788791

789-
if (!(reg & from_host_to_fw_bit)) {
790-
/*USE bit 0 to indicate host wakeup*/
791-
ret = hif_func->hif_write_reg(wilc, from_host_to_fw_reg,
792-
reg | from_host_to_fw_bit);
793-
if (!ret)
794-
goto _fail_;
795-
}
796-
797-
ret = hif_func->hif_read_reg(wilc, wakeup_reg, &reg);
792+
/* Set bit 1 */
793+
ret = hif_func->hif_write_reg(wilc, wakeup_reg,
794+
wakeup_bit);
798795
if (!ret)
799796
goto _fail_;
800-
/* Set bit 1 */
801-
if (!(reg & wakeup_bit)) {
802-
ret = hif_func->hif_write_reg(wilc, wakeup_reg,
803-
reg | wakeup_bit);
804-
if (!ret)
805-
goto _fail_;
806-
}
807797

808798
do {
809799
ret = hif_func->hif_read_reg(wilc, clk_status_reg,

0 commit comments

Comments
 (0)