brcmfmac: hard code ccode map table for BCM4345/9
Although upstream accepts the solution of coding country code map in DT, it will require different DTB between AP5256 (BCM4345/9) and AP5256V (BCM43012/2). To support both chipsets with single kernel image and DTB, let's hard code country code map table of AP5256 in driver, and use it over the one from DT if any. The map table of AP5256 comes from bcmdhd driver, ccode_43456c5[] in drivers/net/wireless/bcmdhd/dhd_ccode.c. Signed-off-by: Shawn Guo <shawn.guo@linaro.org>zero-sugar
parent
fa2634c419
commit
07b703037c
|
@ -539,7 +539,7 @@ struct brcmf_mp_device *brcmf_get_module_param(struct device *dev,
|
|||
}
|
||||
if (!found) {
|
||||
/* No platform data for this device, try OF (Open Firwmare) */
|
||||
brcmf_of_probe(dev, bus_type, settings);
|
||||
brcmf_of_probe(dev, bus_type, settings, chip, chiprev);
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
|
|
@ -23,16 +23,61 @@
|
|||
#include "common.h"
|
||||
#include "of.h"
|
||||
|
||||
static const char * const bcm43456c5_ccode_map[] = {
|
||||
"AE-AE-6", "AG-AG-2", "AI-AI-1", "AL-AL-2", "AS-AS-12", "AT-AT-4",
|
||||
"AU-AU-6", "AW-AW-2", "AZ-AZ-2",
|
||||
"BA-BA-2", "BD-BD-1", "BE-BE-4", "BG-BG-4", "BH-BH-4", "BM-BM-12",
|
||||
"BN-BN-4", "BR-BR-4", "BS-BS-2", "BY-BY-3",
|
||||
"CA-CA-2", "CH-CH-4", "CN-CN-38", "CO-CO-17", "CR-CR-17", "CY-CY-4",
|
||||
"CZ-CZ-4",
|
||||
"DE-DE-7", "DK-DK-4",
|
||||
"EC-EC-21", "EE-EE-4", "EG-EG-13", "ES-ES-4", "ET-ET-2",
|
||||
"FI-FI-4", "FR-FR-5",
|
||||
"GB-GB-6", "GD-GD-2", "GF-GF-2", "GP-GP-2", "GR-GR-4", "GT-GT-1",
|
||||
"GU-GU-30",
|
||||
"HK-HK-2", "HR-HR-4", "HU-HU-4",
|
||||
"ID-ID-1", "IE-IE-5", "IL-IL-14", "IN-IN-3", "IS-IS-4", "IT-IT-4",
|
||||
"JO-JO-3", "JP-JP-58",
|
||||
"KH-KH-2", "KR-KR-96", "KW-KW-5", "KY-KY-3",
|
||||
"LA-LA-2", "LB-LB-5", "LI-LI-4", "LK-LK-1", "LS-LS-2", "LT-LT-4",
|
||||
"LU-LU-3", "LV-LV-4",
|
||||
"MA-MA-2", "MC-MC-1", "MD-MD-2", "ME-ME-2", "MK-MK-2", "MN-MN-1",
|
||||
"MQ-MQ-2", "MR-MR-2", "MT-MT-4", "MU-MU-2", "MV-MV-3", "MW-MW-1",
|
||||
"MX-MX-44", "MY-MY-3",
|
||||
"NI-NI-2", "NL-NL-4", "NO-NO-4", "NZ-NZ-4",
|
||||
"OM-OM-4",
|
||||
"PA-PA-17", "PE-PE-20", "PH-PH-5", "PL-PL-4", "PR-PR-38", "PT-PT-4",
|
||||
"PY-PY-2",
|
||||
"Q2-Q2-993",
|
||||
"RE-RE-2", "RO-RO-4", "RS-RS-2", "RU-RU-13",
|
||||
"SE-SE-4", "SI-SI-4", "SK-SK-4", "SV-SV-25",
|
||||
"TH-TH-5", "TN-TN-1", "TR-TR-7", "TT-TT-3", "TW-TW-65",
|
||||
"UA-UA-8", "US-US-988",
|
||||
"VA-VA-2", "VE-VE-3", "VG-VG-2", "VN-VN-4",
|
||||
"XZ-XZ-11",
|
||||
"YT-YT-2",
|
||||
"ZA-ZA-6",
|
||||
};
|
||||
|
||||
static int brcmf_of_get_country_codes(struct device *dev,
|
||||
struct brcmf_mp_device *settings)
|
||||
struct brcmf_mp_device *settings,
|
||||
u32 chip, u32 chiprev)
|
||||
{
|
||||
struct device_node *np = dev->of_node;
|
||||
const char * const *ccode_map = NULL;
|
||||
struct brcmfmac_pd_cc_entry *cce;
|
||||
struct brcmfmac_pd_cc *cc;
|
||||
int count;
|
||||
int i;
|
||||
|
||||
count = of_property_count_strings(np, "brcm,ccode-map");
|
||||
|
||||
/* Use hard-coded map table over DT one for BCM4345/9 */
|
||||
if (chip == 0x4345 && chiprev == 0x9) {
|
||||
count = ARRAY_SIZE(bcm43456c5_ccode_map);
|
||||
ccode_map = bcm43456c5_ccode_map;
|
||||
}
|
||||
|
||||
if (count < 0) {
|
||||
/* The property is optional, so return success if it doesn't
|
||||
* exist. Otherwise propagate the error code.
|
||||
|
@ -51,9 +96,14 @@ static int brcmf_of_get_country_codes(struct device *dev,
|
|||
|
||||
cce = &cc->table[i];
|
||||
|
||||
if (of_property_read_string_index(np, "brcm,ccode-map",
|
||||
i, &map))
|
||||
continue;
|
||||
/* Try hard-coded map table first, and DT otherwise. */
|
||||
if (ccode_map) {
|
||||
map = ccode_map[i];
|
||||
} else {
|
||||
if (of_property_read_string_index(np, "brcm,ccode-map",
|
||||
i, &map))
|
||||
continue;
|
||||
}
|
||||
|
||||
/* String format e.g. US-Q2-86 */
|
||||
if (sscanf(map, "%2c-%2c-%d", cce->iso3166, cce->cc,
|
||||
|
@ -70,7 +120,7 @@ static int brcmf_of_get_country_codes(struct device *dev,
|
|||
}
|
||||
|
||||
void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
|
||||
struct brcmf_mp_device *settings)
|
||||
struct brcmf_mp_device *settings, u32 chip, u32 chiprev)
|
||||
{
|
||||
struct brcmfmac_sdio_pd *sdio = &settings->bus.sdio;
|
||||
struct device_node *np = dev->of_node;
|
||||
|
@ -83,7 +133,7 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
|
|||
if (!np || !of_device_is_compatible(np, "brcm,bcm4329-fmac"))
|
||||
return;
|
||||
|
||||
err = brcmf_of_get_country_codes(dev, settings);
|
||||
err = brcmf_of_get_country_codes(dev, settings, chip, chiprev);
|
||||
if (err)
|
||||
brcmf_err("failed to get OF country code map (err=%d)\n", err);
|
||||
|
||||
|
|
|
@ -15,10 +15,11 @@
|
|||
*/
|
||||
#ifdef CONFIG_OF
|
||||
void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
|
||||
struct brcmf_mp_device *settings);
|
||||
struct brcmf_mp_device *settings, u32 chip, u32 chiprev);
|
||||
#else
|
||||
static void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
|
||||
struct brcmf_mp_device *settings)
|
||||
struct brcmf_mp_device *settings,
|
||||
u32 chip, u32 chiprev)
|
||||
{
|
||||
}
|
||||
#endif /* CONFIG_OF */
|
||||
|
|
Loading…
Reference in New Issue