1 /* $NetBSD: p5membar.c,v 1.3 2012/10/27 17:17:34 chs 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 #include <sys/extent.h> 45 46 #include <uvm/uvm_extern.h> 47 48 #include <machine/bus.h> 49 #include <machine/cpu.h> 50 51 #include <m68k/bus_dma.h> 52 #include <amiga/dev/zbusvar.h> 53 #include <amiga/pci/p5pbreg.h> 54 #include <amiga/pci/p5pbvar.h> 55 #include <amiga/pci/p5membarvar.h> 56 57 /* Zorro IDs */ 58 #define ZORRO_MANID_P5 8512 59 #define ZORRO_PRODID_P5PB 101 /* CVPPC/BVPPC/G-REX */ 60 61 static int p5membar_match(device_t, cfdata_t, void *); 62 static void p5membar_attach(device_t, device_t, void *); 63 64 CFATTACH_DECL_NEW(p5membar, sizeof(struct p5membar_softc), 65 p5membar_match, p5membar_attach, NULL, NULL); 66 67 static int 68 p5membar_match(device_t parent, cfdata_t cf, void *aux) 69 { 70 struct zbus_args *zap; 71 72 zap = aux; 73 74 if (zap->manid != ZORRO_MANID_P5) 75 return 0; 76 77 if (zap->prodid != ZORRO_PRODID_P5PB) 78 return 0; 79 80 return 1; 81 } 82 83 static void 84 p5membar_attach(device_t parent, device_t self, void *aux) 85 { 86 struct zbus_args *zap; 87 struct p5membar_softc *sc; 88 89 sc = device_private(self); 90 zap = aux; 91 92 sc->sc_dev = self; 93 sc->sc_base = zap->pa; 94 sc->sc_size = zap->size; 95 96 if ((bus_addr_t) zap->pa == P5BUS_PCI_CONF_BASE) { 97 aprint_normal(": PCI config area, %d kB\n", 98 zap->size / 1024); 99 sc->sc_type = P5MEMBAR_TYPE_INTERNAL; 100 } else if ((bus_addr_t) zap->pa == P5BUS_PCI_IO_BASE) { 101 aprint_normal(": PCI I/O area, %d kB\n", 102 zap->size / 1024); 103 sc->sc_type = P5MEMBAR_TYPE_INTERNAL; 104 } else if ((bus_addr_t) zap->pa == P5BUS_BRIDGE_BASE) { 105 aprint_normal(": PCI bridge, %d kB\n", 106 zap->size / 1024); 107 sc->sc_type = P5MEMBAR_TYPE_INTERNAL; 108 } else { 109 aprint_normal(": PCI memory BAR, %d kB\n", 110 zap->size / 1024); 111 sc->sc_type = P5MEMBAR_TYPE_MEMORY; 112 } 113 114 /* 115 * Do nothing here, p5pb should find the p5membar devices 116 * and do the right(tm) thing. 117 */ 118 119 } 120 121