plumisa_machdep.c revision 1.1
1/* $NetBSD: plumisa_machdep.c,v 1.1 1999/11/21 06:46:02 uch Exp $ */ 2 3/* 4 * Copyright (c) 1999, by UCHIYAMA Yasushi 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. The name of the developer may NOT be used to endorse or promote products 13 * derived from this software without specific prior written permission. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 */ 28#include <sys/param.h> 29#include <sys/systm.h> 30#include <sys/device.h> 31 32#include <machine/bus.h> 33 34#include <dev/isa/isavar.h> 35#include <dev/isa/isareg.h> 36 37#include <machine/platid.h> 38#include <machine/platid_mask.h> 39 40#include <hpcmips/tx/tx39var.h> 41#include <hpcmips/dev/plumvar.h> 42#include <hpcmips/dev/plumicuvar.h> 43#include <hpcmips/dev/plumiobusvar.h> 44 45#include "locators.h" 46 47int plumisabprint __P((void*, const char*)); 48int plumisabmatch __P((struct device*, struct cfdata*, void*)); 49void plumisabattach __P((struct device*, struct device*, void*)); 50 51struct plumisab_softc { 52 struct device sc_dev; 53 plum_chipset_tag_t sc_pc; 54 bus_space_tag_t sc_iot; 55 int sc_irq; 56 void *sc_ih; 57}; 58 59struct cfattach plumisab_ca = { 60 sizeof(struct plumisab_softc), plumisabmatch, plumisabattach 61}; 62 63int 64plumisabmatch(parent, match, aux) 65 struct device *parent; 66 struct cfdata *match; 67 void *aux; 68{ 69 struct plumiobus_attach_args *pba = aux; 70 platid_mask_t mask; 71 72 73 if (strcmp(pba->pba_busname, match->cf_driver->cd_name)) { 74 return 0; 75 } 76 77 if (match->cf_loc[PLUMIOBUSIFCF_PLATFORM] == 78 PLUMIOBUSIFCF_PLATFORM_DEFAULT) { 79 return 1; 80 } 81 82 mask = PLATID_DEREF(match->cf_loc[PLUMIOBUSIFCF_PLATFORM]); 83 if (platid_match(&platid, &mask)) { 84 return 2; 85 } 86 87 return 0; 88} 89 90void 91plumisabattach(parent, self, aux) 92 struct device *parent; 93 struct device *self; 94 void *aux; 95{ 96 struct plumiobus_attach_args *pba = aux; 97 struct plumisab_softc *sc = (void*)self; 98 struct isabus_attach_args iba; 99 100 printf("\n"); 101 sc->sc_pc = pba->pba_pc; 102 sc->sc_iot = pba->pba_iot; 103 sc->sc_irq = pba->pba_irq; 104 printf(" base=%#x irq=%d\n", sc->sc_iot->t_base, sc->sc_irq); 105#if 0 106 /* Reset I/O bus */ 107 plum_power_ioreset(sc->sc_pc); 108#endif 109 /* Dump I/O port */ 110 if (0) { 111 bus_space_handle_t ioh; 112 int i; 113 bus_space_map(sc->sc_iot, 0, 0x400, 0, &ioh); 114 for(i = 0; i < 0x400; i += 4) { 115 printf("[%03x]%02x", i, bus_space_read_1(sc->sc_iot, ioh, i + 3)); 116 printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 2)); 117 printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 1)); 118 printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 0)); 119 } 120 bus_space_unmap(sc->sc_iot, ioh, 0x400); 121 } 122 123 iba.iba_busname = "isa"; 124 iba.iba_ic = sc; 125 /* Plum ISA-bus don't have memory space! */ 126 /* Plum ISA port space */ 127 iba.iba_iot = sc->sc_iot; 128 config_found(self, &iba, plumisabprint); 129} 130 131int 132plumisabprint(aux, pnp) 133 void *aux; 134 const char *pnp; 135{ 136 return pnp ? QUIET : UNCONF; 137} 138 139void 140isa_attach_hook(parent, self, iba) 141 struct device *parent, *self; 142 struct isabus_attach_args *iba; 143{ 144} 145 146void * 147isa_intr_establish(ic, irq, type, level, ih_fun, ih_arg) 148 isa_chipset_tag_t ic; 149 int irq; 150 int type; 151 int level; 152 int (*ih_fun) __P((void*)); 153 void *ih_arg; 154{ 155 struct plumisab_softc *sc = (void*)ic; 156 157 sc->sc_ih = plum_intr_establish(sc->sc_pc, sc->sc_irq, type, level, 158 ih_fun, ih_arg); 159 return sc->sc_ih; 160} 161 162void 163isa_intr_disestablish(ic, arg) 164 isa_chipset_tag_t ic; 165 void *arg; 166{ 167 struct plumisab_softc *sc = (void*)ic; 168 169 plum_intr_disestablish(sc->sc_pc, arg); 170} 171 172int 173isa_intr_alloc(ic, mask, type, irq) 174 isa_chipset_tag_t ic; 175 int mask; 176 int type; 177 int *irq; 178{ 179 struct plumisab_softc *sc = (void*)ic; 180 181 *irq = sc->sc_irq; 182 183 return 0; 184} 185