Commit a351f2f5 authored by Lazar Alexei's avatar Lazar Alexei Committed by Kalle Valo

wil6210: support loading dedicated image for sparrow-plus devices

Driver may be used in platforms where some use sparrow cards while
other use sparrow-plus cards, where different FW image is needed.
Add the capability to load dedicated FW image in case sparrow-plus
card is detected and fallback to default image if such does not exist.
Signed-off-by: default avatarLazar Alexei <qca_ailizaro@qca.qualcomm.com>
Signed-off-by: default avatarMaya Erez <qca_merez@qca.qualcomm.com>
Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
parent 849a564b
/* /*
* Copyright (c) 2012-2016 Qualcomm Atheros, Inc. * Copyright (c) 2012-2017 Qualcomm Atheros, Inc.
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
...@@ -1699,6 +1699,7 @@ static const struct dbg_off dbg_wil_off[] = { ...@@ -1699,6 +1699,7 @@ static const struct dbg_off dbg_wil_off[] = {
WIL_FIELD(recovery_count, S_IRUGO, doff_u32), WIL_FIELD(recovery_count, S_IRUGO, doff_u32),
WIL_FIELD(ap_isolate, S_IRUGO, doff_u32), WIL_FIELD(ap_isolate, S_IRUGO, doff_u32),
WIL_FIELD(discovery_mode, S_IRUGO | S_IWUSR, doff_u8), WIL_FIELD(discovery_mode, S_IRUGO | S_IWUSR, doff_u8),
WIL_FIELD(chip_revision, S_IRUGO, doff_u8),
{}, {},
}; };
......
/* /*
* Copyright (c) 2014-2015 Qualcomm Atheros, Inc. * Copyright (c) 2014-2015,2017 Qualcomm Atheros, Inc.
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
...@@ -19,8 +19,9 @@ ...@@ -19,8 +19,9 @@
#include "wil6210.h" #include "wil6210.h"
#include "fw.h" #include "fw.h"
MODULE_FIRMWARE(WIL_FW_NAME); MODULE_FIRMWARE(WIL_FW_NAME_DEFAULT);
MODULE_FIRMWARE(WIL_FW2_NAME); MODULE_FIRMWARE(WIL_FW_NAME_SPARROW_PLUS);
MODULE_FIRMWARE(WIL_BOARD_FILE_NAME);
static static
void wil_memset_toio_32(volatile void __iomem *dst, u32 val, void wil_memset_toio_32(volatile void __iomem *dst, u32 val,
......
/* /*
* Copyright (c) 2014-2016 Qualcomm Atheros, Inc. * Copyright (c) 2014-2017 Qualcomm Atheros, Inc.
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
...@@ -537,3 +537,22 @@ int wil_request_firmware(struct wil6210_priv *wil, const char *name, ...@@ -537,3 +537,22 @@ int wil_request_firmware(struct wil6210_priv *wil, const char *name,
release_firmware(fw); release_firmware(fw);
return rc; return rc;
} }
/**
* wil_fw_verify_file_exists - checks if firmware file exist
*
* @wil: driver context
* @name: firmware file name
*
* return value - boolean, true for success, false for failure
*/
bool wil_fw_verify_file_exists(struct wil6210_priv *wil, const char *name)
{
const struct firmware *fw;
int rc;
rc = request_firmware(&fw, name, wil_to_dev(wil));
if (!rc)
release_firmware(fw);
return rc != -ENOENT;
}
...@@ -934,16 +934,16 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw) ...@@ -934,16 +934,16 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
wil_set_oob_mode(wil, oob_mode); wil_set_oob_mode(wil, oob_mode);
if (load_fw) { if (load_fw) {
wil_info(wil, "Use firmware <%s> + board <%s>\n", WIL_FW_NAME, wil_info(wil, "Use firmware <%s> + board <%s>\n",
WIL_FW2_NAME); wil->wil_fw_name, WIL_BOARD_FILE_NAME);
wil_halt_cpu(wil); wil_halt_cpu(wil);
memset(wil->fw_version, 0, sizeof(wil->fw_version)); memset(wil->fw_version, 0, sizeof(wil->fw_version));
/* Loading f/w from the file */ /* Loading f/w from the file */
rc = wil_request_firmware(wil, WIL_FW_NAME, true); rc = wil_request_firmware(wil, wil->wil_fw_name, true);
if (rc) if (rc)
return rc; return rc;
rc = wil_request_firmware(wil, WIL_FW2_NAME, true); rc = wil_request_firmware(wil, WIL_BOARD_FILE_NAME, true);
if (rc) if (rc)
return rc; return rc;
......
...@@ -36,18 +36,38 @@ static int wil6210_pm_notify(struct notifier_block *notify_block, ...@@ -36,18 +36,38 @@ static int wil6210_pm_notify(struct notifier_block *notify_block,
static static
void wil_set_capabilities(struct wil6210_priv *wil) void wil_set_capabilities(struct wil6210_priv *wil)
{ {
u32 rev_id = wil_r(wil, RGF_USER_JTAG_DEV_ID); u32 jtag_id = wil_r(wil, RGF_USER_JTAG_DEV_ID);
u8 chip_revision = (wil_r(wil, RGF_USER_REVISION_ID) &
RGF_USER_REVISION_ID_MASK);
bitmap_zero(wil->hw_capabilities, hw_capability_last); bitmap_zero(wil->hw_capabilities, hw_capability_last);
bitmap_zero(wil->fw_capabilities, WMI_FW_CAPABILITY_MAX); bitmap_zero(wil->fw_capabilities, WMI_FW_CAPABILITY_MAX);
wil->wil_fw_name = WIL_FW_NAME_DEFAULT;
switch (rev_id) { wil->chip_revision = chip_revision;
case JTAG_DEV_ID_SPARROW_B0:
wil->hw_name = "Sparrow B0"; switch (jtag_id) {
wil->hw_version = HW_VER_SPARROW_B0; case JTAG_DEV_ID_SPARROW:
switch (chip_revision) {
case REVISION_ID_SPARROW_D0:
wil->hw_name = "Sparrow D0";
wil->hw_version = HW_VER_SPARROW_D0;
if (wil_fw_verify_file_exists(wil,
WIL_FW_NAME_SPARROW_PLUS))
wil->wil_fw_name = WIL_FW_NAME_SPARROW_PLUS;
break;
case REVISION_ID_SPARROW_B0:
wil->hw_name = "Sparrow B0";
wil->hw_version = HW_VER_SPARROW_B0;
break;
default:
wil->hw_name = "Unknown";
wil->hw_version = HW_VER_UNKNOWN;
break;
}
break; break;
default: default:
wil_err(wil, "Unknown board hardware 0x%08x\n", rev_id); wil_err(wil, "Unknown board hardware, chip_id 0x%08x, chip_revision 0x%08x\n",
jtag_id, chip_revision);
wil->hw_name = "Unknown"; wil->hw_name = "Unknown";
wil->hw_version = HW_VER_UNKNOWN; wil->hw_version = HW_VER_UNKNOWN;
} }
...@@ -55,7 +75,7 @@ void wil_set_capabilities(struct wil6210_priv *wil) ...@@ -55,7 +75,7 @@ void wil_set_capabilities(struct wil6210_priv *wil)
wil_info(wil, "Board hardware is %s\n", wil->hw_name); wil_info(wil, "Board hardware is %s\n", wil->hw_name);
/* extract FW capabilities from file without loading the FW */ /* extract FW capabilities from file without loading the FW */
wil_request_firmware(wil, WIL_FW_NAME, false); wil_request_firmware(wil, wil->wil_fw_name, false);
} }
void wil_disable_irq(struct wil6210_priv *wil) void wil_disable_irq(struct wil6210_priv *wil)
......
...@@ -36,8 +36,9 @@ extern bool debug_fw; ...@@ -36,8 +36,9 @@ extern bool debug_fw;
extern bool disable_ap_sme; extern bool disable_ap_sme;
#define WIL_NAME "wil6210" #define WIL_NAME "wil6210"
#define WIL_FW_NAME "wil6210.fw" /* code */ #define WIL_FW_NAME_DEFAULT "wil6210.fw" /* code Sparrow B0 */
#define WIL_FW2_NAME "wil6210.brd" /* board & radio parameters */ #define WIL_FW_NAME_SPARROW_PLUS "wil6210_sparrow_plus.fw" /* code Sparrow D0 */
#define WIL_BOARD_FILE_NAME "wil6210.brd" /* board & radio parameters */
#define WIL_MAX_BUS_REQUEST_KBPS 800000 /* ~6.1Gbps */ #define WIL_MAX_BUS_REQUEST_KBPS 800000 /* ~6.1Gbps */
...@@ -253,7 +254,12 @@ struct RGF_ICR { ...@@ -253,7 +254,12 @@ struct RGF_ICR {
#define BIT_CAF_OSC_DIG_XTAL_STABLE BIT(0) #define BIT_CAF_OSC_DIG_XTAL_STABLE BIT(0)
#define RGF_USER_JTAG_DEV_ID (0x880b34) /* device ID */ #define RGF_USER_JTAG_DEV_ID (0x880b34) /* device ID */
#define JTAG_DEV_ID_SPARROW_B0 (0x2632072f) #define JTAG_DEV_ID_SPARROW (0x2632072f)
#define RGF_USER_REVISION_ID (0x88afe4)
#define RGF_USER_REVISION_ID_MASK (3)
#define REVISION_ID_SPARROW_B0 (0x0)
#define REVISION_ID_SPARROW_D0 (0x3)
/* crash codes for FW/Ucode stored here */ /* crash codes for FW/Ucode stored here */
#define RGF_FW_ASSERT_CODE (0x91f020) #define RGF_FW_ASSERT_CODE (0x91f020)
...@@ -261,7 +267,8 @@ struct RGF_ICR { ...@@ -261,7 +267,8 @@ struct RGF_ICR {
enum { enum {
HW_VER_UNKNOWN, HW_VER_UNKNOWN,
HW_VER_SPARROW_B0, /* JTAG_DEV_ID_SPARROW_B0 */ HW_VER_SPARROW_B0, /* REVISION_ID_SPARROW_B0 */
HW_VER_SPARROW_D0, /* REVISION_ID_SPARROW_D0 */
}; };
/* popular locations */ /* popular locations */
...@@ -587,7 +594,9 @@ struct wil6210_priv { ...@@ -587,7 +594,9 @@ struct wil6210_priv {
DECLARE_BITMAP(status, wil_status_last); DECLARE_BITMAP(status, wil_status_last);
u8 fw_version[ETHTOOL_FWVERS_LEN]; u8 fw_version[ETHTOOL_FWVERS_LEN];
u32 hw_version; u32 hw_version;
u8 chip_revision;
const char *hw_name; const char *hw_name;
const char *wil_fw_name;
DECLARE_BITMAP(hw_capabilities, hw_capability_last); DECLARE_BITMAP(hw_capabilities, hw_capability_last);
DECLARE_BITMAP(fw_capabilities, WMI_FW_CAPABILITY_MAX); DECLARE_BITMAP(fw_capabilities, WMI_FW_CAPABILITY_MAX);
u8 n_mids; /* number of additional MIDs as reported by FW */ u8 n_mids; /* number of additional MIDs as reported by FW */
...@@ -923,6 +932,7 @@ int wil_iftype_nl2wmi(enum nl80211_iftype type); ...@@ -923,6 +932,7 @@ int wil_iftype_nl2wmi(enum nl80211_iftype type);
int wil_ioctl(struct wil6210_priv *wil, void __user *data, int cmd); int wil_ioctl(struct wil6210_priv *wil, void __user *data, int cmd);
int wil_request_firmware(struct wil6210_priv *wil, const char *name, int wil_request_firmware(struct wil6210_priv *wil, const char *name,
bool load); bool load);
bool wil_fw_verify_file_exists(struct wil6210_priv *wil, const char *name);
int wil_can_suspend(struct wil6210_priv *wil, bool is_runtime); int wil_can_suspend(struct wil6210_priv *wil, bool is_runtime);
int wil_suspend(struct wil6210_priv *wil, bool is_runtime); int wil_suspend(struct wil6210_priv *wil, bool is_runtime);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment