1 1.6 martin /* -*-C++-*- $NetBSD: sh3_dev.cpp,v 1.6 2008/04/28 20:23:20 martin Exp $ */ 2 1.1 uch 3 1.1 uch /*- 4 1.1 uch * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. 5 1.1 uch * All rights reserved. 6 1.1 uch * 7 1.1 uch * This code is derived from software contributed to The NetBSD Foundation 8 1.1 uch * by UCHIYAMA Yasushi. 9 1.1 uch * 10 1.1 uch * Redistribution and use in source and binary forms, with or without 11 1.1 uch * modification, are permitted provided that the following conditions 12 1.1 uch * are met: 13 1.1 uch * 1. Redistributions of source code must retain the above copyright 14 1.1 uch * notice, this list of conditions and the following disclaimer. 15 1.1 uch * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 uch * notice, this list of conditions and the following disclaimer in the 17 1.1 uch * documentation and/or other materials provided with the distribution. 18 1.1 uch * 19 1.1 uch * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 uch * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 uch * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.1 uch * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.1 uch * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 uch * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 uch * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 uch * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 uch * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 uch * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 uch * POSSIBILITY OF SUCH DAMAGE. 30 1.1 uch */ 31 1.1 uch 32 1.1 uch #include <hpcboot.h> 33 1.1 uch #include <hpcmenu.h> 34 1.1 uch #include <console.h> 35 1.1 uch 36 1.1 uch #include <sh3/cpu/sh3.h> 37 1.1 uch #include <sh3/dev/sh.h> 38 1.1 uch #include <sh3/dev/sh_dev.h> 39 1.1 uch #include <sh3/dev/hd64461.h> 40 1.1 uch 41 1.1 uch static void __tmu_channel_info(int, paddr_t, paddr_t, paddr_t); 42 1.1 uch 43 1.1 uch struct SH3dev::intr_priority SH3dev::_ipr_table[] = { 44 1.1 uch { "TMU0", SH3_IPRA, 12 }, 45 1.1 uch { "TMU1", SH3_IPRA, 8 }, 46 1.1 uch { "TMU2", SH3_IPRA, 4 }, 47 1.1 uch { "RTC", SH3_IPRA, 0 }, 48 1.1 uch { "WDT", SH3_IPRB, 12 }, 49 1.1 uch { "REF", SH3_IPRB, 8 }, 50 1.1 uch { "SCI", SH3_IPRB, 4 }, 51 1.1 uch { "reserve", SH3_IPRB, 0 }, 52 1.1 uch { "IRQ3", SH3_IPRC, 12 }, 53 1.1 uch { "IRQ2", SH3_IPRC, 8 }, 54 1.1 uch { "IRQ1", SH3_IPRC, 4 }, 55 1.1 uch { "IRQ0", SH3_IPRC, 0 }, 56 1.1 uch { "PINT0-7", SH3_IPRD, 12 }, 57 1.1 uch { "PINT8-15", SH3_IPRD, 8 }, 58 1.1 uch { "IRQ5", SH3_IPRD, 4 }, 59 1.1 uch { "IRQ4", SH3_IPRD, 0 }, 60 1.1 uch { "DMAC", SH3_IPRE, 12 }, 61 1.1 uch { "IrDA", SH3_IPRE, 8 }, 62 1.1 uch { "SCIF", SH3_IPRE, 4 }, 63 1.1 uch { "ADC", SH3_IPRE, 0 }, 64 1.1 uch { 0, 0, 0} /* terminator */ 65 1.1 uch }; 66 1.1 uch 67 1.1 uch void 68 1.5 uwe SH3dev::dump(uint8_t bit) 69 1.1 uch { 70 1.1 uch int kmode; 71 1.1 uch 72 1.1 uch super::dump(bit); 73 1.1 uch 74 1.1 uch kmode = SetKMode(1); 75 1.1 uch 76 1.1 uch if (bit & DUMP_DEV) { 77 1.1 uch // INTC 78 1.1 uch icu_dump(); 79 1.1 uch 80 1.1 uch // BSC 81 1.1 uch bsc_dump(); 82 1.1 uch 83 1.1 uch // TMU 84 1.1 uch tmu_dump(); 85 1.1 uch 86 1.1 uch // PFC , I/O port 87 1.1 uch pfc_dump(); 88 1.1 uch } 89 1.1 uch 90 1.1 uch if (bit & DUMP_COMPANION) { 91 1.1 uch // HD64461 92 1.1 uch platid_t platform; 93 1.1 uch platform.dw.dw0 = _menu->_pref.platid_hi; 94 1.1 uch platform.dw.dw1 = _menu->_pref.platid_lo; 95 1.1 uch hd64461_dump(platform); 96 1.1 uch } 97 1.1 uch 98 1.1 uch SetKMode(kmode); 99 1.1 uch } 100 1.1 uch 101 1.1 uch void 102 1.1 uch SH3dev::icu_dump() 103 1.1 uch { 104 1.1 uch 105 1.1 uch super::icu_dump_priority(_ipr_table); 106 1.1 uch icu_control(); 107 1.1 uch DPRINTF((TEXT("ICR0 0x%08x\n"), _reg_read_2(SH3_ICR0))); 108 1.1 uch DPRINTF((TEXT("ICR1 0x%08x\n"), _reg_read_2(SH3_ICR1))); 109 1.1 uch DPRINTF((TEXT("ICR2 0x%08x\n"), _reg_read_2(SH3_ICR2))); 110 1.1 uch DPRINTF((TEXT("PINTER 0x%08x\n"), _reg_read_2(SH3_PINTER))); 111 1.1 uch DPRINTF((TEXT("IPRA 0x%08x\n"), _reg_read_2(SH3_IPRA))); 112 1.1 uch DPRINTF((TEXT("IPRB 0x%08x\n"), _reg_read_2(SH3_IPRB))); 113 1.1 uch DPRINTF((TEXT("IPRC 0x%08x\n"), _reg_read_2(SH3_IPRC))); 114 1.1 uch DPRINTF((TEXT("IPRD 0x%08x\n"), _reg_read_2(SH3_IPRD))); 115 1.1 uch DPRINTF((TEXT("IPRE 0x%08x\n"), _reg_read_2(SH3_IPRE))); 116 1.1 uch DPRINTF((TEXT("IRR0 0x%08x\n"), _reg_read_1(SH3_IRR0))); 117 1.1 uch DPRINTF((TEXT("IRR1 0x%08x\n"), _reg_read_1(SH3_IRR1))); 118 1.1 uch DPRINTF((TEXT("IRR2 0x%08x\n"), _reg_read_1(SH3_IRR2))); 119 1.1 uch } 120 1.1 uch 121 1.1 uch void 122 1.1 uch SH3dev::icu_control() 123 1.1 uch { 124 1.1 uch const char *sense_select[] = { 125 1.1 uch "falling edge", 126 1.1 uch "raising edge", 127 1.1 uch "low level", 128 1.1 uch "reserved", 129 1.1 uch }; 130 1.5 uwe uint16_t r; 131 1.1 uch 132 1.1 uch // PINT0-15 133 1.1 uch DPRINTF((TEXT("PINT enable(on |) :"))); 134 1.1 uch bitdisp(_reg_read_2(SH3_PINTER)); 135 1.1 uch DPRINTF((TEXT("PINT detect(high |):"))); 136 1.1 uch bitdisp(_reg_read_2(SH3_ICR2)); 137 1.1 uch // NMI 138 1.1 uch r = _reg_read_2(SH3_ICR0); 139 1.1 uch DPRINTF((TEXT("NMI(%S %S-edge),"), 140 1.1 uch r & SH3_ICR0_NMIL ? "High" : "Low", 141 1.1 uch r & SH3_ICR0_NMIE ? "raising" : "falling")); 142 1.1 uch r = _reg_read_2(SH3_ICR1); 143 1.1 uch DPRINTF((TEXT(" %S maskable,"), r & SH3_ICR1_MAI ? "" : "never")); 144 1.1 uch DPRINTF((TEXT(" SR.BL %S\n"), 145 1.1 uch r & SH3_ICR1_BLMSK ? "ignored" : "maskable")); 146 1.3 uch // IRQ0-5 147 1.1 uch DPRINTF((TEXT("IRQ[3:0]pin : %S mode\n"), 148 1.1 uch r & SH3_ICR1_IRQLVL ? "IRL 15level" : "IRQ[0:3]")); 149 1.1 uch if (r & SH3_ICR1_IRQLVL) { 150 1.1 uch DPRINTF((TEXT("IRLS[0:3] %S\n"), 151 1.1 uch r & SH3_ICR1_IRLSEN ? "enabled" : "disabled")); 152 1.1 uch } 153 1.1 uch // sense select 154 1.1 uch for (int i = 5; i >= 0; i--) { 155 1.1 uch DPRINTF((TEXT("IRQ[%d] %S\n"), i, 156 1.1 uch sense_select [ 157 1.1 uch (r >>(i * 2)) & SH3_SENSE_SELECT_MASK])); 158 1.1 uch } 159 1.1 uch } 160 1.1 uch 161 1.1 uch // 162 1.1 uch // Debug Functions. 163 1.1 uch // 164 1.1 uch void 165 1.1 uch SH3dev::bsc_dump() 166 1.1 uch { 167 1.1 uch 168 1.1 uch DPRINTF((TEXT("<<<Bus State Controller>>>\n"))); 169 1.3 uch #define DUMP_BSC_REG(x) \ 170 1.1 uch DPRINTF((TEXT("%-8S"), #x)); \ 171 1.1 uch bitdisp(_reg_read_2(SH3_ ## x)) 172 1.1 uch DUMP_BSC_REG(BCR1); 173 1.1 uch DUMP_BSC_REG(BCR2); 174 1.1 uch DUMP_BSC_REG(WCR1); 175 1.1 uch DUMP_BSC_REG(WCR2); 176 1.1 uch DUMP_BSC_REG(MCR); 177 1.1 uch DUMP_BSC_REG(DCR); 178 1.1 uch DUMP_BSC_REG(PCR); 179 1.1 uch DUMP_BSC_REG(RTCSR); 180 1.1 uch DUMP_BSC_REG(RTCNT); 181 1.1 uch DUMP_BSC_REG(RTCOR); 182 1.1 uch DUMP_BSC_REG(RFCR); 183 1.1 uch DUMP_BSC_REG(BCR3); 184 1.1 uch #undef DUMP_BSC_REG 185 1.1 uch } 186 1.1 uch 187 1.1 uch void 188 1.1 uch SH3dev::pfc_dump() 189 1.1 uch { 190 1.1 uch DPRINTF((TEXT("<<<Pin Function Controller>>>\n"))); 191 1.1 uch DPRINTF((TEXT("[control]\n"))); 192 1.3 uch #define DUMP_PFC_REG(x) \ 193 1.1 uch DPRINTF((TEXT("P%SCR :"), #x)); \ 194 1.1 uch bitdisp(_reg_read_2(SH3_P##x##CR)) 195 1.1 uch DUMP_PFC_REG(A); 196 1.1 uch DUMP_PFC_REG(B); 197 1.1 uch DUMP_PFC_REG(C); 198 1.1 uch DUMP_PFC_REG(D); 199 1.1 uch DUMP_PFC_REG(E); 200 1.1 uch DUMP_PFC_REG(F); 201 1.1 uch DUMP_PFC_REG(G); 202 1.1 uch DUMP_PFC_REG(H); 203 1.1 uch DUMP_PFC_REG(J); 204 1.1 uch DUMP_PFC_REG(K); 205 1.1 uch DUMP_PFC_REG(L); 206 1.1 uch #undef DUMP_PFC_REG 207 1.1 uch DPRINTF((TEXT("SCPCR :"))); 208 1.1 uch bitdisp(_reg_read_2(SH3_SCPCR)); 209 1.1 uch DPRINTF((TEXT("\n[data]\n"))); 210 1.3 uch #define DUMP_IOPORT_REG(x) \ 211 1.1 uch DPRINTF((TEXT("P%SDR :"), #x)); \ 212 1.1 uch bitdisp(_reg_read_1(SH3_P##x##DR)) 213 1.1 uch DUMP_IOPORT_REG(A); 214 1.1 uch DUMP_IOPORT_REG(B); 215 1.1 uch DUMP_IOPORT_REG(C); 216 1.1 uch DUMP_IOPORT_REG(D); 217 1.1 uch DUMP_IOPORT_REG(E); 218 1.1 uch DUMP_IOPORT_REG(F); 219 1.1 uch DUMP_IOPORT_REG(G); 220 1.1 uch DUMP_IOPORT_REG(H); 221 1.1 uch DUMP_IOPORT_REG(J); 222 1.1 uch DUMP_IOPORT_REG(K); 223 1.1 uch DUMP_IOPORT_REG(L); 224 1.1 uch #undef DUMP_IOPORT_REG 225 1.1 uch DPRINTF((TEXT("SCPDR :"))); 226 1.1 uch bitdisp(_reg_read_1(SH3_SCPDR)); 227 1.1 uch } 228 1.1 uch 229 1.1 uch void 230 1.1 uch SH3dev::tmu_dump() 231 1.1 uch { 232 1.5 uwe uint8_t r8; 233 1.3 uch 234 1.1 uch DPRINTF((TEXT("<<<TMU>>>\n"))); 235 1.1 uch /* Common */ 236 1.1 uch /* TOCR timer output control register */ 237 1.1 uch r8 = _reg_read_1(SH3_TOCR); 238 1.1 uch DPRINTF((TEXT("TCLK = %S\n"), 239 1.1 uch r8 & SH3_TOCR_TCOE ? "RTC output" : "input")); 240 1.1 uch /* TSTR */ 241 1.1 uch r8 = _reg_read_1(SH3_TSTR); 242 1.1 uch DPRINTF((TEXT("Timer start(#0:2) [%c][%c][%c]\n"), 243 1.1 uch r8 & SH3_TSTR_STR0 ? 'x' : '_', 244 1.1 uch r8 & SH3_TSTR_STR1 ? 'x' : '_', 245 1.1 uch r8 & SH3_TSTR_STR2 ? 'x' : '_')); 246 1.1 uch 247 1.3 uch #define CHANNEL_DUMP(a, x) \ 248 1.1 uch tmu_channel_dump(x, SH##a##_TCOR##x, \ 249 1.1 uch SH##a##_TCNT##x, \ 250 1.1 uch SH##a##_TCR##x##) 251 1.1 uch CHANNEL_DUMP(3, 0); 252 1.1 uch CHANNEL_DUMP(3, 1); 253 1.1 uch CHANNEL_DUMP(3, 2); 254 1.1 uch #undef CHANNEL_DUMP 255 1.1 uch DPRINTF((TEXT("\n"))); 256 1.1 uch } 257 1.1 uch 258 1.1 uch void 259 1.1 uch SH3dev::tmu_channel_dump(int unit, paddr_t tcor, paddr_t tcnt, 260 1.1 uch paddr_t tcr) 261 1.1 uch { 262 1.5 uwe uint32_t r32; 263 1.5 uwe uint16_t r16; 264 1.1 uch 265 1.1 uch DPRINTF((TEXT("TMU#%d:"), unit)); 266 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, SH3_TCR_##m, #m) 267 1.1 uch /* TCR*/ 268 1.1 uch r16 = _reg_read_2(tcr); 269 1.1 uch DBG_BIT_PRINT(r16, UNF); 270 1.1 uch DBG_BIT_PRINT(r16, UNIE); 271 1.1 uch DBG_BIT_PRINT(r16, CKEG1); 272 1.1 uch DBG_BIT_PRINT(r16, CKEG0); 273 1.1 uch DBG_BIT_PRINT(r16, TPSC2); 274 1.1 uch DBG_BIT_PRINT(r16, TPSC1); 275 1.1 uch DBG_BIT_PRINT(r16, TPSC0); 276 1.1 uch /* channel 2 has input capture. */ 277 1.1 uch if (unit == 2) { 278 1.1 uch DBG_BIT_PRINT(r16, ICPF); 279 1.1 uch DBG_BIT_PRINT(r16, ICPE1); 280 1.1 uch DBG_BIT_PRINT(r16, ICPE0); 281 1.1 uch } 282 1.1 uch #undef DBG_BIT_PRINT 283 1.1 uch /* TCNT0 timer counter */ 284 1.1 uch r32 = _reg_read_4(tcnt); 285 1.1 uch DPRINTF((TEXT("\ncnt=0x%08x"), r32)); 286 1.1 uch /* TCOR0 timer constant register */ 287 1.1 uch r32 = _reg_read_4(tcor); 288 1.1 uch DPRINTF((TEXT(" constant=0x%04x"), r32)); 289 1.1 uch 290 1.1 uch if (unit == 2) 291 1.1 uch DPRINTF((TEXT(" input capture=0x%08x\n"), SH3_TCPR2)); 292 1.1 uch else 293 1.1 uch DPRINTF((TEXT("\n"))); 294 1.1 uch } 295 1.1 uch 296 1.1 uch void 297 1.1 uch SH3dev::hd64461_dump(platid_t &platform) 298 1.1 uch { 299 1.5 uwe uint16_t r16; 300 1.5 uwe uint8_t r8; 301 1.1 uch 302 1.3 uch #define MATCH(p) \ 303 1.1 uch platid_match(&platform, &platid_mask_MACH_##p) 304 1.1 uch 305 1.1 uch DPRINTF((TEXT("<<<HD64461>>>\n"))); 306 1.3 uch if (!MATCH(HP_LX) && 307 1.1 uch !MATCH(HP_JORNADA_6XX) && 308 1.1 uch !MATCH(HITACHI_PERSONA_HPW230JC)) { 309 1.1 uch DPRINTF((TEXT("don't exist."))); 310 1.1 uch return; 311 1.1 uch } 312 1.1 uch 313 1.1 uch #if 0 314 1.1 uch DPRINTF((TEXT("frame buffer test start\n"))); 315 1.5 uwe uint8_t *fb = reinterpret_cast<uint8_t *>(HD64461_FBBASE); 316 1.1 uch 317 1.1 uch for (int i = 0; i < 320 * 240 * 2 / 8; i++) 318 1.1 uch *fb++ = 0xff; 319 1.1 uch DPRINTF((TEXT("frame buffer test end\n"))); 320 1.1 uch #endif 321 1.1 uch // System 322 1.1 uch DPRINTF((TEXT("STBCR (System Control Register)\n"))); 323 1.1 uch r16 = _reg_read_2(HD64461_SYSSTBCR_REG16); 324 1.1 uch bitdisp(r16); 325 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_SYSSTBCR_##m, #m) 326 1.1 uch DBG_BIT_PRINT(r16, CKIO_STBY); 327 1.1 uch DBG_BIT_PRINT(r16, SAFECKE_IST); 328 1.1 uch DBG_BIT_PRINT(r16, SLCKE_IST); 329 1.1 uch DBG_BIT_PRINT(r16, SAFECKE_OST); 330 1.1 uch DBG_BIT_PRINT(r16, SLCKE_OST); 331 1.1 uch DBG_BIT_PRINT(r16, SMIAST); 332 1.1 uch DBG_BIT_PRINT(r16, SLCDST); 333 1.1 uch DBG_BIT_PRINT(r16, SPC0ST); 334 1.1 uch DBG_BIT_PRINT(r16, SPC1ST); 335 1.1 uch DBG_BIT_PRINT(r16, SAFEST); 336 1.1 uch DBG_BIT_PRINT(r16, STM0ST); 337 1.1 uch DBG_BIT_PRINT(r16, STM1ST); 338 1.1 uch DBG_BIT_PRINT(r16, SIRST); 339 1.1 uch DBG_BIT_PRINT(r16, SURTSD); 340 1.1 uch #undef DBG_BIT_PRINT 341 1.1 uch DPRINTF((TEXT("\n"))); 342 1.1 uch 343 1.1 uch DPRINTF((TEXT("SYSCR (System Configuration Register)\n"))); 344 1.1 uch r16 = _reg_read_2(HD64461_SYSSYSCR_REG16); 345 1.1 uch bitdisp(r16); 346 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_SYSSYSCR_##m, #m) 347 1.1 uch DBG_BIT_PRINT(r16, SCPU_BUS_IGAT); 348 1.1 uch DBG_BIT_PRINT(r16, SPTA_IR); 349 1.1 uch DBG_BIT_PRINT(r16, SPTA_TM); 350 1.1 uch DBG_BIT_PRINT(r16, SPTB_UR); 351 1.1 uch DBG_BIT_PRINT(r16, WAIT_CTL_SEL); 352 1.1 uch DBG_BIT_PRINT(r16, SMODE1); 353 1.1 uch DBG_BIT_PRINT(r16, SMODE0); 354 1.1 uch #undef DBG_BIT_PRINT 355 1.1 uch DPRINTF((TEXT("\n"))); 356 1.1 uch 357 1.1 uch DPRINTF((TEXT("SCPUCR (CPU Data Bus Control Register)\n"))); 358 1.1 uch r16 = _reg_read_2(HD64461_SYSSCPUCR_REG16); 359 1.1 uch bitdisp(r16); 360 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_SYSSCPUCR_##m, #m) 361 1.1 uch DBG_BIT_PRINT(r16, SPDSTOF); 362 1.1 uch DBG_BIT_PRINT(r16, SPDSTIG); 363 1.1 uch DBG_BIT_PRINT(r16, SPCSTOF); 364 1.1 uch DBG_BIT_PRINT(r16, SPCSTIG); 365 1.1 uch DBG_BIT_PRINT(r16, SPBSTOF); 366 1.1 uch DBG_BIT_PRINT(r16, SPBSTIG); 367 1.1 uch DBG_BIT_PRINT(r16, SPASTOF); 368 1.1 uch DBG_BIT_PRINT(r16, SPASTIG); 369 1.1 uch DBG_BIT_PRINT(r16, SLCDSTIG); 370 1.1 uch DBG_BIT_PRINT(r16, SCPU_CS56_EP); 371 1.1 uch DBG_BIT_PRINT(r16, SCPU_CMD_EP); 372 1.1 uch DBG_BIT_PRINT(r16, SCPU_ADDR_EP); 373 1.1 uch DBG_BIT_PRINT(r16, SCPDPU); 374 1.1 uch DBG_BIT_PRINT(r16, SCPU_A2319_EP); 375 1.1 uch #undef DBG_BIT_PRINT 376 1.1 uch DPRINTF((TEXT("\n"))); 377 1.1 uch 378 1.1 uch DPRINTF((TEXT("\n"))); 379 1.1 uch 380 1.1 uch // INTC 381 1.1 uch DPRINTF((TEXT("NIRR (Interrupt Request Register)\n"))); 382 1.1 uch r16 = _reg_read_2(HD64461_INTCNIRR_REG16); 383 1.1 uch bitdisp(r16); 384 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_INTCNIRR_##m, #m) 385 1.1 uch DBG_BIT_PRINT(r16, PCC0R); 386 1.1 uch DBG_BIT_PRINT(r16, PCC1R); 387 1.1 uch DBG_BIT_PRINT(r16, AFER); 388 1.1 uch DBG_BIT_PRINT(r16, GPIOR); 389 1.1 uch DBG_BIT_PRINT(r16, TMU0R); 390 1.1 uch DBG_BIT_PRINT(r16, TMU1R); 391 1.1 uch DBG_BIT_PRINT(r16, IRDAR); 392 1.1 uch DBG_BIT_PRINT(r16, UARTR); 393 1.1 uch #undef DBG_BIT_PRINT 394 1.1 uch DPRINTF((TEXT("\n"))); 395 1.1 uch 396 1.1 uch DPRINTF((TEXT("NIMR (Interrupt Mask Register)\n"))); 397 1.1 uch r16 = _reg_read_2(HD64461_INTCNIMR_REG16); 398 1.1 uch bitdisp(r16); 399 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_INTCNIMR_##m, #m) 400 1.1 uch DBG_BIT_PRINT(r16, PCC0M); 401 1.1 uch DBG_BIT_PRINT(r16, PCC1M); 402 1.1 uch DBG_BIT_PRINT(r16, AFEM); 403 1.1 uch DBG_BIT_PRINT(r16, GPIOM); 404 1.1 uch DBG_BIT_PRINT(r16, TMU0M); 405 1.1 uch DBG_BIT_PRINT(r16, TMU1M); 406 1.1 uch DBG_BIT_PRINT(r16, IRDAM); 407 1.1 uch DBG_BIT_PRINT(r16, UARTM); 408 1.1 uch #undef DBG_BIT_PRINT 409 1.1 uch DPRINTF((TEXT("\n"))); 410 1.1 uch 411 1.1 uch DPRINTF((TEXT("\n"))); 412 1.1 uch 413 1.1 uch // PCMCIA 414 1.1 uch // PCC0 415 1.1 uch DPRINTF((TEXT("[PCC0 memory and I/O card (SH3 Area 6)]\n"))); 416 1.1 uch DPRINTF((TEXT("PCC0 Interface Status Register\n"))); 417 1.1 uch r8 = _reg_read_1(HD64461_PCC0ISR_REG8); 418 1.1 uch bitdisp(r8); 419 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_PCC0ISR_##m, #m) 420 1.1 uch DBG_BIT_PRINT(r8, P0READY); 421 1.1 uch DBG_BIT_PRINT(r8, P0MWP); 422 1.1 uch DBG_BIT_PRINT(r8, P0VS2); 423 1.1 uch DBG_BIT_PRINT(r8, P0VS1); 424 1.1 uch DBG_BIT_PRINT(r8, P0CD2); 425 1.1 uch DBG_BIT_PRINT(r8, P0CD1); 426 1.1 uch DBG_BIT_PRINT(r8, P0BVD2); 427 1.1 uch DBG_BIT_PRINT(r8, P0BVD1); 428 1.1 uch #undef DBG_BIT_PRINT 429 1.1 uch DPRINTF((TEXT("\n"))); 430 1.1 uch 431 1.1 uch DPRINTF((TEXT("PCC0 General Control Register\n"))); 432 1.3 uch r8 = _reg_read_1(HD64461_PCC0GCR_REG8); 433 1.1 uch bitdisp(r8); 434 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_PCC0GCR_##m, #m) 435 1.1 uch DBG_BIT_PRINT(r8, P0DRVE); 436 1.1 uch DBG_BIT_PRINT(r8, P0PCCR); 437 1.1 uch DBG_BIT_PRINT(r8, P0PCCT); 438 1.1 uch DBG_BIT_PRINT(r8, P0VCC0); 439 1.1 uch DBG_BIT_PRINT(r8, P0MMOD); 440 1.1 uch DBG_BIT_PRINT(r8, P0PA25); 441 1.1 uch DBG_BIT_PRINT(r8, P0PA24); 442 1.1 uch DBG_BIT_PRINT(r8, P0REG); 443 1.1 uch #undef DBG_BIT_PRINT 444 1.1 uch DPRINTF((TEXT("\n"))); 445 1.1 uch 446 1.1 uch DPRINTF((TEXT("PCC0 Card Status Change Register\n"))); 447 1.1 uch r8 = _reg_read_1(HD64461_PCC0CSCR_REG8); 448 1.1 uch bitdisp(r8); 449 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_PCC0CSCR_##m, #m) 450 1.1 uch DBG_BIT_PRINT(r8, P0SCDI); 451 1.1 uch DBG_BIT_PRINT(r8, P0IREQ); 452 1.1 uch DBG_BIT_PRINT(r8, P0SC); 453 1.1 uch DBG_BIT_PRINT(r8, P0CDC); 454 1.1 uch DBG_BIT_PRINT(r8, P0RC); 455 1.1 uch DBG_BIT_PRINT(r8, P0BW); 456 1.1 uch DBG_BIT_PRINT(r8, P0BD); 457 1.1 uch #undef DBG_BIT_PRINT 458 1.1 uch DPRINTF((TEXT("\n"))); 459 1.1 uch 460 1.1 uch DPRINTF((TEXT("PCC0 Card Status Change Interrupt Enable Register\n"))); 461 1.1 uch r8 = _reg_read_1(HD64461_PCC0CSCIER_REG8); 462 1.1 uch bitdisp(r8); 463 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_PCC0CSCIER_##m, #m) 464 1.1 uch DBG_BIT_PRINT(r8, P0CRE); 465 1.1 uch DBG_BIT_PRINT(r8, P0SCE); 466 1.1 uch DBG_BIT_PRINT(r8, P0CDE); 467 1.1 uch DBG_BIT_PRINT(r8, P0RE); 468 1.1 uch DBG_BIT_PRINT(r8, P0BWE); 469 1.1 uch DBG_BIT_PRINT(r8, P0BDE); 470 1.1 uch #undef DBG_BIT_PRINT 471 1.1 uch DPRINTF((TEXT("\ninterrupt type: "))); 472 1.1 uch switch (r8 & HD64461_PCC0CSCIER_P0IREQE_MASK) { 473 1.1 uch case HD64461_PCC0CSCIER_P0IREQE_NONE: 474 1.1 uch DPRINTF((TEXT("none\n"))); 475 1.1 uch break; 476 1.1 uch case HD64461_PCC0CSCIER_P0IREQE_LEVEL: 477 1.1 uch DPRINTF((TEXT("level\n"))); 478 1.1 uch break; 479 1.1 uch case HD64461_PCC0CSCIER_P0IREQE_FEDGE: 480 1.1 uch DPRINTF((TEXT("falling edge\n"))); 481 1.1 uch break; 482 1.1 uch case HD64461_PCC0CSCIER_P0IREQE_REDGE: 483 1.1 uch DPRINTF((TEXT("rising edge\n"))); 484 1.1 uch break; 485 1.1 uch } 486 1.1 uch 487 1.1 uch DPRINTF((TEXT("PCC0 Software Control Register\n"))); 488 1.1 uch r8 = _reg_read_1(HD64461_PCC0SCR_REG8); 489 1.1 uch bitdisp(r8); 490 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_PCC0SCR_##m, #m) 491 1.1 uch DBG_BIT_PRINT(r8, P0VCC1); 492 1.3 uch DBG_BIT_PRINT(r8, P0SWP); 493 1.1 uch #undef DBG_BIT_PRINT 494 1.1 uch DPRINTF((TEXT("\n"))); 495 1.1 uch 496 1.1 uch // PCC1 497 1.1 uch DPRINTF((TEXT("[PCC1 memory card only (SH3 Area 5)]\n"))); 498 1.1 uch DPRINTF((TEXT("PCC1 Interface Status Register\n"))); 499 1.1 uch r8 = _reg_read_1(HD64461_PCC1ISR_REG8); 500 1.1 uch bitdisp(r8); 501 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_PCC1ISR_##m, #m) 502 1.1 uch DBG_BIT_PRINT(r8, P1READY); 503 1.1 uch DBG_BIT_PRINT(r8, P1MWP); 504 1.1 uch DBG_BIT_PRINT(r8, P1VS2); 505 1.1 uch DBG_BIT_PRINT(r8, P1VS1); 506 1.1 uch DBG_BIT_PRINT(r8, P1CD2); 507 1.1 uch DBG_BIT_PRINT(r8, P1CD1); 508 1.1 uch DBG_BIT_PRINT(r8, P1BVD2); 509 1.1 uch DBG_BIT_PRINT(r8, P1BVD1); 510 1.1 uch #undef DBG_BIT_PRINT 511 1.1 uch DPRINTF((TEXT("\n"))); 512 1.1 uch 513 1.1 uch DPRINTF((TEXT("PCC1 General Contorol Register\n"))); 514 1.1 uch r8 = _reg_read_1(HD64461_PCC1GCR_REG8); 515 1.1 uch bitdisp(r8); 516 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_PCC1GCR_##m, #m) 517 1.1 uch DBG_BIT_PRINT(r8, P1DRVE); 518 1.1 uch DBG_BIT_PRINT(r8, P1PCCR); 519 1.1 uch DBG_BIT_PRINT(r8, P1VCC0); 520 1.1 uch DBG_BIT_PRINT(r8, P1MMOD); 521 1.1 uch DBG_BIT_PRINT(r8, P1PA25); 522 1.1 uch DBG_BIT_PRINT(r8, P1PA24); 523 1.1 uch DBG_BIT_PRINT(r8, P1REG); 524 1.1 uch #undef DBG_BIT_PRINT 525 1.1 uch DPRINTF((TEXT("\n"))); 526 1.1 uch 527 1.1 uch DPRINTF((TEXT("PCC1 Card Status Change Register\n"))); 528 1.1 uch r8 = _reg_read_1(HD64461_PCC1CSCR_REG8); 529 1.1 uch bitdisp(r8); 530 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_PCC1CSCR_##m, #m) 531 1.1 uch DBG_BIT_PRINT(r8, P1SCDI); 532 1.1 uch DBG_BIT_PRINT(r8, P1CDC); 533 1.1 uch DBG_BIT_PRINT(r8, P1RC); 534 1.1 uch DBG_BIT_PRINT(r8, P1BW); 535 1.1 uch DBG_BIT_PRINT(r8, P1BD); 536 1.1 uch #undef DBG_BIT_PRINT 537 1.1 uch DPRINTF((TEXT("\n"))); 538 1.1 uch 539 1.1 uch DPRINTF((TEXT("PCC1 Card Status Change Interrupt Enable Register\n"))); 540 1.1 uch r8 = _reg_read_1(HD64461_PCC1CSCIER_REG8); 541 1.1 uch bitdisp(r8); 542 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_PCC1CSCIER_##m, #m) 543 1.1 uch DBG_BIT_PRINT(r8, P1CRE); 544 1.1 uch DBG_BIT_PRINT(r8, P1CDE); 545 1.1 uch DBG_BIT_PRINT(r8, P1RE); 546 1.1 uch DBG_BIT_PRINT(r8, P1BWE); 547 1.1 uch DBG_BIT_PRINT(r8, P1BDE); 548 1.1 uch #undef DBG_BIT_PRINT 549 1.1 uch DPRINTF((TEXT("\n"))); 550 1.1 uch 551 1.1 uch DPRINTF((TEXT("PCC1 Software Control Register\n"))); 552 1.1 uch r8 = _reg_read_1(HD64461_PCC1SCR_REG8); 553 1.1 uch bitdisp(r8); 554 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_PCC1SCR_##m, #m) 555 1.1 uch DBG_BIT_PRINT(r8, P1VCC1); 556 1.1 uch DBG_BIT_PRINT(r8, P1SWP); 557 1.1 uch #undef DBG_BIT_PRINT 558 1.1 uch DPRINTF((TEXT("\n"))); 559 1.1 uch 560 1.1 uch // General Control 561 1.1 uch DPRINTF((TEXT("[General Control]\n"))); 562 1.1 uch DPRINTF((TEXT("PCC0 Output pins Control Register\n"))); 563 1.1 uch r8 = _reg_read_1(HD64461_PCCP0OCR_REG8); 564 1.1 uch bitdisp(r8); 565 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_PCCP0OCR_##m, #m) 566 1.1 uch DBG_BIT_PRINT(r8, P0DEPLUP); 567 1.1 uch DBG_BIT_PRINT(r8, P0AEPLUP); 568 1.1 uch #undef DBG_BIT_PRINT 569 1.1 uch DPRINTF((TEXT("\n"))); 570 1.1 uch 571 1.1 uch DPRINTF((TEXT("PCC1 Output pins Control Register\n"))); 572 1.1 uch r8 = _reg_read_1(HD64461_PCCP1OCR_REG8); 573 1.1 uch bitdisp(r8); 574 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_PCCP1OCR_##m, #m) 575 1.1 uch DBG_BIT_PRINT(r8, P1RST8MA); 576 1.1 uch DBG_BIT_PRINT(r8, P1RST4MA); 577 1.1 uch DBG_BIT_PRINT(r8, P1RAS8MA); 578 1.1 uch DBG_BIT_PRINT(r8, P1RAS4MA); 579 1.1 uch #undef DBG_BIT_PRINT 580 1.1 uch DPRINTF((TEXT("\n"))); 581 1.1 uch 582 1.1 uch DPRINTF((TEXT("PC Card General Control Register\n"))); 583 1.1 uch r8 = _reg_read_1(HD64461_PCCPGCR_REG8); 584 1.1 uch bitdisp(r8); 585 1.3 uch #define DBG_BIT_PRINT(r, m) _dbg_bit_print(r, HD64461_PCCPGCR_##m, #m) 586 1.1 uch DBG_BIT_PRINT(r8, PSSDIR); 587 1.1 uch DBG_BIT_PRINT(r8, PSSRDWR); 588 1.1 uch #undef DBG_BIT_PRINT 589 1.1 uch DPRINTF((TEXT("\n"))); 590 1.1 uch 591 1.1 uch // GPIO 592 1.3 uch #define GPIO_DUMP(x) \ 593 1.1 uch bitdisp(_reg_read_2(HD64461_GPA##x##R_REG16)); \ 594 1.1 uch bitdisp(_reg_read_2(HD64461_GPB##x##R_REG16)); \ 595 1.1 uch bitdisp(_reg_read_2(HD64461_GPC##x##R_REG16)); \ 596 1.1 uch bitdisp(_reg_read_2(HD64461_GPD##x##R_REG16)) 597 1.1 uch 598 1.1 uch DPRINTF((TEXT("GPIO Port Control Register\n"))); 599 1.1 uch GPIO_DUMP(C); 600 1.1 uch DPRINTF((TEXT("GPIO Port Data Register\n"))); 601 1.1 uch GPIO_DUMP(D); 602 1.1 uch DPRINTF((TEXT("GPIO Port Interrupt Control Register\n"))); 603 1.1 uch GPIO_DUMP(IC); 604 1.1 uch DPRINTF((TEXT("GPIO Port Interrupt Status Register\n"))); 605 1.1 uch GPIO_DUMP(IS); 606 1.1 uch } 607 1.1 uch 608 1.1 uch #ifdef SH7709TEST 609 1.5 uwe uint32_t sh7707_fb_dma_addr; 610 1.5 uwe uint16_t val; 611 1.1 uch int s; 612 1.3 uch 613 1.1 uch s = suspendIntr(); 614 1.1 uch VOLATILE_REF16(SH7707_LCDAR) = SH7707_LCDAR_LCDDMR0; 615 1.1 uch val = VOLATILE_REF16(SH7707_LCDDMR); 616 1.1 uch sh7707_fb_dma_addr = val; 617 1.3 uch VOLATILE_REF16(SH7707_LCDAR) = SH7707_LCDAR_LCDDMR1; 618 1.1 uch val = VOLATILE_REF16(SH7707_LCDDMR); 619 1.1 uch sh7707_fb_dma_addr |= (val << 16); 620 1.1 uch resumeIntr(s); 621 1.1 uch 622 1.2 wiz DPRINTF((TEXT("SH7707 frame buffer DMA address: 0x%08x\n"), 623 1.1 uch sh7707_fb_dma_addr)); 624 1.1 uch #endif 625