From 5ea0cc518644111bf853959969f2e1ed199520ef Mon Sep 17 00:00:00 2001 From: patrick Date: Mon, 27 Dec 2021 10:59:20 +0000 Subject: [PATCH] Handle trailing odd-sized 1024 byte blocks when calculating TCM RAM size. --- sys/dev/ic/bwfm.c | 10 +++++++--- sys/dev/ic/bwfmreg.h | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/dev/ic/bwfm.c b/sys/dev/ic/bwfm.c index e9ccba46005..1087892bfb1 100644 --- a/sys/dev/ic/bwfm.c +++ b/sys/dev/ic/bwfm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bwfm.c,v 1.93 2021/12/26 20:50:17 patrick Exp $ */ +/* $OpenBSD: bwfm.c,v 1.94 2021/12/27 10:59:20 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation * Copyright (c) 2016,2017 Patrick Wildt @@ -1526,7 +1526,7 @@ bwfm_chip_sysmem_ramsize(struct bwfm_softc *sc, struct bwfm_core *core) void bwfm_chip_tcm_ramsize(struct bwfm_softc *sc, struct bwfm_core *core) { - uint32_t cap, nab, nbb, totb, bxinfo, ramsize = 0; + uint32_t cap, nab, nbb, totb, bxinfo, blksize, ramsize = 0; int i; cap = sc->sc_buscore_ops->bc_read(sc, core->co_base + BWFM_ARMCR4_CAP); @@ -1539,8 +1539,12 @@ bwfm_chip_tcm_ramsize(struct bwfm_softc *sc, struct bwfm_core *core) core->co_base + BWFM_ARMCR4_BANKIDX, i); bxinfo = sc->sc_buscore_ops->bc_read(sc, core->co_base + BWFM_ARMCR4_BANKINFO); + if (bxinfo & BWFM_ARMCR4_BANKINFO_BLK_1K_MASK) + blksize = 1024; + else + blksize = 8192; ramsize += ((bxinfo & BWFM_ARMCR4_BANKINFO_BSZ_MASK) + 1) * - BWFM_ARMCR4_BANKINFO_BSZ_MULT; + blksize; } sc->sc_chip.ch_ramsize = ramsize; diff --git a/sys/dev/ic/bwfmreg.h b/sys/dev/ic/bwfmreg.h index 4bfbc298ee6..0f728a06c0a 100644 --- a/sys/dev/ic/bwfmreg.h +++ b/sys/dev/ic/bwfmreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bwfmreg.h,v 1.22 2021/12/26 20:50:17 patrick Exp $ */ +/* $OpenBSD: bwfmreg.h,v 1.23 2021/12/27 10:59:20 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation * Copyright (c) 2016,2017 Patrick Wildt @@ -87,8 +87,8 @@ #define BWFM_ARMCR4_CAP_TCBBNB_SHIFT 4 #define BWFM_ARMCR4_BANKIDX 0x0040 #define BWFM_ARMCR4_BANKINFO 0x0044 -#define BWFM_ARMCR4_BANKINFO_BSZ_MASK 0x3f -#define BWFM_ARMCR4_BANKINFO_BSZ_MULT 8192 +#define BWFM_ARMCR4_BANKINFO_BSZ_MASK 0x7f +#define BWFM_ARMCR4_BANKINFO_BLK_1K_MASK 0x200 #define BWFM_ARMCR4_BANKPDA 0x004C /* GCI (OTP) registers */ -- 2.20.1