Module Name:    src
Committed By:   msaitoh
Date:           Thu Jul 18 08:53:41 UTC 2019

Modified Files:
        src/sys/arch/x86/pci: amdsmn.c

Log Message:
 Add support for Ryzen 2xxx and 3xxx.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/pci/amdsmn.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdsmn.c
diff -u src/sys/arch/x86/pci/amdsmn.c:1.3 src/sys/arch/x86/pci/amdsmn.c:1.4
--- src/sys/arch/x86/pci/amdsmn.c:1.3	Sat Jan 27 21:24:30 2018
+++ src/sys/arch/x86/pci/amdsmn.c	Thu Jul 18 08:53:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdsmn.c,v 1.3 2018/01/27 21:24:30 kardel Exp $	*/
+/*	$NetBSD: amdsmn.c,v 1.4 2019/07/18 08:53:41 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2017 Conrad Meyer <c...@freebsd.org>
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.3 2018/01/27 21:24:30 kardel Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.4 2019/07/18 08:53:41 msaitoh Exp $ ");
 
 /*
  * Driver for the AMD Family 17h CPU System Management Network.
@@ -54,7 +54,6 @@ __KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1
 
 #define	SMN_ADDR_REG	0x60
 #define	SMN_DATA_REG	0x64
-#define	AMD_17H_MANAGEMENT_NETWORK_PCI_ID	0x14501022
 
 struct amdsmn_softc {
 	kmutex_t smn_lock;
@@ -63,6 +62,14 @@ struct amdsmn_softc {
 	pcitag_t pcitag;
 };
 
+static const struct pciid {
+	uint16_t	amdsmn_deviceid;
+} amdsmn_ids[] = {
+	{ PCI_PRODUCT_AMD_F17_RC },
+	{ PCI_PRODUCT_AMD_F17_1X_RC },
+	{ PCI_PRODUCT_AMD_F17_7X_RC },
+};
+
 static int amdsmn_match(device_t, cfdata_t, void *);
 static void amdsmn_attach(device_t, device_t, void *);
 static int amdsmn_rescan(device_t, const char *, const int *);
@@ -76,8 +83,16 @@ static int
 amdsmn_match(device_t parent, cfdata_t match, void *aux) 
 {
 	struct pci_attach_args *pa = aux;
-	
-	return pa->pa_id == AMD_17H_MANAGEMENT_NETWORK_PCI_ID ? 2 : 0;
+	int i;
+
+	if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_AMD)
+		return 0;
+
+	for (i = 0; i <  __arraycount(amdsmn_ids); i++)
+		if (PCI_PRODUCT(pa->pa_id) == amdsmn_ids[i].amdsmn_deviceid)
+			return 2;
+
+	return 0;
 }
 
 static int 

Reply via email to