Home | History | Annotate | Line # | Download | only in dev
      1  1.5  martin /* -*-C++-*-	$NetBSD: sh4_dev.cpp,v 1.5 2008/04/28 20:23:20 martin Exp $	*/
      2  1.1     uch 
      3  1.1     uch /*-
      4  1.1     uch  * Copyright (c) 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/sh_arch.h> //suspend/resumeIntr
     37  1.1     uch 
     38  1.1     uch #include <sh3/cpu/sh4.h>
     39  1.1     uch #include <sh3/dev/sh_dev.h>
     40  1.1     uch 
     41  1.1     uch #include <sh3/dev/sh.h>
     42  1.1     uch #include <sh3/dev/hd64465.h>
     43  1.1     uch #include <sh3/dev/mq100.h>
     44  1.1     uch 
     45  1.1     uch struct SH4dev::intr_priority SH4dev::_ipr_table[] = {
     46  1.1     uch 	// SH7750, SH7750S
     47  1.1     uch 	{ "TMU0",	SH4_IPRA, 12 },
     48  1.1     uch 	{ "TMU1",	SH4_IPRA,  8 },
     49  1.1     uch 	{ "TMU2",	SH4_IPRA,  4 },
     50  1.1     uch 	{ "RTC",	SH4_IPRA,  0 },
     51  1.1     uch 	{ "WDT",	SH4_IPRB, 12 },
     52  1.1     uch 	{ "REF",	SH4_IPRB,  8 },
     53  1.1     uch 	{ "SCI",	SH4_IPRB,  4 },
     54  1.1     uch 	{ "reserve",	SH4_IPRB,  0 },
     55  1.1     uch 	{ "GPIO",	SH4_IPRC, 12 },
     56  1.1     uch 	{ "DMAC",	SH4_IPRC,  8 },
     57  1.1     uch 	{ "SCIF",	SH4_IPRC,  4 },
     58  1.1     uch 	{ "H-UDI",	SH4_IPRC,  0 },
     59  1.1     uch 	// SH7750S
     60  1.1     uch 	{ "IRL0",	SH4_IPRD, 12 },
     61  1.1     uch 	{ "IRL1",	SH4_IPRD,  8 },
     62  1.1     uch 	{ "IRL2",	SH4_IPRD,  4 },
     63  1.1     uch 	{ "IRL3",	SH4_IPRD,  0 },
     64  1.1     uch 	{ 0, 0, 0} /* terminator */
     65  1.1     uch };
     66  1.1     uch 
     67  1.1     uch void
     68  1.4     uwe SH4dev::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 	if (bit & DUMP_DEV) {
     76  1.1     uch 		// INTC
     77  1.1     uch 		icu_dump();
     78  1.1     uch 	}
     79  1.1     uch 
     80  1.1     uch 	if (bit & DUMP_COMPANION) {
     81  1.1     uch 		// HD64465
     82  1.1     uch 		hd64465_dump();
     83  1.1     uch 	}
     84  1.1     uch 
     85  1.1     uch 	if (bit & DUMP_VIDEO) {
     86  1.1     uch 		// MQ100
     87  1.1     uch 		mq100_dump();
     88  1.1     uch 	}
     89  1.1     uch 
     90  1.1     uch 	SetKMode(kmode);
     91  1.1     uch 
     92  1.1     uch }
     93  1.1     uch 
     94  1.1     uch // INTC
     95  1.1     uch void
     96  1.1     uch SH4dev::icu_dump()
     97  1.1     uch {
     98  1.2     uch #define	ON(x, c)	((x) & (c) ? check[1] : check[0])
     99  1.2     uch #define	_(n)		DPRINTF((TEXT("%S %S "), #n, ON(r, SH4_ICR_ ## n)))
    100  1.1     uch 	static const char *check[] = { "[_]", "[x]" };
    101  1.4     uwe 	uint16_t r;
    102  1.2     uch 
    103  1.1     uch 	super::icu_dump_priority(_ipr_table);
    104  1.1     uch 
    105  1.1     uch 	r = _reg_read_2(SH4_ICR);
    106  1.1     uch 	DPRINTF((TEXT("ICR: ")));
    107  1.1     uch 	_(NMIL);_(MAI);_(NMIB);_(NMIE);_(IRLM);
    108  1.1     uch 	DPRINTF((TEXT("0x%04x\n"), r));
    109  1.1     uch 
    110  1.1     uch #if 0 // monitoring SH4 interrupt request.
    111  1.1     uch 	// disable SH3 internal devices interrupt.
    112  1.1     uch 	suspendIntr();
    113  1.1     uch 	_reg_write_2(SH4_IPRA, 0);
    114  1.1     uch 	_reg_write_2(SH4_IPRB, 0);
    115  1.1     uch 	_reg_write_2(SH4_IPRC, 0);
    116  1.1     uch //	_reg_write_2(SH4_IPRD, 0);  SH7709S only.
    117  1.1     uch 	resumeIntr(0);	// all interrupts enable.
    118  1.1     uch 	while (1) {
    119  1.1     uch 		DPRINTF((TEXT("%04x ", _reg_read_2(HD64465_NIRR))));
    120  1.1     uch 		bitdisp(_reg_read_4(SH4_INTEVT));
    121  1.1     uch 	}
    122  1.1     uch 	/* NOTREACHED */
    123  1.1     uch #endif
    124  1.1     uch #undef _
    125  1.1     uch #undef ON
    126  1.1     uch }
    127  1.1     uch 
    128  1.1     uch void
    129  1.1     uch SH4dev::hd64465_dump()
    130  1.1     uch {
    131  1.1     uch 
    132  1.1     uch 	DPRINTF((TEXT("<<<HD64465>>>\n")));
    133  1.1     uch 	if (_reg_read_2(HD64465_SDIDR) != 0x8122) {
    134  1.1     uch 		DPRINTF((TEXT("not found.\n")));
    135  1.1     uch 		return;
    136  1.1     uch 	}
    137  1.1     uch 
    138  1.1     uch 	DPRINTF((TEXT("SMSCR:  ")));	// standby
    139  1.1     uch 	bitdisp(_reg_read_2(HD64465_SMSCR));
    140  1.1     uch 	DPRINTF((TEXT("SPCCR:  ")));	// clock
    141  1.1     uch 	bitdisp(_reg_read_2(HD64465_SPCCR));
    142  1.1     uch 
    143  1.1     uch 	DPRINTF((TEXT("\nNIRR:   ")));	// request
    144  1.1     uch 	bitdisp(_reg_read_2(HD64465_NIRR));
    145  1.1     uch 	DPRINTF((TEXT("NIMR:   ")));	// mask
    146  1.1     uch 	bitdisp(_reg_read_2(HD64465_NIMR));
    147  1.1     uch 	DPRINTF((TEXT("NITR:   ")));	// trigger
    148  1.1     uch 	bitdisp(_reg_read_2(HD64465_NITR));
    149  1.1     uch 
    150  1.1     uch #if 0 // monitoring HD64465 interrupt request.
    151  1.1     uch 	suspendIntr();
    152  1.1     uch 	while (1)
    153  1.1     uch 		bitdisp(_reg_read_2(HD64465_NIRR));
    154  1.1     uch 	/* NOTREACHED */
    155  1.2     uch #endif
    156  1.1     uch }
    157  1.1     uch 
    158  1.1     uch void
    159  1.1     uch SH4dev::mq100_dump()
    160  1.1     uch {
    161  1.4     uwe 	uint32_t a, e;
    162  1.1     uch 	int i;
    163  1.1     uch 
    164  1.1     uch 	// This is HPW650PA test. 640 * 480 linebytes 1280.
    165  1.1     uch 	DPRINTF((TEXT("<<<MQ100/HD64464>>>\n")));
    166  1.1     uch 	a = MQ100_FB_BASE + 0x4b000;
    167  1.4     uwe 	e = a + 640 * 480 * sizeof(uint16_t);
    168  1.1     uch 	while (a < e) {
    169  1.4     uwe 		for (i = 0; i < 640; i++, a += sizeof(uint16_t))
    170  1.1     uch 			_reg_write_2(a, ~_reg_read_2(a) & 0xffff);
    171  1.1     uch 	}
    172  1.1     uch }
    173