dec_3min.c revision 1.73
11.73Schristos/* $NetBSD: dec_3min.c,v 1.73 2014/03/24 19:31:40 christos Exp $ */
21.1Sjonathan
31.1Sjonathan/*
41.1Sjonathan * Copyright (c) 1998 Jonathan Stone.  All rights reserved.
51.1Sjonathan *
61.1Sjonathan * Redistribution and use in source and binary forms, with or without
71.1Sjonathan * modification, are permitted provided that the following conditions
81.1Sjonathan * are met:
91.1Sjonathan * 1. Redistributions of source code must retain the above copyright
101.1Sjonathan *    notice, this list of conditions and the following disclaimer.
111.1Sjonathan * 2. Redistributions in binary form must reproduce the above copyright
121.1Sjonathan *    notice, this list of conditions and the following disclaimer in the
131.1Sjonathan *    documentation and/or other materials provided with the distribution.
141.1Sjonathan * 3. All advertising materials mentioning features or use of this software
151.1Sjonathan *    must display the following acknowledgement:
161.1Sjonathan *	This product includes software developed by Jonathan Stone for
171.1Sjonathan *      the NetBSD Project.
181.1Sjonathan * 4. The name of the author may not be used to endorse or promote products
191.1Sjonathan *    derived from this software without specific prior written permission.
201.1Sjonathan *
211.1Sjonathan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
221.1Sjonathan * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
231.1Sjonathan * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
241.1Sjonathan * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
251.1Sjonathan * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
261.1Sjonathan * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
271.1Sjonathan * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
281.1Sjonathan * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
291.1Sjonathan * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
301.1Sjonathan * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
311.1Sjonathan */
321.1Sjonathan
331.1Sjonathan/*
341.67Srmind * Copyright (c) 1988 University of Utah.
351.1Sjonathan * Copyright (c) 1992, 1993
361.1Sjonathan *	The Regents of the University of California.  All rights reserved.
371.1Sjonathan *
381.1Sjonathan * This code is derived from software contributed to Berkeley by
391.1Sjonathan * the Systems Programming Group of the University of Utah Computer
401.1Sjonathan * Science Department, The Mach Operating System project at
411.1Sjonathan * Carnegie-Mellon University and Ralph Campbell.
421.1Sjonathan *
431.1Sjonathan * Redistribution and use in source and binary forms, with or without
441.1Sjonathan * modification, are permitted provided that the following conditions
451.1Sjonathan * are met:
461.1Sjonathan * 1. Redistributions of source code must retain the above copyright
471.1Sjonathan *    notice, this list of conditions and the following disclaimer.
481.1Sjonathan * 2. Redistributions in binary form must reproduce the above copyright
491.1Sjonathan *    notice, this list of conditions and the following disclaimer in the
501.1Sjonathan *    documentation and/or other materials provided with the distribution.
511.50Sagc * 3. Neither the name of the University nor the names of its contributors
521.50Sagc *    may be used to endorse or promote products derived from this software
531.50Sagc *    without specific prior written permission.
541.50Sagc *
551.50Sagc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
561.50Sagc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
571.50Sagc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
581.50Sagc * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
591.50Sagc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
601.50Sagc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
611.50Sagc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
621.50Sagc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
631.50Sagc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
641.50Sagc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
651.50Sagc * SUCH DAMAGE.
661.50Sagc *
671.50Sagc *	@(#)machdep.c	8.3 (Berkeley) 1/12/94
681.50Sagc */
691.1Sjonathan
701.68Smatt#define	__INTR_PRIVATE
711.68Smatt
721.67Srmind#include <sys/cdefs.h>
731.73Schristos__KERNEL_RCSID(0, "$NetBSD: dec_3min.c,v 1.73 2014/03/24 19:31:40 christos Exp $");
741.1Sjonathan
751.34Snisimura#include <sys/param.h>
761.71Smatt#include <sys/cpu.h>
771.71Smatt#include <sys/device.h>
781.71Smatt#include <sys/intr.h>
791.71Smatt#include <sys/lwp.h>
801.1Sjonathan#include <sys/systm.h>
811.59Sjoerg#include <sys/timetc.h>
821.1Sjonathan
831.71Smatt#include <pmax/sysconf.h>
841.1Sjonathan
851.1Sjonathan#include <mips/mips/mips_mcclock.h>	/* mcclock CPUspeed estimation */
861.2Sjonathan
871.2Sjonathan/* all these to get ioasic_base */
881.2Sjonathan#include <dev/tc/tcvar.h>		/* tc type definitions for.. */
891.7Sjonathan#include <dev/tc/ioasicreg.h>		/* ioasic interrrupt masks */
901.2Sjonathan#include <dev/tc/ioasicvar.h>		/* ioasic_base */
911.1Sjonathan
921.20Ssimonb#include <pmax/pmax/machdep.h>
931.1Sjonathan#include <pmax/pmax/kmin.h>		/* 3min baseboard addresses */
941.15Snisimura#include <pmax/pmax/memc.h>		/* 3min/maxine memory errors */
951.51Sad
961.51Sad#include <pmax/pmax/cons.h>
971.51Sad#include <dev/ic/z8530sc.h>
981.51Sad#include <dev/tc/zs_ioasicvar.h>
991.51Sad#include "wsdisplay.h"
1001.1Sjonathan
1011.61Sdslvoid		dec_3min_init(void);		/* XXX */
1021.61Sdslstatic void	dec_3min_bus_reset(void);
1031.61Sdslstatic void	dec_3min_cons_init(void);
1041.68Smattstatic void	dec_3min_intr(uint32_t, vaddr_t, uint32_t);
1051.72Stsutsuistatic void	dec_3min_intr_establish(device_t, void *,
1061.61Sdsl		    int, int (*)(void *), void *);
1071.1Sjonathan
1081.61Sdslstatic void	kn02ba_wbflush(void);
1091.1Sjonathan
1101.59Sjoergstatic void	dec_3min_tc_init(void);
1111.1Sjonathan
1121.1Sjonathan/*
1131.1Sjonathan * Local declarations.
1141.1Sjonathan */
1151.65Stsutsuistatic uint32_t kmin_tc3_imask;
1161.18Snisimura
1171.68Smattstatic const struct ipl_sr_map dec_3min_ipl_sr_map = {
1181.68Smatt    .sr_bits = {
1191.57Syamt	[IPL_NONE] = 0,
1201.68Smatt	[IPL_SOFTCLOCK] = MIPS_SOFT_INT_MASK_0,
1211.68Smatt	[IPL_SOFTNET] = MIPS_SOFT_INT_MASK,
1221.57Syamt	/*
1231.57Syamt	 * Since all the motherboard interrupts come through the
1241.57Syamt	 * IOASIC, it has to be turned off for all the spls and
1251.57Syamt	 * since we don't know what kinds of devices are in the
1261.57Syamt	 * TURBOchannel option slots, just splhigh().
1271.57Syamt	 */
1281.68Smatt	[IPL_VM] = MIPS_SPLHIGH,
1291.68Smatt	[IPL_SCHED] = MIPS_SPLHIGH,
1301.68Smatt	[IPL_DDB] = MIPS_SPLHIGH,
1311.68Smatt	[IPL_HIGH] = MIPS_SPLHIGH,
1321.68Smatt    },
1331.57Syamt};
1341.1Sjonathan
1351.1Sjonathanvoid
1361.65Stsutsuidec_3min_init(void)
1371.1Sjonathan{
1381.65Stsutsui
1391.24Snisimura	platform.iobus = "tcbus";
1401.1Sjonathan	platform.bus_reset = dec_3min_bus_reset;
1411.1Sjonathan	platform.cons_init = dec_3min_cons_init;
1421.22Snisimura	platform.iointr = dec_3min_intr;
1431.33Ssimonb	platform.intr_establish = dec_3min_intr_establish;
1441.47Smhitch	platform.memsize = memsize_bitmap;
1451.59Sjoerg	platform.tc_init = dec_3min_tc_init;
1461.1Sjonathan
1471.22Snisimura	/* clear any memory errors */
1481.65Stsutsui	*(volatile uint32_t *)MIPS_PHYS_TO_KSEG1(KMIN_REG_TIMEOUT) = 0;
1491.14Snisimura	kn02ba_wbflush();
1501.1Sjonathan
1511.1Sjonathan	ioasic_base = MIPS_PHYS_TO_KSEG1(KMIN_SYS_ASIC);
1521.1Sjonathan
1531.68Smatt	ipl_sr_map = dec_3min_ipl_sr_map;
1541.16Snisimura
1551.28Snisimura	/* enable posting of MIPS_INT_MASK_3 to CAUSE register */
1561.65Stsutsui	*(volatile uint32_t *)(ioasic_base + IOASIC_IMSK) = KMIN_INTR_CLOCK;
1571.44Stsutsui	/* calibrate cpu_mhz value */
1581.29Snisimura	mc_cpuspeed(ioasic_base+IOASIC_SLOT_8_START, MIPS_INT_MASK_3);
1591.1Sjonathan
1601.65Stsutsui	*(volatile uint32_t *)(ioasic_base + IOASIC_LANCE_DECODE) = 0x3;
1611.65Stsutsui	*(volatile uint32_t *)(ioasic_base + IOASIC_SCSI_DECODE) = 0xe;
1621.44Stsutsui#if 0
1631.65Stsutsui	*(volatile uint32_t *)(ioasic_base + IOASIC_SCC0_DECODE) = (0x10|4);
1641.65Stsutsui	*(volatile uint32_t *)(ioasic_base + IOASIC_SCC1_DECODE) = (0x10|6);
1651.65Stsutsui	*(volatile uint32_t *)(ioasic_base + IOASIC_CSR) = 0x00000f00;
1661.44Stsutsui#endif
1671.44Stsutsui
1681.22Snisimura	/* sanitize interrupt mask */
1691.22Snisimura	kmin_tc3_imask = (KMIN_INTR_CLOCK|KMIN_INTR_PSWARN|KMIN_INTR_TIMEOUT);
1701.65Stsutsui	*(volatile uint32_t *)(ioasic_base + IOASIC_INTR) = 0;
1711.65Stsutsui	*(volatile uint32_t *)(ioasic_base + IOASIC_IMSK) = kmin_tc3_imask;
1721.1Sjonathan
1731.1Sjonathan	/*
1741.22Snisimura	 * The kmin memory hardware seems to wrap memory addresses
1751.1Sjonathan	 * with 4Mbyte SIMMs, which causes the physmem computation
1761.1Sjonathan	 * to lose.  Find out how big the SIMMS are and set
1771.22Snisimura	 * max_ physmem accordingly.
1781.22Snisimura	 * XXX Do MAXINEs lose the same way?
1791.1Sjonathan	 */
1801.1Sjonathan	physmem_boardmax = KMIN_PHYS_MEMORY_END + 1;
1811.22Snisimura	if ((KMIN_MSR_SIZE_16Mb & *(int *)MIPS_PHYS_TO_KSEG1(KMIN_REG_MSR))
1821.65Stsutsui	    == 0)
1831.1Sjonathan		physmem_boardmax = physmem_boardmax >> 2;
1841.1Sjonathan	physmem_boardmax = MIPS_PHYS_TO_KSEG1(physmem_boardmax);
1851.10Sjonathan
1861.73Schristos	cpu_setmodel("DECstation 5000/1%d (3MIN)", mips_options.mips_cpu_mhz);
1871.22Snisimura}
1881.22Snisimura
1891.22Snisimura/*
1901.49Stsutsui * Initialize the memory system and I/O buses.
1911.22Snisimura */
1921.31Ssimonbstatic void
1931.65Stsutsuidec_3min_bus_reset(void)
1941.22Snisimura{
1951.22Snisimura
1961.22Snisimura	/*
1971.22Snisimura	 * Reset interrupts, clear any errors from newconf probes
1981.22Snisimura	 */
1991.22Snisimura
2001.65Stsutsui	*(volatile uint32_t *)MIPS_PHYS_TO_KSEG1(KMIN_REG_TIMEOUT) = 0;
2011.17Snisimura	kn02ba_wbflush();
2021.17Snisimura
2031.65Stsutsui	*(volatile uint32_t *)(ioasic_base + IOASIC_INTR) = 0;
2041.22Snisimura	kn02ba_wbflush();
2051.1Sjonathan}
2061.1Sjonathan
2071.31Ssimonbstatic void
2081.65Stsutsuidec_3min_cons_init(void)
2091.1Sjonathan{
2101.34Snisimura	int kbd, crt, screen;
2111.34Snisimura
2121.34Snisimura	kbd = crt = screen = 0;
2131.34Snisimura	prom_findcons(&kbd, &crt, &screen);
2141.34Snisimura
2151.34Snisimura	if (screen > 0) {
2161.51Sad#if NWSDISPLAY > 0
2171.51Sad 		if (tcfb_cnattach(crt) > 0) {
2181.51Sad			zs_ioasic_lk201_cnattach(ioasic_base, 0x180000, 0);
2191.51Sad 			return;
2201.51Sad 		}
2211.34Snisimura#endif
2221.34Snisimura		printf("No framebuffer device configured for slot %d: ", crt);
2231.34Snisimura		printf("using serial console\n");
2241.34Snisimura	}
2251.34Snisimura	/*
2261.34Snisimura	 * Delay to allow PROM putchars to complete.
2271.34Snisimura	 * FIFO depth * character time,
2281.34Snisimura	 * character time = (1000000 / (defaultrate / 10))
2291.34Snisimura	 */
2301.34Snisimura	DELAY(160000000 / 9600);	/* XXX */
2311.34Snisimura
2321.51Sad	zs_ioasic_cnattach(ioasic_base, 0x180000, 1);
2331.1Sjonathan}
2341.1Sjonathan
2351.31Ssimonbstatic void
2361.72Stsutsuidec_3min_intr_establish(device_t dev, void *cookie, int level,
2371.65Stsutsui    int (*handler)(void *), void *arg)
2381.1Sjonathan{
2391.65Stsutsui	uint32_t mask;
2401.1Sjonathan
2411.66Smatt	switch ((uintptr_t)cookie) {
2421.1Sjonathan		/* slots 0-2 don't interrupt through the IOASIC. */
2431.65Stsutsui	case SYS_DEV_OPT0:
2441.33Ssimonb		mask = MIPS_INT_MASK_0;
2451.33Ssimonb		break;
2461.65Stsutsui	case SYS_DEV_OPT1:
2471.33Ssimonb		mask = MIPS_INT_MASK_1;
2481.33Ssimonb		break;
2491.65Stsutsui	case SYS_DEV_OPT2:
2501.33Ssimonb		mask = MIPS_INT_MASK_2;
2511.33Ssimonb		break;
2521.1Sjonathan
2531.65Stsutsui	case SYS_DEV_SCSI:
2541.7Sjonathan		mask = (IOASIC_INTR_SCSI | IOASIC_INTR_SCSI_PTR_LOAD |
2551.7Sjonathan			IOASIC_INTR_SCSI_OVRUN | IOASIC_INTR_SCSI_READ_E);
2561.1Sjonathan		break;
2571.65Stsutsui	case SYS_DEV_LANCE:
2581.1Sjonathan		mask = KMIN_INTR_LANCE;
2591.1Sjonathan		break;
2601.65Stsutsui	case SYS_DEV_SCC0:
2611.1Sjonathan		mask = KMIN_INTR_SCC_0;
2621.1Sjonathan		break;
2631.65Stsutsui	case SYS_DEV_SCC1:
2641.1Sjonathan		mask = KMIN_INTR_SCC_1;
2651.1Sjonathan		break;
2661.65Stsutsui	default:
2671.33Ssimonb#ifdef DIAGNOSTIC
2681.66Smatt		printf("warning: enabling unknown intr %p\n", cookie);
2691.33Ssimonb#endif
2701.1Sjonathan		return;
2711.1Sjonathan	}
2721.1Sjonathan
2731.38Sad#if defined(DEBUG)
2741.66Smatt	printf("3MIN: imask %x, enabling slot %p, dev %p handler %p\n",
2751.66Smatt	    kmin_tc3_imask, cookie, dev, handler);
2761.1Sjonathan#endif
2771.1Sjonathan
2781.1Sjonathan	/*
2791.1Sjonathan	 * Enable the interrupt  handler, and if it's an IOASIC
2801.1Sjonathan	 * slot, set the IOASIC interrupt mask.
2811.1Sjonathan	 * Otherwise, set the appropriate spl level in the R3000
2821.1Sjonathan	 * register.
2831.35Snisimura	 * Be careful to set handlers before enabling, and disable
2841.1Sjonathan	 * interrupts before clearing handlers.
2851.1Sjonathan	 */
2861.1Sjonathan
2871.33Ssimonb	/* Set the interrupt handler and argument ... */
2881.66Smatt	intrtab[(uintptr_t)cookie].ih_func = handler;
2891.66Smatt	intrtab[(uintptr_t)cookie].ih_arg = arg;
2901.33Ssimonb	/* ... and set the relevant mask */
2911.66Smatt	switch ((uintptr_t)cookie) {
2921.35Snisimura	case SYS_DEV_OPT0:
2931.35Snisimura	case SYS_DEV_OPT1:
2941.35Snisimura	case SYS_DEV_OPT2:
2951.33Ssimonb		/* it's an option slot */
2961.35Snisimura		{
2971.33Ssimonb		int s = splhigh();
2981.33Ssimonb		s |= mask;
2991.33Ssimonb		splx(s);
3001.35Snisimura		}
3011.35Snisimura		break;
3021.35Snisimura	default:
3031.35Snisimura		/* it's a baseboard device going via the IOASIC */
3041.33Ssimonb		kmin_tc3_imask |= mask;
3051.35Snisimura		break;
3061.1Sjonathan	}
3071.33Ssimonb
3081.65Stsutsui	*(volatile uint32_t *)(ioasic_base + IOASIC_IMSK) = kmin_tc3_imask;
3091.25Snisimura	kn02ba_wbflush();
3101.1Sjonathan}
3111.1Sjonathan
3121.1Sjonathan
3131.44Stsutsui#define CHECKINTR(slot, bits)					\
3141.35Snisimura    do {							\
3151.44Stsutsui	if (can_serve & (bits)) {				\
3161.52Ssimonb		intrtab[slot].ih_count.ev_count++;		\
3171.44Stsutsui		(*intrtab[slot].ih_func)(intrtab[slot].ih_arg);	\
3181.44Stsutsui	}							\
3191.65Stsutsui    } while (/*CONSTCOND*/0)
3201.1Sjonathan
3211.42Snisimurastatic void
3221.68Smattdec_3min_intr(uint32_t status, vaddr_t pc, uint32_t ipending)
3231.1Sjonathan{
3241.1Sjonathan	static int user_warned = 0;
3251.65Stsutsui	uint32_t old_mask;
3261.1Sjonathan
3271.65Stsutsui	old_mask = *(volatile uint32_t *)(ioasic_base + IOASIC_IMSK);
3281.10Sjonathan
3291.68Smatt	do {
3301.68Smatt		if (ipending & MIPS_INT_MASK_4)
3311.68Smatt			prom_haltbutton();
3321.68Smatt
3331.68Smatt		if (ipending & MIPS_INT_MASK_3) {
3341.68Smatt			/* NB: status & MIPS_INT_MASK3 must also be set */
3351.68Smatt			/* masked interrupts are still observable */
3361.68Smatt			uint32_t intr, imsk, can_serve, turnoff;
3371.68Smatt
3381.68Smatt			turnoff = 0;
3391.68Smatt			intr = *(volatile uint32_t *)(ioasic_base + IOASIC_INTR);
3401.68Smatt			imsk = *(volatile uint32_t *)(ioasic_base + IOASIC_IMSK);
3411.68Smatt			can_serve = intr & imsk;
3421.1Sjonathan
3431.68Smatt			if (intr & IOASIC_INTR_SCSI_PTR_LOAD) {
3441.68Smatt				turnoff |= IOASIC_INTR_SCSI_PTR_LOAD;
3451.1Sjonathan#ifdef notdef
3461.68Smatt				asc_dma_intr();
3471.1Sjonathan#endif
3481.68Smatt			}
3491.12Ssimonb
3501.68Smatt			if (intr & (IOASIC_INTR_SCSI_OVRUN | IOASIC_INTR_SCSI_READ_E))
3511.68Smatt				turnoff |= IOASIC_INTR_SCSI_OVRUN | IOASIC_INTR_SCSI_READ_E;
3521.12Ssimonb
3531.68Smatt			if (intr & IOASIC_INTR_LANCE_READ_E)
3541.68Smatt				turnoff |= IOASIC_INTR_LANCE_READ_E;
3551.17Snisimura
3561.68Smatt			if (turnoff)
3571.68Smatt				*(volatile uint32_t *)(ioasic_base + IOASIC_INTR) = ~turnoff;
3581.68Smatt
3591.68Smatt			if (intr & KMIN_INTR_TIMEOUT) {
3601.68Smatt				kn02ba_errintr();
3611.68Smatt				pmax_memerr_evcnt.ev_count++;
3621.68Smatt			}
3631.68Smatt
3641.68Smatt			if (intr & KMIN_INTR_CLOCK) {
3651.68Smatt				struct clockframe cf;
3661.68Smatt
3671.68Smatt				__asm volatile("lbu $0,48(%0)" ::
3681.68Smatt					"r"(ioasic_base + IOASIC_SLOT_8_START));
3691.68Smatt
3701.68Smatt				cf.pc = pc;
3711.68Smatt				cf.sr = status;
3721.69Stsutsui				cf.intr = (curcpu()->ci_idepth > 1);
3731.68Smatt				hardclock(&cf);
3741.68Smatt				pmax_clock_evcnt.ev_count++;
3751.68Smatt			}
3761.68Smatt
3771.68Smatt			/* If clock interrupts were enabled, re-enable them ASAP. */
3781.68Smatt			if (old_mask & KMIN_INTR_CLOCK) {
3791.68Smatt				/* ioctl interrupt mask to splclock and higher */
3801.68Smatt				*(uint32_t *)(ioasic_base + IOASIC_IMSK) =
3811.68Smatt				    old_mask &
3821.68Smatt					~(KMIN_INTR_SCC_0|KMIN_INTR_SCC_1
3831.68Smatt					  |IOASIC_INTR_LANCE|IOASIC_INTR_SCSI);
3841.68Smatt				kn02ba_wbflush();
3851.68Smatt			}
3861.59Sjoerg
3871.68Smatt			if (curcpu()->ci_idepth > 1)
3881.68Smatt				 break;
3891.10Sjonathan
3901.68Smatt			CHECKINTR(SYS_DEV_SCC0, IOASIC_INTR_SCC_0);
3911.68Smatt			CHECKINTR(SYS_DEV_SCC1, IOASIC_INTR_SCC_1);
3921.10Sjonathan
3931.68Smatt#ifdef notyet /* untested */
3941.68Smatt			/* If tty interrupts were enabled, re-enable them ASAP. */
3951.68Smatt			if ((old_mask & (KMIN_INTR_SCC_1|KMIN_INTR_SCC_0)) ==
3961.68Smatt			     (KMIN_INTR_SCC_1|KMIN_INTR_SCC_0)) {
3971.68Smatt				*imaskp = old_mask &
3981.68Smatt				  ~(KMIN_INTR_SCC_0|KMIN_INTR_SCC_1 |
3991.68Smatt				  IOASIC_INTR_LANCE|IOASIC_INTR_SCSI);
4001.68Smatt				kn02ba_wbflush();
4011.68Smatt			}
4021.68Smatt
4031.68Smatt			/* XXX until we know about SPLs of TC options. */
4041.68Smatt			if (curcpu()->ci_idepth > 1)
4051.68Smatt				 break;
4061.68Smatt#endif
4071.68Smatt			CHECKINTR(SYS_DEV_LANCE, IOASIC_INTR_LANCE);
4081.68Smatt			CHECKINTR(SYS_DEV_SCSI, IOASIC_INTR_SCSI);
4091.11Sjonathan
4101.68Smatt			if (user_warned && ((intr & KMIN_INTR_PSWARN) == 0)) {
4111.68Smatt				printf("%s\n", "Power supply ok now.");
4121.68Smatt				user_warned = 0;
4131.68Smatt			}
4141.68Smatt			if ((intr & KMIN_INTR_PSWARN) && (user_warned < 3)) {
4151.68Smatt				user_warned++;
4161.68Smatt				printf("%s\n", "Power supply overheating");
4171.68Smatt			}
4181.68Smatt		}
4191.68Smatt		if ((ipending & MIPS_INT_MASK_0) && intrtab[SYS_DEV_OPT0].ih_func) {
4201.68Smatt			(*intrtab[SYS_DEV_OPT0].ih_func)(intrtab[SYS_DEV_OPT0].ih_arg);
4211.68Smatt			intrtab[SYS_DEV_OPT0].ih_count.ev_count++;
4221.10Sjonathan		}
4231.10Sjonathan
4241.68Smatt		if ((ipending & MIPS_INT_MASK_1) && intrtab[SYS_DEV_OPT1].ih_func) {
4251.68Smatt			(*intrtab[SYS_DEV_OPT1].ih_func)(intrtab[SYS_DEV_OPT1].ih_arg);
4261.68Smatt			intrtab[SYS_DEV_OPT1].ih_count.ev_count++;
4271.1Sjonathan		}
4281.68Smatt		if ((ipending & MIPS_INT_MASK_2) && intrtab[SYS_DEV_OPT2].ih_func) {
4291.68Smatt			(*intrtab[SYS_DEV_OPT2].ih_func)(intrtab[SYS_DEV_OPT2].ih_arg);
4301.68Smatt			intrtab[SYS_DEV_OPT2].ih_count.ev_count++;
4311.1Sjonathan		}
4321.68Smatt	} while (0);
4331.1Sjonathan
4341.10Sjonathan	/* restore entry state */
4351.68Smatt	*(uint32_t *)(ioasic_base + IOASIC_IMSK) = old_mask;
4361.1Sjonathan}
4371.1Sjonathan
4381.1Sjonathan
4391.1Sjonathan
4401.1Sjonathan/*
4411.1Sjonathan ************************************************************************
4421.1Sjonathan * Extra functions
4431.1Sjonathan ************************************************************************
4441.1Sjonathan */
4451.14Snisimura
4461.31Ssimonbstatic void
4471.65Stsutsuikn02ba_wbflush(void)
4481.14Snisimura{
4491.65Stsutsui
4501.21Snisimura	/* read twice IOASIC_IMSK */
4511.54Sperry	__asm volatile("lw $0,%0; lw $0,%0" ::
4521.27Ssimonb	    "i"(MIPS_PHYS_TO_KSEG1(KMIN_REG_IMSK)));
4531.14Snisimura}
4541.14Snisimura
4551.59Sjoerg/*
4561.59Sjoerg * Support for using the MIPS 3 clock as a timecounter.
4571.59Sjoerg */
4581.59Sjoerg
4591.59Sjoergvoid
4601.59Sjoergdec_3min_tc_init(void)
4611.14Snisimura{
4621.60Stsutsui#if defined(MIPS3)
4631.59Sjoerg	static struct timecounter tc =  {
4641.59Sjoerg		.tc_get_timecount = (timecounter_get_t *)mips3_cp0_count_read,
4651.59Sjoerg		.tc_counter_mask = ~0u,
4661.59Sjoerg		.tc_name = "mips3_cp0_counter",
4671.59Sjoerg		.tc_quality = 100,
4681.59Sjoerg	};
4691.59Sjoerg
4701.59Sjoerg	if (MIPS_HAS_CLOCK) {
4711.68Smatt		tc.tc_frequency = mips_options.mips_cpu_mhz * 1000000;
4721.59Sjoerg
4731.59Sjoerg		tc_init(&tc);
4741.14Snisimura	}
4751.60Stsutsui#endif
4761.1Sjonathan}
477