Skip to content

Commit

Permalink
mwifiex: Select firmware based on strapping
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220422090313.125857-2-andrejs.cainikovs@toradex.com
  • Loading branch information
Andrejs Cainikovs authored and Kalle Valo committed Apr 27, 2022
1 parent 68d57a0 commit 255ca28
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
21 changes: 20 additions & 1 deletion drivers/net/wireless/marvell/mwifiex/sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -283,6 +286,9 @@ static const struct mwifiex_sdio_card_reg mwifiex_reg_sd8987 = {
.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,
Expand Down Expand Up @@ -536,6 +542,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;
Expand Down Expand Up @@ -2439,6 +2446,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;
Expand All @@ -2455,7 +2463,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;
Expand Down
5 changes: 5 additions & 0 deletions drivers/net/wireless/marvell/mwifiex/sdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 255ca28

Please sign in to comment.