Module Name: src
Committed By: martin
Date: Tue Aug 6 16:05:11 UTC 2019
Modified Files:
src/sys/arch/x86/pci [netbsd-8]: amdsmn.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1328):
sys/arch/x86/pci/amdsmn.c: revision 1.4
sys/arch/x86/pci/amdsmn.c: revision 1.5
sys/arch/x86/pci/amdsmn.c: revision 1.6
Add support for Ryzen 2xxx and 3xxx.
Use unsigned to fix compile error on i386.
Whitespace fix.
To generate a diff of this commit:
cvs rdiff -u -r1.3.2.3 -r1.3.2.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.2.3 src/sys/arch/x86/pci/amdsmn.c:1.3.2.4
--- src/sys/arch/x86/pci/amdsmn.c:1.3.2.3 Tue Feb 6 09:05:27 2018
+++ src/sys/arch/x86/pci/amdsmn.c Tue Aug 6 16:05:11 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: amdsmn.c,v 1.3.2.3 2018/02/06 09:05:27 martin Exp $ */
+/* $NetBSD: amdsmn.c,v 1.3.2.4 2019/08/06 16:05:11 martin Exp $ */
/*-
* Copyright (c) 2017 Conrad Meyer <[email protected]>
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.3.2.3 2018/02/06 09:05:27 martin Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.3.2.4 2019/08/06 16:05:11 martin 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 *);
@@ -71,17 +78,25 @@ static int amdsmn_misc_search(device_t,
CFATTACH_DECL3_NEW(amdsmn, sizeof(struct amdsmn_softc), amdsmn_match,
amdsmn_attach, amdsmn_detach, NULL, amdsmn_rescan, NULL, 0);
-
+
static int
-amdsmn_match(device_t parent, cfdata_t match, void *aux)
+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;
+ unsigned 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
-amdsmn_misc_search(device_t parent, cfdata_t cf, const int *locs, void *aux)
+static int
+amdsmn_misc_search(device_t parent, cfdata_t cf, const int *locs, void *aux)
{
if (config_match(parent, cf, aux))
config_attach_loc(parent, cf, locs, aux, NULL);
@@ -89,8 +104,8 @@ amdsmn_misc_search(device_t parent, cfda
return 0;
}
-static void
-amdsmn_attach(device_t parent, device_t self, void *aux)
+static void
+amdsmn_attach(device_t parent, device_t self, void *aux)
{
struct amdsmn_softc *sc = device_private(self);
struct pci_attach_args *pa = aux;
@@ -115,7 +130,7 @@ amdsmn_rescan(device_t self, const char
}
static int
-amdsmn_detach(device_t self, int flags)
+amdsmn_detach(device_t self, int flags)
{
struct amdsmn_softc *sc = device_private(self);