344-0008-brcmfmac-use-device-memsize-config-from-fw-if-define.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. From: Hante Meuleman <meuleman@broadcom.com>
  2. Date: Wed, 17 Feb 2016 11:26:57 +0100
  3. Subject: [PATCH] brcmfmac: use device memsize config from fw if defined
  4. Newer type pcie devices have memory which get shared between fw and
  5. hw. The division of this memory is done firmware compile time. As a
  6. result the ramsize as used by driver needs to be adjusted for this.
  7. This is done by reading the memory size from the firmware.
  8. Reviewed-by: Arend Van Spriel <arend@broadcom.com>
  9. Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
  10. Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
  11. Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
  12. Signed-off-by: Arend van Spriel <arend@broadcom.com>
  13. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  14. ---
  15. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  16. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  17. @@ -207,6 +207,10 @@ static struct brcmf_firmware_mapping brc
  18. #define BRCMF_PCIE_CFGREG_REG_BAR3_CONFIG 0x4F4
  19. #define BRCMF_PCIE_LINK_STATUS_CTRL_ASPM_ENAB 3
  20. +/* Magic number at a magic location to find RAM size */
  21. +#define BRCMF_RAMSIZE_MAGIC 0x534d4152 /* SMAR */
  22. +#define BRCMF_RAMSIZE_OFFSET 0x6c
  23. +
  24. struct brcmf_pcie_console {
  25. u32 base_addr;
  26. @@ -1412,6 +1416,28 @@ static const struct brcmf_bus_ops brcmf_
  27. };
  28. +static void
  29. +brcmf_pcie_adjust_ramsize(struct brcmf_pciedev_info *devinfo, u8 *data,
  30. + u32 data_len)
  31. +{
  32. + __le32 *field;
  33. + u32 newsize;
  34. +
  35. + if (data_len < BRCMF_RAMSIZE_OFFSET + 8)
  36. + return;
  37. +
  38. + field = (__le32 *)&data[BRCMF_RAMSIZE_OFFSET];
  39. + if (le32_to_cpup(field) != BRCMF_RAMSIZE_MAGIC)
  40. + return;
  41. + field++;
  42. + newsize = le32_to_cpup(field);
  43. +
  44. + brcmf_dbg(PCIE, "Found ramsize info in FW, adjusting to 0x%x\n",
  45. + newsize);
  46. + devinfo->ci->ramsize = newsize;
  47. +}
  48. +
  49. +
  50. static int
  51. brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo,
  52. u32 sharedram_addr)
  53. @@ -1694,6 +1720,13 @@ static void brcmf_pcie_setup(struct devi
  54. brcmf_pcie_attach(devinfo);
  55. + /* Some of the firmwares have the size of the memory of the device
  56. + * defined inside the firmware. This is because part of the memory in
  57. + * the device is shared and the devision is determined by FW. Parse
  58. + * the firmware and adjust the chip memory size now.
  59. + */
  60. + brcmf_pcie_adjust_ramsize(devinfo, (u8 *)fw->data, fw->size);
  61. +
  62. ret = brcmf_pcie_download_fw_nvram(devinfo, fw, nvram, nvram_len);
  63. if (ret)
  64. goto fail;