1 /* $OpenBSD: wax.c,v 1.11 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 #include <sys/param.h> 30 #include <sys/systm.h> 31 #include <sys/device.h> 32 #include <sys/reboot.h> 33 34 #include <machine/iomod.h> 35 #include <machine/autoconf.h> 36 37 #include <hppa/dev/cpudevs.h> 38 39 #include <hppa/gsc/gscbusvar.h> 40 41 #define WAX_IOMASK 0xfff00000 42 43 int waxmatch(struct device *, void *, void *); 44 void waxattach(struct device *, struct device *, void *); 45 void wax_gsc_attach(struct device *); 46 47 const struct cfattach wax_ca = { 48 sizeof(struct device), waxmatch, waxattach 49 }; 50 51 struct cfdriver wax_cd = { 52 NULL, "wax", DV_DULL 53 }; 54 55 int 56 waxmatch(parent, cfdata, aux) 57 struct device *parent; 58 void *cfdata; 59 void *aux; 60 { 61 struct confargs *ca = aux; 62 struct cfdata *cf = cfdata; 63 64 /* there will be only one */ 65 if (cf->cf_unit > 0 || 66 ca->ca_type.iodc_type != HPPA_TYPE_BHA || 67 ca->ca_type.iodc_sv_model != HPPA_BHA_WAX) 68 return 0; 69 70 return 1; 71 } 72 73 void 74 waxattach(parent, self, aux) 75 struct device *parent; 76 struct device *self; 77 void *aux; 78 { 79 struct confargs *ca = aux; 80 struct gsc_attach_args ga; 81 struct gscbus_ic *ic; 82 bus_space_handle_t ioh; 83 int s; 84 85 if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) { 86 printf(": can't map IO space\n"); 87 return; 88 } 89 90 printf("\n"); 91 92 /* interrupts guts */ 93 ic = (struct gscbus_ic *)ca->ca_hpa; 94 s = splhigh(); 95 ic->iar = 0; /* will be set up by gsc when attaching */ 96 ic->icr = 0; 97 ic->imr = ~0U; 98 (void)ic->irr; 99 ic->imr = 0; 100 splx(s); 101 102 ga.ga_ca = *ca; /* clone from us */ 103 if (!strcmp(parent->dv_xname, "mainbus0")) { 104 ga.ga_dp.dp_bc[0] = ga.ga_dp.dp_bc[1]; 105 ga.ga_dp.dp_bc[1] = ga.ga_dp.dp_bc[2]; 106 ga.ga_dp.dp_bc[2] = ga.ga_dp.dp_bc[3]; 107 ga.ga_dp.dp_bc[3] = ga.ga_dp.dp_bc[4]; 108 ga.ga_dp.dp_bc[4] = ga.ga_dp.dp_bc[5]; 109 ga.ga_dp.dp_bc[5] = ga.ga_dp.dp_mod; 110 ga.ga_dp.dp_mod = 0; 111 } 112 113 ga.ga_name = "gsc"; 114 ga.ga_hpamask = WAX_IOMASK; 115 ga.ga_parent = gsc_wax; 116 ga.ga_ic = ic; 117 118 config_found(self, &ga, gscprint); 119 } 120