plumisa_machdep.c revision 1.3
11.3Sthorpej/* $NetBSD: plumisa_machdep.c,v 1.3 2002/09/27 02:24:14 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.2Such * 3. All advertising materials mentioning features or use of this software 191.2Such * must display the following acknowledgement: 201.2Such * This product includes software developed by the NetBSD 211.2Such * Foundation, Inc. and its contributors. 221.2Such * 4. Neither the name of The NetBSD Foundation nor the names of its 231.2Such * contributors may be used to endorse or promote products derived 241.2Such * from this software without specific prior written permission. 251.1Such * 261.2Such * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.2Such * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.2Such * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.2Such * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.2Such * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.2Such * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.2Such * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.2Such * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.2Such * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.2Such * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.2Such * POSSIBILITY OF SUCH DAMAGE. 371.1Such */ 381.2Such 391.1Such#include <sys/param.h> 401.1Such#include <sys/systm.h> 411.1Such 421.1Such#include <machine/bus.h> 431.1Such 441.1Such#include <dev/isa/isavar.h> 451.1Such#include <dev/isa/isareg.h> 461.1Such 471.1Such#include <machine/platid.h> 481.1Such#include <machine/platid_mask.h> 491.1Such 501.1Such#include <hpcmips/tx/tx39var.h> 511.1Such#include <hpcmips/dev/plumvar.h> 521.1Such#include <hpcmips/dev/plumicuvar.h> 531.1Such#include <hpcmips/dev/plumiobusvar.h> 541.1Such 551.1Such#include "locators.h" 561.1Such 571.2Suchint plumisabprint(void *, const char *); 581.2Suchint plumisabmatch(struct device *, struct cfdata *, void *); 591.2Suchvoid plumisabattach(struct device *, struct device *, void *); 601.1Such 611.1Suchstruct plumisab_softc { 621.1Such struct device sc_dev; 631.1Such plum_chipset_tag_t sc_pc; 641.1Such bus_space_tag_t sc_iot; 651.1Such int sc_irq; 661.1Such void *sc_ih; 671.1Such}; 681.1Such 691.1Suchstruct cfattach plumisab_ca = { 701.1Such sizeof(struct plumisab_softc), plumisabmatch, plumisabattach 711.1Such}; 721.1Such 731.1Suchint 741.2Suchplumisabmatch(struct device *parent, struct cfdata *match, void *aux) 751.1Such{ 761.1Such struct plumiobus_attach_args *pba = aux; 771.1Such platid_mask_t mask; 781.1Such 791.3Sthorpej if (strcmp(pba->pba_busname, match->cf_name)) { 801.2Such return (0); 811.1Such } 821.1Such 831.1Such if (match->cf_loc[PLUMIOBUSIFCF_PLATFORM] == 841.1Such PLUMIOBUSIFCF_PLATFORM_DEFAULT) { 851.2Such return (1); 861.1Such } 871.1Such 881.1Such mask = PLATID_DEREF(match->cf_loc[PLUMIOBUSIFCF_PLATFORM]); 891.1Such if (platid_match(&platid, &mask)) { 901.2Such return (2); 911.1Such } 921.1Such 931.2Such return (0); 941.1Such} 951.1Such 961.1Suchvoid 971.2Suchplumisabattach(struct device *parent, struct device *self, void *aux) 981.1Such{ 991.1Such struct plumiobus_attach_args *pba = aux; 1001.1Such struct plumisab_softc *sc = (void*)self; 1011.1Such struct isabus_attach_args iba; 1021.1Such 1031.1Such printf("\n"); 1041.1Such sc->sc_pc = pba->pba_pc; 1051.1Such sc->sc_iot = pba->pba_iot; 1061.1Such sc->sc_irq = pba->pba_irq; 1071.1Such printf(" base=%#x irq=%d\n", sc->sc_iot->t_base, sc->sc_irq); 1081.1Such#if 0 1091.1Such /* Reset I/O bus */ 1101.1Such plum_power_ioreset(sc->sc_pc); 1111.1Such#endif 1121.1Such /* Dump I/O port */ 1131.1Such if (0) { 1141.1Such bus_space_handle_t ioh; 1151.1Such int i; 1161.1Such bus_space_map(sc->sc_iot, 0, 0x400, 0, &ioh); 1171.1Such for(i = 0; i < 0x400; i += 4) { 1181.1Such printf("[%03x]%02x", i, bus_space_read_1(sc->sc_iot, ioh, i + 3)); 1191.1Such printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 2)); 1201.1Such printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 1)); 1211.1Such printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 0)); 1221.1Such } 1231.1Such bus_space_unmap(sc->sc_iot, ioh, 0x400); 1241.1Such } 1251.1Such 1261.1Such iba.iba_busname = "isa"; 1271.1Such iba.iba_ic = sc; 1281.1Such /* Plum ISA-bus don't have memory space! */ 1291.1Such /* Plum ISA port space */ 1301.1Such iba.iba_iot = sc->sc_iot; 1311.1Such config_found(self, &iba, plumisabprint); 1321.1Such} 1331.1Such 1341.1Suchint 1351.2Suchplumisabprint(void *aux, const char *pnp) 1361.1Such{ 1371.2Such 1381.2Such return (pnp ? QUIET : UNCONF); 1391.1Such} 1401.1Such 1411.1Suchvoid 1421.2Suchisa_attach_hook(struct device *parent, struct device *self, 1431.2Such struct isabus_attach_args *iba) 1441.1Such{ 1451.2Such 1461.1Such} 1471.1Such 1481.1Suchvoid * 1491.2Suchisa_intr_establish(isa_chipset_tag_t ic, int irq, int type, int level, 1501.2Such int (*ih_fun)(void *), void *ih_arg) 1511.1Such{ 1521.1Such struct plumisab_softc *sc = (void*)ic; 1531.1Such 1541.1Such sc->sc_ih = plum_intr_establish(sc->sc_pc, sc->sc_irq, type, level, 1551.1Such ih_fun, ih_arg); 1561.2Such return (sc->sc_ih); 1571.1Such} 1581.1Such 1591.1Suchvoid 1601.2Suchisa_intr_disestablish(isa_chipset_tag_t ic, void *arg) 1611.1Such{ 1621.1Such struct plumisab_softc *sc = (void*)ic; 1631.1Such 1641.1Such plum_intr_disestablish(sc->sc_pc, arg); 1651.1Such} 1661.1Such 1671.1Suchint 1681.2Suchisa_intr_alloc(isa_chipset_tag_t ic, int mask, int type, int *irq) 1691.1Such{ 1701.1Such struct plumisab_softc *sc = (void*)ic; 1711.1Such 1721.1Such *irq = sc->sc_irq; 1731.1Such 1741.2Such return (0); 1751.1Such} 176