b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl> |
| 2 | Subject: [PATCH] brcmfmac: add in-driver tables with country codes |
| 3 | MIME-Version: 1.0 |
| 4 | Content-Type: text/plain; charset=UTF-8 |
| 5 | Content-Transfer-Encoding: 8bit |
| 6 | |
| 7 | This adds early support for changing region. Ideally this data should |
| 8 | be stored in DT as all these mappings are devices specific. |
| 9 | |
| 10 | Signed-off-by: Rafał Miłecki <rafal@milecki.pl> |
| 11 | --- |
| 12 | |
| 13 | --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c |
| 14 | +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c |
| 15 | @@ -12,6 +12,36 @@ |
| 16 | #include "common.h" |
| 17 | #include "of.h" |
| 18 | |
| 19 | +/* TODO: FIXME: Use DT */ |
| 20 | +static void brcmf_of_probe_cc(struct device *dev, |
| 21 | + struct brcmf_mp_device *settings) |
| 22 | +{ |
| 23 | + static struct brcmfmac_pd_cc_entry netgear_r8000_cc_ent[] = { |
| 24 | + { "JP", "JP", 78 }, |
| 25 | + { "US", "Q2", 86 }, |
| 26 | + }; |
| 27 | + struct brcmfmac_pd_cc_entry *cc_ent = NULL; |
| 28 | + int table_size = 0; |
| 29 | + |
| 30 | + if (of_machine_is_compatible("netgear,r8000")) { |
| 31 | + cc_ent = netgear_r8000_cc_ent; |
| 32 | + table_size = ARRAY_SIZE(netgear_r8000_cc_ent); |
| 33 | + } |
| 34 | + |
| 35 | + if (cc_ent && table_size) { |
| 36 | + struct brcmfmac_pd_cc *cc; |
| 37 | + size_t memsize; |
| 38 | + |
| 39 | + memsize = table_size * sizeof(struct brcmfmac_pd_cc_entry); |
| 40 | + cc = devm_kzalloc(dev, sizeof(*cc) + memsize, GFP_KERNEL); |
| 41 | + if (!cc) |
| 42 | + return; |
| 43 | + cc->table_size = table_size; |
| 44 | + memcpy(cc->table, cc_ent, memsize); |
| 45 | + settings->country_codes = cc; |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, |
| 50 | struct brcmf_mp_device *settings) |
| 51 | { |
| 52 | @@ -43,6 +73,8 @@ void brcmf_of_probe(struct device *dev, |
| 53 | of_node_put(root); |
| 54 | } |
| 55 | |
| 56 | + brcmf_of_probe_cc(dev, settings); |
| 57 | + |
| 58 | if (!np || bus_type != BRCMF_BUSTYPE_SDIO || |
| 59 | !of_device_is_compatible(np, "brcm,bcm4329-fmac")) |
| 60 | return; |