Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88aabc45 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "wil6210: support FCC board file"

parents f4459ee9 b62bdcf9
Loading
Loading
Loading
Loading
+49 −10
Original line number Diff line number Diff line
@@ -21,7 +21,8 @@
#include "ftm.h"

#define WIL_MAX_ROC_DURATION_MS 5000
#define CTRY_CHINA "CN"
#define WIL_BRD_SUFFIX_CN "CN"
#define WIL_BRD_SUFFIX_FCC "FCC"

bool disable_ap_sme;
module_param(disable_ap_sme, bool, 0444);
@@ -60,6 +61,25 @@ static struct wiphy_wowlan_support wil_wowlan_support = {
};
#endif

struct wil_regd_2_brd_suffix {
	const char regdomain[3]; /* alpha2 */
	const char *brd_suffix;
};

static struct wil_regd_2_brd_suffix wil_regd_2_brd_suffix_map[] = {
	{"BO", WIL_BRD_SUFFIX_FCC},
	{"CN", WIL_BRD_SUFFIX_CN},
	{"EC", WIL_BRD_SUFFIX_FCC},
	{"GU", WIL_BRD_SUFFIX_FCC},
	{"HN", WIL_BRD_SUFFIX_FCC},
	{"JM", WIL_BRD_SUFFIX_FCC},
	{"MX", WIL_BRD_SUFFIX_FCC},
	{"NI", WIL_BRD_SUFFIX_FCC},
	{"PY", WIL_BRD_SUFFIX_FCC},
	{"TT", WIL_BRD_SUFFIX_FCC},
	{"US", WIL_BRD_SUFFIX_FCC},
};

enum wil_nl_60g_cmd_type {
	NL_60G_CMD_FW_WMI,
	NL_60G_CMD_DEBUG,
@@ -1989,24 +2009,43 @@ wil_cfg80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
	return 0;
}

static void wil_get_brd_reg_suffix(struct wil6210_priv *wil,
				   const u8 *new_regdomain,
				   char *brd_reg_suffix, size_t len)
{
	int i;
	struct wil_regd_2_brd_suffix *entry;

	for (i = 0; i < ARRAY_SIZE(wil_regd_2_brd_suffix_map); i++) {
		entry = &wil_regd_2_brd_suffix_map[i];
		if (!memcmp(entry->regdomain, new_regdomain, 2)) {
			strlcpy(brd_reg_suffix, entry->brd_suffix, len);
			return;
		}
	}

	/* regdomain not found in our map, set suffix to none */
	brd_reg_suffix[0] = '\0';
}

static int wil_switch_board_file(struct wil6210_priv *wil,
				 const u8 *new_regdomain)
{
	int rc = 0;
	char brd_reg_suffix[WIL_BRD_SUFFIX_LEN];

	if (!country_specific_board_file)
		return 0;

	if (memcmp(wil->regdomain, CTRY_CHINA, 2) == 0) {
		wil_info(wil, "moving out of China reg domain, use default board file\n");
		wil->board_file_country[0] = '\0';
	} else if (memcmp(new_regdomain, CTRY_CHINA, 2) == 0) {
		wil_info(wil, "moving into China reg domain, use country specific board file\n");
		strlcpy(wil->board_file_country, CTRY_CHINA,
			sizeof(wil->board_file_country));
	} else {
	wil_get_brd_reg_suffix(wil, new_regdomain, brd_reg_suffix,
			       sizeof(brd_reg_suffix));
	if (!strcmp(wil->board_file_reg_suffix, brd_reg_suffix))
		return 0;
	}

	wil_info(wil, "switch board file suffix '%s' => '%s'\n",
		 wil->board_file_reg_suffix, brd_reg_suffix);
	strlcpy(wil->board_file_reg_suffix, brd_reg_suffix,
		sizeof(wil->board_file_reg_suffix));

	/* need to switch board file - reset the device */

+4 −4
Original line number Diff line number Diff line
@@ -954,19 +954,19 @@ void wil_get_board_file(struct wil6210_priv *wil, char *buf, size_t len)
	const char *ext;
	int prefix_len;

	if (wil->board_file_country[0] == '\0') {
	if (wil->board_file_reg_suffix[0] == '\0') {
		strlcpy(buf, board_file, len);
		return;
	}

	/* use country specific board file */
	if (len < strlen(board_file) + 4 /* for _XX and terminating null */)
	if (len < strlen(board_file) + 1 + WIL_BRD_SUFFIX_LEN) /* 1 for '_' */
		return;

	ext = strrchr(board_file, '.');
	prefix_len = (ext ? ext - board_file : strlen(board_file));
	snprintf(buf, len, "%.*s_%.2s",
		 prefix_len, board_file, wil->board_file_country);
	snprintf(buf, len, "%.*s_%.3s",
		 prefix_len, board_file, wil->board_file_reg_suffix);
	if (ext)
		strlcat(buf, ext, len);
}
+3 −1
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ extern bool disable_ap_sme;
#define WIL_DEFAULT_BUS_REQUEST_KBPS 128000 /* ~1Gbps */
#define WIL_MAX_BUS_REQUEST_KBPS 800000 /* ~6.1Gbps */

#define WIL_BRD_SUFFIX_LEN 4 /* max 3 letters + terminating null */

/**
 * extract bits [@b0:@b1] (inclusive) from the value @x
 * it should be @b0 <= @b1, or result is incorrect
@@ -683,7 +685,7 @@ struct wil6210_priv {
	const char *hw_name;
	const char *wil_fw_name;
	char *board_file;
	char board_file_country[3]; /* alpha2 */
	char board_file_reg_suffix[WIL_BRD_SUFFIX_LEN]; /* empty or CN or FCC */
	u32 brd_file_addr;
	u32 brd_file_max_size;
	DECLARE_BITMAP(hw_capa, hw_capa_last);