11.14Sthorpej/* $NetBSD: plumisa_machdep.c,v 1.14 2021/08/07 16:18:54 thorpej Exp $ */ 21.1Such 31.2Such/*- 41.2Such * Copyright (c) 1999 The NetBSD Foundation, Inc. 51.1Such * All rights reserved. 61.1Such * 71.2Such * This code is derived from software contributed to The NetBSD Foundation 81.2Such * by UCHIYAMA Yasushi. 91.2Such * 101.1Such * Redistribution and use in source and binary forms, with or without 111.1Such * modification, are permitted provided that the following conditions 121.1Such * are met: 131.1Such * 1. Redistributions of source code must retain the above copyright 141.1Such * notice, this list of conditions and the following disclaimer. 151.2Such * 2. Redistributions in binary form must reproduce the above copyright 161.2Such * notice, this list of conditions and the following disclaimer in the 171.2Such * documentation and/or other materials provided with the distribution. 181.1Such * 191.2Such * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.2Such * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.2Such * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.2Such * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.2Such * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.2Such * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.2Such * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.2Such * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.2Such * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.2Such * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.2Such * POSSIBILITY OF SUCH DAMAGE. 301.1Such */ 311.6Slukem 321.6Slukem#include <sys/cdefs.h> 331.14Sthorpej__KERNEL_RCSID(0, "$NetBSD: plumisa_machdep.c,v 1.14 2021/08/07 16:18:54 thorpej Exp $"); 341.2Such 351.1Such#include <sys/param.h> 361.1Such#include <sys/systm.h> 371.1Such 381.1Such#include <machine/bus.h> 391.1Such 401.1Such#include <dev/isa/isavar.h> 411.1Such#include <dev/isa/isareg.h> 421.1Such 431.1Such#include <machine/platid.h> 441.1Such#include <machine/platid_mask.h> 451.1Such 461.1Such#include <hpcmips/tx/tx39var.h> 471.1Such#include <hpcmips/dev/plumvar.h> 481.1Such#include <hpcmips/dev/plumicuvar.h> 491.1Such#include <hpcmips/dev/plumiobusvar.h> 501.1Such 511.1Such#include "locators.h" 521.1Such 531.2Suchint plumisabprint(void *, const char *); 541.12Schsint plumisabmatch(device_t, cfdata_t, void *); 551.12Schsvoid plumisabattach(device_t, device_t, void *); 561.1Such 571.1Suchstruct plumisab_softc { 581.1Such plum_chipset_tag_t sc_pc; 591.1Such bus_space_tag_t sc_iot; 601.1Such int sc_irq; 611.1Such void *sc_ih; 621.1Such}; 631.1Such 641.12SchsCFATTACH_DECL_NEW(plumisab, sizeof(struct plumisab_softc), 651.5Sthorpej plumisabmatch, plumisabattach, NULL, NULL); 661.1Such 671.1Suchint 681.12Schsplumisabmatch(device_t parent, cfdata_t match, void *aux) 691.1Such{ 701.1Such struct plumiobus_attach_args *pba = aux; 711.1Such platid_mask_t mask; 721.1Such 731.3Sthorpej if (strcmp(pba->pba_busname, match->cf_name)) { 741.2Such return (0); 751.1Such } 761.1Such 771.1Such if (match->cf_loc[PLUMIOBUSIFCF_PLATFORM] == 781.1Such PLUMIOBUSIFCF_PLATFORM_DEFAULT) { 791.2Such return (1); 801.1Such } 811.1Such 821.1Such mask = PLATID_DEREF(match->cf_loc[PLUMIOBUSIFCF_PLATFORM]); 831.1Such if (platid_match(&platid, &mask)) { 841.2Such return (2); 851.1Such } 861.1Such 871.2Such return (0); 881.1Such} 891.1Such 901.1Suchvoid 911.12Schsplumisabattach(device_t parent, device_t self, void *aux) 921.1Such{ 931.1Such struct plumiobus_attach_args *pba = aux; 941.12Schs struct plumisab_softc *sc = device_private(self); 951.1Such struct isabus_attach_args iba; 961.1Such 971.1Such printf("\n"); 981.1Such sc->sc_pc = pba->pba_pc; 991.1Such sc->sc_iot = pba->pba_iot; 1001.1Such sc->sc_irq = pba->pba_irq; 1011.1Such printf(" base=%#x irq=%d\n", sc->sc_iot->t_base, sc->sc_irq); 1021.1Such#if 0 1031.1Such /* Reset I/O bus */ 1041.1Such plum_power_ioreset(sc->sc_pc); 1051.1Such#endif 1061.1Such /* Dump I/O port */ 1071.1Such if (0) { 1081.1Such bus_space_handle_t ioh; 1091.1Such int i; 1101.1Such bus_space_map(sc->sc_iot, 0, 0x400, 0, &ioh); 1111.1Such for(i = 0; i < 0x400; i += 4) { 1121.1Such printf("[%03x]%02x", i, bus_space_read_1(sc->sc_iot, ioh, i + 3)); 1131.1Such printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 2)); 1141.1Such printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 1)); 1151.1Such printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 0)); 1161.1Such } 1171.1Such bus_space_unmap(sc->sc_iot, ioh, 0x400); 1181.1Such } 1191.1Such 1201.1Such iba.iba_ic = sc; 1211.1Such /* Plum ISA-bus don't have memory space! */ 1221.1Such /* Plum ISA port space */ 1231.1Such iba.iba_iot = sc->sc_iot; 1241.14Sthorpej config_found(self, &iba, plumisabprint, CFARGS_NONE); 1251.1Such} 1261.1Such 1271.1Suchint 1281.2Suchplumisabprint(void *aux, const char *pnp) 1291.1Such{ 1301.2Such 1311.2Such return (pnp ? QUIET : UNCONF); 1321.1Such} 1331.1Such 1341.1Suchvoid 1351.12Schsisa_attach_hook(device_t parent, device_t self, 1361.2Such struct isabus_attach_args *iba) 1371.1Such{ 1381.2Such 1391.1Such} 1401.1Such 1411.10Sdyoungvoid 1421.11Sdyoungisa_detach_hook(isa_chipset_tag_t, device_t self) 1431.10Sdyoung{ 1441.10Sdyoung} 1451.10Sdyoung 1461.1Suchvoid * 1471.2Suchisa_intr_establish(isa_chipset_tag_t ic, int irq, int type, int level, 1481.2Such int (*ih_fun)(void *), void *ih_arg) 1491.1Such{ 1501.1Such struct plumisab_softc *sc = (void*)ic; 1511.1Such 1521.1Such sc->sc_ih = plum_intr_establish(sc->sc_pc, sc->sc_irq, type, level, 1531.1Such ih_fun, ih_arg); 1541.2Such return (sc->sc_ih); 1551.1Such} 1561.1Such 1571.1Suchvoid 1581.2Suchisa_intr_disestablish(isa_chipset_tag_t ic, void *arg) 1591.1Such{ 1601.1Such struct plumisab_softc *sc = (void*)ic; 1611.1Such 1621.1Such plum_intr_disestablish(sc->sc_pc, arg); 1631.1Such} 1641.1Such 1651.1Suchint 1661.2Suchisa_intr_alloc(isa_chipset_tag_t ic, int mask, int type, int *irq) 1671.1Such{ 1681.1Such struct plumisab_softc *sc = (void*)ic; 1691.1Such 1701.1Such *irq = sc->sc_irq; 1711.1Such 1721.2Such return (0); 1731.1Such} 174