1 /* $OpenBSD: asp.c,v 1.15 2018/05/14 13:54:39 kettenis Exp $ */ 2 3 /* 4 * Copyright (c) 1998-2003 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 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, 20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 25 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 * THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /* 30 * References: 31 * 32 * 1. Cobra/Coral I/O Subsystem External Reference Specification 33 * Hewlett-Packard 34 * 35 */ 36 37 #include <sys/param.h> 38 #include <sys/systm.h> 39 #include <sys/device.h> 40 #include <sys/reboot.h> 41 42 #include <machine/bus.h> 43 #include <machine/iomod.h> 44 #include <machine/autoconf.h> 45 #include <machine/cpufunc.h> 46 47 #include <hppa/dev/cpudevs.h> 48 49 #include <hppa/gsc/gscbusvar.h> 50 51 struct asp_hwr { 52 u_int8_t asp_reset; 53 u_int8_t asp_resv[31]; 54 u_int8_t asp_version; 55 u_int8_t asp_resv1[15]; 56 u_int8_t asp_scsidsync; 57 u_int8_t asp_resv2[15]; 58 u_int8_t asp_error; 59 }; 60 61 struct asp_trs { 62 struct gscbus_ic asp_ic; 63 u_int8_t asp_cled; 64 u_int8_t asp_resv[3]; 65 struct { 66 u_int :20, 67 asp_spu : 3, /* SPU ID board jumper */ 68 #define ASP_SPUCOBRA 0 69 #define ASP_SPUCORAL 1 70 #define ASP_SPUBUSH 2 71 #define ASP_SPUHARDBALL 3 72 #define ASP_SPUSCORPIO 4 73 #define ASP_SPUCORAL2 5 74 asp_sw : 1, /* front switch is normal */ 75 asp_clk : 1, /* SCSI clock is doubled */ 76 asp_lan : 2, /* LAN iface selector */ 77 #define ASP_LANINVAL 0 78 #define ASP_LANAUI 1 79 #define ASP_LANTHIN 2 80 #define ASP_LANMISS 3 81 asp_lanf: 1, /* LAN AUI fuse is ok */ 82 asp_spwr: 1, /* SCSI power ok */ 83 asp_scsi: 3; /* SCSI ctrl ID */ 84 } _asp_ios; 85 #define asp_spu _asp_ios.asp_spu 86 #define asp_sw _asp_ios.asp_sw 87 #define asp_clk _asp_ios.asp_clk 88 #define asp_lan _asp_ios.asp_lan 89 #define asp_lanf _asp_ios.asp_lanf 90 #define asp_spwr _asp_ios.asp_spwr 91 #define asp_scsi _asp_ios.asp_scsi 92 }; 93 94 const struct asp_spus_tag { 95 char name[12]; 96 int ledword; 97 } asp_spus[] = { 98 { "Cobra", 0 }, 99 { "Coral", 0 }, 100 { "Bushmaster", 0 }, 101 { "Hardball", 1 }, 102 { "Scorpio", 0 }, 103 { "Coral II", 1 }, 104 { "#6", 0 }, 105 { "#7", 0 } 106 }; 107 108 #define ASP_IOMASK 0xfe000000 109 /* ASP "Primary Controller" HPA */ 110 #define ASP_CHPA 0xF0800000 111 112 int aspmatch(struct device *, void *, void *); 113 void aspattach(struct device *, struct device *, void *); 114 115 const struct cfattach asp_ca = { 116 sizeof(struct device), aspmatch, aspattach 117 }; 118 119 struct cfdriver asp_cd = { 120 NULL, "asp", DV_DULL 121 }; 122 123 int 124 aspmatch(parent, cfdata, aux) 125 struct device *parent; 126 void *cfdata; 127 void *aux; 128 { 129 struct confargs *ca = aux; 130 /* struct cfdata *cf = cfdata; */ 131 132 if (ca->ca_type.iodc_type != HPPA_TYPE_BHA || 133 ca->ca_type.iodc_sv_model != HPPA_BHA_ASP) 134 return 0; 135 136 return 1; 137 } 138 139 void 140 aspattach(parent, self, aux) 141 struct device *parent; 142 struct device *self; 143 void *aux; 144 { 145 struct confargs *ca = aux; 146 volatile struct asp_trs *trs; 147 volatile struct asp_hwr *hw; 148 struct gscbus_ic *ic; 149 struct gsc_attach_args ga; 150 bus_space_handle_t ioh; 151 int s; 152 153 if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) { 154 printf(": can't map IO space\n"); 155 return; 156 } 157 158 hw = (struct asp_hwr *)ca->ca_hpa; 159 trs = (struct asp_trs *)ASP_CHPA; 160 ic = (struct gscbus_ic *)&trs->asp_ic; 161 162 #ifdef USELEDS 163 machine_ledaddr = &trs->asp_cled; 164 machine_ledword = asp_spus[trs->asp_spu].ledword; 165 #endif 166 167 /* reset ASP */ 168 /* hw->asp_reset = 1; */ 169 /* delay(400000); */ 170 171 s = splhigh(); 172 ic->imr = ~0; 173 (void)ic->irr; 174 ic->imr = 0; 175 splx(s); 176 177 printf (": %s rev %d, lan %d scsi %d\n", 178 asp_spus[trs->asp_spu].name, hw->asp_version, 179 trs->asp_lan, trs->asp_scsi); 180 181 ga.ga_ca = *ca; /* clone from us */ 182 ga.ga_dp.dp_bc[0] = ga.ga_dp.dp_bc[1]; 183 ga.ga_dp.dp_bc[1] = ga.ga_dp.dp_bc[2]; 184 ga.ga_dp.dp_bc[2] = ga.ga_dp.dp_bc[3]; 185 ga.ga_dp.dp_bc[3] = ga.ga_dp.dp_bc[4]; 186 ga.ga_dp.dp_bc[4] = ga.ga_dp.dp_bc[5]; 187 ga.ga_dp.dp_bc[5] = ga.ga_dp.dp_mod; 188 ga.ga_dp.dp_mod = 0; 189 ga.ga_hpamask = ASP_IOMASK; 190 ga.ga_name = "gsc"; 191 ga.ga_parent = gsc_asp; 192 ga.ga_ic = ic; 193 config_found(self, &ga, gscprint); 194 } 195