All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] mwifiex: Select firmware based on strapping
@ 2022-04-08  7:50 Andrejs Cainikovs
  2022-04-08  7:50 ` [PATCH 1/2] " Andrejs Cainikovs
  2022-04-08  7:51 ` [PATCH 2/2] mwifiex: Add SD8997 SDIO-UART firmware Andrejs Cainikovs
  0 siblings, 2 replies; 4+ messages in thread
From: Andrejs Cainikovs @ 2022-04-08  7:50 UTC (permalink / raw)
  To: linux-wireless, Amitkumar Karwar, Ganapathi Bhat,
	Sharvari Harisangam, Xinming Hu
  Cc: Andrejs Cainikovs, Kalle Valo, David S . Miller, Jakub Kicinski,
	Brian Norris, Jonas Dreßler, Francesco Dolcini, netdev

This patch set introduces a way to automatically select appropriate
firmware depending of the host connection method.

Andrejs Cainikovs (2):
  mwifiex: Select firmware based on strapping
  mwifiex: Add SD8997 SDIO-UART firmware

 drivers/net/wireless/marvell/mwifiex/sdio.c | 20 +++++++++++++++++++-
 drivers/net/wireless/marvell/mwifiex/sdio.h |  6 ++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] mwifiex: Select firmware based on strapping
  2022-04-08  7:50 [PATCH 0/2] mwifiex: Select firmware based on strapping Andrejs Cainikovs
@ 2022-04-08  7:50 ` Andrejs Cainikovs
  2022-04-12 23:08   ` Alvin Šipraga
  2022-04-08  7:51 ` [PATCH 2/2] mwifiex: Add SD8997 SDIO-UART firmware Andrejs Cainikovs
  1 sibling, 1 reply; 4+ messages in thread
From: Andrejs Cainikovs @ 2022-04-08  7:50 UTC (permalink / raw)
  To: linux-wireless, Amitkumar Karwar, Ganapathi Bhat,
	Sharvari Harisangam, Xinming Hu
  Cc: Andrejs Cainikovs, Kalle Valo, David S . Miller, Jakub Kicinski,
	Brian Norris, Jonas Dreßler, Francesco Dolcini, netdev

Some WiFi/Bluetooth modules might have different host connection
options, allowing to either use SDIO for both WiFi and Bluetooth,
or SDIO for WiFi and UART for Bluetooth. It is possible to detect
whether a module has SDIO-SDIO or SDIO-UART connection by reading
its host strap register.

This change introduces a way to automatically select appropriate
firmware depending of the connection method, and removes a need
of symlinking or overwriting the original firmware file with a
required one.

Host strap register used in this commit comes from the NXP driver [1]
hosted at Code Aurora.

[1] https://source.codeaurora.org/external/imx/linux-imx/tree/drivers/net/wireless/nxp/mxm_wifiex/wlan_src/mlinux/moal_sdio_mmc.c?h=rel_imx_5.4.70_2.3.2&id=688b67b2c7220b01521ffe560da7eee33042c7bd#n1274

Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>
---
 drivers/net/wireless/marvell/mwifiex/sdio.c | 18 +++++++++++++++++-
 drivers/net/wireless/marvell/mwifiex/sdio.h |  5 +++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c
index bde9e4bbfffe..23160d179485 100644
--- a/drivers/net/wireless/marvell/mwifiex/sdio.c
+++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
@@ -182,6 +182,9 @@ static const struct mwifiex_sdio_card_reg mwifiex_reg_sd8997 = {
 	.host_int_rsr_reg = 0x4,
 	.host_int_status_reg = 0x0C,
 	.host_int_mask_reg = 0x08,
+	.host_strap_reg = 0xF4,
+	.host_strap_mask = 0x01,
+	.host_strap_value = 0x00,
 	.status_reg_0 = 0xE8,
 	.status_reg_1 = 0xE9,
 	.sdio_int_mask = 0xff,
@@ -536,6 +539,7 @@ mwifiex_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id)
 		struct mwifiex_sdio_device *data = (void *)id->driver_data;
 
 		card->firmware = data->firmware;
+		card->firmware_sdiouart = data->firmware_sdiouart;
 		card->reg = data->reg;
 		card->max_ports = data->max_ports;
 		card->mp_agg_pkt_limit = data->mp_agg_pkt_limit;
@@ -2439,6 +2443,7 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter)
 	int ret;
 	struct sdio_mmc_card *card = adapter->card;
 	struct sdio_func *func = card->func;
+	const char *firmware = card->firmware;
 
 	/* save adapter pointer in card */
 	card->adapter = adapter;
@@ -2455,7 +2460,18 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter)
 		return ret;
 	}
 
-	strcpy(adapter->fw_name, card->firmware);
+	/* Select correct firmware (sdsd or sdiouart) firmware based on the strapping
+	 * option
+	 */
+	if (card->firmware_sdiouart) {
+		u8 val;
+
+		mwifiex_read_reg(adapter, card->reg->host_strap_reg, &val);
+		if ((val & card->reg->host_strap_mask) == card->reg->host_strap_value)
+			firmware = card->firmware_sdiouart;
+	}
+	strcpy(adapter->fw_name, firmware);
+
 	if (card->fw_dump_enh) {
 		adapter->mem_type_mapping_tbl = generic_mem_type_map;
 		adapter->num_mem_types = 1;
diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.h b/drivers/net/wireless/marvell/mwifiex/sdio.h
index 5648512c9300..ad2c28cbb630 100644
--- a/drivers/net/wireless/marvell/mwifiex/sdio.h
+++ b/drivers/net/wireless/marvell/mwifiex/sdio.h
@@ -196,6 +196,9 @@ struct mwifiex_sdio_card_reg {
 	u8 host_int_rsr_reg;
 	u8 host_int_status_reg;
 	u8 host_int_mask_reg;
+	u8 host_strap_reg;
+	u8 host_strap_mask;
+	u8 host_strap_value;
 	u8 status_reg_0;
 	u8 status_reg_1;
 	u8 sdio_int_mask;
@@ -241,6 +244,7 @@ struct sdio_mmc_card {
 
 	struct completion fw_done;
 	const char *firmware;
+	const char *firmware_sdiouart;
 	const struct mwifiex_sdio_card_reg *reg;
 	u8 max_ports;
 	u8 mp_agg_pkt_limit;
@@ -274,6 +278,7 @@ struct sdio_mmc_card {
 
 struct mwifiex_sdio_device {
 	const char *firmware;
+	const char *firmware_sdiouart;
 	const struct mwifiex_sdio_card_reg *reg;
 	u8 max_ports;
 	u8 mp_agg_pkt_limit;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] mwifiex: Add SD8997 SDIO-UART firmware
  2022-04-08  7:50 [PATCH 0/2] mwifiex: Select firmware based on strapping Andrejs Cainikovs
  2022-04-08  7:50 ` [PATCH 1/2] " Andrejs Cainikovs
