Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Nov 2018 03:42:39 +0000 (UTC)
From:      Conrad Meyer <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r340425 - in head/sys/dev: amdsmn amdtemp
Message-ID:  <201811140342.wAE3gd87012897@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Wed Nov 14 03:42:39 2018
New Revision: 340425
URL: https://svnweb.freebsd.org/changeset/base/340425

Log:
  amdsmn(4)/amdtemp(4): Attach to Ryzen 2 hostbridges
  
  As reported, tested, and patch supplied by Johannes.
  
  There may be future work to do to support multiple sensors, but for now, any
  sensor at all is a strict improvement for Ryzen 2 systems.
  
  PR:		228480
  Submitted by:	Johannes Lundberg <johalun0 AT gmail.com> (earlier version)
  Reported by:	deischen@, Johannes, and numerous others
  MFC after:	3.72 days

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	Wed Nov 14 00:46:02 2018	(r340424)
+++ head/sys/dev/amdsmn/amdsmn.c	Wed Nov 14 03:42:39 2018	(r340425)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 
 #include <machine/cpufunc.h>
+#include <machine/cputypes.h>
 #include <machine/md_var.h>
 #include <machine/specialreg.h>
 
@@ -53,14 +54,21 @@ __FBSDID("$FreeBSD$");
 #define	SMN_ADDR_REG	0x60
 #define	SMN_DATA_REG	0x64
 
+#define	PCI_DEVICE_ID_AMD_17H_ROOT		0x1450
+#define	PCI_DEVICE_ID_AMD_17H_ROOT_DF_F3	0x1463
+#define	PCI_DEVICE_ID_AMD_17H_M10H_ROOT		0x15d0
+#define	PCI_DEVICE_ID_AMD_17H_M10H_ROOT_DF_F3	0x15eb
+
 struct amdsmn_softc {
 	struct mtx smn_lock;
 };
 
 static struct pciid {
-	uint32_t	device_id;
+	uint16_t	amdsmn_vendorid;
+	uint16_t	amdsmn_deviceid;
 } amdsmn_ids[] = {
-	{ 0x14501022 },
+	{ CPU_VENDOR_AMD, PCI_DEVICE_ID_AMD_17H_ROOT },
+	{ CPU_VENDOR_AMD, PCI_DEVICE_ID_AMD_17H_M10H_ROOT },
 };
 
 /*
@@ -89,18 +97,21 @@ static driver_t amdsmn_driver = {
 static devclass_t amdsmn_devclass;
 DRIVER_MODULE(amdsmn, hostb, amdsmn_driver, amdsmn_devclass, NULL, NULL);
 MODULE_VERSION(amdsmn, 1);
-MODULE_PNP_INFO("W32:vendor/device", pci, amdsmn, amdsmn_ids,
+MODULE_PNP_INFO("U16:vendor;U16:device", pci, amdsmn, amdsmn_ids,
     nitems(amdsmn_ids));
 
 static bool
 amdsmn_match(device_t parent)
 {
-	uint32_t devid;
+	uint16_t vendor, device;
 	size_t i;
 
-	devid = pci_get_devid(parent);
+	vendor = pci_get_vendor(parent);
+	device = pci_get_device(parent);
+
 	for (i = 0; i < nitems(amdsmn_ids); i++)
-		if (amdsmn_ids[i].device_id == devid)
+		if (vendor == amdsmn_ids[i].amdsmn_vendorid &&
+		    device == amdsmn_ids[i].amdsmn_deviceid)
 			return (true);
 	return (false);
 }

Modified: head/sys/dev/amdtemp/amdtemp.c
==============================================================================
--- head/sys/dev/amdtemp/amdtemp.c	Wed Nov 14 00:46:02 2018	(r340424)
+++ head/sys/dev/amdtemp/amdtemp.c	Wed Nov 14 03:42:39 2018	(r340425)
@@ -86,7 +86,10 @@ struct amdtemp_softc {
 #define	DEVICEID_AMD_MISC16	0x1533
 #define	DEVICEID_AMD_MISC16_M30H	0x1583
 #define	DEVICEID_AMD_MISC17	0x141d
-#define	DEVICEID_AMD_HOSTB17H	0x1450
+#define	DEVICEID_AMD_HOSTB17H_ROOT	0x1450
+#define	DEVICEID_AMD_HOSTB17H_DF_F3	0x1463
+#define	DEVICEID_AMD_HOSTB17H_M10H_ROOT	0x15d0
+#define	DEVICEID_AMD_HOSTB17H_M10H_DF_F3 0x15eb
 
 static struct amdtemp_product {
 	uint16_t	amdtemp_vendorid;
@@ -101,7 +104,8 @@ static struct amdtemp_product {
 	{ VENDORID_AMD,	DEVICEID_AMD_MISC16 },
 	{ VENDORID_AMD,	DEVICEID_AMD_MISC16_M30H },
 	{ VENDORID_AMD,	DEVICEID_AMD_MISC17 },
-	{ VENDORID_AMD,	DEVICEID_AMD_HOSTB17H },
+	{ VENDORID_AMD,	DEVICEID_AMD_HOSTB17H_ROOT },
+	{ VENDORID_AMD,	DEVICEID_AMD_HOSTB17H_M10H_ROOT },
 };
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811140342.wAE3gd87012897>