plumisa_machdep.c revision 1.11
11.11Sdyoung/* $NetBSD: plumisa_machdep.c,v 1.11 2009/08/19 15:12:31 dyoung 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.11Sdyoung__KERNEL_RCSID(0, "$NetBSD: plumisa_machdep.c,v 1.11 2009/08/19 15:12:31 dyoung 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.2Suchint plumisabmatch(struct device *, struct cfdata *, void *); 551.2Suchvoid plumisabattach(struct device *, struct device *, void *); 561.1Such 571.1Suchstruct plumisab_softc { 581.1Such struct device sc_dev; 591.1Such plum_chipset_tag_t sc_pc; 601.1Such bus_space_tag_t sc_iot; 611.1Such int sc_irq; 621.1Such void *sc_ih; 631.1Such}; 641.1Such 651.5SthorpejCFATTACH_DECL(plumisab, sizeof(struct plumisab_softc), 661.5Sthorpej plumisabmatch, plumisabattach, NULL, NULL); 671.1Such 681.1Suchint 691.2Suchplumisabmatch(struct device *parent, struct cfdata *match, void *aux) 701.1Such{ 711.1Such struct plumiobus_attach_args *pba = aux; 721.1Such platid_mask_t mask; 731.1Such 741.3Sthorpej if (strcmp(pba->pba_busname, match->cf_name)) { 751.2Such return (0); 761.1Such } 771.1Such 781.1Such if (match->cf_loc[PLUMIOBUSIFCF_PLATFORM] == 791.1Such PLUMIOBUSIFCF_PLATFORM_DEFAULT) { 801.2Such return (1); 811.1Such } 821.1Such 831.1Such mask = PLATID_DEREF(match->cf_loc[PLUMIOBUSIFCF_PLATFORM]); 841.1Such if (platid_match(&platid, &mask)) { 851.2Such return (2); 861.1Such } 871.1Such 881.2Such return (0); 891.1Such} 901.1Such 911.1Suchvoid 921.2Suchplumisabattach(struct device *parent, struct device *self, void *aux) 931.1Such{ 941.1Such struct plumiobus_attach_args *pba = aux; 951.1Such struct plumisab_softc *sc = (void*)self; 961.1Such struct isabus_attach_args iba; 971.1Such 981.1Such printf("\n"); 991.1Such sc->sc_pc = pba->pba_pc; 1001.1Such sc->sc_iot = pba->pba_iot; 1011.1Such sc->sc_irq = pba->pba_irq; 1021.1Such printf(" base=%#x irq=%d\n", sc->sc_iot->t_base, sc->sc_irq); 1031.1Such#if 0 1041.1Such /* Reset I/O bus */ 1051.1Such plum_power_ioreset(sc->sc_pc); 1061.1Such#endif 1071.1Such /* Dump I/O port */ 1081.1Such if (0) { 1091.1Such bus_space_handle_t ioh; 1101.1Such int i; 1111.1Such bus_space_map(sc->sc_iot, 0, 0x400, 0, &ioh); 1121.1Such for(i = 0; i < 0x400; i += 4) { 1131.1Such printf("[%03x]%02x", i, bus_space_read_1(sc->sc_iot, ioh, i + 3)); 1141.1Such printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 2)); 1151.1Such printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 1)); 1161.1Such printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 0)); 1171.1Such } 1181.1Such bus_space_unmap(sc->sc_iot, ioh, 0x400); 1191.1Such } 1201.1Such 1211.1Such iba.iba_ic = sc; 1221.1Such /* Plum ISA-bus don't have memory space! */ 1231.1Such /* Plum ISA port space */ 1241.1Such iba.iba_iot = sc->sc_iot; 1251.7Sdrochner config_found_ia(self, "isabus", &iba, plumisabprint); 1261.1Such} 1271.1Such 1281.1Suchint 1291.2Suchplumisabprint(void *aux, const char *pnp) 1301.1Such{ 1311.2Such 1321.2Such return (pnp ? QUIET : UNCONF); 1331.1Such} 1341.1Such 1351.1Suchvoid 1361.2Suchisa_attach_hook(struct device *parent, struct device *self, 1371.2Such struct isabus_attach_args *iba) 1381.1Such{ 1391.2Such 1401.1Such} 1411.1Such 1421.10Sdyoungvoid 1431.11Sdyoungisa_detach_hook(isa_chipset_tag_t, device_t self) 1441.10Sdyoung{ 1451.10Sdyoung} 1461.10Sdyoung 1471.1Suchvoid * 1481.2Suchisa_intr_establish(isa_chipset_tag_t ic, int irq, int type, int level, 1491.2Such int (*ih_fun)(void *), void *ih_arg) 1501.1Such{ 1511.1Such struct plumisab_softc *sc = (void*)ic; 1521.1Such 1531.1Such sc->sc_ih = plum_intr_establish(sc->sc_pc, sc->sc_irq, type, level, 1541.1Such ih_fun, ih_arg); 1551.2Such return (sc->sc_ih); 1561.1Such} 1571.1Such 1581.1Suchvoid 1591.2Suchisa_intr_disestablish(isa_chipset_tag_t ic, void *arg) 1601.1Such{ 1611.1Such struct plumisab_softc *sc = (void*)ic; 1621.1Such 1631.1Such plum_intr_disestablish(sc->sc_pc, arg); 1641.1Such} 1651.1Such 1661.1Suchint 1671.2Suchisa_intr_alloc(isa_chipset_tag_t ic, int mask, int type, int *irq) 1681.1Such{ 1691.1Such struct plumisab_softc *sc = (void*)ic; 1701.1Such 1711.1Such *irq = sc->sc_irq; 1721.1Such 1731.2Such return (0); 1741.1Such} 175