plumisa_machdep.c revision 1.1
11.1Such/* $NetBSD: plumisa_machdep.c,v 1.1 1999/11/21 06:46:02 uch Exp $ */ 21.1Such 31.1Such/* 41.1Such * Copyright (c) 1999, by UCHIYAMA Yasushi 51.1Such * All rights reserved. 61.1Such * 71.1Such * Redistribution and use in source and binary forms, with or without 81.1Such * modification, are permitted provided that the following conditions 91.1Such * are met: 101.1Such * 1. Redistributions of source code must retain the above copyright 111.1Such * notice, this list of conditions and the following disclaimer. 121.1Such * 2. The name of the developer may NOT be used to endorse or promote products 131.1Such * derived from this software without specific prior written permission. 141.1Such * 151.1Such * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 161.1Such * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 171.1Such * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 181.1Such * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 191.1Such * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 201.1Such * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 211.1Such * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 221.1Such * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 231.1Such * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 241.1Such * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 251.1Such * SUCH DAMAGE. 261.1Such * 271.1Such */ 281.1Such#include <sys/param.h> 291.1Such#include <sys/systm.h> 301.1Such#include <sys/device.h> 311.1Such 321.1Such#include <machine/bus.h> 331.1Such 341.1Such#include <dev/isa/isavar.h> 351.1Such#include <dev/isa/isareg.h> 361.1Such 371.1Such#include <machine/platid.h> 381.1Such#include <machine/platid_mask.h> 391.1Such 401.1Such#include <hpcmips/tx/tx39var.h> 411.1Such#include <hpcmips/dev/plumvar.h> 421.1Such#include <hpcmips/dev/plumicuvar.h> 431.1Such#include <hpcmips/dev/plumiobusvar.h> 441.1Such 451.1Such#include "locators.h" 461.1Such 471.1Suchint plumisabprint __P((void*, const char*)); 481.1Suchint plumisabmatch __P((struct device*, struct cfdata*, void*)); 491.1Suchvoid plumisabattach __P((struct device*, struct device*, void*)); 501.1Such 511.1Suchstruct plumisab_softc { 521.1Such struct device sc_dev; 531.1Such plum_chipset_tag_t sc_pc; 541.1Such bus_space_tag_t sc_iot; 551.1Such int sc_irq; 561.1Such void *sc_ih; 571.1Such}; 581.1Such 591.1Suchstruct cfattach plumisab_ca = { 601.1Such sizeof(struct plumisab_softc), plumisabmatch, plumisabattach 611.1Such}; 621.1Such 631.1Suchint 641.1Suchplumisabmatch(parent, match, aux) 651.1Such struct device *parent; 661.1Such struct cfdata *match; 671.1Such void *aux; 681.1Such{ 691.1Such struct plumiobus_attach_args *pba = aux; 701.1Such platid_mask_t mask; 711.1Such 721.1Such 731.1Such if (strcmp(pba->pba_busname, match->cf_driver->cd_name)) { 741.1Such return 0; 751.1Such } 761.1Such 771.1Such if (match->cf_loc[PLUMIOBUSIFCF_PLATFORM] == 781.1Such PLUMIOBUSIFCF_PLATFORM_DEFAULT) { 791.1Such return 1; 801.1Such } 811.1Such 821.1Such mask = PLATID_DEREF(match->cf_loc[PLUMIOBUSIFCF_PLATFORM]); 831.1Such if (platid_match(&platid, &mask)) { 841.1Such return 2; 851.1Such } 861.1Such 871.1Such return 0; 881.1Such} 891.1Such 901.1Suchvoid 911.1Suchplumisabattach(parent, self, aux) 921.1Such struct device *parent; 931.1Such struct device *self; 941.1Such void *aux; 951.1Such{ 961.1Such struct plumiobus_attach_args *pba = aux; 971.1Such struct plumisab_softc *sc = (void*)self; 981.1Such struct isabus_attach_args iba; 991.1Such 1001.1Such printf("\n"); 1011.1Such sc->sc_pc = pba->pba_pc; 1021.1Such sc->sc_iot = pba->pba_iot; 1031.1Such sc->sc_irq = pba->pba_irq; 1041.1Such printf(" base=%#x irq=%d\n", sc->sc_iot->t_base, sc->sc_irq); 1051.1Such#if 0 1061.1Such /* Reset I/O bus */ 1071.1Such plum_power_ioreset(sc->sc_pc); 1081.1Such#endif 1091.1Such /* Dump I/O port */ 1101.1Such if (0) { 1111.1Such bus_space_handle_t ioh; 1121.1Such int i; 1131.1Such bus_space_map(sc->sc_iot, 0, 0x400, 0, &ioh); 1141.1Such for(i = 0; i < 0x400; i += 4) { 1151.1Such printf("[%03x]%02x", i, bus_space_read_1(sc->sc_iot, ioh, i + 3)); 1161.1Such printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 2)); 1171.1Such printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 1)); 1181.1Such printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 0)); 1191.1Such } 1201.1Such bus_space_unmap(sc->sc_iot, ioh, 0x400); 1211.1Such } 1221.1Such 1231.1Such iba.iba_busname = "isa"; 1241.1Such iba.iba_ic = sc; 1251.1Such /* Plum ISA-bus don't have memory space! */ 1261.1Such /* Plum ISA port space */ 1271.1Such iba.iba_iot = sc->sc_iot; 1281.1Such config_found(self, &iba, plumisabprint); 1291.1Such} 1301.1Such 1311.1Suchint 1321.1Suchplumisabprint(aux, pnp) 1331.1Such void *aux; 1341.1Such const char *pnp; 1351.1Such{ 1361.1Such return pnp ? QUIET : UNCONF; 1371.1Such} 1381.1Such 1391.1Suchvoid 1401.1Suchisa_attach_hook(parent, self, iba) 1411.1Such struct device *parent, *self; 1421.1Such struct isabus_attach_args *iba; 1431.1Such{ 1441.1Such} 1451.1Such 1461.1Suchvoid * 1471.1Suchisa_intr_establish(ic, irq, type, level, ih_fun, ih_arg) 1481.1Such isa_chipset_tag_t ic; 1491.1Such int irq; 1501.1Such int type; 1511.1Such int level; 1521.1Such int (*ih_fun) __P((void*)); 1531.1Such void *ih_arg; 1541.1Such{ 1551.1Such struct plumisab_softc *sc = (void*)ic; 1561.1Such 1571.1Such sc->sc_ih = plum_intr_establish(sc->sc_pc, sc->sc_irq, type, level, 1581.1Such ih_fun, ih_arg); 1591.1Such return sc->sc_ih; 1601.1Such} 1611.1Such 1621.1Suchvoid 1631.1Suchisa_intr_disestablish(ic, arg) 1641.1Such isa_chipset_tag_t ic; 1651.1Such void *arg; 1661.1Such{ 1671.1Such struct plumisab_softc *sc = (void*)ic; 1681.1Such 1691.1Such plum_intr_disestablish(sc->sc_pc, arg); 1701.1Such} 1711.1Such 1721.1Suchint 1731.1Suchisa_intr_alloc(ic, mask, type, irq) 1741.1Such isa_chipset_tag_t ic; 1751.1Such int mask; 1761.1Such int type; 1771.1Such int *irq; 1781.1Such{ 1791.1Such struct plumisab_softc *sc = (void*)ic; 1801.1Such 1811.1Such *irq = sc->sc_irq; 1821.1Such 1831.1Such return 0; 1841.1Such} 185