1 /* $OpenBSD: asp.c,v 1.10 2003/02/18 09:40:40 miod Exp $ */ 2 3 /* 4 * Copyright (c) 1998-2002 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 56 struct 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 66 struct 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 104 const 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 118 struct 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 130 int aspmatch(struct device *, void *, void *); 131 void aspattach(struct device *, struct device *, void *); 132 133 struct cfattach asp_ca = { 134 sizeof(struct asp_softc), aspmatch, aspattach 135 }; 136 137 struct cfdriver asp_cd = { 138 NULL, "asp", DV_DULL 139 }; 140 141 int 142 aspmatch(parent, cfdata, aux) 143 struct device *parent; 144 void *cfdata; 145 void *aux; 146 { 147 struct confargs *ca = aux; 148 /* struct cfdata *cf = cfdata; */ 149 150 if (ca->ca_type.iodc_type != HPPA_TYPE_BHA || 151 ca->ca_type.iodc_sv_model != HPPA_BHA_ASP) 152 return 0; 153 154 return 1; 155 } 156 157 void 158 aspattach(parent, self, aux) 159 struct device *parent; 160 struct device *self; 161 void *aux; 162 { 163 register struct confargs *ca = aux; 164 register struct asp_softc *sc = (struct asp_softc *)self; 165 struct gsc_attach_args ga; 166 bus_space_handle_t ioh; 167 register u_int32_t irr; 168 register int s; 169 170 if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) { 171 #ifdef DEBUG 172 printf("aspattach: can't map IO space\n"); 173 #endif 174 return; 175 } 176 177 sc->sc_trs = (struct asp_trs *)ASP_CHPA; 178 sc->sc_hw = (struct asp_hwr *)ca->ca_hpa; 179 180 #ifdef USELEDS 181 machine_ledaddr = &sc->sc_trs->asp_cled; 182 machine_ledword = asp_spus[sc->sc_trs->asp_spu].ledword; 183 #endif 184 185 /* reset ASP */ 186 /* sc->sc_hw->asp_reset = 1; */ 187 /* delay(400000); */ 188 189 s = splhigh(); 190 viper_setintrwnd(1 << ca->ca_irq); 191 192 sc->sc_trs->asp_imr = ~0; 193 irr = sc->sc_trs->asp_irr; 194 sc->sc_trs->asp_imr = 0; 195 splx(s); 196 197 printf (": %s rev %d, lan %d scsi %d\n", 198 asp_spus[sc->sc_trs->asp_spu].name, sc->sc_hw->asp_version, 199 sc->sc_trs->asp_lan, sc->sc_trs->asp_scsi); 200 201 sc->sc_ic.gsc_type = gsc_asp; 202 sc->sc_ic.gsc_dv = sc; 203 sc->sc_ic.gsc_base = sc->sc_trs; 204 205 ga.ga_ca = *ca; /* clone from us */ 206 ga.ga_dp.dp_bc[0] = ga.ga_dp.dp_bc[1]; 207 ga.ga_dp.dp_bc[1] = ga.ga_dp.dp_bc[2]; 208 ga.ga_dp.dp_bc[2] = ga.ga_dp.dp_bc[3]; 209 ga.ga_dp.dp_bc[3] = ga.ga_dp.dp_bc[4]; 210 ga.ga_dp.dp_bc[4] = ga.ga_dp.dp_bc[5]; 211 ga.ga_dp.dp_bc[5] = ga.ga_dp.dp_mod; 212 ga.ga_dp.dp_mod = 0; 213 ga.ga_hpamask = ASP_IOMASK; 214 ga.ga_name = "gsc"; 215 ga.ga_ic = &sc->sc_ic; 216 config_found(self, &ga, gscprint); 217 } 218