From ea6189d3a470ce9ffb19335f915eab6af0cfef57 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Sat, 12 Dec 2020 19:34:12 +0000 Subject: [PATCH] amdsmn(4), amdtemp(4): add support for Family 19h (Zen 3) Zen 3 "Vermeer" support, tested on Ryzen 9 5950X. Model numbers from https://en.wikichip.org/wiki/amd/cpuid "Extended Model" column. Submitted by: Greg V Differential Revision: https://reviews.freebsd.org/D27552 --- sys/dev/amdsmn/amdsmn.c | 3 +- sys/dev/amdtemp/amdtemp.c | 69 +++++++++++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 19 deletions(-) diff --git a/sys/dev/amdsmn/amdsmn.c b/sys/dev/amdsmn/amdsmn.c index ebc45256d14d..e83219b02705 100644 --- a/sys/dev/amdsmn/amdsmn.c +++ b/sys/dev/amdsmn/amdsmn.c @@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$"); #define PCI_DEVICE_ID_AMD_15H_M60H_ROOT 0x1576 #define PCI_DEVICE_ID_AMD_17H_ROOT 0x1450 #define PCI_DEVICE_ID_AMD_17H_M10H_ROOT 0x15d0 -#define PCI_DEVICE_ID_AMD_17H_M30H_ROOT 0x1480 /* Also M70H. */ +#define PCI_DEVICE_ID_AMD_17H_M30H_ROOT 0x1480 /* Also M70H, F19H M00H/M20H */ #define PCI_DEVICE_ID_AMD_17H_M60H_ROOT 0x1630 struct pciid; @@ -187,6 +187,7 @@ amdsmn_probe(device_t dev) switch (family) { case 0x15: case 0x17: + case 0x19: break; default: return (ENXIO); diff --git a/sys/dev/amdtemp/amdtemp.c b/sys/dev/amdtemp/amdtemp.c index 466f512ab18e..764db4e95b98 100644 --- a/sys/dev/amdtemp/amdtemp.c +++ b/sys/dev/amdtemp/amdtemp.c @@ -106,7 +106,7 @@ struct amdtemp_softc { #define DEVICEID_AMD_MISC16_M30H 0x1583 #define DEVICEID_AMD_HOSTB17H_ROOT 0x1450 #define DEVICEID_AMD_HOSTB17H_M10H_ROOT 0x15d0 -#define DEVICEID_AMD_HOSTB17H_M30H_ROOT 0x1480 /* Also M70h. */ +#define DEVICEID_AMD_HOSTB17H_M30H_ROOT 0x1480 /* Also M70H, F19H M00H/M20H */ #define DEVICEID_AMD_HOSTB17H_M60H_ROOT 0x1630 static const struct amdtemp_product { @@ -207,6 +207,7 @@ static int32_t amdtemp_gettemp(device_t dev, amdsensor_t sensor); static int32_t amdtemp_gettemp15hm60h(device_t dev, amdsensor_t sensor); static int32_t amdtemp_gettemp17h(device_t dev, amdsensor_t sensor); static void amdtemp_probe_ccd_sensors17h(device_t dev, uint32_t model); +static void amdtemp_probe_ccd_sensors19h(device_t dev, uint32_t model); static int amdtemp_sysctl(SYSCTL_HANDLER_ARGS); static device_method_t amdtemp_methods[] = { @@ -294,6 +295,7 @@ amdtemp_probe(device_t dev) case 0x15: case 0x16: case 0x17: + case 0x19: break; default: return (ENXIO); @@ -451,6 +453,7 @@ amdtemp_attach(device_t dev) sc->sc_gettemp = amdtemp_gettemp; break; case 0x17: + case 0x19: sc->sc_ntemps = 1; sc->sc_gettemp = amdtemp_gettemp17h; needsmn = true; @@ -509,6 +512,8 @@ amdtemp_attach(device_t dev) if (family == 0x17) amdtemp_probe_ccd_sensors17h(dev, model); + else if (family == 0x19) + amdtemp_probe_ccd_sensors19h(dev, model); else if (sc->sc_ntemps > 1) { SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(sysctlnode), @@ -773,28 +778,13 @@ amdtemp_gettemp17h(device_t dev, amdsensor_t sensor) } static void -amdtemp_probe_ccd_sensors17h(device_t dev, uint32_t model) +amdtemp_probe_ccd_sensors(device_t dev, uint32_t maxreg) { char sensor_name[16], sensor_descr[32]; struct amdtemp_softc *sc; - uint32_t maxreg, i, val; + uint32_t i, val; int error; - switch (model) { - case 0x00 ... 0x1f: /* Zen1, Zen+ */ - maxreg = 4; - break; - case 0x30 ... 0x3f: /* Zen2 TR/Epyc */ - case 0x70 ... 0x7f: /* Zen2 Ryzen */ - maxreg = 8; - _Static_assert((int)NUM_CCDS >= 8, ""); - break; - default: - device_printf(dev, - "Unrecognized Family 17h Model: %02xh\n", model); - return; - } - sc = device_get_softc(dev); for (i = 0; i < maxreg; i++) { error = amdsmn_read(sc->sc_smn, AMDTEMP_17H_CCD_TMP_BASE + @@ -814,3 +804,46 @@ amdtemp_probe_ccd_sensors17h(device_t dev, uint32_t model) dev, CCD_BASE + i, amdtemp_sysctl, "IK", sensor_descr); } } + +static void +amdtemp_probe_ccd_sensors17h(device_t dev, uint32_t model) +{ + uint32_t maxreg; + + switch (model) { + case 0x00 ... 0x1f: /* Zen1, Zen+ */ + maxreg = 4; + break; + case 0x30 ... 0x3f: /* Zen2 TR/EPYC */ + case 0x70 ... 0x7f: /* Zen2 Ryzen */ + maxreg = 8; + _Static_assert((int)NUM_CCDS >= 8, ""); + break; + default: + device_printf(dev, + "Unrecognized Family 17h Model: %02xh\n", model); + return; + } + + amdtemp_probe_ccd_sensors(dev, maxreg); +} + +static void +amdtemp_probe_ccd_sensors19h(device_t dev, uint32_t model) +{ + uint32_t maxreg; + + switch (model) { + case 0x00 ... 0x0f: /* Zen3 EPYC "Milan" */ + case 0x20 ... 0x2f: /* Zen3 Ryzen "Vermeer" */ + maxreg = 8; + _Static_assert((int)NUM_CCDS >= 8, ""); + break; + default: + device_printf(dev, + "Unrecognized Family 19h Model: %02xh\n", model); + return; + } + + amdtemp_probe_ccd_sensors(dev, maxreg); +}