imc.c revision 1.1 1 1.1 thorpej /* $NetBSD: imc.c,v 1.1 2001/05/11 04:22:55 thorpej Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*
4 1.1 thorpej * Copyright (c) 2001 Rafal K. Boni
5 1.1 thorpej * All rights reserved.
6 1.1 thorpej *
7 1.1 thorpej * Redistribution and use in source and binary forms, with or without
8 1.1 thorpej * modification, are permitted provided that the following conditions
9 1.1 thorpej * are met:
10 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
11 1.1 thorpej * notice, this list of conditions and the following disclaimer.
12 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
14 1.1 thorpej * documentation and/or other materials provided with the distribution.
15 1.1 thorpej * 3. The name of the author may not be used to endorse or promote products
16 1.1 thorpej * derived from this software without specific prior written permission.
17 1.1 thorpej *
18 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 1.1 thorpej * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.1 thorpej * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.1 thorpej * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 1.1 thorpej * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 1.1 thorpej * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 1.1 thorpej * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 1.1 thorpej * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 1.1 thorpej * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 1.1 thorpej * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 1.1 thorpej */
29 1.1 thorpej
30 1.1 thorpej #include <sys/param.h>
31 1.1 thorpej #include <sys/device.h>
32 1.1 thorpej #include <sys/systm.h>
33 1.1 thorpej
34 1.1 thorpej #include <machine/cpu.h>
35 1.1 thorpej #include <machine/locore.h>
36 1.1 thorpej #include <machine/autoconf.h>
37 1.1 thorpej #include <machine/bus.h>
38 1.1 thorpej
39 1.1 thorpej #include "locators.h"
40 1.1 thorpej
41 1.1 thorpej struct imc_softc {
42 1.1 thorpej struct device sc_dev;
43 1.1 thorpej
44 1.1 thorpej int eisa_present : 1;
45 1.1 thorpej };
46 1.1 thorpej
47 1.1 thorpej static int imc_match(struct device *, struct cfdata *, void *);
48 1.1 thorpej static void imc_attach(struct device *, struct device *, void *);
49 1.1 thorpej static int imc_print(void *, const char *);
50 1.1 thorpej
51 1.1 thorpej struct cfattach imc_ca = {
52 1.1 thorpej sizeof(struct imc_softc), imc_match, imc_attach
53 1.1 thorpej };
54 1.1 thorpej
55 1.1 thorpej struct imc_attach_args {
56 1.1 thorpej const char* iaa_name;
57 1.1 thorpej
58 1.1 thorpej bus_space_tag_t iaa_st;
59 1.1 thorpej bus_space_handle_t iaa_sh;
60 1.1 thorpej
61 1.1 thorpej /* ? */
62 1.1 thorpej long iaa_offset;
63 1.1 thorpej int iaa_intr;
64 1.1 thorpej #if 0
65 1.1 thorpej int iaa_stride;
66 1.1 thorpej #endif
67 1.1 thorpej };
68 1.1 thorpej
69 1.1 thorpej static int
70 1.1 thorpej imc_match(parent, match, aux)
71 1.1 thorpej struct device *parent;
72 1.1 thorpej struct cfdata *match;
73 1.1 thorpej void *aux;
74 1.1 thorpej {
75 1.1 thorpej struct mainbus_attach_args *ma = aux;
76 1.1 thorpej
77 1.1 thorpej /*
78 1.1 thorpej * The IMC is an INDY/INDIGO2 thing.
79 1.1 thorpej */
80 1.1 thorpej switch (ma->ma_arch) {
81 1.1 thorpej case 22:
82 1.1 thorpej /* Make sure it's actually there and readable */
83 1.1 thorpej if (badaddr((void*)MIPS_PHYS_TO_KSEG1(0x1fa0001c),
84 1.1 thorpej sizeof(u_int32_t)))
85 1.1 thorpej return 0;
86 1.1 thorpej
87 1.1 thorpej return 1;
88 1.1 thorpej default:
89 1.1 thorpej return 0;
90 1.1 thorpej }
91 1.1 thorpej }
92 1.1 thorpej
93 1.1 thorpej static void
94 1.1 thorpej imc_attach(parent, self, aux)
95 1.1 thorpej struct device *parent;
96 1.1 thorpej struct device *self;
97 1.1 thorpej void *aux;
98 1.1 thorpej {
99 1.1 thorpej u_int32_t reg;
100 1.1 thorpej struct imc_attach_args iaa;
101 1.1 thorpej struct imc_softc *isc = (void *) self;
102 1.1 thorpej u_int32_t sysid = *(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa0001c);
103 1.1 thorpej
104 1.1 thorpej isc->eisa_present = (sysid >> 4) & 1;
105 1.1 thorpej
106 1.1 thorpej printf("\nimc0: Revision %d", (sysid & 0x03));
107 1.1 thorpej
108 1.1 thorpej if (isc->eisa_present)
109 1.1 thorpej printf(", EISA bus present");
110 1.1 thorpej
111 1.1 thorpej printf("\n");
112 1.1 thorpej
113 1.1 thorpej /* Clear CPU/GIO error status registers to clear any leftover bits. */
114 1.1 thorpej *(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa000ec) = 0;
115 1.1 thorpej *(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa000fc) = 0;
116 1.1 thorpej
117 1.1 thorpej /*
118 1.1 thorpej * Enable parity reporting on memory/GIO accesses, turn off parity
119 1.1 thorpej * checking on CPU reads from memory (flags cribbed from Linux --
120 1.1 thorpej * why is the last one off?). Also, enable MC interrupt writes to
121 1.1 thorpej * the CPU.
122 1.1 thorpej */
123 1.1 thorpej reg = *(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa00004);
124 1.1 thorpej reg |= 0x4002060;
125 1.1 thorpej *(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa00004) = reg;
126 1.1 thorpej
127 1.1 thorpej /* Setup the MC write buffer depth */
128 1.1 thorpej reg = *(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa0000c);
129 1.1 thorpej reg &= ~0xf;
130 1.1 thorpej reg |= 0xd;
131 1.1 thorpej *(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa0000c) = reg;
132 1.1 thorpej
133 1.1 thorpej /* Set GIO64 arbitrator configuration register. */
134 1.1 thorpej
135 1.1 thorpej /* GIO64 invariant for all IP22 platforms: one GIO bus, HPC1 @ 64 */
136 1.1 thorpej reg = 0x401;
137 1.1 thorpej
138 1.1 thorpej /* XXXrkb: I2 setting for now */
139 1.1 thorpej reg |= 0xc222; /* GFX, HPC2 @ 64, EXP1,2 pipelined, EISA masters */
140 1.1 thorpej *(volatile u_int32_t *)MIPS_PHYS_TO_KSEG1(0x1fa00084) = reg;
141 1.1 thorpej
142 1.1 thorpej if (isc->eisa_present) {
143 1.1 thorpej #if notyet
144 1.1 thorpej memset(&iaa, 0, sizeof(iaa));
145 1.1 thorpej
146 1.1 thorpej iaa.iaa_name = "eisa";
147 1.1 thorpej (void)config_found(self, (void*)&iaa, imc_print);
148 1.1 thorpej #endif
149 1.1 thorpej }
150 1.1 thorpej
151 1.1 thorpej memset(&iaa, 0, sizeof(iaa));
152 1.1 thorpej
153 1.1 thorpej iaa.iaa_name = "gio";
154 1.1 thorpej (void)config_found(self, (void*)&iaa, imc_print);
155 1.1 thorpej }
156 1.1 thorpej
157 1.1 thorpej
158 1.1 thorpej static int
159 1.1 thorpej imc_print(aux, name)
160 1.1 thorpej void *aux;
161 1.1 thorpej const char *name;
162 1.1 thorpej {
163 1.1 thorpej struct imc_attach_args* iaa = aux;
164 1.1 thorpej
165 1.1 thorpej if (name)
166 1.1 thorpej printf("%s at %s", iaa->iaa_name, name);
167 1.1 thorpej
168 1.1 thorpej return UNCONF;
169 1.1 thorpej }
170 1.1 thorpej
171