863-brcmfmac-add-in-driver-tables-with-country-codes.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. This adds early support for changing region. Ideally this data should
  7. be stored in DT as all these mappings are devices specific.
  8. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  9. ---
  10. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
  11. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
  12. @@ -23,6 +23,36 @@
  13. #include "common.h"
  14. #include "of.h"
  15. +/* TODO: FIXME: Use DT */
  16. +static void brcmf_of_probe_cc(struct device *dev,
  17. + struct brcmf_mp_device *settings)
  18. +{
  19. + static struct brcmfmac_pd_cc_entry netgear_r8000_cc_ent[] = {
  20. + { "JP", "JP", 78 },
  21. + { "US", "Q2", 86 },
  22. + };
  23. + struct brcmfmac_pd_cc_entry *cc_ent = NULL;
  24. + int table_size = 0;
  25. +
  26. + if (of_machine_is_compatible("netgear,r8000")) {
  27. + cc_ent = netgear_r8000_cc_ent;
  28. + table_size = ARRAY_SIZE(netgear_r8000_cc_ent);
  29. + }
  30. +
  31. + if (cc_ent && table_size) {
  32. + struct brcmfmac_pd_cc *cc;
  33. + size_t memsize;
  34. +
  35. + memsize = table_size * sizeof(struct brcmfmac_pd_cc_entry);
  36. + cc = devm_kzalloc(dev, sizeof(*cc) + memsize, GFP_KERNEL);
  37. + if (!cc)
  38. + return;
  39. + cc->table_size = table_size;
  40. + memcpy(cc->table, cc_ent, memsize);
  41. + settings->country_codes = cc;
  42. + }
  43. +}
  44. +
  45. void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
  46. struct brcmf_mp_device *settings)
  47. {
  48. @@ -32,6 +62,8 @@ void brcmf_of_probe(struct device *dev,
  49. u32 irqf;
  50. u32 val;
  51. + brcmf_of_probe_cc(dev, settings);
  52. +
  53. if (!np || bus_type != BRCMF_BUSTYPE_SDIO ||
  54. !of_device_is_compatible(np, "brcm,bcm4329-fmac"))
  55. return;