tx39biu.c revision 1.3.2.2 1 1.3.2.2 wrstuden /* $NetBSD: tx39biu.c,v 1.3.2.2 1999/12/27 18:32:11 wrstuden Exp $ */
2 1.3.2.2 wrstuden
3 1.3.2.2 wrstuden /*
4 1.3.2.2 wrstuden * Copyright (c) 1999, by UCHIYAMA Yasushi
5 1.3.2.2 wrstuden * All rights reserved.
6 1.3.2.2 wrstuden *
7 1.3.2.2 wrstuden * Redistribution and use in source and binary forms, with or without
8 1.3.2.2 wrstuden * modification, are permitted provided that the following conditions
9 1.3.2.2 wrstuden * are met:
10 1.3.2.2 wrstuden * 1. Redistributions of source code must retain the above copyright
11 1.3.2.2 wrstuden * notice, this list of conditions and the following disclaimer.
12 1.3.2.2 wrstuden * 2. The name of the developer may NOT be used to endorse or promote products
13 1.3.2.2 wrstuden * derived from this software without specific prior written permission.
14 1.3.2.2 wrstuden *
15 1.3.2.2 wrstuden * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 1.3.2.2 wrstuden * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 1.3.2.2 wrstuden * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 1.3.2.2 wrstuden * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 1.3.2.2 wrstuden * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 1.3.2.2 wrstuden * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 1.3.2.2 wrstuden * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 1.3.2.2 wrstuden * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 1.3.2.2 wrstuden * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 1.3.2.2 wrstuden * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 1.3.2.2 wrstuden * SUCH DAMAGE.
26 1.3.2.2 wrstuden *
27 1.3.2.2 wrstuden */
28 1.3.2.2 wrstuden #include "opt_tx39_debug.h"
29 1.3.2.2 wrstuden #include "opt_tx39_watchdogtimer.h"
30 1.3.2.2 wrstuden #include "opt_tx39biudebug.h"
31 1.3.2.2 wrstuden
32 1.3.2.2 wrstuden #include <sys/param.h>
33 1.3.2.2 wrstuden #include <sys/systm.h>
34 1.3.2.2 wrstuden #include <sys/device.h>
35 1.3.2.2 wrstuden
36 1.3.2.2 wrstuden #include <machine/bus.h>
37 1.3.2.2 wrstuden
38 1.3.2.2 wrstuden #include <hpcmips/tx/tx39var.h>
39 1.3.2.2 wrstuden #include <hpcmips/tx/tx39biureg.h>
40 1.3.2.2 wrstuden
41 1.3.2.2 wrstuden #include <hpcmips/tx/txcsbusvar.h>
42 1.3.2.2 wrstuden
43 1.3.2.2 wrstuden #define ISSET(x, s) ((x) & (1 << (s)))
44 1.3.2.2 wrstuden #define ISSETPRINT(r, s, m) __is_set_print((u_int32_t)(r), \
45 1.3.2.2 wrstuden TX39_MEMCONFIG##s##_##m, #m)
46 1.3.2.2 wrstuden
47 1.3.2.2 wrstuden int tx39biu_match __P((struct device*, struct cfdata*, void*));
48 1.3.2.2 wrstuden void tx39biu_attach __P((struct device*, struct device*, void*));
49 1.3.2.2 wrstuden void tx39biu_callback __P((struct device*));
50 1.3.2.2 wrstuden int tx39biu_print __P((void*, const char*));
51 1.3.2.2 wrstuden int tx39biu_intr __P((void*));
52 1.3.2.2 wrstuden
53 1.3.2.2 wrstuden static void *__sc; /* XXX */
54 1.3.2.2 wrstuden
55 1.3.2.2 wrstuden void tx39biu_dump __P((tx_chipset_tag_t));
56 1.3.2.2 wrstuden
57 1.3.2.2 wrstuden struct tx39biu_softc {
58 1.3.2.2 wrstuden struct device sc_dev;
59 1.3.2.2 wrstuden tx_chipset_tag_t sc_tc;
60 1.3.2.2 wrstuden };
61 1.3.2.2 wrstuden
62 1.3.2.2 wrstuden struct cfattach tx39biu_ca = {
63 1.3.2.2 wrstuden sizeof(struct tx39biu_softc), tx39biu_match, tx39biu_attach
64 1.3.2.2 wrstuden };
65 1.3.2.2 wrstuden
66 1.3.2.2 wrstuden int
67 1.3.2.2 wrstuden tx39biu_match(parent, cf, aux)
68 1.3.2.2 wrstuden struct device *parent;
69 1.3.2.2 wrstuden struct cfdata *cf;
70 1.3.2.2 wrstuden void *aux;
71 1.3.2.2 wrstuden {
72 1.3.2.2 wrstuden return 1;
73 1.3.2.2 wrstuden }
74 1.3.2.2 wrstuden
75 1.3.2.2 wrstuden void
76 1.3.2.2 wrstuden tx39biu_attach(parent, self, aux)
77 1.3.2.2 wrstuden struct device *parent;
78 1.3.2.2 wrstuden struct device *self;
79 1.3.2.2 wrstuden void *aux;
80 1.3.2.2 wrstuden {
81 1.3.2.2 wrstuden struct txsim_attach_args *ta = aux;
82 1.3.2.2 wrstuden struct tx39biu_softc *sc = (void*)self;
83 1.3.2.2 wrstuden tx_chipset_tag_t tc;
84 1.3.2.2 wrstuden #ifdef TX39_WATCHDOGTIMER
85 1.3.2.2 wrstuden txreg_t reg;
86 1.3.2.2 wrstuden #endif
87 1.3.2.2 wrstuden
88 1.3.2.2 wrstuden sc->sc_tc = tc = ta->ta_tc;
89 1.3.2.2 wrstuden printf("\n");
90 1.3.2.2 wrstuden #ifdef TX39BIUDEBUG
91 1.3.2.2 wrstuden tx39biu_dump(tc);
92 1.3.2.2 wrstuden #endif
93 1.3.2.2 wrstuden
94 1.3.2.2 wrstuden #ifdef TX39_WATCHDOGTIMER
95 1.3.2.2 wrstuden /*
96 1.3.2.2 wrstuden * CLRWRBUSERRINT Bus error connected CPU HwInt0
97 1.3.2.2 wrstuden */
98 1.3.2.2 wrstuden reg = tx_conf_read(tc, TX39_MEMCONFIG4_REG);
99 1.3.2.2 wrstuden reg |= TX39_MEMCONFIG4_ENWATCH;
100 1.3.2.2 wrstuden reg = TX39_MEMCONFIG4_WATCHTIMEVAL_SET(reg, 0xf);
101 1.3.2.2 wrstuden tx_conf_write(tc, TX39_MEMCONFIG4_REG, reg);
102 1.3.2.2 wrstuden
103 1.3.2.2 wrstuden reg = tx_conf_read(tc, TX39_MEMCONFIG4_REG);
104 1.3.2.2 wrstuden if (reg & TX39_MEMCONFIG4_ENWATCH) {
105 1.3.2.2 wrstuden int i;
106 1.3.2.2 wrstuden i = TX39_MEMCONFIG4_WATCHTIMEVAL(reg);
107 1.3.2.2 wrstuden i = (1000 * (i + 1) * 64) / 36864;
108 1.3.2.2 wrstuden printf("WatchDogTimerRate: %dus\n", i);
109 1.3.2.2 wrstuden }
110 1.3.2.2 wrstuden #endif
111 1.3.2.2 wrstuden __sc = sc;
112 1.3.2.2 wrstuden
113 1.3.2.2 wrstuden /* Clear watch dog timer interrupt */
114 1.3.2.2 wrstuden tx39biu_intr(sc);
115 1.3.2.2 wrstuden
116 1.3.2.2 wrstuden /*
117 1.3.2.2 wrstuden * Chip select virtual bridge
118 1.3.2.2 wrstuden */
119 1.3.2.2 wrstuden config_defer(self, tx39biu_callback);
120 1.3.2.2 wrstuden }
121 1.3.2.2 wrstuden
122 1.3.2.2 wrstuden void
123 1.3.2.2 wrstuden tx39biu_callback(self)
124 1.3.2.2 wrstuden struct device *self;
125 1.3.2.2 wrstuden {
126 1.3.2.2 wrstuden struct tx39biu_softc *sc = (void*)self;
127 1.3.2.2 wrstuden struct csbus_attach_args cba;
128 1.3.2.2 wrstuden
129 1.3.2.2 wrstuden cba.cba_busname = "txcsbus";
130 1.3.2.2 wrstuden cba.cba_tc = sc->sc_tc;
131 1.3.2.2 wrstuden config_found(self, &cba, tx39biu_print);
132 1.3.2.2 wrstuden }
133 1.3.2.2 wrstuden
134 1.3.2.2 wrstuden int
135 1.3.2.2 wrstuden tx39biu_print(aux, pnp)
136 1.3.2.2 wrstuden void *aux;
137 1.3.2.2 wrstuden const char *pnp;
138 1.3.2.2 wrstuden {
139 1.3.2.2 wrstuden return pnp ? QUIET : UNCONF;
140 1.3.2.2 wrstuden }
141 1.3.2.2 wrstuden
142 1.3.2.2 wrstuden int
143 1.3.2.2 wrstuden tx39biu_intr(arg)
144 1.3.2.2 wrstuden void *arg;
145 1.3.2.2 wrstuden {
146 1.3.2.2 wrstuden struct tx39biu_softc *sc = __sc;
147 1.3.2.2 wrstuden tx_chipset_tag_t tc;
148 1.3.2.2 wrstuden txreg_t reg;
149 1.3.2.2 wrstuden
150 1.3.2.2 wrstuden if (!sc) {
151 1.3.2.2 wrstuden return 0;
152 1.3.2.2 wrstuden }
153 1.3.2.2 wrstuden tc = sc->sc_tc;
154 1.3.2.2 wrstuden /* Clear interrupt */
155 1.3.2.2 wrstuden reg = tx_conf_read(tc, TX39_MEMCONFIG4_REG);
156 1.3.2.2 wrstuden reg |= TX39_MEMCONFIG4_CLRWRBUSERRINT;
157 1.3.2.2 wrstuden tx_conf_write(tc, TX39_MEMCONFIG4_REG, reg);
158 1.3.2.2 wrstuden reg = tx_conf_read(tc, TX39_MEMCONFIG4_REG);
159 1.3.2.2 wrstuden reg &= ~TX39_MEMCONFIG4_CLRWRBUSERRINT;
160 1.3.2.2 wrstuden tx_conf_write(tc, TX39_MEMCONFIG4_REG, reg);
161 1.3.2.2 wrstuden
162 1.3.2.2 wrstuden return 0;
163 1.3.2.2 wrstuden }
164 1.3.2.2 wrstuden
165 1.3.2.2 wrstuden void
166 1.3.2.2 wrstuden tx39biu_dump(tc)
167 1.3.2.2 wrstuden tx_chipset_tag_t tc;
168 1.3.2.2 wrstuden {
169 1.3.2.2 wrstuden char *rowsel[] = {"18,17:9", "22,18,20,19,17:9", "20,22,21,19,17:9", "22,23,21,19,17:9"};
170 1.3.2.2 wrstuden char *colsel[] = {"22,20,18,8:1", "19,18,8:2", "21,20,18,8:2", "23,22,20,18,8:2",
171 1.3.2.2 wrstuden "24,22,20,18,8:2", "18,p,X,8:0","22,p,X,21,8:0", "18,p,X,21,8:1",
172 1.3.2.2 wrstuden "22,p,X,23,21,8:1", "24,23,21,8:2"};
173 1.3.2.2 wrstuden txreg_t reg;
174 1.3.2.2 wrstuden int i;
175 1.3.2.2 wrstuden /*
176 1.3.2.2 wrstuden * Memory config 0 register
177 1.3.2.2 wrstuden */
178 1.3.2.2 wrstuden reg = tx_conf_read(tc, TX39_MEMCONFIG0_REG);
179 1.3.2.2 wrstuden printf(" config0:");
180 1.3.2.2 wrstuden ISSETPRINT(reg, 0, ENDCLKOUTTRI);
181 1.3.2.2 wrstuden ISSETPRINT(reg, 0, DISDQMINIT);
182 1.3.2.2 wrstuden ISSETPRINT(reg, 0, ENSDRAMPD);
183 1.3.2.2 wrstuden ISSETPRINT(reg, 0, SHOWDINO);
184 1.3.2.2 wrstuden ISSETPRINT(reg, 0, ENRMAP2);
185 1.3.2.2 wrstuden ISSETPRINT(reg, 0, ENRMAP1);
186 1.3.2.2 wrstuden ISSETPRINT(reg, 0, ENWRINPAGE);
187 1.3.2.2 wrstuden ISSETPRINT(reg, 0, ENCS3USER);
188 1.3.2.2 wrstuden ISSETPRINT(reg, 0, ENCS2USER);
189 1.3.2.2 wrstuden ISSETPRINT(reg, 0, ENCS1USER);
190 1.3.2.2 wrstuden ISSETPRINT(reg, 0, ENCS1DRAM);
191 1.3.2.2 wrstuden ISSETPRINT(reg, 0, CS3SIZE);
192 1.3.2.2 wrstuden ISSETPRINT(reg, 0, CS2SIZE);
193 1.3.2.2 wrstuden ISSETPRINT(reg, 0, CS1SIZE);
194 1.3.2.2 wrstuden ISSETPRINT(reg, 0, CS0SIZE);
195 1.3.2.2 wrstuden printf("\n");
196 1.3.2.2 wrstuden for (i = 0; i < 2; i++) {
197 1.3.2.2 wrstuden int r, c;
198 1.3.2.2 wrstuden printf(" BANK%d: ", i);
199 1.3.2.2 wrstuden switch (i ? TX39_MEMCONFIG0_BANK1CONF(reg)
200 1.3.2.2 wrstuden : TX39_MEMCONFIG0_BANK0CONF(reg)) {
201 1.3.2.2 wrstuden case TX39_MEMCONFIG0_BANKCONF_16BITSDRAM:
202 1.3.2.2 wrstuden printf("16bit SDRAM");
203 1.3.2.2 wrstuden break;
204 1.3.2.2 wrstuden case TX39_MEMCONFIG0_BANKCONF_8BITSDRAM:
205 1.3.2.2 wrstuden printf("8bit SDRAM");
206 1.3.2.2 wrstuden break;
207 1.3.2.2 wrstuden case TX39_MEMCONFIG0_BANKCONF_32BITSDHDRAM:
208 1.3.2.2 wrstuden printf("32bit DRAM/HDRAM");
209 1.3.2.2 wrstuden break;
210 1.3.2.2 wrstuden case TX39_MEMCONFIG0_BANKCONF_16BITSDHDRAM:
211 1.3.2.2 wrstuden printf("16bit DRAM/HDRAM");
212 1.3.2.2 wrstuden break;
213 1.3.2.2 wrstuden }
214 1.3.2.2 wrstuden if (i == 1) {
215 1.3.2.2 wrstuden r = TX39_MEMCONFIG0_ROWSEL1(reg);
216 1.3.2.2 wrstuden c = TX39_MEMCONFIG0_COLSEL1(reg);
217 1.3.2.2 wrstuden } else {
218 1.3.2.2 wrstuden r = TX39_MEMCONFIG0_ROWSEL0(reg);
219 1.3.2.2 wrstuden c = TX39_MEMCONFIG0_COLSEL0(reg);
220 1.3.2.2 wrstuden }
221 1.3.2.2 wrstuden printf(" ROW %s COL %s\n", rowsel[r], colsel[c]);
222 1.3.2.2 wrstuden }
223 1.3.2.2 wrstuden
224 1.3.2.2 wrstuden /*
225 1.3.2.2 wrstuden * Memory config 3 register
226 1.3.2.2 wrstuden */
227 1.3.2.2 wrstuden printf(" config3:");
228 1.3.2.2 wrstuden reg = tx_conf_read(tc, TX39_MEMCONFIG3_REG);
229 1.3.2.2 wrstuden #ifdef TX391X
230 1.3.2.2 wrstuden ISSETPRINT(reg, 3, ENMCS3PAGE);
231 1.3.2.2 wrstuden ISSETPRINT(reg, 3, ENMCS2PAGE);
232 1.3.2.2 wrstuden ISSETPRINT(reg, 3, ENMCS1PAGE);
233 1.3.2.2 wrstuden ISSETPRINT(reg, 3, ENMCS0PAGE);
234 1.3.2.2 wrstuden #endif /* TX391X */
235 1.3.2.2 wrstuden ISSETPRINT(reg, 3, ENCS3PAGE);
236 1.3.2.2 wrstuden ISSETPRINT(reg, 3, ENCS2PAGE);
237 1.3.2.2 wrstuden ISSETPRINT(reg, 3, ENCS1PAGE);
238 1.3.2.2 wrstuden ISSETPRINT(reg, 3, ENCS0PAGE);
239 1.3.2.2 wrstuden ISSETPRINT(reg, 3, CARD2WAITEN);
240 1.3.2.2 wrstuden ISSETPRINT(reg, 3, CARD1WAITEN);
241 1.3.2.2 wrstuden ISSETPRINT(reg, 3, CARD2IOEN);
242 1.3.2.2 wrstuden ISSETPRINT(reg, 3, CARD1IOEN);
243 1.3.2.2 wrstuden #ifdef TX391X
244 1.3.2.2 wrstuden ISSETPRINT(reg, 3, PORT8SEL);
245 1.3.2.2 wrstuden #endif /* TX391X */
246 1.3.2.2 wrstuden #ifdef TX392X
247 1.3.2.2 wrstuden ISSETPRINT(reg, 3, CARD2_8SEL);
248 1.3.2.2 wrstuden ISSETPRINT(reg, 3, CARD1_8SEL);
249 1.3.2.2 wrstuden #endif /* TX392X */
250 1.3.2.2 wrstuden
251 1.3.2.2 wrstuden printf("\n");
252 1.3.2.2 wrstuden
253 1.3.2.2 wrstuden /*
254 1.3.2.2 wrstuden * Memory config 4 register
255 1.3.2.2 wrstuden */
256 1.3.2.2 wrstuden reg = tx_conf_read(tc, TX39_MEMCONFIG4_REG);
257 1.3.2.2 wrstuden printf(" config4:");
258 1.3.2.2 wrstuden ISSETPRINT(reg, 4, ENBANK1HDRAM);
259 1.3.2.2 wrstuden ISSETPRINT(reg, 4, ENBANK0HDRAM);
260 1.3.2.2 wrstuden ISSETPRINT(reg, 4, ENARB);
261 1.3.2.2 wrstuden ISSETPRINT(reg, 4, DISSNOOP);
262 1.3.2.2 wrstuden ISSETPRINT(reg, 4, CLRWRBUSERRINT);
263 1.3.2.2 wrstuden ISSETPRINT(reg, 4, ENBANK1OPT);
264 1.3.2.2 wrstuden ISSETPRINT(reg, 4, ENBANK0OPT);
265 1.3.2.2 wrstuden ISSETPRINT(reg, 4, ENWATCH);
266 1.3.2.2 wrstuden ISSETPRINT(reg, 4, MEMPOWERDOWN);
267 1.3.2.2 wrstuden ISSETPRINT(reg, 4, ENRFSH1);
268 1.3.2.2 wrstuden ISSETPRINT(reg, 4, ENRFSH0);
269 1.3.2.2 wrstuden if (reg & TX39_MEMCONFIG4_ENWATCH) {
270 1.3.2.2 wrstuden i = TX39_MEMCONFIG4_WATCHTIMEVAL(reg);
271 1.3.2.2 wrstuden i = (1000 * (i + 1) * 64) / 36864;
272 1.3.2.2 wrstuden printf("WatchDogTimerRate: %dus", i);
273 1.3.2.2 wrstuden }
274 1.3.2.2 wrstuden printf("\n");
275 1.3.2.2 wrstuden }
276 1.3.2.2 wrstuden
277