git: e81e724358e4 - main - asmc: output the SMC firmware revision on attach
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 01 Mar 2026 19:03:47 UTC
The branch main has been updated by ngie:
URL: https://cgit.FreeBSD.org/src/commit/?id=e81e724358e43dcf951e244a9df9df3eaa983fe9
commit e81e724358e43dcf951e244a9df9df3eaa983fe9
Author: Enji Cooper <ngie@FreeBSD.org>
AuthorDate: 2026-03-01 18:54:56 +0000
Commit: Enji Cooper <ngie@FreeBSD.org>
CommitDate: 2026-03-01 19:03:38 +0000
asmc: output the SMC firmware revision on attach
The SMC firmware revision can prove helpful when determining why the
behavior of a given controller varies from the maintainers' expected
behavior.
This should be a sysctl (eventually), but for now dumping out the
information via `device_printf(..)` suffices, given that only one
asmc(4) compatible device can exist in an Apple platform at any
given point in time. This will become a sysctl in the future after
additional improvements are incorporated from OpenBSD and NetBSD.
MFC after: 1 week
Obtained from: https://github.com/openbsd/src/ (sys/dev/acpi/asmc.c @ 142d064)
Differential Revision: https://reviews.freebsd.org/D55577
---
sys/dev/asmc/asmc.c | 11 +++++++++--
sys/dev/asmc/asmcvar.h | 3 +++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c
index cf977071cc69..726d52874026 100644
--- a/sys/dev/asmc/asmc.c
+++ b/sys/dev/asmc/asmc.c
@@ -51,6 +51,7 @@
#include <sys/rman.h>
#include <machine/resource.h>
+#include <netinet/in.h>
#include <contrib/dev/acpica/include/acpi.h>
@@ -935,11 +936,17 @@ asmc_init(device_t dev)
{
struct asmc_softc *sc = device_get_softc(dev);
struct sysctl_ctx_list *sysctlctx;
+ uint8_t buf[6];
int i, error = 1;
- uint8_t buf[4];
sysctlctx = device_get_sysctl_ctx(dev);
+ error = asmc_key_read(dev, ASMC_KEY_REV, buf, 6);
+ if (error != 0)
+ goto out_err;
+ device_printf(dev, "SMC revision: %x.%x%x%x\n", buf[0], buf[1], buf[2],
+ ntohs(*(uint16_t *)buf + 4));
+
if (sc->sc_model->smc_sms_x == NULL)
goto nosms;
@@ -1039,10 +1046,10 @@ nosms:
sc->sc_nkeys = 0;
}
+out_err:
#ifdef ASMC_DEBUG
asmc_dumpall(dev);
#endif
-
return (error);
}
diff --git a/sys/dev/asmc/asmcvar.h b/sys/dev/asmc/asmcvar.h
index 97e5076455c9..5afc1012849c 100644
--- a/sys/dev/asmc/asmcvar.h
+++ b/sys/dev/asmc/asmcvar.h
@@ -78,6 +78,9 @@ struct asmc_softc {
/* Number of keys */
#define ASMC_NKEYS "#KEY" /* RO; 4 bytes */
+/* Query the ASMC revision */
+#define ASMC_KEY_REV "REV " /* RO: 6 bytes */
+
/*
* Fan control via SMC.
*/