1 /* $NetBSD: p5membar.c,v 1.4 2020/06/17 06:40:45 thorpej Exp $ */ 2 3 /*- 4 * Copyright (c) 2012 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Radoslaw Kujawa. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /* 33 * Handle autoconfigured PCI resources on some revisions of CyberVision PPC, 34 * BlizzardVision PPC graphics cards and all G-REX PCI busboards. 35 */ 36 37 #include <sys/types.h> 38 #include <sys/param.h> 39 #include <sys/time.h> 40 #include <sys/systm.h> 41 #include <sys/errno.h> 42 #include <sys/device.h> 43 #include <sys/malloc.h> 44 45 #include <uvm/uvm_extern.h> 46 47 #include <machine/bus.h> 48 #include <machine/cpu.h> 49 50 #include <m68k/bus_dma.h> 51 #include <amiga/dev/zbusvar.h> 52 #include <amiga/pci/p5pbreg.h> 53 #include <amiga/pci/p5pbvar.h> 54 #include <amiga/pci/p5membarvar.h> 55 56 /* Zorro IDs */ 57 #define ZORRO_MANID_P5 8512 58 #define ZORRO_PRODID_P5PB 101 /* CVPPC/BVPPC/G-REX */ 59 60 static int p5membar_match(device_t, cfdata_t, void *); 61 static void p5membar_attach(device_t, device_t, void *); 62 63 CFATTACH_DECL_NEW(p5membar, sizeof(struct p5membar_softc), 64 p5membar_match, p5membar_attach, NULL, NULL); 65 66 static int 67 p5membar_match(device_t parent, cfdata_t cf, void *aux) 68 { 69 struct zbus_args *zap; 70 71 zap = aux; 72 73 if (zap->manid != ZORRO_MANID_P5) 74 return 0; 75 76 if (zap->prodid != ZORRO_PRODID_P5PB) 77 return 0; 78 79 return 1; 80 } 81 82 static void 83 p5membar_attach(device_t parent, device_t self, void *aux) 84 { 85 struct zbus_args *zap; 86 struct p5membar_softc *sc; 87 88 sc = device_private(self); 89 zap = aux; 90 91 sc->sc_dev = self; 92 sc->sc_base = zap->pa; 93 sc->sc_size = zap->size; 94 95 if ((bus_addr_t) zap->pa == P5BUS_PCI_CONF_BASE) { 96 aprint_normal(": PCI config area, %d kB\n", 97 zap->size / 1024); 98 sc->sc_type = P5MEMBAR_TYPE_INTERNAL; 99 } else if ((bus_addr_t) zap->pa == P5BUS_PCI_IO_BASE) { 100 aprint_normal(": PCI I/O area, %d kB\n", 101 zap->size / 1024); 102 sc->sc_type = P5MEMBAR_TYPE_INTERNAL; 103 } else if ((bus_addr_t) zap->pa == P5BUS_BRIDGE_BASE) { 104 aprint_normal(": PCI bridge, %d kB\n", 105 zap->size / 1024); 106 sc->sc_type = P5MEMBAR_TYPE_INTERNAL; 107 } else { 108 aprint_normal(": PCI memory BAR, %d kB\n", 109 zap->size / 1024); 110 sc->sc_type = P5MEMBAR_TYPE_MEMORY; 111 } 112 113 /* 114 * Do nothing here, p5pb should find the p5membar devices 115 * and do the right(tm) thing. 116 */ 117 118 } 119 120