From owner-p4-projects@FreeBSD.ORG Thu May 10 01:16:32 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 F1A1116A406; Thu, 10 May 2007 01:16:31 +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 CF75C16A402 for ; Thu, 10 May 2007 01:16:31 +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 C0BED13C458 for ; Thu, 10 May 2007 01:16:31 +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 l4A1GVTJ030115 for ; Thu, 10 May 2007 01:16:31 GMT (envelope-from bms@incunabulum.net) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l4A1GVvj030112 for perforce@freebsd.org; Thu, 10 May 2007 01:16:31 GMT (envelope-from bms@incunabulum.net) Date: Thu, 10 May 2007 01:16:31 GMT Message-Id: <200705100116.l4A1GVvj030112@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 119614 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: Thu, 10 May 2007 01:16:32 -0000 http://perforce.freebsd.org/chv.cgi?CH=119614 Change 119614 by bms@bms_anglepoise on 2007/05/10 01:15:48 Bring in stubs for PCI host bridge. Affected files ... .. //depot/projects/mips2/src/sys/mips/mips32/sentry5/siba_pcib.c#3 edit .. //depot/projects/mips2/src/sys/mips/mips32/sentry5/siba_pcibvar.h#1 add Differences ... ==== //depot/projects/mips2/src/sys/mips/mips32/sentry5/siba_pcib.c#3 (text+ko) ==== @@ -39,14 +39,62 @@ #include #include +#include +#include +#include + #include +#include +#include +#include + +#include +#include +#include + +#include "pcib_if.h" #include #include #include +#include +#ifndef MIPS_MEM_RID +#define MIPS_MEM_RID 0x20 +#endif + +/* + * TODO: interrupt routing. + * TODO: implement configuration space access. + * TODO: map pci i/o windows. + * TODO: fully implement bus allocation. + * TODO: implement resource managers. + */ + +static int siba_pcib_activate_resource(device_t, device_t, int, + int, struct resource *); +static struct resource * + siba_pcib_alloc_resource(device_t, device_t, int, int *, + u_long , u_long, u_long, u_int); static int siba_pcib_attach(device_t); +static int siba_pcib_deactivate_resource(device_t, device_t, int, + int, struct resource *); +static int siba_pcib_maxslots(device_t); static int siba_pcib_probe(device_t); +static u_int32_t + siba_pcib_read_config(device_t, u_int, u_int, u_int, u_int, + int); +static int siba_pcib_read_ivar(device_t, device_t, int, uintptr_t *); +static int siba_pcib_release_resource(device_t, device_t, int, int, + struct resource *); +static int siba_pcib_route_interrupt(device_t, device_t, int); +static int siba_pcib_setup_intr(device_t, device_t, struct resource *, + int, driver_filter_t *, driver_intr_t *, void *, void **); +static int siba_pcib_teardown_intr(device_t, device_t, struct resource *, + void *); +static void siba_pcib_write_config(device_t, u_int, u_int, u_int, u_int, + u_int32_t, int); +static int siba_pcib_write_ivar(device_t, device_t, int, uintptr_t); static int siba_pcib_probe(device_t dev) @@ -61,10 +109,6 @@ return (ENXIO); } -struct siba_pcib_softc { - void *notused; -}; - static int siba_pcib_attach(device_t dev) { @@ -75,9 +119,7 @@ /* * Allocate the resources which the parent bus has already * determined for us. - * TODO: interrupt routing */ -#define MIPS_MEM_RID 0x20 rid = MIPS_MEM_RID; mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); @@ -85,12 +127,175 @@ device_printf(dev, "unable to allocate memory\n"); return (ENXIO); } + + device_add_child(dev, "pci", -1); + return (bus_generic_attach(dev)); +} + +/* bus functions */ + +static int +siba_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + struct siba_pcib_softc *sc; + + sc = device_get_softc(dev); + switch (which) { + case PCIB_IVAR_BUS: + *result = sc->sc_bus; + return (0); + } + + return (ENOENT); +} + +static int +siba_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value) +{ + struct siba_pcib_softc *sc; + + sc = device_get_softc(dev); + switch (which) { + case PCIB_IVAR_BUS: + sc->sc_bus = value; + return (0); + } + + return (ENOENT); +} + +static int +siba_pcib_setup_intr(device_t dev, device_t child, struct resource *ires, + int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, + void **cookiep) +{ + + return (BUS_SETUP_INTR(device_get_parent(dev), child, ires, flags, + filt, intr, arg, cookiep)); +} + +static int +siba_pcib_teardown_intr(device_t dev, device_t child, struct resource *vec, + void *cookie) +{ + + return (BUS_TEARDOWN_INTR(device_get_parent(dev), child, vec, cookie)); +} + +static struct resource * +siba_pcib_alloc_resource(device_t bus, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ +#if 1 + + device_printf(bus, "%s: not yet implemented\n", __func__); + return (NULL); +#else + bus_space_tag_t tag; + struct siba_pcib_softc *sc = device_get_softc(bus); + struct rman *rmanp; + struct resource *rv; + + tag = 0; + rv = NULL; + switch (type) { + case SYS_RES_IRQ: + rmanp = &sc->sc_irq_rman; + break; + + case SYS_RES_MEMORY: + rmanp = &sc->sc_mem_rman; + tag = &sc->sc_pci_memt; + break; + + default: + return (rv); + } + + rv = rman_reserve_resource(rmanp, start, end, count, flags, child); + if (rv != NULL) { + rman_set_rid(rv, *rid); + if (type == SYS_RES_MEMORY) { #if 0 - device_printf(dev, "start %08lx size %04lx\n", - rman_get_start(mem), rman_get_size(mem)); + rman_set_bustag(rv, tag); + rman_set_bushandle(rv, rman_get_bushandle(sc->sc_mem) + + (rman_get_start(rv) - IXP425_PCI_MEM_HWBASE)); +#endif + } + } + + return (rv); #endif +} + +static int +siba_pcib_activate_resource(device_t bus, device_t child, int type, int rid, + struct resource *r) +{ + + device_printf(bus, "%s: not yet implemented\n", __func__); + device_printf(bus, "%s called activate_resource\n", + device_get_nameunit(child)); + return (ENXIO); +} + +static int +siba_pcib_deactivate_resource(device_t bus, device_t child, int type, int rid, + struct resource *r) +{ - return (0); + device_printf(bus, "%s: not yet implemented\n", __func__); + device_printf(bus, "%s called deactivate_resource\n", + device_get_nameunit(child)); + return (ENXIO); +} + +static int +siba_pcib_release_resource(device_t bus, device_t child, int type, int rid, + struct resource *r) +{ + + device_printf(bus, "%s: not yet implemented\n", __func__); + device_printf(bus, "%s called release_resource\n", + device_get_nameunit(child)); + return (ENXIO); +} + +/* pcib interface functions */ + +static int +siba_pcib_maxslots(device_t dev) +{ + + //return (PCI_SLOTMAX); + return (1); +} + +static u_int32_t +siba_pcib_read_config(device_t dev, u_int bus, u_int slot, + u_int func, u_int reg, int bytes) +{ + + /* read from pci configuration space */ + device_printf(dev, "%s: not yet implemented\n", __func__); + return (-1); +} + +static void +siba_pcib_write_config(device_t dev, u_int bus, u_int slot, + u_int func, u_int reg, u_int32_t val, int bytes) +{ + + /* write to pci configuration space */ + device_printf(dev, "%s: not yet implemented\n", __func__); +} + +static int +siba_pcib_route_interrupt(device_t bridge, device_t device, int pin) +{ + + device_printf(bridge, "%s: not yet implemented\n", __func__); + return (-1); } static device_method_t siba_pcib_methods[] = { @@ -98,11 +303,28 @@ DEVMETHOD(device_attach, siba_pcib_attach), DEVMETHOD(device_probe, siba_pcib_probe), + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, siba_pcib_read_ivar), + DEVMETHOD(bus_write_ivar, siba_pcib_write_ivar), + DEVMETHOD(bus_setup_intr, siba_pcib_setup_intr), + DEVMETHOD(bus_teardown_intr, siba_pcib_teardown_intr), + DEVMETHOD(bus_alloc_resource, siba_pcib_alloc_resource), + DEVMETHOD(bus_activate_resource, siba_pcib_activate_resource), + DEVMETHOD(bus_deactivate_resource, siba_pcib_deactivate_resource), + DEVMETHOD(bus_release_resource, siba_pcib_release_resource), + + /* pcib interface */ + DEVMETHOD(pcib_maxslots, siba_pcib_maxslots), + DEVMETHOD(pcib_read_config, siba_pcib_read_config), + DEVMETHOD(pcib_write_config, siba_pcib_write_config), + DEVMETHOD(pcib_route_interrupt, siba_pcib_route_interrupt), + {0, 0}, }; static driver_t siba_pcib_driver = { - "siba_pcib", + "pcib", siba_pcib_methods, sizeof(struct siba_softc), };