Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mainline driver for WiFi on Flat S 2022 (REVPI-2882) #141

Merged
merged 9 commits into from
Feb 20, 2023
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Marvell 8787/8897/8997 (sd8787/sd8897/sd8997/pcie8997) SDIO/PCIE devices
Marvell 8787/8897/8978/8997 (sd8787/sd8897/sd8978/sd8997/pcie8997) SDIO/PCIE devices
------

This node provides properties for controlling the Marvell SDIO/PCIE wireless device.
Expand All @@ -10,7 +10,9 @@ Required properties:
- compatible : should be one of the following:
* "marvell,sd8787"
* "marvell,sd8897"
* "marvell,sd8978"
* "marvell,sd8997"
* "nxp,iw416"
* "pci11ab,2b42"
* "pci1b4b,2b42"

Expand Down
17 changes: 7 additions & 10 deletions arch/arm/boot/dts/overlays/revpi-flat-s-2022-overlay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
};

wlan_pwrseq: wlan_pwrseq {
compatible = "mmc-pwrseq-simple";
reset-gpios = <&expander 12 GPIO_ACTIVE_LOW>;
compatible = "mmc-pwrseq-sd8787";
reset-gpios = <&expander 10 GPIO_ACTIVE_HIGH>;
powerdown-gpios = <&expander 12 GPIO_ACTIVE_HIGH>;
};

leds {
Expand Down Expand Up @@ -345,14 +346,10 @@
mmc-pwrseq = <&wlan_pwrseq>;
status = "okay";

sdxxx-wlan {
cfg80211_wext = <0xf>;
cal_data_cfg = "none";
max_vir_bss=<1>;
ps_mode=<1>;
auto_ds=<1>;
host_mlme=<1>;
fw_name="nxp/sdiouartiw416_combo_v0.bin";
wlan0: wifi@1 {
compatible = "nxp,iw416";
reg = <1>;
status = "okay";
};
};
};
Expand Down
1 change: 1 addition & 0 deletions arch/arm/configs/revpi-v7_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ CONFIG_LIBERTAS_THINFIRM=m
CONFIG_LIBERTAS_THINFIRM_USB=m
CONFIG_MWIFIEX=m
CONFIG_MWIFIEX_SDIO=m
CONFIG_PWRSEQ_SD8787=y
CONFIG_MT7601U=m
CONFIG_MT76x0U=m
CONFIG_MT76x2U=m
Expand Down
1 change: 1 addition & 0 deletions arch/arm/configs/revpi-v7l_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ CONFIG_LIBERTAS_THINFIRM=m
CONFIG_LIBERTAS_THINFIRM_USB=m
CONFIG_MWIFIEX=m
CONFIG_MWIFIEX_SDIO=m
CONFIG_PWRSEQ_SD8787=y
CONFIG_MT7601U=m
CONFIG_MT76x0U=m
CONFIG_MT76x2U=m
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/configs/revpi-v8_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ CONFIG_LIBERTAS_THINFIRM=m
CONFIG_LIBERTAS_THINFIRM_USB=m
CONFIG_MWIFIEX=m
CONFIG_MWIFIEX_SDIO=m
CONFIG_PWRSEQ_SD8787=y
CONFIG_MT7601U=m
CONFIG_MT76x0U=m
CONFIG_MT76x2U=m
Expand Down
2 changes: 1 addition & 1 deletion drivers/mmc/core/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ config PWRSEQ_EMMC

config PWRSEQ_SD8787
tristate "HW reset support for SD8787 BT + Wifi module"
depends on OF && (MWIFIEX || BT_MRVL_SDIO || LIBERTAS_SDIO)
depends on OF && (MWIFIEX != n || BT_MRVL_SDIO != n || LIBERTAS_SDIO != n || WILC1000_SDIO != n)
help
This selects hardware reset support for the SD8787 BT + Wifi
module. By default this option is set to n.
Expand Down
4 changes: 3 additions & 1 deletion drivers/mmc/host/bcm2835-mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,9 @@ static int bcm2835_mmc_probe(struct platform_device *pdev)
}

