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