1 /* $NetBSD: plumisa_machdep.c,v 1.2 2001/09/16 05:32:20 uch 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/param.h> 40 #include <sys/systm.h> 41 42 #include <machine/bus.h> 43 44 #include <dev/isa/isavar.h> 45 #include <dev/isa/isareg.h> 46 47 #include <machine/platid.h> 48 #include <machine/platid_mask.h> 49 50 #include <hpcmips/tx/tx39var.h> 51 #include <hpcmips/dev/plumvar.h> 52 #include <hpcmips/dev/plumicuvar.h> 53 #include <hpcmips/dev/plumiobusvar.h> 54 55 #include "locators.h" 56 57 int plumisabprint(void *, const char *); 58 int plumisabmatch(struct device *, struct cfdata *, void *); 59 void plumisabattach(struct device *, struct device *, void *); 60 61 struct plumisab_softc { 62 struct device sc_dev; 63 plum_chipset_tag_t sc_pc; 64 bus_space_tag_t sc_iot; 65 int sc_irq; 66 void *sc_ih; 67 }; 68 69 struct cfattach plumisab_ca = { 70 sizeof(struct plumisab_softc), plumisabmatch, plumisabattach 71 }; 72 73 int 74 plumisabmatch(struct device *parent, struct cfdata *match, void *aux) 75 { 76 struct plumiobus_attach_args *pba = aux; 77 platid_mask_t mask; 78 79 if (strcmp(pba->pba_busname, match->cf_driver->cd_name)) { 80 return (0); 81 } 82 83 if (match->cf_loc[PLUMIOBUSIFCF_PLATFORM] == 84 PLUMIOBUSIFCF_PLATFORM_DEFAULT) { 85 return (1); 86 } 87 88 mask = PLATID_DEREF(match->cf_loc[PLUMIOBUSIFCF_PLATFORM]); 89 if (platid_match(&platid, &mask)) { 90 return (2); 91 } 92 93 return (0); 94 } 95 96 void 97 plumisabattach(struct device *parent, struct device *self, void *aux) 98 { 99 struct plumiobus_attach_args *pba = aux; 100 struct plumisab_softc *sc = (void*)self; 101 struct isabus_attach_args iba; 102 103 printf("\n"); 104 sc->sc_pc = pba->pba_pc; 105 sc->sc_iot = pba->pba_iot; 106 sc->sc_irq = pba->pba_irq; 107 printf(" base=%#x irq=%d\n", sc->sc_iot->t_base, sc->sc_irq); 108 #if 0 109 /* Reset I/O bus */ 110 plum_power_ioreset(sc->sc_pc); 111 #endif 112 /* Dump I/O port */ 113 if (0) { 114 bus_space_handle_t ioh; 115 int i; 116 bus_space_map(sc->sc_iot, 0, 0x400, 0, &ioh); 117 for(i = 0; i < 0x400; i += 4) { 118 printf("[%03x]%02x", i, bus_space_read_1(sc->sc_iot, ioh, i + 3)); 119 printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 2)); 120 printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 1)); 121 printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 0)); 122 } 123 bus_space_unmap(sc->sc_iot, ioh, 0x400); 124 } 125 126 iba.iba_busname = "isa"; 127 iba.iba_ic = sc; 128 /* Plum ISA-bus don't have memory space! */ 129 /* Plum ISA port space */ 130 iba.iba_iot = sc->sc_iot; 131 config_found(self, &iba, plumisabprint); 132 } 133 134 int 135 plumisabprint(void *aux, const char *pnp) 136 { 137 138 return (pnp ? QUIET : UNCONF); 139 } 140 141 void 142 isa_attach_hook(struct device *parent, struct device *self, 143 struct isabus_attach_args *iba) 144 { 145 146 } 147 148 void * 149 isa_intr_establish(isa_chipset_tag_t ic, int irq, int type, int level, 150 int (*ih_fun)(void *), void *ih_arg) 151 { 152 struct plumisab_softc *sc = (void*)ic; 153 154 sc->sc_ih = plum_intr_establish(sc->sc_pc, sc->sc_irq, type, level, 155 ih_fun, ih_arg); 156 return (sc->sc_ih); 157 } 158 159 void 160 isa_intr_disestablish(isa_chipset_tag_t ic, void *arg) 161 { 162 struct plumisab_softc *sc = (void*)ic; 163 164 plum_intr_disestablish(sc->sc_pc, arg); 165 } 166 167 int 168 isa_intr_alloc(isa_chipset_tag_t ic, int mask, int type, int *irq) 169 { 170 struct plumisab_softc *sc = (void*)ic; 171 172 *irq = sc->sc_irq; 173 174 return (0); 175 } 176