svn commit: r368586 - in head/sys/dev: amdsmn amdtemp

Conrad Meyer cem at FreeBSD.org
Sat Dec 12 19:34:13 UTC 2020


Author: cem
Date: Sat Dec 12 19:34:12 2020
New Revision: 368586
URL: https://svnweb.freebsd.org/changeset/base/368586

Log:
  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 <greg AT unrelenting.technology>
  Differential Revision:	https://reviews.freebsd.org/D27552

Modified:
  head/sys/dev/amdsmn/amdsmn.c
  head/sys/dev/amdtemp/amdtemp.c

Modified: head/sys/dev/amdsmn/amdsmn.c
==============================================================================
--- head/sys/dev/amdsmn/amdsmn.c	Sat Dec 12 18:34:15 2020	(r368585)
+++ head/sys/dev/amdsmn/amdsmn.c	Sat Dec 12 19:34:12 2020	(r368586)
@@ -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);

Modified: head/sys/dev/amdtemp/amdtemp.c
==============================================================================
--- head/sys/dev/amdtemp/amdtemp.c	Sat Dec 12 18:34:15 2020	(r368585)
+++ head/sys/dev/amdtemp/amdtemp.c	Sat Dec 12 19:34:12 2020	(r368586)
@@ -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
 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 +
@@ -813,4 +803,47 @@ amdtemp_probe_ccd_sensors17h(device_t dev, uint32_t mo
 		    sensor_name, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE,
 		    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);
 }


More information about the svn-src-head mailing list