@ 2022-04-08  7:51 ` Andrejs Cainikovs
  1 sibling, 0 replies; 4+ messages in thread
From: Andrejs Cainikovs @ 2022-04-08  7:51 UTC (permalink / raw)
  To: linux-wireless, Amitkumar Karwar, Ganapathi Bhat,
	Sharvari Harisangam, Xinming Hu
  Cc: Andrejs Cainikovs, Kalle Valo, David S . Miller, Jakub Kicinski,
	Brian Norris, Jonas Dreßler, Francesco Dolcini, netdev

With a recent change now it is possible to detect the strapping
option on SD8997, which allows to pick up a correct firmware
for either SDIO-SDIO or SDIO-UART.

This commit enables SDIO-UART firmware on SD8997.

Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>
---
 drivers/net/wireless/marvell/mwifiex/sdio.c | 2 ++
 drivers/net/wireless/marvell/mwifiex/sdio.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c
index 23160d179485..dd5eb1a370b0 100644
--- a/drivers/net/wireless/marvell/mwifiex/sdio.c
+++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
@@ -405,6 +405,7 @@ static const struct mwifiex_sdio_device mwifiex_sdio_sd8977 = {
 
 static const struct mwifiex_sdio_device mwifiex_sdio_sd8997 = {
 	.firmware = SD8997_DEFAULT_FW_NAME,
+	.firmware_sdiouart = SD8997_SDIOUART_FW_NAME,
 	.reg = &mwifiex_reg_sd8997,
 	.max_ports = 32,
 	.mp_agg_pkt_limit = 16,
@@ -3173,3 +3174,4 @@ MODULE_FIRMWARE(SD8887_DEFAULT_FW_NAME);
 MODULE_FIRMWARE(SD8977_DEFAULT_FW_NAME);
 MODULE_FIRMWARE(SD8987_DEFAULT_FW_NAME);
 MODULE_FIRMWARE(SD8997_DEFAULT_FW_NAME);
+MODULE_FIRMWARE(SD8997_SDIOUART_FW_NAME);
diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.h b/drivers/net/wireless/marvell/mwifiex/sdio.h
index ad2c28cbb630..28e8f76bdd58 100644
--- a/drivers/net/wireless/marvell/mwifiex/sdio.h
+++ b/drivers/net/wireless/marvell/mwifiex/sdio.h
@@ -39,6 +39,7 @@
 #define SD8977_DEFAULT_FW_NAME "mrvl/sdsd8977_combo_v2.bin"
 #define SD8987_DEFAULT_FW_NAME "mrvl/sd8987_uapsta.bin"
 #define SD8997_DEFAULT_FW_NAME "mrvl/sdsd8997_combo_v4.bin"
+#define SD8997_SDIOUART_FW_NAME "mrvl/sdiouart8997_combo_v4.bin"
 
 #define BLOCK_MODE	1
 #define BYTE_MODE	0
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] mwifiex: Select firmware based on strapping
  2022-04-08  7:50 ` [PATCH 1/2] " Andrejs Cainikovs
