xref: /freebsd/sys/powerpc/mpc85xx/pci_mpc85xx_pcib.c (revision fe11dfea798af61d11584eaadf38e1ea5331ef0d)
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 
53809923caSJustin Hibbits #include <dev/pci/pcivar.h>
54809923caSJustin Hibbits #include <dev/pci/pcireg.h>
55809923caSJustin Hibbits #include <dev/pci/pcib_private.h>
56809923caSJustin Hibbits 
57809923caSJustin Hibbits #include "pcib_if.h"
58809923caSJustin Hibbits 
59809923caSJustin Hibbits static int
60809923caSJustin Hibbits fsl_pcib_rc_probe(device_t dev)
61809923caSJustin Hibbits {
62*fe11dfeaSJustin Hibbits 
63809923caSJustin Hibbits 	if (pci_get_vendor(dev) != 0x1957)
64809923caSJustin Hibbits 		return (ENXIO);
65809923caSJustin Hibbits 	if (pci_get_progif(dev) != 0)
66809923caSJustin Hibbits 		return (ENXIO);
67809923caSJustin Hibbits 	if (pci_get_class(dev) != PCIC_PROCESSOR)
68809923caSJustin Hibbits 		return (ENXIO);
69809923caSJustin Hibbits 	if (pci_get_subclass(dev) != PCIS_PROCESSOR_POWERPC)
70809923caSJustin Hibbits 		return (ENXIO);
71809923caSJustin Hibbits 
72809923caSJustin Hibbits 	return (BUS_PROBE_DEFAULT);
73809923caSJustin Hibbits }
74809923caSJustin Hibbits 
75809923caSJustin Hibbits static device_method_t fsl_pcib_rc_methods[] = {
76809923caSJustin Hibbits 	DEVMETHOD(device_probe,		fsl_pcib_rc_probe),
77809923caSJustin Hibbits 	DEVMETHOD_END
78809923caSJustin Hibbits };
79809923caSJustin Hibbits 
80809923caSJustin Hibbits static devclass_t fsl_pcib_rc_devclass;
81809923caSJustin Hibbits DEFINE_CLASS_1(pcib, fsl_pcib_rc_driver, fsl_pcib_rc_methods,
82809923caSJustin Hibbits     sizeof(struct pcib_softc), pcib_driver);
83809923caSJustin Hibbits DRIVER_MODULE(rcpcib, pci, fsl_pcib_rc_driver, fsl_pcib_rc_devclass, 0, 0);
84809923caSJustin Hibbits 
85