Skip to content

Commit 37e537d

Browse files
committed
brcmfmac: chip: Handle 1024-unit sizes for TCM blocks
BCM4387 has trailing odd-sized blocks as part of TCM which have their size described as a multiple of 1024 instead of 8192. Handle this so we can compute the TCM size properly. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent 2bd5d69 commit 37e537d

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

  • drivers/net/wireless/broadcom/brcm80211/brcmfmac

drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ struct sbsocramregs {
212212
#define ARMCR4_TCBANB_MASK 0xf
213213
#define ARMCR4_TCBANB_SHIFT 0
214214

215-
#define ARMCR4_BSZ_MASK 0x3f
216-
#define ARMCR4_BSZ_MULT 8192
215+
#define ARMCR4_BSZ_MASK 0x7f
216+
#define ARMCR4_BLK_1K_MASK 0x200
217217

218218
struct brcmf_core_priv {
219219
struct brcmf_core pub;
@@ -676,14 +676,16 @@ static u32 brcmf_chip_sysmem_ramsize(struct brcmf_core_priv *sysmem)
676676
}
677677

678678
/** Return the TCM-RAM size of the ARMCR4 core. */
679-
static u32 brcmf_chip_tcm_ramsize(struct brcmf_core_priv *cr4)
679+
static u32 brcmf_chip_tcm_ramsize(struct brcmf_chip_priv *ci,
680+
struct brcmf_core_priv *cr4)
680681
{
681682
u32 corecap;
682683
u32 memsize = 0;
683684
u32 nab;
684685
u32 nbb;
685686
u32 totb;
686687
u32 bxinfo;
688+
u32 blksize;
687689
u32 idx;
688690

689691
corecap = brcmf_chip_core_read32(cr4, ARMCR4_CAP);
@@ -695,7 +697,12 @@ static u32 brcmf_chip_tcm_ramsize(struct brcmf_core_priv *cr4)
695697
for (idx = 0; idx < totb; idx++) {
696698
brcmf_chip_core_write32(cr4, ARMCR4_BANKIDX, idx);
697699
bxinfo = brcmf_chip_core_read32(cr4, ARMCR4_BANKINFO);
698-
memsize += ((bxinfo & ARMCR4_BSZ_MASK) + 1) * ARMCR4_BSZ_MULT;
700+
if (bxinfo & ARMCR4_BLK_1K_MASK)
701+
blksize = 1024;
702+
else
703+
blksize = 8192;
704+
705+
memsize += ((bxinfo & ARMCR4_BSZ_MASK) + 1) * blksize;
699706
}
700707

701708
return memsize;
@@ -754,7 +761,7 @@ int brcmf_chip_get_raminfo(struct brcmf_chip *pub)
754761
mem = brcmf_chip_get_core(&ci->pub, BCMA_CORE_ARM_CR4);
755762
if (mem) {
756763
mem_core = container_of(mem, struct brcmf_core_priv, pub);
757-
ci->pub.ramsize = brcmf_chip_tcm_ramsize(mem_core);
764+
ci->pub.ramsize = brcmf_chip_tcm_ramsize(ci, mem_core);
758765
ci->pub.rambase = brcmf_chip_tcm_rambase(ci);
759766
if (ci->pub.rambase == INVALID_RAMBASE) {
760767
brcmf_err("RAM base not provided with ARM CR4 core\n");

0 commit comments

Comments
 (0)