From 4e9dcb19d33fa7f2f2945926a960d1f5f76dec6c Mon Sep 17 00:00:00 2001 From: kettenis Date: Sun, 1 Oct 2023 08:56:24 +0000 Subject: [PATCH] Print the correct SDHC spec version. ok deraadt@ --- sys/dev/sdmmc/sdhc.c | 19 ++++++++++++++++--- sys/dev/sdmmc/sdhcreg.h | 4 +++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/sys/dev/sdmmc/sdhc.c b/sys/dev/sdmmc/sdhc.c index 2f3a6f4bce7..eb0a8e5374b 100644 --- a/sys/dev/sdmmc/sdhc.c +++ b/sys/dev/sdmmc/sdhc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sdhc.c,v 1.75 2023/04/19 02:01:02 dlg Exp $ */ +/* $OpenBSD: sdhc.c,v 1.76 2023/10/01 08:56:24 kettenis Exp $ */ /* * Copyright (c) 2006 Uwe Stuehler @@ -244,6 +244,7 @@ sdhc_host_found(struct sdhc_softc *sc, bus_space_tag_t iot, struct sdmmcbus_attach_args saa; struct sdhc_host *hp; uint32_t caps; + int major, minor; int error = 1; int max_clock; @@ -310,8 +311,20 @@ sdhc_host_found(struct sdhc_softc *sc, bus_space_tag_t iot, goto err; } - printf("%s: SDHC %d.0, %d MHz base clock\n", DEVNAME(sc), - SDHC_SPEC_VERSION(hp->version) + 1, hp->clkbase / 1000); + switch (SDHC_SPEC_VERSION(hp->version)) { + case SDHC_SPEC_VERS_4_10: + major = 4, minor = 10; + break; + case SDHC_SPEC_VERS_4_20: + major = 4, minor = 20; + break; + default: + major = SDHC_SPEC_VERSION(hp->version) + 1, minor = 0; + break; + } + + printf("%s: SDHC %d.%02d, %d MHz base clock\n", DEVNAME(sc), + major, minor, hp->clkbase / 1000); /* * XXX Set the data timeout counter value according to diff --git a/sys/dev/sdmmc/sdhcreg.h b/sys/dev/sdmmc/sdhcreg.h index 9a891688695..8f98a6295d4 100644 --- a/sys/dev/sdmmc/sdhcreg.h +++ b/sys/dev/sdmmc/sdhcreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sdhcreg.h,v 1.9 2018/09/06 10:15:17 patrick Exp $ */ +/* $OpenBSD: sdhcreg.h,v 1.10 2023/10/01 08:56:24 kettenis Exp $ */ /* * Copyright (c) 2006 Uwe Stuehler @@ -201,6 +201,8 @@ #define SDHC_HOST_CTL_VERSION 0xfe #define SDHC_SPEC_VERS_SHIFT 0 #define SDHC_SPEC_VERS_MASK 0xff +#define SDHC_SPEC_VERS_4_10 0x04 +#define SDHC_SPEC_VERS_4_20 0x05 #define SDHC_VENDOR_VERS_SHIFT 8 #define SDHC_VENDOR_VERS_MASK 0xff #define SDHC_SPEC_V1 0 -- 2.20.1