From owner-p4-projects@FreeBSD.ORG Wed Jun 9 09:20:32 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6582F16A4D1; Wed, 9 Jun 2004 09:20:32 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3B68316A4CE for ; Wed, 9 Jun 2004 09:20:32 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 207EC43D39 for ; Wed, 9 Jun 2004 09:20:32 +0000 (GMT) (envelope-from jmallett@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i599KVZM063807 for ; Wed, 9 Jun 2004 09:20:31 GMT (envelope-from jmallett@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i599KVCb063804 for perforce@freebsd.org; Wed, 9 Jun 2004 09:20:31 GMT (envelope-from jmallett@freebsd.org) Date: Wed, 9 Jun 2004 09:20:31 GMT Message-Id: <200406090920.i599KVCb063804@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jmallett@freebsd.org using -f From: Juli Mallett To: Perforce Change Reviews Subject: PERFORCE change 54459 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2004 09:20:33 -0000 http://perforce.freebsd.org/chv.cgi?CH=54459 Change 54459 by jmallett@jmallett_oingo on 2004/06/09 09:19:32 Change how children are attached and stuff... Learn the lesson that you have to go through bus_generic_attach or do the probe_and_attach on children yourself! Affected files ... .. //depot/projects/mips/sys/mips/sgimips/imc/imc.c#5 edit Differences ... ==== //depot/projects/mips/sys/mips/sgimips/imc/imc.c#5 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $P4: //depot/projects/mips/sys/mips/sgimips/imc/imc.c#4 $ + * $P4: //depot/projects/mips/sys/mips/sgimips/imc/imc.c#5 $ */ #include @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -64,36 +65,51 @@ "imc", imc_methods, 1 }; +static const char *imc_devices[] = { + "gio", + NULL +}; + +static const u_long imc_port = 0x1fa00000; /* XXX hints */ + +#define IMC_READ_4(port, r) \ + bus_space_read_4(device_space_tag, (port), (r)) + +#define IMC_WRITE_4(port, r, v) \ + bus_space_write_4(device_space_tag, (port), (r), (v)) + static int imc_probe(device_t dev) { + const char **namep; + + if (device_get_unit(dev) != 0) + return (ENXIO); + switch (mach_type) { case MACH_SGI_IP22: + device_set_desc(dev, "IMC Bus"); + for (namep = imc_devices; *namep != NULL; namep++) + device_add_child(dev, *namep, -1); return (0); default: return (ENOENT); } } -#define IMC_READ_4(port, r) \ - (*(volatile uint32_t *)(MIPS_PHYS_TO_KSEG1(port) | r)) - -#define IMC_WRITE_4(port, r, v) \ - ((*(volatile uint32_t *)(MIPS_PHYS_TO_KSEG1(port) | r)) = (v)) - static int imc_attach(device_t dev) { - const u_long port = 0x1fa00000; /* XXX hints */ + uint32_t reg; uint32_t sysid; - uint32_t reg; - sysid = IMC_READ_4(port, IMC_SYSID); - device_printf(dev, "revision %d, EISA %s\n", sysid & IMC_SYSID_REVMASK, sysid & IMC_SYSID_HAVEISA ? "present" : "not present"); + sysid = IMC_READ_4(imc_port, IMC_SYSID); + device_printf(dev, "revision %d, EISA %s\n", sysid & IMC_SYSID_REVMASK, + sysid & IMC_SYSID_HAVEISA ? "present" : "not present"); /* Clear error status. */ - IMC_WRITE_4(port, IMC_CPU_ERRSTAT, 0); - IMC_WRITE_4(port, IMC_GIO_ERRSTAT, 0); + IMC_WRITE_4(imc_port, IMC_CPU_ERRSTAT, 0); + IMC_WRITE_4(imc_port, IMC_GIO_ERRSTAT, 0); /* * Enable parity reporting on GIO/main memory transactions. @@ -103,15 +119,15 @@ * has the opposite sense... Turning it on turns the checks off!). * Finally, turn on interrupt writes to the CPU from the MC. */ - reg = IMC_READ_4(port, IMC_CPUCTRL0); + reg = IMC_READ_4(imc_port, IMC_CPUCTRL0); reg &= ~IMC_CPUCTRL0_NCHKMEMPAR; reg |= (IMC_CPUCTRL0_GPR | IMC_CPUCTRL0_MPR | IMC_CPUCTRL0_INTENA); - IMC_WRITE_4(port, IMC_CPUCTRL0, reg); + IMC_WRITE_4(imc_port, IMC_CPUCTRL0, reg); /* Setup the MC write buffer depth */ - reg = IMC_READ_4(port, IMC_CPUCTRL1); + reg = IMC_READ_4(imc_port, IMC_CPUCTRL1); reg = (reg & ~IMC_CPUCTRL1_MCHWMSK) | 13; - IMC_WRITE_4(port, IMC_CPUCTRL1, reg); + IMC_WRITE_4(imc_port, IMC_CPUCTRL1, reg); /* * Set GIO64 arbitrator configuration register: @@ -120,7 +136,7 @@ * on the graphics variant present and I'm not sure how to figure * that out or 100% sure what the correct settings are for each. */ - reg = IMC_READ_4(port, IMC_GIO64ARB); + reg = IMC_READ_4(imc_port, IMC_GIO64ARB); reg &= (IMC_GIO64ARB_GRX64 | IMC_GIO64ARB_GRXRT | IMC_GIO64ARB_GRXMST); /* GIO64 invariant for all IP22 platforms: one GIO bus, HPC1 @ 64 */ @@ -149,9 +165,9 @@ } break; } - IMC_WRITE_4(port, IMC_GIO64ARB, reg); + IMC_WRITE_4(imc_port, IMC_GIO64ARB, reg); - device_add_child(dev, "gio", 0); + bus_generic_attach(dev); return (0); }