-/* $OpenBSD: ufshci.c,v 1.26 2024/05/20 12:42:45 mglocker Exp $ */
+/* $OpenBSD: ufshci.c,v 1.27 2024/05/20 20:08:04 mglocker Exp $ */
/*
* Copyright (c) 2022 Marcus Glocker <mglocker@openbsd.org>
DPRINTF(1, " BI=0x%04x\n", UFSHCI_REG_HCMID_BI(sc->sc_hcmid));
DPRINTF(1, " MIC=0x%04x\n", UFSHCI_REG_HCMID_MIC(sc->sc_hcmid));
- if (sc->sc_nutrs > 32) {
- printf("%s: NUTRS can't be >32 (is %d)!\n",
- sc->sc_dev.dv_xname, sc->sc_nutrs);
+ if (sc->sc_nutrs < UFSHCI_SLOTS_MIN ||
+ sc->sc_nutrs > UFSHCI_SLOTS_MAX) {
+ printf("%s: Invalid NUTRS value %d (must be %d-%d)!\n",
+ sc->sc_dev.dv_xname, sc->sc_nutrs,
+ UFSHCI_SLOTS_MIN, UFSHCI_SLOTS_MAX);
return 1;
- } else if (sc->sc_nutrs == 1) {
- sc->sc_iacth = sc->sc_nutrs;
- } else if (sc->sc_nutrs > 1) {
- sc->sc_iacth = sc->sc_nutrs - 1;
}
+ if (sc->sc_nutrs == UFSHCI_SLOTS_MAX)
+ sc->sc_iacth = UFSHCI_INTR_AGGR_COUNT_MAX;
+ else
+ sc->sc_iacth = sc->sc_nutrs;
DPRINTF(1, "Intr. aggr. counter threshold:\nIACTH=%d\n", sc->sc_iacth);
/*
-/* $OpenBSD: ufshcireg.h,v 1.9 2024/05/16 10:52:11 mglocker Exp $ */
+/* $OpenBSD: ufshcireg.h,v 1.10 2024/05/20 20:08:04 mglocker Exp $ */
/*
* Copyright (c) 2022 Marcus Glocker <mglocker@openbsd.org>
#define UFSHCI_UCD_PRDT_MAX_SEGS 64
#define UFSHCI_UCD_PRDT_MAX_XFER (UFSHCI_UCD_PRDT_MAX_SEGS * PAGE_SIZE)
#define UFSHCI_INTR_AGGR_TIMEOUT 0x08 /* 320us (1 unit = 40us) */
-#define UFSHCI_MAX_UNITS 32
+#define UFSHCI_INTR_AGGR_COUNT_MAX 31
+#define UFSHCI_SLOTS_MIN 1
+#define UFSHCI_SLOTS_MAX 32
#define UFSHCI_LBS 4096 /* UFS Logical Block Size:
For UFS minimum size shall be
4096 bytes */