Module Name:    src
Committed By:   jakllsch
Date:           Sat Aug 20 20:01:09 UTC 2011

Modified Files:
        src/sys/arch/x86/pci: pchb.c pchbvar.h

Log Message:
Add rescan support for 'amdtempbus' to x86 pchb(4).
Maybe finally fixes PR#45268.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/x86/pci/pchb.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x86/pci/pchbvar.h

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/pchb.c
diff -u src/sys/arch/x86/pci/pchb.c:1.31 src/sys/arch/x86/pci/pchb.c:1.32
--- src/sys/arch/x86/pci/pchb.c:1.31	Sat Aug 20 19:56:31 2011
+++ src/sys/arch/x86/pci/pchb.c	Sat Aug 20 20:01:08 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pchb.c,v 1.31 2011/08/20 19:56:31 jakllsch Exp $ */
+/*	$NetBSD: pchb.c,v 1.32 2011/08/20 20:01:08 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 1996, 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.31 2011/08/20 19:56:31 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.32 2011/08/20 20:01:08 jakllsch Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -72,12 +72,16 @@
 static int	pchbmatch(device_t, cfdata_t, void *);
 static void	pchbattach(device_t, device_t, void *);
 static int	pchbdetach(device_t, int);
+static int	pchbrescan(device_t, const char *, const int *);
+static void	pchbchilddet(device_t, device_t);
 
 static bool	pchb_resume(device_t, const pmf_qual_t *);
 static bool	pchb_suspend(device_t, const pmf_qual_t *);
 
+static void	pchb_amdtempbus_configure(struct pchb_softc *);
+
 CFATTACH_DECL3_NEW(pchb, sizeof(struct pchb_softc),
-    pchbmatch, pchbattach, pchbdetach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN);
+    pchbmatch, pchbattach, pchbdetach, NULL, pchbrescan, pchbchilddet, DVF_DETACH_SHUTDOWN);
 
 static int
 pchbmatch(device_t parent, cfdata_t match, void *aux)
@@ -166,8 +170,7 @@
 	attachflags = pa->pa_flags;
 
 	sc->sc_dev = self;
-	sc->sc_pc = pa->pa_pc;
-	sc->sc_tag = pa->pa_tag;
+	sc->sc_pa = *pa;
 
 	/*
 	 * Print out a description, and configure certain chipsets which
@@ -440,7 +443,7 @@
 		config_found_ia(self, "pcibus", &pba, pcibusprint);
 	}
 
-	config_found_ia(self, "amdtempbus", aux, NULL);
+	pchb_amdtempbus_configure(sc);
 }
 
 static int
@@ -456,6 +459,28 @@
 	return 0;
 }
 
+static int
+pchbrescan(device_t self, const char *ifattr, const int *locators)
+{
+	struct pchb_softc *sc = device_private(self);
+
+	if (ifattr_match(ifattr, "amdtempbus"))
+		pchb_amdtempbus_configure(sc);
+
+	return 0;
+}
+
+static void
+pchbchilddet(device_t self, device_t child)
+{
+	struct pchb_softc *sc = device_private(self);
+
+	if (sc->sc_amdtempbus == child) {
+		sc->sc_amdtempbus = NULL;
+		return;
+	}
+}
+
 static bool
 pchb_suspend(device_t dv, const pmf_qual_t *qual)
 {
@@ -464,8 +489,8 @@
 	pcitag_t tag;
 	int off;
 
-	pc = sc->sc_pc;
-	tag = sc->sc_tag;
+	pc = sc->sc_pa.pa_pc;
+	tag = sc->sc_pa.pa_tag;
 
 	for (off = 0x40; off <= 0xff; off += 4)
 		sc->sc_pciconfext[(off - 0x40) / 4] = pci_conf_read(pc, tag, off);
@@ -481,11 +506,20 @@
 	pcitag_t tag;
 	int off;
 
-	pc = sc->sc_pc;
-	tag = sc->sc_tag;
+	pc = sc->sc_pa.pa_pc;
+	tag = sc->sc_pa.pa_tag;
 
 	for (off = 0x40; off <= 0xff; off += 4)
 		pci_conf_write(pc, tag, off, sc->sc_pciconfext[(off - 0x40) / 4]);
 
 	return true;
 }
+
+static void
+pchb_amdtempbus_configure(struct pchb_softc *sc)
+{
+	if (sc->sc_amdtempbus != NULL)
+		return;
+
+	sc->sc_amdtempbus = config_found_ia(sc->sc_dev, "amdtempbus", &sc->sc_pa, NULL);
+}

Index: src/sys/arch/x86/pci/pchbvar.h
diff -u src/sys/arch/x86/pci/pchbvar.h:1.7 src/sys/arch/x86/pci/pchbvar.h:1.8
--- src/sys/arch/x86/pci/pchbvar.h:1.7	Fri Jul 23 02:23:58 2010
+++ src/sys/arch/x86/pci/pchbvar.h	Sat Aug 20 20:01:08 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pchbvar.h,v 1.7 2010/07/23 02:23:58 jakllsch Exp $	*/
+/*	$NetBSD: pchbvar.h,v 1.8 2011/08/20 20:01:08 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -34,9 +34,9 @@
 
 struct pchb_softc {
 	device_t sc_dev;
+	device_t sc_amdtempbus;
 
-	pci_chipset_tag_t sc_pc;
-	pcitag_t sc_tag;
+	struct pci_attach_args sc_pa;
 
 	pcireg_t sc_pciconfext[48];
 };

Reply via email to