1 /* $NetBSD: plumisa_machdep.c,v 1.5 2002/10/02 05:26:49 thorpej 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 CFATTACH_DECL(plumisab, sizeof(struct plumisab_softc), 70 plumisabmatch, plumisabattach, NULL, NULL); 71 72 int 73 plumisabmatch(struct device *parent, struct cfdata *match, void *aux) 74 { 75 struct plumiobus_attach_args *pba = aux; 76 platid_mask_t mask; 77 78 if (strcmp(pba->pba_busname, match->cf_name)) { 79 return (0); 80 } 81 82 if (match->cf_loc[PLUMIOBUSIFCF_PLATFORM] == 83 PLUMIOBUSIFCF_PLATFORM_DEFAULT) { 84 return (1); 85 } 86 87 mask = PLATID_DEREF(match->cf_loc[PLUMIOBUSIFCF_PLATFORM]); 88 if (platid_match(&platid, &mask)) { 89 return (2); 90 } 91 92 return (0); 93 } 94 95 void 96 plumisabattach(struct device *parent, struct device *self, void *aux) 97 { 98 struct plumiobus_attach_args *pba = aux; 99 struct plumisab_softc *sc = (void*)self; 100 struct isabus_attach_args iba; 101 102 printf("\n"); 103 sc->sc_pc = pba->pba_pc; 104 sc->sc_iot = pba->pba_iot; 105 sc->sc_irq = pba->pba_irq; 106 printf(" base=%#x irq=%d\n", sc->sc_iot->t_base, sc->sc_irq); 107 #if 0 108 /* Reset I/O bus */ 109 plum_power_ioreset(sc->sc_pc); 110 #endif 111 /* Dump I/O port */ 112 if (0) { 113 bus_space_handle_t ioh; 114 int i; 115 bus_space_map(sc->sc_iot, 0, 0x400, 0, &ioh); 116 for(i = 0; i < 0x400; i += 4) { 117 printf("[%03x]%02x", i, bus_space_read_1(sc->sc_iot, ioh, i + 3)); 118 printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 2)); 119 printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 1)); 120 printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 0)); 121 } 122 bus_space_unmap(sc->sc_iot, ioh, 0x400); 123 } 124 125 iba.iba_busname = "isa"; 126 iba.iba_ic = sc; 127 /* Plum ISA-bus don't have memory space! */ 128 /* Plum ISA port space */ 129 iba.iba_iot = sc->sc_iot; 130 config_found(self, &iba, plumisabprint); 131 } 132 133 int 134 plumisabprint(void *aux, const char *pnp) 135 { 136 137 return (pnp ? QUIET : UNCONF); 138 } 139 140 void 141 isa_attach_hook(struct device *parent, struct device *self, 142 struct isabus_attach_args *iba) 143 { 144 145 } 146 147 void * 148 isa_intr_establish(isa_chipset_tag_t ic, int irq, int type, int level, 149 int (*ih_fun)(void *), void *ih_arg) 150 { 151 struct plumisab_softc *sc = (void*)ic; 152 153 sc->sc_ih = plum_intr_establish(sc->sc_pc, sc->sc_irq, type, level, 154 ih_fun, ih_arg); 155 return (sc->sc_ih); 156 } 157 158 void 159 isa_intr_disestablish(isa_chipset_tag_t ic, void *arg) 160 { 161 struct plumisab_softc *sc = (void*)ic; 162 163 plum_intr_disestablish(sc->sc_pc, arg); 164 } 165 166 int 167 isa_intr_alloc(isa_chipset_tag_t ic, int mask, int type, int *irq) 168 { 169 struct plumisab_softc *sc = (void*)ic; 170 171 *irq = sc->sc_irq; 172 173 return (0); 174 } 175