asp.c revision 1.7
1/* $OpenBSD: asp.c,v 1.7 2002/04/22 01:48:37 mickey Exp $ */ 2 3/* 4 * Copyright (c) 1998,1999 Michael Shalayeff 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. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Michael Shalayeff. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF MIND, 27 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33/* 34 * References: 35 * 36 * 1. Cobra/Coral I/O Subsystem External Reference Specification 37 * Hewlett-Packard 38 * 39 */ 40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/device.h> 44#include <sys/reboot.h> 45 46#include <machine/bus.h> 47#include <machine/iomod.h> 48#include <machine/autoconf.h> 49#include <machine/cpufunc.h> 50 51#include <hppa/dev/cpudevs.h> 52#include <hppa/dev/viper.h> 53 54#include <hppa/gsc/gscbusvar.h> 55 56struct asp_hwr { 57 u_int8_t asp_reset; 58 u_int8_t asp_resv[31]; 59 u_int8_t asp_version; 60 u_int8_t asp_resv1[15]; 61 u_int8_t asp_scsidsync; 62 u_int8_t asp_resv2[15]; 63 u_int8_t asp_error; 64}; 65 66struct asp_trs { 67 u_int32_t asp_irr; 68 u_int32_t asp_imr; 69 u_int32_t asp_ipr; 70 u_int32_t asp_icr; 71 u_int32_t asp_iar; 72 u_int32_t asp_resv[3]; 73 u_int8_t asp_cled; 74 u_int8_t asp_resv1[3]; 75 struct { 76 u_int :20, 77 asp_spu : 3, /* SPU ID board jumper */ 78#define ASP_SPUCOBRA 0 79#define ASP_SPUCORAL 1 80#define ASP_SPUBUSH 2 81#define ASP_SPUHARDBALL 3 82#define ASP_SPUSCORPIO 4 83#define ASP_SPUCORAL2 5 84 asp_sw : 1, /* front switch is normal */ 85 asp_clk : 1, /* SCSI clock is doubled */ 86 asp_lan : 2, /* LAN iface selector */ 87#define ASP_LANINVAL 0 88#define ASP_LANAUI 1 89#define ASP_LANTHIN 2 90#define ASP_LANMISS 3 91 asp_lanf: 1, /* LAN AUI fuse is ok */ 92 asp_spwr: 1, /* SCSI power ok */ 93 asp_scsi: 3; /* SCSI ctrl ID */ 94 } _asp_ios; 95#define asp_spu _asp_ios.asp_spu 96#define asp_sw _asp_ios.asp_sw 97#define asp_clk _asp_ios.asp_clk 98#define asp_lan _asp_ios.asp_lan 99#define asp_lanf _asp_ios.asp_lanf 100#define asp_spwr _asp_ios.asp_spwr 101#define asp_scsi _asp_ios.asp_scsi 102}; 103 104const struct asp_spus_tag { 105 char name[12]; 106 int ledword; 107} asp_spus[] = { 108 { "Cobra", 0 }, 109 { "Coral", 0 }, 110 { "Bushmaster", 0 }, 111 { "Hardball", 1 }, 112 { "Scorpio", 0 }, 113 { "Coral II", 1 }, 114 { "#6", 0 }, 115 { "#7", 0 } 116}; 117 118struct asp_softc { 119 struct device sc_dev; 120 struct gscbus_ic sc_ic; 121 122 volatile struct asp_hwr *sc_hw; 123 volatile struct asp_trs *sc_trs; 124}; 125 126#define ASP_IOMASK 0xfff00000 127/* ASP "Primary Controller" HPA */ 128#define ASP_CHPA 0xF0800000 129 130int aspmatch(struct device *, void *, void *); 131void aspattach(struct device *, struct device *, void *); 132 133struct cfattach asp_ca = { 134 sizeof(struct asp_softc), aspmatch, aspattach 135}; 136 137struct cfdriver asp_cd = { 138 NULL, "asp", DV_DULL 139}; 140 141void asp_intr_establish(void *v, u_int32_t mask); 142void asp_intr_disestablish(void *v, u_int32_t mask); 143u_int32_t asp_intr_check(void *v); 144void asp_intr_ack(void *v, u_int32_t mask); 145 146int 147aspmatch(parent, cfdata, aux) 148 struct device *parent; 149 void *cfdata; 150 void *aux; 151{ 152 struct confargs *ca = aux; 153 /* struct cfdata *cf = cfdata; */ 154 155 if (ca->ca_type.iodc_type != HPPA_TYPE_BHA || 156 ca->ca_type.iodc_sv_model != HPPA_BHA_ASP) 157 return 0; 158 159 return 1; 160} 161 162void 163aspattach(parent, self, aux) 164 struct device *parent; 165 struct device *self; 166 void *aux; 167{ 168 register struct confargs *ca = aux; 169 register struct asp_softc *sc = (struct asp_softc *)self; 170 struct gsc_attach_args ga; 171 bus_space_handle_t ioh; 172 register u_int32_t irr; 173 register int s; 174 175 if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) { 176#ifdef DEBUG 177 printf("aspattach: can't map IO space\n"); 178#endif 179 return; 180 } 181 182 sc->sc_trs = (struct asp_trs *)ASP_CHPA; 183 sc->sc_hw = (struct asp_hwr *)ca->ca_hpa; 184 185 machine_ledaddr = &sc->sc_trs->asp_cled; 186 machine_ledword = asp_spus[sc->sc_trs->asp_spu].ledword; 187 188 /* reset ASP */ 189 /* sc->sc_hw->asp_reset = 1; */ 190 /* delay(400000); */ 191 192 s = splhigh(); 193 viper_setintrwnd(1 << ca->ca_irq); 194 195 sc->sc_trs->asp_imr = ~0; 196 irr = sc->sc_trs->asp_irr; 197 sc->sc_trs->asp_imr = 0; 198 splx(s); 199 200 printf (": %s rev %d, lan %d scsi %d\n", 201 asp_spus[sc->sc_trs->asp_spu].name, sc->sc_hw->asp_version, 202 sc->sc_trs->asp_lan, sc->sc_trs->asp_scsi); 203 204 sc->sc_ic.gsc_type = gsc_asp; 205 sc->sc_ic.gsc_dv = sc; 206 sc->sc_ic.gsc_intr_establish = asp_intr_establish; 207 sc->sc_ic.gsc_intr_disestablish = asp_intr_disestablish; 208 sc->sc_ic.gsc_intr_check = asp_intr_check; 209 sc->sc_ic.gsc_intr_ack = asp_intr_ack; 210 211 ga.ga_ca = *ca; /* clone from us */ 212 ga.ga_hpamask = ASP_IOMASK; 213 ga.ga_name = "gsc"; 214 ga.ga_ic = &sc->sc_ic; 215 config_found(self, &ga, gscprint); 216} 217 218void 219asp_intr_establish(v, mask) 220 void *v; 221 u_int32_t mask; 222{ 223 register struct asp_softc *sc = v; 224 225 sc->sc_trs->asp_imr |= mask; 226} 227 228void 229asp_intr_disestablish(v, mask) 230 void *v; 231 u_int32_t mask; 232{ 233 register struct asp_softc *sc = v; 234 235 sc->sc_trs->asp_imr &= ~mask; 236} 237 238u_int32_t 239asp_intr_check(v) 240 void *v; 241{ 242 register struct asp_softc *sc = v; 243 register u_int32_t irr, imr; 244 245 imr = sc->sc_trs->asp_imr; 246 irr = sc->sc_trs->asp_irr; 247 sc->sc_trs->asp_imr = imr & ~irr; 248 249 return irr; 250} 251 252void 253asp_intr_ack(v, mask) 254 void *v; 255 u_int32_t mask; 256{ 257 register struct asp_softc *sc = v; 258 259 sc->sc_trs->asp_imr |= mask; 260} 261