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