Handle trailing odd-sized 1024 byte blocks when calculating TCM RAM size.
authorpatrick <patrick@openbsd.org>
Mon, 27 Dec 2021 10:59:20 +0000 (10:59 +0000)
committerpatrick <patrick@openbsd.org>
Mon, 27 Dec 2021 10:59:20 +0000 (10:59 +0000)
sys/dev/ic/bwfm.c
sys/dev/ic/bwfmreg.h

index e9ccba4..1087892 100644 (file)
@@ -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 <patrick@blueri.se>
@@ -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;
index 4bfbc29..0f728a0 100644 (file)
@@ -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 <patrick@blueri.se>
@@ -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 */