Home | History | Annotate | Line # | Download | only in mace
pci_mace.c revision 1.23.4.1
      1  1.23.4.1   thorpej /*	$NetBSD: pci_mace.c,v 1.23.4.1 2021/03/23 07:14:51 thorpej Exp $	*/
      2       1.1    sekiya 
      3       1.1    sekiya /*
      4       1.1    sekiya  * Copyright (c) 2001,2003 Christopher Sekiya
      5       1.1    sekiya  * Copyright (c) 2000 Soren S. Jorvang
      6       1.1    sekiya  * All rights reserved.
      7       1.1    sekiya  *
      8       1.1    sekiya  * Redistribution and use in source and binary forms, with or without
      9       1.1    sekiya  * modification, are permitted provided that the following conditions
     10       1.1    sekiya  * are met:
     11       1.1    sekiya  * 1. Redistributions of source code must retain the above copyright
     12       1.1    sekiya  *    notice, this list of conditions and the following disclaimer.
     13       1.1    sekiya  * 2. Redistributions in binary form must reproduce the above copyright
     14       1.1    sekiya  *    notice, this list of conditions and the following disclaimer in the
     15       1.1    sekiya  *    documentation and/or other materials provided with the distribution.
     16       1.1    sekiya  * 3. All advertising materials mentioning features or use of this software
     17       1.1    sekiya  *    must display the following acknowledgement:
     18       1.1    sekiya  *          This product includes software developed for the
     19       1.1    sekiya  *          NetBSD Project.  See http://www.NetBSD.org/ for
     20       1.1    sekiya  *          information about NetBSD.
     21       1.1    sekiya  * 4. The name of the author may not be used to endorse or promote products
     22       1.1    sekiya  *    derived from this software without specific prior written permission.
     23       1.1    sekiya  *
     24       1.1    sekiya  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     25       1.1    sekiya  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     26       1.1    sekiya  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     27       1.1    sekiya  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     28       1.1    sekiya  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     29       1.1    sekiya  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     30       1.1    sekiya  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     31       1.1    sekiya  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     32       1.1    sekiya  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     33       1.1    sekiya  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     34       1.1    sekiya  */
     35       1.1    sekiya 
     36       1.1    sekiya #include <sys/cdefs.h>
     37  1.23.4.1   thorpej __KERNEL_RCSID(0, "$NetBSD: pci_mace.c,v 1.23.4.1 2021/03/23 07:14:51 thorpej Exp $");
     38       1.7   tsutsui 
     39       1.7   tsutsui #include "opt_pci.h"
     40       1.7   tsutsui #include "pci.h"
     41       1.1    sekiya 
     42       1.1    sekiya #include <sys/param.h>
     43       1.1    sekiya #include <sys/device.h>
     44       1.1    sekiya #include <sys/systm.h>
     45       1.1    sekiya 
     46       1.1    sekiya #include <machine/cpu.h>
     47       1.1    sekiya #include <machine/locore.h>
     48       1.1    sekiya #include <machine/autoconf.h>
     49       1.1    sekiya #include <machine/vmparam.h>
     50      1.13    dyoung #include <sys/bus.h>
     51       1.1    sekiya #include <machine/machtype.h>
     52       1.1    sekiya 
     53       1.7   tsutsui #include <mips/cache.h>
     54       1.7   tsutsui 
     55       1.1    sekiya #include <dev/pci/pcivar.h>
     56       1.1    sekiya #include <dev/pci/pcireg.h>
     57       1.1    sekiya #include <dev/pci/pcidevs.h>
     58       1.1    sekiya 
     59       1.7   tsutsui #include <sys/malloc.h>
     60       1.7   tsutsui #include <dev/pci/pciconf.h>
     61       1.7   tsutsui 
     62       1.1    sekiya #include <sgimips/mace/macereg.h>
     63       1.1    sekiya #include <sgimips/mace/macevar.h>
     64       1.1    sekiya 
     65       1.1    sekiya #include <sgimips/mace/pcireg_mace.h>
     66       1.1    sekiya 
     67      1.19  macallan #ifndef __mips_o32
     68      1.19  macallan #define USE_HIGH_PCI
     69      1.19  macallan #endif
     70      1.19  macallan 
     71      1.19  macallan 
     72       1.1    sekiya struct macepci_softc {
     73       1.1    sekiya 	struct sgimips_pci_chipset sc_pc;
     74       1.1    sekiya };
     75       1.1    sekiya 
     76      1.15       chs static int	macepci_match(device_t, cfdata_t, void *);
     77      1.15       chs static void	macepci_attach(device_t, device_t, void *);
     78       1.8    rumble static int	macepci_bus_maxdevs(pci_chipset_tag_t, int);
     79       1.8    rumble static pcireg_t	macepci_conf_read(pci_chipset_tag_t, pcitag_t, int);
     80       1.8    rumble static void	macepci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
     81      1.11    dyoung static int	macepci_intr_map(const struct pci_attach_args *,
     82      1.11    dyoung 		    pci_intr_handle_t *);
     83       1.8    rumble static const char *
     84      1.17  christos 		macepci_intr_string(pci_chipset_tag_t, pci_intr_handle_t,
     85      1.17  christos 		    char *, size_t);
     86       1.8    rumble static int	macepci_intr(void *);
     87       1.1    sekiya 
     88      1.15       chs CFATTACH_DECL_NEW(macepci, sizeof(struct macepci_softc),
     89       1.1    sekiya     macepci_match, macepci_attach, NULL, NULL);
     90       1.1    sekiya 
     91      1.18  macallan static void pcimem_bus_mem_init(bus_space_tag_t, void *);
     92      1.18  macallan static void pciio_bus_mem_init(bus_space_tag_t, void *);
     93      1.18  macallan static struct mips_bus_space	pcimem_mbst;
     94      1.18  macallan static struct mips_bus_space	pciio_mbst;
     95      1.18  macallan bus_space_tag_t	mace_pci_memt = NULL;
     96      1.18  macallan bus_space_tag_t	mace_pci_iot = NULL;
     97      1.18  macallan 
     98      1.23   thorpej #define	PCI_IO_START	0x00001000
     99      1.23   thorpej #define	PCI_IO_END	0x01ffffff
    100      1.23   thorpej #define	PCI_IO_SIZE	((PCI_IO_END - PCI_IO_START) + 1)
    101      1.23   thorpej 
    102      1.23   thorpej #ifdef USE_HIGH_PCI
    103      1.23   thorpej #define	PCI_MEM_START	0x80000000
    104      1.23   thorpej #define	PCI_MEM_END	0xffffffff
    105      1.23   thorpej #else /* ! USE_HIGH_PCI */
    106      1.23   thorpej /* XXX no idea why we limit ourselves to only half of the 32MB window */
    107      1.23   thorpej #define	PCI_MEM_START	0x80100000
    108      1.23   thorpej #define	PCI_MEM_END	0x81ffffff
    109      1.23   thorpej #endif /* USE_HIGH_PCI */
    110      1.23   thorpej 
    111      1.23   thorpej #define	PCI_MEM_SIZE	((PCI_MEM_END - PCI_MEM_START) + 1)
    112      1.23   thorpej 
    113       1.1    sekiya static int
    114      1.15       chs macepci_match(device_t parent, cfdata_t match, void *aux)
    115       1.1    sekiya {
    116       1.1    sekiya 
    117       1.2    sekiya 	return (1);
    118       1.1    sekiya }
    119       1.1    sekiya 
    120       1.1    sekiya static void
    121      1.15       chs macepci_attach(device_t parent, device_t self, void *aux)
    122       1.1    sekiya {
    123      1.15       chs 	struct macepci_softc *sc = device_private(self);
    124       1.1    sekiya 	pci_chipset_tag_t pc = &sc->sc_pc;
    125       1.1    sekiya 	struct mace_attach_args *maa = aux;
    126       1.1    sekiya 	struct pcibus_attach_args pba;
    127       1.1    sekiya 	u_int32_t control;
    128       1.7   tsutsui 	int rev;
    129       1.1    sekiya 
    130       1.1    sekiya 	if (bus_space_subregion(maa->maa_st, maa->maa_sh,
    131       1.1    sekiya 	    maa->maa_offset, 0, &pc->ioh) )
    132       1.1    sekiya 		panic("macepci_attach: couldn't map");
    133       1.1    sekiya 
    134       1.1    sekiya 	pc->iot = maa->maa_st;
    135       1.1    sekiya 
    136       1.1    sekiya 	rev = bus_space_read_4(pc->iot, pc->ioh, MACEPCI_REVISION);
    137       1.1    sekiya 	printf(": rev %d\n", rev);
    138       1.1    sekiya 
    139      1.18  macallan 	pcimem_bus_mem_init(&pcimem_mbst, NULL);
    140      1.18  macallan 	mace_pci_memt = &pcimem_mbst;
    141      1.18  macallan 	pciio_bus_mem_init(&pciio_mbst, NULL);
    142      1.18  macallan 	mace_pci_iot = &pciio_mbst;
    143      1.18  macallan 
    144       1.8    rumble 	pc->pc_bus_maxdevs = macepci_bus_maxdevs;
    145       1.1    sekiya 	pc->pc_conf_read = macepci_conf_read;
    146       1.1    sekiya 	pc->pc_conf_write = macepci_conf_write;
    147       1.8    rumble 	pc->pc_intr_map = macepci_intr_map;
    148       1.8    rumble 	pc->pc_intr_string = macepci_intr_string;
    149       1.4    sekiya 	pc->intr_establish = mace_intr_establish;
    150       1.4    sekiya 	pc->intr_disestablish = mace_intr_disestablish;
    151       1.1    sekiya 
    152       1.1    sekiya 	bus_space_write_4(pc->iot, pc->ioh, MACE_PCI_ERROR_ADDR, 0);
    153       1.1    sekiya 	bus_space_write_4(pc->iot, pc->ioh, MACE_PCI_ERROR_FLAGS, 0);
    154       1.1    sekiya 
    155       1.1    sekiya 	/* Turn on PCI error interrupts */
    156       1.1    sekiya 	bus_space_write_4(pc->iot, pc->ioh, MACE_PCI_CONTROL,
    157       1.1    sekiya 	    MACE_PCI_CONTROL_SERR_ENA |
    158       1.1    sekiya 	    MACE_PCI_CONTROL_PARITY_ERR |
    159       1.1    sekiya 	    MACE_PCI_CONTROL_PARK_LIU |
    160       1.1    sekiya 	    MACE_PCI_CONTROL_OVERRUN_INT |
    161       1.1    sekiya 	    MACE_PCI_CONTROL_PARITY_INT |
    162       1.1    sekiya 	    MACE_PCI_CONTROL_SERR_INT |
    163       1.1    sekiya 	    MACE_PCI_CONTROL_IT_INT |
    164       1.1    sekiya 	    MACE_PCI_CONTROL_RE_INT |
    165       1.1    sekiya 	    MACE_PCI_CONTROL_DPED_INT |
    166       1.1    sekiya 	    MACE_PCI_CONTROL_TAR_INT |
    167       1.1    sekiya 	    MACE_PCI_CONTROL_MAR_INT);
    168       1.1    sekiya 
    169       1.1    sekiya 	/*
    170       1.1    sekiya 	 * Enable all MACE PCI interrupts. They will be masked by
    171       1.1    sekiya 	 * the CRIME code.
    172       1.1    sekiya 	 */
    173       1.1    sekiya 	control = bus_space_read_4(pc->iot, pc->ioh, MACEPCI_CONTROL);
    174       1.1    sekiya 	control |= CONTROL_INT_MASK;
    175       1.1    sekiya 	bus_space_write_4(pc->iot, pc->ioh, MACEPCI_CONTROL, control);
    176       1.1    sekiya 
    177       1.1    sekiya #if NPCI > 0
    178      1.23   thorpej 	struct pciconf_resources *pcires = pciconf_resource_init();
    179      1.23   thorpej 
    180      1.23   thorpej 	pciconf_resource_add(pcires, PCICONF_RESOURCE_IO,
    181      1.23   thorpej 	    PCI_IO_START, PCI_IO_SIZE);
    182      1.23   thorpej 	pciconf_resource_add(pcires, PCICONF_RESOURCE_MEM,
    183      1.23   thorpej 	    PCI_MEM_START, PCI_MEM_SIZE);
    184      1.23   thorpej 
    185      1.23   thorpej 	pci_configure_bus(pc, pcires, 0,
    186      1.10      matt 	    mips_cache_info.mci_dcache_align);
    187      1.23   thorpej 
    188      1.23   thorpej 	pciconf_resource_fini(pcires);
    189      1.23   thorpej 
    190       1.1    sekiya 	memset(&pba, 0, sizeof pba);
    191      1.19  macallan 	pba.pba_iot = mace_pci_iot;
    192      1.19  macallan 	pba.pba_memt = mace_pci_memt;
    193       1.1    sekiya 	pba.pba_dmat = &pci_bus_dma_tag;
    194       1.1    sekiya 	pba.pba_dmat64 = NULL;
    195       1.1    sekiya 	pba.pba_bus = 0;
    196       1.1    sekiya 	pba.pba_bridgetag = NULL;
    197      1.12    dyoung 	pba.pba_flags = PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY |
    198       1.1    sekiya 	    PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;
    199       1.1    sekiya 	pba.pba_pc = pc;
    200       1.1    sekiya 
    201       1.1    sekiya #ifdef MACEPCI_IO_WAS_BUGGY
    202       1.1    sekiya 	if (rev == 0)
    203      1.12    dyoung 		pba.pba_flags &= ~PCI_FLAGS_IO_OKAY;		/* Buggy? */
    204       1.1    sekiya #endif
    205       1.1    sekiya 
    206       1.1    sekiya 	cpu_intr_establish(maa->maa_intr, IPL_NONE, macepci_intr, sc);
    207       1.1    sekiya 
    208  1.23.4.1   thorpej 	config_found(self, &pba, pcibusprint, CFARG_EOL);
    209       1.1    sekiya #endif
    210       1.1    sekiya }
    211       1.1    sekiya 
    212       1.8    rumble int
    213       1.8    rumble macepci_bus_maxdevs(pci_chipset_tag_t pc, int busno)
    214       1.8    rumble {
    215       1.8    rumble 
    216       1.8    rumble 	if (busno == 0)
    217       1.8    rumble 		return 5;	/* 2 on-board SCSI chips, slots 0, 1 and 2 */
    218       1.8    rumble 	else
    219       1.8    rumble 		return 0;	/* XXX */
    220       1.8    rumble }
    221       1.8    rumble 
    222       1.1    sekiya pcireg_t
    223       1.5    sekiya macepci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg)
    224       1.1    sekiya {
    225       1.1    sekiya 	pcireg_t data;
    226       1.1    sekiya 
    227      1.20   msaitoh 	if ((unsigned int)reg >= PCI_CONF_SIZE)
    228      1.20   msaitoh 		return (pcireg_t) -1;
    229      1.20   msaitoh 
    230       1.1    sekiya 	bus_space_write_4(pc->iot, pc->ioh, MACE_PCI_CONFIG_ADDR, (tag | reg));
    231       1.1    sekiya 	data = bus_space_read_4(pc->iot, pc->ioh, MACE_PCI_CONFIG_DATA);
    232       1.1    sekiya 	bus_space_write_4(pc->iot, pc->ioh, MACE_PCI_CONFIG_ADDR, 0);
    233       1.1    sekiya 
    234       1.1    sekiya 	return data;
    235       1.1    sekiya }
    236       1.1    sekiya 
    237       1.1    sekiya void
    238       1.5    sekiya macepci_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data)
    239       1.1    sekiya {
    240       1.1    sekiya 
    241      1.20   msaitoh 	if ((unsigned int)reg >= PCI_CONF_SIZE)
    242      1.20   msaitoh 		return;
    243      1.20   msaitoh 
    244       1.1    sekiya 	bus_space_write_4(pc->iot, pc->ioh, MACE_PCI_CONFIG_ADDR, (tag | reg));
    245       1.1    sekiya 	bus_space_write_4(pc->iot, pc->ioh, MACE_PCI_CONFIG_DATA, data);
    246       1.1    sekiya 	bus_space_write_4(pc->iot, pc->ioh, MACE_PCI_CONFIG_ADDR, 0);
    247       1.1    sekiya }
    248       1.1    sekiya 
    249       1.8    rumble int
    250      1.11    dyoung macepci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
    251       1.8    rumble {
    252       1.8    rumble 	pci_chipset_tag_t pc = pa->pa_pc;
    253       1.8    rumble 	pcitag_t intrtag = pa->pa_intrtag;
    254       1.8    rumble 	int pin = pa->pa_intrpin;
    255       1.8    rumble 	int bus, dev, func, start;
    256       1.8    rumble 
    257       1.8    rumble 	pci_decompose_tag(pc, intrtag, &bus, &dev, &func);
    258       1.8    rumble 
    259       1.8    rumble 	if (dev < 3 && pin != PCI_INTERRUPT_PIN_A)
    260       1.8    rumble 		panic("SCSI0 and SCSI1 must be hardwired!");
    261       1.8    rumble 
    262       1.8    rumble 	switch (pin) {
    263       1.8    rumble 	default:
    264       1.8    rumble 	case PCI_INTERRUPT_PIN_NONE:
    265       1.8    rumble 		return -1;
    266       1.8    rumble 
    267       1.8    rumble 	case PCI_INTERRUPT_PIN_A:
    268       1.8    rumble 		/*
    269       1.8    rumble 		 * Each of SCSI{0,1}, & slots 0 - 2 has dedicated interrupt
    270       1.8    rumble 		 * for pin A?
    271       1.8    rumble 		 */
    272       1.8    rumble 		*ihp = dev + 7;
    273       1.8    rumble 		return 0;
    274       1.8    rumble 
    275       1.8    rumble 	case PCI_INTERRUPT_PIN_B:
    276       1.8    rumble 		start = 0;
    277       1.8    rumble 		break;
    278       1.8    rumble 	case PCI_INTERRUPT_PIN_C:
    279       1.8    rumble 		start = 1;
    280       1.8    rumble 		break;
    281       1.8    rumble 	case PCI_INTERRUPT_PIN_D:
    282       1.8    rumble 		start = 2;
    283       1.8    rumble 		break;
    284       1.8    rumble 	}
    285       1.8    rumble 
    286       1.8    rumble 	/* Pins B,C,D are mapped to PCI_SHARED0 - PCI_SHARED2 interrupts */
    287       1.8    rumble 	*ihp = 13 /* PCI_SHARED0 */ + (start + dev - 3) % 3;
    288       1.8    rumble 	return 0;
    289       1.8    rumble }
    290       1.8    rumble 
    291       1.8    rumble const char *
    292      1.17  christos macepci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih, char *buf,
    293      1.17  christos     size_t len)
    294       1.8    rumble {
    295      1.17  christos 	snprintf(buf, len, "crime interrupt %d", ih);
    296      1.17  christos 	return buf;
    297       1.8    rumble }
    298       1.8    rumble 
    299       1.1    sekiya 
    300       1.1    sekiya /*
    301       1.1    sekiya  * Handle PCI error interrupts.
    302       1.1    sekiya  */
    303       1.1    sekiya int
    304       1.5    sekiya macepci_intr(void *arg)
    305       1.1    sekiya {
    306       1.1    sekiya 	struct macepci_softc *sc = (struct macepci_softc *)arg;
    307       1.1    sekiya 	pci_chipset_tag_t pc = &sc->sc_pc;
    308      1.21  macallan 	uint32_t error, address;
    309       1.1    sekiya 
    310       1.1    sekiya 	error = bus_space_read_4(pc->iot, pc->ioh, MACE_PCI_ERROR_FLAGS);
    311       1.1    sekiya 	address = bus_space_read_4(pc->iot, pc->ioh, MACE_PCI_ERROR_ADDR);
    312      1.21  macallan 	if (error & 0xffc00000) {
    313       1.1    sekiya 		if (error & MACE_PERR_MASTER_ABORT) {
    314       1.1    sekiya 			/*
    315       1.1    sekiya 			 * this seems to be a more-or-less normal error
    316       1.1    sekiya 			 * condition (e.g., "pcictl pci0 list" generates
    317       1.1    sekiya 			 * a _lot_ of these errors, so no message for now
    318       1.1    sekiya 			 * while I figure out if I missed a trick somewhere.
    319       1.1    sekiya 			 */
    320       1.1    sekiya 		}
    321       1.1    sekiya 
    322       1.1    sekiya 		if (error & MACE_PERR_TARGET_ABORT) {
    323       1.1    sekiya 			printf("mace: target abort at %x\n", address);
    324       1.1    sekiya 		}
    325       1.1    sekiya 
    326       1.1    sekiya 		if (error & MACE_PERR_DATA_PARITY_ERR) {
    327       1.1    sekiya 			printf("mace: parity error at %x\n", address);
    328       1.1    sekiya 		}
    329       1.1    sekiya 
    330       1.1    sekiya 		if (error & MACE_PERR_RETRY_ERR) {
    331       1.1    sekiya 			printf("mace: retry error at %x\n", address);
    332       1.1    sekiya 		}
    333       1.1    sekiya 
    334       1.1    sekiya 		if (error & MACE_PERR_ILLEGAL_CMD) {
    335       1.1    sekiya 			printf("mace: illegal command at %x\n", address);
    336       1.1    sekiya 		}
    337       1.1    sekiya 
    338       1.1    sekiya 		if (error & MACE_PERR_SYSTEM_ERR) {
    339       1.1    sekiya 			printf("mace: system error at %x\n", address);
    340       1.1    sekiya 		}
    341       1.1    sekiya 
    342       1.1    sekiya 		if (error & MACE_PERR_INTERRUPT_TEST) {
    343       1.1    sekiya 			printf("mace: interrupt test at %x\n", address);
    344       1.1    sekiya 		}
    345       1.1    sekiya 
    346       1.1    sekiya 		if (error & MACE_PERR_PARITY_ERR) {
    347       1.1    sekiya 			printf("mace: parity error at %x\n", address);
    348       1.1    sekiya 		}
    349       1.1    sekiya 
    350       1.1    sekiya 		if (error & MACE_PERR_RSVD) {
    351       1.1    sekiya 			printf("mace: reserved condition at %x\n", address);
    352       1.1    sekiya 		}
    353       1.1    sekiya 
    354       1.1    sekiya 		if (error & MACE_PERR_OVERRUN) {
    355       1.1    sekiya 			printf("mace: overrun at %x\n", address);
    356       1.1    sekiya 		}
    357      1.21  macallan 
    358      1.21  macallan 		/* clear all */
    359      1.21  macallan 		bus_space_write_4(pc->iot, pc->ioh,
    360      1.21  macallan 			    MACE_PCI_ERROR_FLAGS, error & ~0xffc00000);
    361       1.1    sekiya 	}
    362       1.1    sekiya 	return 0;
    363       1.1    sekiya }
    364      1.18  macallan 
    365      1.18  macallan /*
    366      1.18  macallan  * use the 32MB windows to access PCI space when running a 32bit kernel,
    367      1.18  macallan  * use full views at >4GB in LP64
    368      1.18  macallan  * XXX access to PCI space is endian-twiddled which can't be turned off so we
    369      1.18  macallan  * need to instruct bus_space to un-twiddle them for us so 8bit and 16bit
    370      1.18  macallan  * accesses look little-endian
    371      1.18  macallan  */
    372      1.18  macallan #define CHIP	   		pcimem
    373      1.18  macallan #define	CHIP_MEM		/* defined */
    374      1.18  macallan #define CHIP_WRONG_ENDIAN
    375      1.18  macallan 
    376      1.18  macallan /*
    377      1.18  macallan  * the lower 2GB of PCI space are two views of system memory, with and without
    378      1.18  macallan  * endianness twiddling
    379      1.18  macallan  */
    380      1.18  macallan #define	CHIP_W1_BUS_START(v)	0x80000000UL
    381      1.18  macallan #define CHIP_W1_BUS_END(v)	0xffffffffUL
    382      1.19  macallan #ifdef USE_HIGH_PCI
    383      1.18  macallan #define	CHIP_W1_SYS_START(v)	MACE_PCI_HI_MEMORY
    384      1.18  macallan #define	CHIP_W1_SYS_END(v)	MACE_PCI_HI_MEMORY + 0x7fffffffUL
    385      1.18  macallan #else
    386      1.18  macallan #define	CHIP_W1_SYS_START(v)	MACE_PCI_LOW_MEMORY
    387      1.18  macallan #define	CHIP_W1_SYS_END(v)	MACE_PCI_LOW_MEMORY + 0x01ffffffUL
    388      1.18  macallan #endif
    389      1.18  macallan 
    390      1.18  macallan #include <mips/mips/bus_space_alignstride_chipdep.c>
    391      1.18  macallan 
    392      1.18  macallan #undef CHIP
    393      1.18  macallan #undef CHIP_W1_BUS_START
    394      1.18  macallan #undef CHIP_W1_BUS_END
    395      1.18  macallan #undef CHIP_W1_SYS_START
    396      1.18  macallan #undef CHIP_W1_SYS_END
    397      1.18  macallan 
    398      1.18  macallan #define CHIP	   		pciio
    399      1.18  macallan /*
    400      1.18  macallan  * Even though it's PCI IO space, it's memory mapped so there is no reason not
    401      1.18  macallan  * to allow linear mappings or mmapings into userland. In fact we may need to
    402      1.18  macallan  * do just that in order to use things like PCI graphics cards in X.
    403      1.18  macallan  */
    404      1.18  macallan #define	CHIP_MEM		/* defined */
    405      1.18  macallan #define	CHIP_W1_BUS_START(v)	0x00000000UL
    406      1.18  macallan #define CHIP_W1_BUS_END(v)	0xffffffffUL
    407      1.19  macallan #ifdef USE_HIGH_PCI
    408      1.18  macallan #define	CHIP_W1_SYS_START(v)	MACE_PCI_HI_IO
    409      1.18  macallan #define	CHIP_W1_SYS_END(v)	MACE_PCI_HI_IO + 0xffffffffUL
    410      1.18  macallan #else
    411      1.18  macallan #define	CHIP_W1_SYS_START(v)	MACE_PCI_LOW_IO
    412      1.18  macallan #define	CHIP_W1_SYS_END(v)	MACE_PCI_LOW_IO + 0x01ffffffUL
    413      1.18  macallan #endif
    414      1.18  macallan 
    415      1.18  macallan #include <mips/mips/bus_space_alignstride_chipdep.c>
    416