aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHante Meuleman <meuleman@broadcom.com>2016-02-17 05:26:57 -0500
committerKalle Valo <kvalo@codeaurora.org>2016-03-07 07:14:50 -0500
commit6ac27689b01e23e21f08d6f55d23a94eb10a8efc (patch)
tree790f7f7cfc2c7fbb4f08edf61266cba53812977b
parentcd2bc19c61b2da81ce310edb20f98e51fa7a5889 (diff)
brcmfmac: use device memsize config from fw if defined
Newer type pcie devices have memory which get shared between fw and hw. The division of this memory is done firmware compile time. As a result the ramsize as used by driver needs to be adjusted for this. This is done by reading the memory size from the firmware. Reviewed-by: Arend Van Spriel <arend@broadcom.com> Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com> Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com> Signed-off-by: Hante Meuleman <meuleman@broadcom.com> Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index d5f9ef470447..d89212b4649e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -207,6 +207,10 @@ static struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
207#define BRCMF_PCIE_CFGREG_REG_BAR3_CONFIG 0x4F4 207#define BRCMF_PCIE_CFGREG_REG_BAR3_CONFIG 0x4F4
208#define BRCMF_PCIE_LINK_STATUS_CTRL_ASPM_ENAB 3 208#define BRCMF_PCIE_LINK_STATUS_CTRL_ASPM_ENAB 3
209 209
210/* Magic number at a magic location to find RAM size */
211#define BRCMF_RAMSIZE_MAGIC 0x534d4152 /* SMAR */
212#define BRCMF_RAMSIZE_OFFSET 0x6c
213
210 214
211struct brcmf_pcie_console { 215struct brcmf_pcie_console {
212 u32 base_addr; 216 u32 base_addr;
@@ -1412,6 +1416,28 @@ static const struct brcmf_bus_ops brcmf_pcie_bus_ops = {
1412}; 1416};
1413 1417
1414 1418
1419static void
1420brcmf_pcie_adjust_ramsize(struct brcmf_pciedev_info *devinfo, u8 *data,
1421 u32 data_len)
1422{
1423 __le32 *field;
1424 u32 newsize;
1425
1426 if (data_len < BRCMF_RAMSIZE_OFFSET + 8)
1427 return;
1428
1429 field = (__le32 *)&data[BRCMF_RAMSIZE_OFFSET];
1430 if (le32_to_cpup(field) != BRCMF_RAMSIZE_MAGIC)
1431 return;
1432 field++;
1433 newsize = le32_to_cpup(field);
1434
1435 brcmf_dbg(PCIE, "Found ramsize info in FW, adjusting to 0x%x\n",
1436 newsize);
1437 devinfo->ci->ramsize = newsize;
1438}
1439
1440
1415static int 1441static int
1416brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo, 1442brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo,
1417 u32 sharedram_addr) 1443 u32 sharedram_addr)
@@ -1694,6 +1720,13 @@ static void brcmf_pcie_setup(struct device *dev, const struct firmware *fw,
1694 1720
1695 brcmf_pcie_attach(devinfo); 1721 brcmf_pcie_attach(devinfo);
1696 1722
1723 /* Some of the firmwares have the size of the memory of the device
1724 * defined inside the firmware. This is because part of the memory in
1725 * the device is shared and the devision is determined by FW. Parse
1726 * the firmware and adjust the chip memory size now.
1727 */
1728 brcmf_pcie_adjust_ramsize(devinfo, (u8 *)fw->data, fw->size);
1729
1697 ret = brcmf_pcie_download_fw_nvram(devinfo, fw, nvram, nvram_len); 1730 ret = brcmf_pcie_download_fw_nvram(devinfo, fw, nvram, nvram_len);
1698 if (ret) 1731 if (ret)
1699 goto fail; 1732 goto fail;