Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86/pci Add rescan support for 'amdtempbus' to x86 ...



details:   https://anonhg.NetBSD.org/src/rev/fcf54819e89f
branches:  trunk
changeset: 768565:fcf54819e89f
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Sat Aug 20 20:01:08 2011 +0000

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

diffstat:

 sys/arch/x86/pci/pchb.c    |  54 +++++++++++++++++++++++++++++++++++++--------
 sys/arch/x86/pci/pchbvar.h |   6 ++--
 2 files changed, 47 insertions(+), 13 deletions(-)

diffs (139 lines):

diff -r a9062ba65651 -r fcf54819e89f sys/arch/x86/pci/pchb.c
--- a/sys/arch/x86/pci/pchb.c   Sat Aug 20 19:56:31 2011 +0000
+++ b/sys/arch/x86/pci/pchb.c   Sat Aug 20 20:01:08 2011 +0000
@@ -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);
+}
diff -r a9062ba65651 -r fcf54819e89f sys/arch/x86/pci/pchbvar.h
--- a/sys/arch/x86/pci/pchbvar.h        Sat Aug 20 19:56:31 2011 +0000
+++ b/sys/arch/x86/pci/pchbvar.h        Sat Aug 20 20:01:08 2011 +0000
@@ -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];
 };



Home | Main Index | Thread Index | Old Index