1809923caSJustin Hibbits /*- 2809923caSJustin Hibbits * Copyright 2015 Justin Hibbits 3809923caSJustin Hibbits * All rights reserved. 4809923caSJustin Hibbits * 5809923caSJustin Hibbits * Redistribution and use in source and binary forms, with or without 6809923caSJustin Hibbits * modification, are permitted provided that the following conditions 7809923caSJustin Hibbits * are met: 8809923caSJustin Hibbits * 1. Redistributions of source code must retain the above copyright 9809923caSJustin Hibbits * notice, this list of conditions and the following disclaimer. 10809923caSJustin Hibbits * 2. Redistributions in binary form must reproduce the above copyright 11809923caSJustin Hibbits * notice, this list of conditions and the following disclaimer in the 12809923caSJustin Hibbits * documentation and/or other materials provided with the distribution. 13809923caSJustin Hibbits * 3. The name of the author may not be used to endorse or promote products 14809923caSJustin Hibbits * derived from this software without specific prior written permission. 15809923caSJustin Hibbits * 16809923caSJustin Hibbits * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17809923caSJustin Hibbits * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18809923caSJustin Hibbits * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19809923caSJustin Hibbits * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20809923caSJustin Hibbits * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21809923caSJustin Hibbits * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22809923caSJustin Hibbits * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23809923caSJustin Hibbits * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24809923caSJustin Hibbits * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25809923caSJustin Hibbits * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26809923caSJustin Hibbits * SUCH DAMAGE. 27809923caSJustin Hibbits * 28809923caSJustin Hibbits * From: FreeBSD: src/sys/powerpc/mpc85xx/pci_ocp.c,v 1.9 2010/03/23 23:46:28 marcel 29809923caSJustin Hibbits */ 30809923caSJustin Hibbits 31809923caSJustin Hibbits #include <sys/cdefs.h> 32809923caSJustin Hibbits __FBSDID("$FreeBSD$"); 33809923caSJustin Hibbits 34809923caSJustin Hibbits #include <sys/param.h> 35809923caSJustin Hibbits #include <sys/systm.h> 36809923caSJustin Hibbits #include <sys/ktr.h> 37809923caSJustin Hibbits #include <sys/sockio.h> 38809923caSJustin Hibbits #include <sys/mbuf.h> 39809923caSJustin Hibbits #include <sys/malloc.h> 40809923caSJustin Hibbits #include <sys/kernel.h> 41809923caSJustin Hibbits #include <sys/module.h> 42809923caSJustin Hibbits #include <sys/socket.h> 43809923caSJustin Hibbits #include <sys/queue.h> 44809923caSJustin Hibbits #include <sys/bus.h> 45809923caSJustin Hibbits #include <sys/lock.h> 46809923caSJustin Hibbits #include <sys/mutex.h> 47809923caSJustin Hibbits #include <sys/rman.h> 48809923caSJustin Hibbits #include <sys/endian.h> 49809923caSJustin Hibbits 50809923caSJustin Hibbits #include <vm/vm.h> 51809923caSJustin Hibbits #include <vm/pmap.h> 52809923caSJustin Hibbits 5327353776SJustin Hibbits #include <dev/ofw/openfirm.h> 5427353776SJustin Hibbits #include <dev/ofw/ofw_pci.h> 5527353776SJustin Hibbits #include <dev/ofw/ofw_bus.h> 5627353776SJustin Hibbits #include <dev/ofw/ofw_bus_subr.h> 5727353776SJustin Hibbits 58809923caSJustin Hibbits #include <dev/pci/pcivar.h> 59809923caSJustin Hibbits #include <dev/pci/pcireg.h> 60809923caSJustin Hibbits #include <dev/pci/pcib_private.h> 61809923caSJustin Hibbits 6227353776SJustin Hibbits #include <machine/intr_machdep.h> 6327353776SJustin Hibbits 64809923caSJustin Hibbits #include "pcib_if.h" 65809923caSJustin Hibbits 66*c9bd5beeSJustin Hibbits DECLARE_CLASS(ofw_pcib_pci_driver); 67*c9bd5beeSJustin Hibbits 6827353776SJustin Hibbits struct fsl_pcib_softc { 6927353776SJustin Hibbits /* 7027353776SJustin Hibbits * This is here so that we can use pci bridge methods, too - the 7127353776SJustin Hibbits * generic routines only need the dev, secbus and subbus members 7227353776SJustin Hibbits * filled. 73*c9bd5beeSJustin Hibbits * 74*c9bd5beeSJustin Hibbits * XXX: This should be extracted from ofw_pcib_pci.c, and shared in a 75*c9bd5beeSJustin Hibbits * header. 7627353776SJustin Hibbits */ 7727353776SJustin Hibbits struct pcib_softc ops_pcib_sc; 7827353776SJustin Hibbits phandle_t ops_node; 7927353776SJustin Hibbits struct ofw_bus_iinfo ops_iinfo; 8027353776SJustin Hibbits }; 8127353776SJustin Hibbits 82809923caSJustin Hibbits static int 83809923caSJustin Hibbits fsl_pcib_rc_probe(device_t dev) 84809923caSJustin Hibbits { 85fe11dfeaSJustin Hibbits 86809923caSJustin Hibbits if (pci_get_vendor(dev) != 0x1957) 87809923caSJustin Hibbits return (ENXIO); 88809923caSJustin Hibbits if (pci_get_progif(dev) != 0) 89809923caSJustin Hibbits return (ENXIO); 90809923caSJustin Hibbits if (pci_get_class(dev) != PCIC_PROCESSOR) 91809923caSJustin Hibbits return (ENXIO); 92809923caSJustin Hibbits if (pci_get_subclass(dev) != PCIS_PROCESSOR_POWERPC) 93809923caSJustin Hibbits return (ENXIO); 94809923caSJustin Hibbits 95809923caSJustin Hibbits return (BUS_PROBE_DEFAULT); 96809923caSJustin Hibbits } 97809923caSJustin Hibbits 98809923caSJustin Hibbits static device_method_t fsl_pcib_rc_methods[] = { 99809923caSJustin Hibbits DEVMETHOD(device_probe, fsl_pcib_rc_probe), 100809923caSJustin Hibbits DEVMETHOD_END 101809923caSJustin Hibbits }; 102809923caSJustin Hibbits 103809923caSJustin Hibbits static devclass_t fsl_pcib_rc_devclass; 104809923caSJustin Hibbits DEFINE_CLASS_1(pcib, fsl_pcib_rc_driver, fsl_pcib_rc_methods, 105*c9bd5beeSJustin Hibbits sizeof(struct fsl_pcib_softc), ofw_pcib_pci_driver); 106809923caSJustin Hibbits DRIVER_MODULE(rcpcib, pci, fsl_pcib_rc_driver, fsl_pcib_rc_devclass, 0, 0); 107