diff mbox series

[08/12] wilc1000: invoke chip reset register while FW download

Message ID 20210423182925.5865-9-ajay.kathat@microchip.com
State Superseded
Headers show
Series wilc1000: added chip wakeup support and few fixes | expand

Commit Message

Ajay Singh April 23, 2021, 6:29 p.m. UTC
From: Ajay Singh <ajay.kathat@microchip.com>

Added chip-reset command before firmware download to initialize the
chip. Also configure chip in wake state, ready to accept the FW
binary.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
---
 .../net/wireless/microchip/wilc1000/wlan.c    | 22 ++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

Comments

Kalle Valo June 24, 2021, 9:32 a.m. UTC | #1
<Ajay.Kathat@microchip.com> writes:

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

>

> Added chip-reset command before firmware download to initialize the

> chip. Also configure chip in wake state, ready to accept the FW

> binary.


"Added" -> "Add"

This repeats many times, so I don't comment on that anymore.

> @@ -1088,10 +1089,22 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer,

>  		return -EIO;

>  

>  	offset = 0;

> +	pr_info("%s: Downloading firmware size = %d\n", __func__, buffer_size);

> +

> +	acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP);

> +

> +	wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, &reg);

> +	reg &= ~BIT(10);

> +	ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg);

> +	wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, &reg);

> +	if (reg & BIT(10))

> +		pr_err("%s: Failed to reset\n", __func__);

> +

> +	release_bus(wilc, WILC_BUS_RELEASE_ONLY);

>  	do {

>  		addr = get_unaligned_le32(&buffer[offset]);

>  		size = get_unaligned_le32(&buffer[offset + 4]);

> -		acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);

> +		acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP);

>  		offset += 8;

>  		while (((int)size) && (offset < buffer_size)) {

>  			if (size <= blksz)

> @@ -1109,10 +1122,13 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer,

>  			offset += size2;

>  			size -= size2;

>  		}

> -		release_bus(wilc, WILC_BUS_RELEASE_ONLY);

> +		release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);

>  

> -		if (ret)

> +		if (ret) {

> +			pr_err("%s Bus error\n", __func__);

>  			goto fail;

> +		}

> +		pr_info("%s Offset = %d\n", __func__, offset);


Please use pr_info() sparingly, it's only for important messages like
hardware info, firmware version/features and so on. I think pr_info()
calls in this function should be debug messages instead.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
diff mbox series

Patch

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
index 9f0bb876975a..24e016a0dfa8 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.c
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -1080,6 +1080,7 @@  int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer,
 	u32 addr, size, size2, blksz;
 	u8 *dma_buffer;
 	int ret = 0;
+	u32 reg = 0;
 
 	blksz = BIT(12);
 
@@ -1088,10 +1089,22 @@  int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer,
 		return -EIO;
 
 	offset = 0;
+	pr_info("%s: Downloading firmware size = %d\n", __func__, buffer_size);
+
+	acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP);
+
+	wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, &reg);
+	reg &= ~BIT(10);
+	ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
+	wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, &reg);
+	if (reg & BIT(10))
+		pr_err("%s: Failed to reset\n", __func__);
+
+	release_bus(wilc, WILC_BUS_RELEASE_ONLY);
 	do {
 		addr = get_unaligned_le32(&buffer[offset]);
 		size = get_unaligned_le32(&buffer[offset + 4]);
-		acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
+		acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP);
 		offset += 8;
 		while (((int)size) && (offset < buffer_size)) {
 			if (size <= blksz)
@@ -1109,10 +1122,13 @@  int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer,
 			offset += size2;
 			size -= size2;
 		}
-		release_bus(wilc, WILC_BUS_RELEASE_ONLY);
+		release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
 
-		if (ret)
+		if (ret) {
+			pr_err("%s Bus error\n", __func__);
 			goto fail;
+		}
+		pr_info("%s Offset = %d\n", __func__, offset);
 	} while (offset < buffer_size);
 
 fail: