From owner-p4-projects@FreeBSD.ORG Wed May 9 22:02:29 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DB49916A408; Wed, 9 May 2007 22:02:28 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8C7B816A403 for ; Wed, 9 May 2007 22:02:28 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 7D7D213C465 for ; Wed, 9 May 2007 22:02:28 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l49M2SgT083233 for ; Wed, 9 May 2007 22:02:28 GMT (envelope-from bms@incunabulum.net) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l49M2SWJ083229 for perforce@freebsd.org; Wed, 9 May 2007 22:02:28 GMT (envelope-from bms@incunabulum.net) Date: Wed, 9 May 2007 22:02:28 GMT Message-Id: <200705092202.l49M2SWJ083229@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bms@incunabulum.net using -f From: Bruce M Simpson To: Perforce Change Reviews Cc: Subject: PERFORCE change 119602 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 May 2007 22:02:29 -0000 http://perforce.freebsd.org/chv.cgi?CH=119602 Change 119602 by bms@bms_anglepoise on 2007/05/09 22:02:18 Clean up bus enumeration slightly by moving the code which initializes the devinfo into siba_setup_devinfo(), and reading it from the currently mapped core. Affected files ... .. //depot/projects/mips2/src/sys/mips/mips32/sentry5/siba.c#6 edit Differences ... ==== //depot/projects/mips2/src/sys/mips/mips32/sentry5/siba.c#6 (text+ko) ==== @@ -96,7 +96,9 @@ siba_alloc_resource(device_t, device_t, int, int *, u_long, u_long, u_long, u_int); static int siba_attach(device_t); +#ifdef notyet static void siba_destroy_devinfo(struct siba_devinfo *); +#endif static struct siba_devid * siba_dev_match(uint16_t, uint16_t, uint8_t); static struct resource_list * @@ -285,68 +287,26 @@ { struct siba_softc *sc = device_get_softc(dev); struct siba_devinfo *sdi; - uint32_t idlo, idhi; - uint32_t rev; - uint16_t vendorid; - uint16_t ccid; - int idx; + device_t child; + int idx; if (siba_debug) printf("%s: entry\n", __func__); - bus_generic_probe(dev); /* XXX should this happen here ? */ + bus_generic_probe(dev); /* * Now that all bus space is mapped and visible to the CPU, * enumerate its children. - * Note that only one core may be mapped at any time if the siba - * bus is the child of a PCI or PCMCIA bus. + * NB: only one core may be mapped at any time if the siba bus + * is the child of a PCI or PCMCIA bus. */ for (idx = 0; idx < sc->sc_ncores; idx++) { - idlo = siba_read_4(sc, idx, SIBA_CORE_IDLO); - idhi = siba_read_4(sc, idx, SIBA_CORE_IDHI); - ccid = ((idhi & 0x8ff0) >> 4); - vendorid = (idhi & SSB_IDHIGH_VC) >> SSB_IDHIGH_VC_SHIFT; - rev = (idhi & SSB_IDHIGH_RCLO); - rev |= (idhi & SSB_IDHIGH_RCHI) >> SSB_IDHIGH_RCHI_SHIFT; - - /* XXX setup devinfo should read the values from - * the core on the bus. */ - sdi = siba_setup_devinfo(NULL, 0); - sdi->sdi_vid = vendorid; - sdi->sdi_devid = ccid; - sdi->sdi_rev = rev; - sdi->sdi_idx = idx; - sdi->sdi_irq = 0; /* XXX notyet */ - - /* - * Try to attach the child. - * We need to set resources for the child from here; - * drivers which attach to siba will need to use the - * instance variables like children of pcib do. - */ - device_t child; - + sdi = siba_setup_devinfo(dev, idx); child = device_add_child(dev, NULL, -1); - if (child == NULL) { - /* XXX should panic */ - device_printf(dev, "could not add child\n"); - siba_destroy_devinfo(sdi); - } else { - /* - * Set resources for child. - * TODO: IRQs. - * Clean this up... - */ - device_set_ivars(child, sdi); - resource_list_init(&sdi->sdi_rl); - bus_addr_t baseaddr; - baseaddr = sc->sc_maddr + (idx * SIBA_CORE_LEN); - resource_list_add(&sdi->sdi_rl, SYS_RES_MEMORY, - MIPS_MEM_RID, /* XXX */ - baseaddr, baseaddr + SIBA_CORE_LEN - 1, - SIBA_CORE_LEN); - } + if (child == NULL) + panic("%s: device_add_child() failed\n", __func__); + device_set_ivars(child, sdi); } return (bus_generic_attach(dev)); @@ -454,32 +414,55 @@ start, end, count, flags)); } +/* + * The parent bus is responsible for resource activation; in the + * case of MIPS, this boils down to setting the virtual address and + * bus handle by mapping the physical address into KSEG1. + */ static int siba_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { -// if (siba_debug) -// printf("%s: entry\n", __func__); - - /* - * Pass it to parent. - */ return (rman_activate_resource(r)); } -/* XXX this should read the info from the core being probed */ static struct siba_devinfo * siba_setup_devinfo(device_t dev, uint8_t idx) { + struct siba_softc *sc = device_get_softc(dev); struct siba_devinfo *sdi; + uint32_t idlo, idhi, rev; + uint16_t vendorid, devid; sdi = malloc(sizeof(*sdi), M_DEVBUF, M_WAITOK | M_ZERO); resource_list_init(&sdi->sdi_rl); + idlo = siba_read_4(sc, idx, SIBA_CORE_IDLO); + idhi = siba_read_4(sc, idx, SIBA_CORE_IDHI); + + vendorid = (idhi & SSB_IDHIGH_VC) >> SSB_IDHIGH_VC_SHIFT; + devid = ((idhi & 0x8ff0) >> 4); + rev = (idhi & SSB_IDHIGH_RCLO); + rev |= (idhi & SSB_IDHIGH_RCHI) >> SSB_IDHIGH_RCHI_SHIFT; + + sdi->sdi_vid = vendorid; + sdi->sdi_devid = devid; + sdi->sdi_rev = rev; + sdi->sdi_idx = idx; + sdi->sdi_irq = 0; /* XXX notyet */ + + bus_addr_t baseaddr; + baseaddr = sc->sc_maddr + (idx * SIBA_CORE_LEN); + resource_list_add(&sdi->sdi_rl, SYS_RES_MEMORY, + MIPS_MEM_RID, /* XXX */ + baseaddr, baseaddr + SIBA_CORE_LEN - 1, + SIBA_CORE_LEN); + return (sdi); } +#ifdef notyet static void siba_destroy_devinfo(struct siba_devinfo *sdi) { @@ -487,7 +470,9 @@ resource_list_free(&sdi->sdi_rl); free(sdi, M_DEVBUF); } +#endif +/* XXX is this needed? */ static device_t siba_add_child(device_t dev, int order, const char *name, int unit) {