1/* $NetBSD: isa_machdep.c,v 1.43 2021/08/07 16:18:46 thorpej Exp $ */ 2 3/* 4 * Copyright (c) 1997 Leo Weppelman. All rights reserved. 5 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 6 * Copyright (c) 1994 Charles M. Hannum. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by Charles M. Hannum. 19 * 4. The name of the author may not be used to endorse or promote products 20 * derived from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h> 35__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.43 2021/08/07 16:18:46 thorpej Exp $"); 36 37#include <sys/types.h> 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/device.h> 41 42#define _ATARI_BUS_DMA_PRIVATE 43#include <sys/bus.h> 44#include <dev/isa/isavar.h> 45#include <dev/isa/isareg.h> 46 47#include "pckbc.h" 48#if (NPCKBC > 0) 49#include <dev/ic/pckbcvar.h> 50#include <dev/ic/i8042reg.h> 51#endif /* NPCKBC > 0 */ 52 53#include <machine/iomap.h> 54#include <machine/mfp.h> 55#include <atari/atari/device.h> 56 57#include "isadma.h" 58 59#if NISADMA == 0 60 61/* 62 * Entry points for ISA DMA while no DMA capable devices are attached. 63 * This must be a serious error. Cause a panic... 64 */ 65struct atari_bus_dma_tag isa_bus_dma_tag = { 66 0 67}; 68#endif /* NISADMA == 0 */ 69 70static int atariisabusprint(void *, const char *); 71static int isabusmatch(device_t, cfdata_t, void *); 72static void isabusattach(device_t, device_t, void *); 73 74struct isabus_softc { 75 device_t sc_dev; 76 struct atari_isa_chipset sc_chipset; 77}; 78 79CFATTACH_DECL_NEW(isab, sizeof(struct isabus_softc), 80 isabusmatch, isabusattach, NULL, NULL); 81 82/* 83 * We need some static storage to attach a console keyboard on the Milan 84 * during early console init. 85 */ 86static struct atari_bus_space bs_storage[2]; /* 1 iot, 1 memt */ 87 88int 89isabusmatch(device_t parent, cfdata_t cf, void *aux) 90{ 91 static int nmatched = 0; 92 93 if (strcmp((char *)aux, "isab")) 94 return 0; /* Wrong number... */ 95 96 if (atari_realconfig == 0) 97 return 1; 98 99 if (machineid & (ATARI_HADES|ATARI_MILAN)) { 100 /* 101 * The Hades and Milan have only one pci bus 102 */ 103 if (nmatched) 104 return 0; 105 nmatched++; 106 return 1; 107 } 108 return 0; 109} 110 111void 112isabusattach(device_t parent, device_t self, void *aux) 113{ 114 struct isabus_softc *sc; 115 struct isabus_attach_args iba; 116 extern struct atari_bus_dma_tag isa_bus_dma_tag; 117 extern void isa_bus_init(void); 118 119 iba.iba_dmat = &isa_bus_dma_tag; 120 iba.iba_iot = leb_alloc_bus_space_tag(&bs_storage[0]); 121 iba.iba_memt = leb_alloc_bus_space_tag(&bs_storage[1]); 122 if ((iba.iba_iot == NULL) || (iba.iba_memt == NULL)) { 123 printf("leb_alloc_bus_space_tag failed!\n"); 124 return; 125 } 126 iba.iba_iot->base = ISA_IOSTART; 127 iba.iba_memt->base = ISA_MEMSTART; 128 129 if (machineid & ATARI_HADES) 130 MFP->mf_aer |= (IO_ISA1|IO_ISA2); /* ISA interrupts: LOW->HIGH */ 131 isa_bus_init(); 132 if (self == NULL) { /* Early init */ 133#if (NPCKBC > 0) 134 pckbc_cnattach(iba.iba_iot, IO_KBD, KBCMDP, PCKBC_KBD_SLOT, 0); 135#endif 136 return; 137 } 138 139 sc = device_private(self); 140 sc->sc_dev = self; 141 iba.iba_ic = &sc->sc_chipset; 142 143 printf("\n"); 144 config_found(self, &iba, atariisabusprint, CFARGS_NONE); 145} 146 147int 148atariisabusprint(void *aux, const char *name) 149{ 150 151 if (name == NULL) 152 return UNCONF; 153 return QUIET; 154} 155 156void 157isa_attach_hook(device_t parent, device_t self, struct isabus_attach_args *iba) 158{ 159} 160 161void 162isa_detach_hook(isa_chipset_tag_t ic, device_t self) 163{ 164} 165 166const struct evcnt * 167isa_intr_evcnt(isa_chipset_tag_t ic, int irq) 168{ 169 170 /* XXX for now, no evcnt parent reported */ 171 return NULL; 172} 173