All of lore.kernel.org
 help / color / mirror / Atom feed
From: <Ajay.Kathat@microchip.com>
To: <linux-wireless@vger.kernel.org>
Cc: <Claudiu.Beznea@microchip.com>, <Ajay.Kathat@microchip.com>
Subject: [PATCH v2 06/11] wilc1000: handle read failure issue for clockless registers
Date: Thu, 16 Sep 2021 16:49:20 +0000	[thread overview]
Message-ID: <20210916164902.74629-7-ajay.kathat@microchip.com> (raw)
In-Reply-To: <20210916164902.74629-1-ajay.kathat@microchip.com>

From: Ajay Singh <ajay.kathat@microchip.com>

For SPI bus, the register read fails after read/write to the clockless
register during chip wakeup sequence. Add workaround to send CMD_RESET
command during chip wake-up sequence to overcome the issue.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
---
 drivers/net/wireless/microchip/wilc1000/sdio.c |  1 +
 drivers/net/wireless/microchip/wilc1000/spi.c  | 16 ++++++++++++++++
 drivers/net/wireless/microchip/wilc1000/wlan.c |  5 +++++
 drivers/net/wireless/microchip/wilc1000/wlan.h |  1 +
 4 files changed, 23 insertions(+)

diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c
index 42e03a701ae1..26ebf6664342 100644
--- a/drivers/net/wireless/microchip/wilc1000/sdio.c
+++ b/drivers/net/wireless/microchip/wilc1000/sdio.c
@@ -978,6 +978,7 @@ static const struct wilc_hif_func wilc_hif_sdio = {
 	.hif_sync_ext = wilc_sdio_sync_ext,
 	.enable_interrupt = wilc_sdio_enable_interrupt,
 	.disable_interrupt = wilc_sdio_disable_interrupt,
+	.hif_reset = wilc_sdio_reset,
 };
 
 static int wilc_sdio_resume(struct device *dev)
diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wireless/microchip/wilc1000/spi.c
index 602316f4367c..511b9264185f 100644
--- a/drivers/net/wireless/microchip/wilc1000/spi.c
+++ b/drivers/net/wireless/microchip/wilc1000/spi.c
@@ -47,6 +47,8 @@ struct wilc_spi {
 
 static const struct wilc_hif_func wilc_hif_spi;
 
+static int wilc_spi_reset(struct wilc *wilc);
+
 /********************************************
  *
  *      Spi protocol Function
@@ -956,6 +958,19 @@ static int wilc_spi_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
  *
  ********************************************/
 
+static int wilc_spi_reset(struct wilc *wilc)
+{
+	struct spi_device *spi = to_spi_device(wilc->dev);
+	struct wilc_spi *spi_priv = wilc->bus_data;
+	int result;
+
+	result = wilc_spi_special_cmd(wilc, CMD_RESET);
+	if (result && !spi_priv->probing_crc)
+		dev_err(&spi->dev, "Failed cmd reset\n");
+
+	return result;
+}
+
 static int wilc_spi_deinit(struct wilc *wilc)
 {
 	/*
@@ -1173,4 +1188,5 @@ static const struct wilc_hif_func wilc_hif_spi = {
 	.hif_block_tx_ext = wilc_spi_write,
 	.hif_block_rx_ext = wilc_spi_read,
 	.hif_sync_ext = wilc_spi_sync_ext,
+	.hif_reset = wilc_spi_reset,
 };
diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
index 1aad537c468f..f9256c1bad45 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.c
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -669,6 +669,11 @@ void chip_wakeup(struct wilc *wilc)
 		pr_err("Failed to wake-up the chip\n");
 		return;
 	}
+	/* Sometimes spi fail to read clock regs after reading
+	 * writing clockless registers
+	 */
+	if (wilc->io_type == WILC_HIF_SPI)
+		wilc->hif_func->hif_reset(wilc);
 }
 EXPORT_SYMBOL_GPL(chip_wakeup);
 
diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/microchip/wilc1000/wlan.h
index 285e5d9a2b48..150648b2c872 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.h
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.h
@@ -373,6 +373,7 @@ struct wilc_hif_func {
 	int (*hif_sync_ext)(struct wilc *wilc, int nint);
 	int (*enable_interrupt)(struct wilc *nic);
 	void (*disable_interrupt)(struct wilc *nic);
+	int (*hif_reset)(struct wilc *wilc);
 };
 
 #define WILC_MAX_CFG_FRAME_SIZE		1468
-- 
2.25.1

  parent reply	other threads:[~2021-09-16 16:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16 16:49 [PATCH v2 00/11] wilc1000: add chip wakeup support and few fixes Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 01/11] wilc1000: move 'deinit_lock' lock init/destroy inside module probe Ajay.Kathat
2021-09-21 15:08   ` Kalle Valo
2021-09-16 16:49 ` [PATCH v2 03/11] wilc1000: add new WID to pass wake_enable information to firmware Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 02/11] wilc1000: fix possible memory leak in cfg_scan_result() Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 04/11] wilc1000: configure registers to handle chip wakeup sequence Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 05/11] wilc1000: add reset/terminate/repeat command support for SPI bus Ajay.Kathat
2021-09-16 16:49 ` Ajay.Kathat [this message]
2021-09-16 16:49 ` [PATCH v2 07/11] wilc1000: ignore clockless registers status response for SPI Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 08/11] wilc1000: invoke chip reset register before firmware download Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 09/11] wilc1000: add 'initialized' flag check before adding an element to TX queue Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 10/11] wilc1000: use correct write command sequence in wilc_spi_sync_ext() Ajay.Kathat
2021-09-16 16:49 ` [PATCH v2 11/11] wilc1000: increase config packets response wait timeout limit Ajay.Kathat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210916164902.74629-7-ajay.kathat@microchip.com \
    --to=ajay.kathat@microchip.com \
    --cc=Claudiu.Beznea@microchip.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.