if (node) {
mmc_of_parse(mmc);
ret = mmc_of_parse(mmc);
if (ret)
goto err;

/* Read any custom properties */
of_property_read_u32(node,
Expand Down
5 changes: 3 additions & 2 deletions drivers/net/wireless/marvell/mwifiex/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ config MWIFIEX
mwifiex.

config MWIFIEX_SDIO
tristate "Marvell WiFi-Ex Driver for SD8786/SD8787/SD8797/SD8887/SD8897/SD8977/SD8987/SD8997"
tristate "Marvell WiFi-Ex Driver for SD8786/SD8787/SD8797/SD8887/SD8897/SD8977/SD8978/SD8987/SD8997"
depends on MWIFIEX && MMC
select FW_LOADER
select WANT_DEV_COREDUMP
help
This adds support for wireless adapters based on Marvell
8786/8787/8797/8887/8897/8977/8987/8997 chipsets with SDIO interface.
8786/8787/8797/8887/8897/8977/8978/8987/8997 chipsets with
SDIO interface. SD8978 is also known as NXP IW416.

If you choose to build it as a module, it will be called
mwifiex_sdio.
Expand Down
5 changes: 5 additions & 0 deletions drivers/net/wireless/marvell/mwifiex/cmdevt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,11 @@ int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
api_rev->major_ver,
api_rev->minor_ver);
break;
case FW_HOTFIX_VER_ID:
mwifiex_dbg(adapter, INFO,
"Firmware hotfix version %d\n",
api_rev->major_ver);
break;
default:
mwifiex_dbg(adapter, FATAL,
"Unknown api_id: %d\n",
Expand Down
1 change: 1 addition & 0 deletions drivers/net/wireless/marvell/mwifiex/fw.h
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,7 @@ enum API_VER_ID {
FW_API_VER_ID = 2,
UAP_FW_API_VER_ID = 3,
CHANRPT_API_VER_ID = 4,
FW_HOTFIX_VER_ID = 5,
};

struct hw_spec_api_rev {
Expand Down
47 changes: 44 additions & 3 deletions 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 @@ -272,7 +275,7 @@ static const struct mwifiex_sdio_card_reg mwifiex_reg_sd8887 = {
0x68, 0x69, 0x6a},
};

static const struct mwifiex_sdio_card_reg mwifiex_reg_sd8987 = {
static const struct mwifiex_sdio_card_reg mwifiex_reg_sd89xx = {
.start_rd_port = 0,
.start_wr_port = 0,
.base_0_reg = 0xF8,
Expand All @@ -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 @@ -400,6 +406,22 @@ static const struct mwifiex_sdio_device mwifiex_sdio_sd8977 = {
.can_ext_scan = true,
};

static const struct mwifiex_sdio_device mwifiex_sdio_sd8978 = {
.firmware_sdiouart = SD8978_SDIOUART_FW_NAME,
.reg = &mwifiex_reg_sd89xx,
.max_ports = 32,
.mp_agg_pkt_limit = 16,
.tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_4K,
.mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_MAX,
.mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_MAX,
.supports_sdio_new_mode = true,
.has_control_mask = false,
.can_dump_fw = true,
.fw_dump_enh = true,
.can_auto_tdls = false,
.can_ext_scan = true,
};

static const struct mwifiex_sdio_device mwifiex_sdio_sd8997 = {
.firmware = SD8997_DEFAULT_FW_NAME,
.reg = &mwifiex_reg_sd8997,
Expand Down Expand Up @@ -433,7 +455,7 @@ static const struct mwifiex_sdio_device mwifiex_sdio_sd8887 = {

static const struct mwifiex_sdio_device mwifiex_sdio_sd8987 = {
.firmware = SD8987_DEFAULT_FW_NAME,
.reg = &mwifiex_reg_sd8987,
.reg = &mwifiex_reg_sd89xx,
.max_ports = 32,
.mp_agg_pkt_limit = 16,
.tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_2K,
Expand Down Expand Up @@ -485,8 +507,11 @@ static struct memory_type_mapping mem_type_mapping_tbl[] = {
};

static const struct of_device_id mwifiex_sdio_of_match_table[] = {
{ .compatible = "marvell,sd8787" },
{ .compatible = "marvell,sd8897" },
{ .compatible = "marvell,sd8978" },
{ .compatible = "marvell,sd8997" },
{ .compatible = "nxp,iw416" },
{ }
};

Expand Down Expand Up @@ -536,6 +561,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 @@ -923,6 +949,8 @@ static const struct sdio_device_id mwifiex_ids[] = {
.driver_data = (unsigned long)&mwifiex_sdio_sd8801},
{SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8977_WLAN),
.driver_data = (unsigned long)&mwifiex_sdio_sd8977},
{SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8978_WLAN),
.driver_data = (unsigned long)&mwifiex_sdio_sd8978},
{SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8987_WLAN),
.driver_data = (unsigned long)&mwifiex_sdio_sd8987},
{SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8997_WLAN),
Expand Down Expand Up @@ -2439,6 +2467,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 +2484,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 Expand Up @@ -3155,5 +3195,6 @@ MODULE_FIRMWARE(SD8797_DEFAULT_FW_NAME);
MODULE_FIRMWARE(SD8897_DEFAULT_FW_NAME);
MODULE_FIRMWARE(SD8887_DEFAULT_FW_NAME);
MODULE_FIRMWARE(SD8977_DEFAULT_FW_NAME);
MODULE_FIRMWARE(SD8978_SDIOUART_FW_NAME);
MODULE_FIRMWARE(SD8987_DEFAULT_FW_NAME);
MODULE_FIRMWARE(SD8997_DEFAULT_FW_NAME);
6 changes: 6 additions & 0 deletions drivers/net/wireless/marvell/mwifiex/sdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#define SD8887_DEFAULT_FW_NAME "mrvl/sd8887_uapsta.bin"
#define SD8801_DEFAULT_FW_NAME "mrvl/sd8801_uapsta.bin"
#define SD8977_DEFAULT_FW_NAME "mrvl/sdsd8977_combo_v2.bin"
#define SD8978_SDIOUART_FW_NAME "mrvl/sdiouartiw416_combo_v0.bin"
#define SD8987_DEFAULT_FW_NAME "mrvl/sd8987_uapsta.bin"
#define SD8997_DEFAULT_FW_NAME "mrvl/sdsd8997_combo_v4.bin"

Expand Down Expand Up @@ -198,6 +199,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 @@ -243,6 +247,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 @@ -276,6 +281,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
1 change: 1 addition & 0 deletions include/linux/mmc/sdio_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
#define SDIO_DEVICE_ID_MARVELL_8977_BT 0x9146
#define SDIO_DEVICE_ID_MARVELL_8987_WLAN 0x9149
#define SDIO_DEVICE_ID_MARVELL_8987_BT 0x914a
#define SDIO_DEVICE_ID_MARVELL_8978_WLAN 0x9159

#define SDIO_VENDOR_ID_MEDIATEK 0x037a
#define SDIO_DEVICE_ID_MEDIATEK_MT7663 0x7663
Expand Down