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
5 Newer type pcie devices have memory which get shared between fw and
6 hw. The division of this memory is done firmware compile time. As a
7 result the ramsize as used by driver needs to be adjusted for this.
8 This is done by reading the memory size from the firmware.
10 Reviewed-by: Arend Van Spriel <arend@broadcom.com>
11 Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
12 Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
13 Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
14 Signed-off-by: Arend van Spriel <arend@broadcom.com>
15 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
18 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
19 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
20 @@ -207,6 +207,10 @@ static struct brcmf_firmware_mapping brc
21 #define BRCMF_PCIE_CFGREG_REG_BAR3_CONFIG 0x4F4
22 #define BRCMF_PCIE_LINK_STATUS_CTRL_ASPM_ENAB 3
24 +/* Magic number at a magic location to find RAM size */
25 +#define BRCMF_RAMSIZE_MAGIC 0x534d4152 /* SMAR */
26 +#define BRCMF_RAMSIZE_OFFSET 0x6c
29 struct brcmf_pcie_console {
31 @@ -1412,6 +1416,28 @@ static const struct brcmf_bus_ops brcmf_
36 +brcmf_pcie_adjust_ramsize(struct brcmf_pciedev_info *devinfo, u8 *data,
42 + if (data_len < BRCMF_RAMSIZE_OFFSET + 8)
45 + field = (__le32 *)&data[BRCMF_RAMSIZE_OFFSET];
46 + if (le32_to_cpup(field) != BRCMF_RAMSIZE_MAGIC)
49 + newsize = le32_to_cpup(field);
51 + brcmf_dbg(PCIE, "Found ramsize info in FW, adjusting to 0x%x\n",
53 + devinfo->ci->ramsize = newsize;
58 brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo,
60 @@ -1694,6 +1720,13 @@ static void brcmf_pcie_setup(struct devi
62 brcmf_pcie_attach(devinfo);
64 + /* Some of the firmwares have the size of the memory of the device
65 + * defined inside the firmware. This is because part of the memory in
66 + * the device is shared and the devision is determined by FW. Parse
67 + * the firmware and adjust the chip memory size now.
69 + brcmf_pcie_adjust_ramsize(devinfo, (u8 *)fw->data, fw->size);
71 ret = brcmf_pcie_download_fw_nvram(devinfo, fw, nvram, nvram_len);