@ 2022-04-12 23:08   ` Alvin Šipraga
  0 siblings, 0 replies; 4+ messages in thread
From: Alvin Šipraga @ 2022-04-12 23:08 UTC (permalink / raw)
  To: Andrejs Cainikovs
  Cc: linux-wireless, Amitkumar Karwar, Ganapathi Bhat,
	Sharvari Harisangam, Xinming Hu, Kalle Valo, David S . Miller,
	Jakub Kicinski, Brian Norris, Jonas Dreßler,
	Francesco Dolcini, netdev

Hi Andrejs,

On Fri, Apr 08, 2022 at 09:50:59AM +0200, Andrejs Cainikovs wrote:
> Some WiFi/Bluetooth modules might have different host connection
> options, allowing to either use SDIO for both WiFi and Bluetooth,
> or SDIO for WiFi and UART for Bluetooth. It is possible to detect
> whether a module has SDIO-SDIO or SDIO-UART connection by reading
> its host strap register.
> 
> This change introduces a way to automatically select appropriate
> firmware depending of the connection method, and removes a need
> of symlinking or overwriting the original firmware file with a
> required one.
> 
> Host strap register used in this commit comes from the NXP driver [1]
> hosted at Code Aurora.
> 
> [1] https://source.codeaurora.org/external/imx/linux-imx/tree/drivers/net/wireless/nxp/mxm_wifiex/wlan_src/mlinux/moal_sdio_mmc.c?h=rel_imx_5.4.70_2.3.2&id=688b67b2c7220b01521ffe560da7eee33042c7bd#n1274
> 
> Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>
> ---
>  drivers/net/wireless/marvell/mwifiex/sdio.c | 18 +++++++++++++++++-
>  drivers/net/wireless/marvell/mwifiex/sdio.h |  5 +++++
>  2 files changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c
> index bde9e4bbfffe..23160d179485 100644
> --- a/drivers/net/wireless/marvell/mwifiex/sdio.c
> +++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
> @@ -182,6 +182,9 @@ static const struct mwifiex_sdio_card_reg mwifiex_reg_sd8997 = {
>  	.host_int_rsr_reg = 0x4,
>  	.host_int_status_reg = 0x0C,
>  	.host_int_mask_reg = 0x08,
> +	.host_strap_reg = 0xF4,
> +	.host_strap_mask = 0x01,
> +	.host_strap_value = 0x00,

I had a look at the cards supported by mwifiex, and it seems that the SD8987
also supports this strapping detection [1]. Could you perhaps add the same
.host_strap_{reg,mask,value} settings to mwifiex_reg_sd8987?

[1] https://source.codeaurora.org/external/imx/linux-imx/tree/drivers/net/wireless/nxp/mxm_wifiex/wlan_src/mlinux/moal_sdio_mmc.c?h=rel_imx_5.4.70_2.3.2&id=688b67b2c7220b01521ffe560da7eee33042c7bd#n1364

>  	.status_reg_0 = 0xE8,
>  	.status_reg_1 = 0xE9,
>  	.sdio_int_mask = 0xff,

With that change added, feel free to carry my Reviewed-by in your v2 patch:

Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk>

Kind regards,
Alvin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-12 23:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-08  7:50 [PATCH 0/2] mwifiex: Select firmware based on strapping Andrejs Cainikovs
2022-04-08  7:50 ` [PATCH 1/2] " Andrejs Cainikovs
2022-04-12 23:08   ` Alvin Šipraga
2022-04-08  7:51 ` [PATCH 2/2] mwifiex: Add SD8997 SDIO-UART firmware Andrejs Cainikovs

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.