dec_3min.c revision 1.27
11.27Ssimonb/* $NetBSD: dec_3min.c,v 1.27 1999/11/28 08:29:00 simonb 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.1Sjonathan * 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.1Sjonathan * 3. All advertising materials mentioning features or use of this software 521.1Sjonathan * must display the following acknowledgement: 531.1Sjonathan * This product includes software developed by the University of 541.1Sjonathan * California, Berkeley and its contributors. 551.1Sjonathan * 4. Neither the name of the University nor the names of its contributors 561.1Sjonathan * may be used to endorse or promote products derived from this software 571.1Sjonathan * without specific prior written permission. 581.1Sjonathan * 591.1Sjonathan * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 601.1Sjonathan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 611.1Sjonathan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 621.1Sjonathan * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 631.1Sjonathan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 641.1Sjonathan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 651.1Sjonathan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 661.1Sjonathan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 671.1Sjonathan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 681.1Sjonathan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 691.1Sjonathan * SUCH DAMAGE. 701.1Sjonathan * 711.1Sjonathan * @(#)machdep.c 8.3 (Berkeley) 1/12/94 721.1Sjonathan */ 731.1Sjonathan 741.1Sjonathan#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 751.1Sjonathan 761.27Ssimonb__KERNEL_RCSID(0, "$NetBSD: dec_3min.c,v 1.27 1999/11/28 08:29:00 simonb Exp $"); 771.1Sjonathan 781.1Sjonathan 791.1Sjonathan#include <sys/types.h> 801.1Sjonathan#include <sys/systm.h> 811.1Sjonathan 821.1Sjonathan#include <machine/cpu.h> 831.1Sjonathan#include <machine/intr.h> 841.1Sjonathan#include <machine/reg.h> 851.1Sjonathan#include <machine/psl.h> 861.1Sjonathan#include <machine/sysconf.h> 871.1Sjonathan 881.1Sjonathan#include <mips/mips/mips_mcclock.h> /* mcclock CPUspeed estimation */ 891.2Sjonathan 901.2Sjonathan/* all these to get ioasic_base */ 911.2Sjonathan#include <sys/device.h> /* struct cfdata for.. */ 921.2Sjonathan#include <dev/tc/tcvar.h> /* tc type definitions for.. */ 931.7Sjonathan#include <dev/tc/ioasicreg.h> /* ioasic interrrupt masks */ 941.2Sjonathan#include <dev/tc/ioasicvar.h> /* ioasic_base */ 951.1Sjonathan 961.12Ssimonb#include <pmax/pmax/turbochannel.h> 971.20Ssimonb#include <pmax/pmax/machdep.h> 981.1Sjonathan 991.1Sjonathan#include <pmax/pmax/kmin.h> /* 3min baseboard addresses */ 1001.15Snisimura#include <pmax/pmax/memc.h> /* 3min/maxine memory errors */ 1011.1Sjonathan 1021.1Sjonathan 1031.1Sjonathan/* 1041.1Sjonathan * forward declarations 1051.1Sjonathan */ 1061.1Sjonathanvoid dec_3min_init __P((void)); 1071.1Sjonathanvoid dec_3min_bus_reset __P((void)); 1081.1Sjonathan 1091.12Ssimonbvoid dec_3min_enable_intr 1101.24Snisimura __P ((unsigned slotno, int (*handler)(void *), 1111.24Snisimura void *sc, int onoff)); 1121.17Snisimuraint dec_3min_intr __P((unsigned, unsigned, unsigned, unsigned)); 1131.1Sjonathanvoid dec_3min_device_register __P((struct device *, void *)); 1141.1Sjonathanvoid dec_3min_cons_init __P((void)); 1151.1Sjonathan 1161.1Sjonathan 1171.1Sjonathan/* 1181.1Sjonathan * Local declarations. 1191.1Sjonathan */ 1201.1Sjonathanvoid dec_3min_mcclock_cpuspeed __P((volatile struct chiptime *mcclock_addr, 1211.1Sjonathan int clockmask)); 1221.14Snisimuravoid kn02ba_wbflush __P((void)); 1231.14Snisimuraunsigned kn02ba_clkread __P((void)); 1241.18Snisimura 1251.22Snisimurastatic u_int32_t kmin_tc3_imask; 1261.18Snisimura 1271.18Snisimura#ifdef MIPS3 1281.19Snisimurastatic unsigned latched_cycle_cnt; 1291.18Snisimuraextern u_int32_t mips3_cycle_count __P((void)); 1301.18Snisimura#endif 1311.18Snisimura 1321.1Sjonathan 1331.1Sjonathanvoid 1341.1Sjonathandec_3min_init() 1351.1Sjonathan{ 1361.22Snisimura extern char cpu_model[]; 1371.22Snisimura extern int physmem_boardmax; 1381.22Snisimura 1391.24Snisimura platform.iobus = "tcbus"; 1401.1Sjonathan platform.bus_reset = dec_3min_bus_reset; 1411.1Sjonathan platform.cons_init = dec_3min_cons_init; 1421.1Sjonathan platform.device_register = dec_3min_device_register; 1431.22Snisimura platform.iointr = dec_3min_intr; 1441.26Ssimonb platform.memsize = memsize_scan; 1451.22Snisimura platform.clkread = kn02ba_clkread; 1461.1Sjonathan 1471.22Snisimura /* clear any memory errors */ 1481.17Snisimura *(u_int32_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.22Snisimura mips_hardware_intr = dec_3min_intr; 1531.22Snisimura tc_enable_interrupt = dec_3min_enable_intr; 1541.1Sjonathan 1551.1Sjonathan /* 1561.22Snisimura * Since all the motherboard interrupts come through the 1571.22Snisimura * IOASIC, it has to be turned off for all the spls and 1581.22Snisimura * since we don't know what kinds of devices are in the 1591.22Snisimura * TURBOchannel option slots, just splhigh(). 1601.1Sjonathan */ 1611.16Snisimura splvec.splbio = MIPS_SPL_0_1_2_3; 1621.22Snisimura splvec.splnet = MIPS_SPL_0_1_2_3; 1631.16Snisimura splvec.spltty = MIPS_SPL_0_1_2_3; 1641.16Snisimura splvec.splimp = MIPS_SPL_0_1_2_3; 1651.16Snisimura splvec.splclock = MIPS_SPL_0_1_2_3; 1661.16Snisimura splvec.splstatclock = MIPS_SPL_0_1_2_3; 1671.16Snisimura 1681.22Snisimura /* calibrate cpu_mhz value */ 1691.22Snisimura dec_3min_mcclock_cpuspeed( 1701.22Snisimura (void *)(ioasic_base + IOASIC_SLOT_8_START), MIPS_INT_MASK_3); 1711.1Sjonathan 1721.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_LANCE_DECODE) = 0x3; 1731.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_SCSI_DECODE) = 0xe; 1741.22Snisimura#if 0 1751.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_SCC0_DECODE) = (0x10|4); 1761.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_SCC1_DECODE) = (0x10|6); 1771.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_CSR) = 0x00000f00; 1781.22Snisimura#endif 1791.22Snisimura 1801.22Snisimura /* sanitize interrupt mask */ 1811.22Snisimura kmin_tc3_imask = (KMIN_INTR_CLOCK|KMIN_INTR_PSWARN|KMIN_INTR_TIMEOUT); 1821.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_INTR) = 0; 1831.22Snisimura *(u_int32_t *)(ioasic_base + IOASIC_IMSK) = kmin_tc3_imask; 1841.1Sjonathan 1851.1Sjonathan /* 1861.22Snisimura * The kmin memory hardware seems to wrap memory addresses 1871.1Sjonathan * with 4Mbyte SIMMs, which causes the physmem computation 1881.1Sjonathan * to lose. Find out how big the SIMMS are and set 1891.22Snisimura * max_ physmem accordingly. 1901.22Snisimura * XXX Do MAXINEs lose the same way? 1911.1Sjonathan */ 1921.1Sjonathan physmem_boardmax = KMIN_PHYS_MEMORY_END + 1; 1931.22Snisimura if ((KMIN_MSR_SIZE_16Mb & *(int *)MIPS_PHYS_TO_KSEG1(KMIN_REG_MSR)) 1941.22Snisimura == 0) 1951.1Sjonathan physmem_boardmax = physmem_boardmax >> 2; 1961.1Sjonathan physmem_boardmax = MIPS_PHYS_TO_KSEG1(physmem_boardmax); 1971.10Sjonathan 1981.22Snisimura sprintf(cpu_model, "DECstation 5000/1%d (3MIN)", cpu_mhz); 1991.22Snisimura} 2001.22Snisimura 2011.22Snisimura/* 2021.22Snisimura * Initalize the memory system and I/O buses. 2031.22Snisimura */ 2041.22Snisimuravoid 2051.22Snisimuradec_3min_bus_reset() 2061.22Snisimura{ 2071.22Snisimura 2081.22Snisimura /* 2091.22Snisimura * Reset interrupts, clear any errors from newconf probes 2101.22Snisimura */ 2111.22Snisimura 2121.17Snisimura *(u_int32_t *)MIPS_PHYS_TO_KSEG1(KMIN_REG_TIMEOUT) = 0; 2131.17Snisimura kn02ba_wbflush(); 2141.17Snisimura 2151.22Snisimura *(u_int32_t *)(ioasic_base + IOASIC_INTR) = 0; 2161.22Snisimura kn02ba_wbflush(); 2171.1Sjonathan} 2181.1Sjonathan 2191.1Sjonathanvoid 2201.1Sjonathandec_3min_cons_init() 2211.1Sjonathan{ 2221.1Sjonathan /* notyet */ 2231.1Sjonathan} 2241.1Sjonathan 2251.1Sjonathan 2261.1Sjonathanvoid 2271.1Sjonathandec_3min_device_register(dev, aux) 2281.1Sjonathan struct device *dev; 2291.1Sjonathan void *aux; 2301.1Sjonathan{ 2311.1Sjonathan panic("dec_3min_device_register unimplemented"); 2321.1Sjonathan} 2331.1Sjonathan 2341.1Sjonathan 2351.1Sjonathanvoid 2361.1Sjonathandec_3min_enable_intr(slotno, handler, sc, on) 2371.13Ssimonb unsigned int slotno; 2381.24Snisimura int (*handler) __P((void *)); 2391.1Sjonathan void *sc; 2401.1Sjonathan int on; 2411.1Sjonathan{ 2421.13Ssimonb unsigned mask; 2431.1Sjonathan 2441.1Sjonathan switch (slotno) { 2451.1Sjonathan /* slots 0-2 don't interrupt through the IOASIC. */ 2461.1Sjonathan case 0: 2471.1Sjonathan mask = MIPS_INT_MASK_0; break; 2481.1Sjonathan case 1: 2491.1Sjonathan mask = MIPS_INT_MASK_1; break; 2501.1Sjonathan case 2: 2511.1Sjonathan mask = MIPS_INT_MASK_2; break; 2521.1Sjonathan 2531.1Sjonathan case KMIN_SCSI_SLOT: 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.1Sjonathan 2581.1Sjonathan case KMIN_LANCE_SLOT: 2591.1Sjonathan mask = KMIN_INTR_LANCE; 2601.1Sjonathan break; 2611.1Sjonathan case KMIN_SCC0_SLOT: 2621.1Sjonathan mask = KMIN_INTR_SCC_0; 2631.1Sjonathan break; 2641.1Sjonathan case KMIN_SCC1_SLOT: 2651.1Sjonathan mask = KMIN_INTR_SCC_1; 2661.1Sjonathan break; 2671.1Sjonathan case KMIN_ASIC_SLOT: 2681.1Sjonathan mask = KMIN_INTR_ASIC; 2691.1Sjonathan break; 2701.1Sjonathan default: 2711.1Sjonathan return; 2721.1Sjonathan } 2731.1Sjonathan 2741.1Sjonathan#if defined(DEBUG) || defined(DIAGNOSTIC) 2751.25Snisimura printf("3MIN: imask %x, %sabling slot %d, sc %p handler %p\n", 2761.1Sjonathan kmin_tc3_imask, (on? "en" : "dis"), slotno, sc, handler); 2771.1Sjonathan#endif 2781.1Sjonathan 2791.1Sjonathan /* 2801.1Sjonathan * Enable the interrupt handler, and if it's an IOASIC 2811.1Sjonathan * slot, set the IOASIC interrupt mask. 2821.1Sjonathan * Otherwise, set the appropriate spl level in the R3000 2831.1Sjonathan * register. 2841.1Sjonathan * Be careful to set handlers before enabling, and disable 2851.1Sjonathan * interrupts before clearing handlers. 2861.1Sjonathan */ 2871.1Sjonathan 2881.1Sjonathan if (on) { 2891.1Sjonathan /* Set the interrupt handler and argument ... */ 2901.1Sjonathan tc_slot_info[slotno].intr = handler; 2911.1Sjonathan tc_slot_info[slotno].sc = sc; 2921.1Sjonathan 2931.1Sjonathan /* ... and set the relevant mask */ 2941.1Sjonathan if (slotno <= 2) { 2951.1Sjonathan /* it's an option slot */ 2961.1Sjonathan int s = splhigh(); 2971.1Sjonathan s |= mask; 2981.1Sjonathan splx(s); 2991.1Sjonathan } else { 3001.1Sjonathan /* it's a baseboard device going via the ASIC */ 3011.1Sjonathan kmin_tc3_imask |= mask; 3021.1Sjonathan } 3031.1Sjonathan } else { 3041.1Sjonathan /* Clear the relevant mask... */ 3051.12Ssimonb if (slotno <= 2) { 3061.1Sjonathan /* it's an option slot */ 3071.1Sjonathan int s = splhigh(); 3081.1Sjonathan printf("kmin_intr: cannot disable option slot %d\n", 3091.1Sjonathan slotno); 3101.1Sjonathan s &= ~mask; 3111.1Sjonathan splx(s); 3121.1Sjonathan } else { 3131.1Sjonathan /* it's a baseboard device going via the ASIC */ 3141.1Sjonathan kmin_tc3_imask &= ~mask; 3151.1Sjonathan } 3161.1Sjonathan /* ... and clear the handler */ 3171.1Sjonathan tc_slot_info[slotno].intr = 0; 3181.1Sjonathan tc_slot_info[slotno].sc = 0; 3191.1Sjonathan } 3201.25Snisimura *(u_int32_t *)(ioasic_base + IOASIC_IMSK) = kmin_tc3_imask; 3211.25Snisimura kn02ba_wbflush(); 3221.1Sjonathan} 3231.1Sjonathan 3241.1Sjonathan 3251.1Sjonathan 3261.1Sjonathan/* 3271.1Sjonathan * 3min hardware interrupts. (DECstation 5000/1xx) 3281.1Sjonathan */ 3291.1Sjonathanint 3301.17Snisimuradec_3min_intr(cpumask, pc, status, cause) 3311.17Snisimura unsigned cpumask; 3321.1Sjonathan unsigned pc; 3331.17Snisimura unsigned status; 3341.17Snisimura unsigned cause; 3351.1Sjonathan{ 3361.1Sjonathan static int user_warned = 0; 3371.17Snisimura static int intr_depth = 0; 3381.17Snisimura u_int32_t old_mask; 3391.1Sjonathan 3401.10Sjonathan intr_depth++; 3411.17Snisimura old_mask = *(u_int32_t *)(ioasic_base + IOASIC_IMSK); 3421.10Sjonathan 3431.17Snisimura if (cpumask & MIPS_INT_MASK_4) 3441.1Sjonathan prom_haltbutton(); 3451.1Sjonathan 3461.17Snisimura if (cpumask & MIPS_INT_MASK_3) { 3471.10Sjonathan /* NB: status & MIPS_INT_MASK3 must also be set */ 3481.10Sjonathan /* masked interrupts are still observable */ 3491.17Snisimura u_int32_t intr, imsk, turnoff; 3501.17Snisimura 3511.17Snisimura turnoff = 0; 3521.17Snisimura intr = *(u_int32_t *)(ioasic_base + IOASIC_INTR); 3531.17Snisimura imsk = *(u_int32_t *)(ioasic_base + IOASIC_IMSK); 3541.17Snisimura intr &= imsk; 3551.1Sjonathan 3561.7Sjonathan if (intr & IOASIC_INTR_SCSI_PTR_LOAD) { 3571.17Snisimura turnoff |= IOASIC_INTR_SCSI_PTR_LOAD; 3581.1Sjonathan#ifdef notdef 3591.1Sjonathan asc_dma_intr(); 3601.1Sjonathan#endif 3611.1Sjonathan } 3621.12Ssimonb 3631.7Sjonathan if (intr & (IOASIC_INTR_SCSI_OVRUN | IOASIC_INTR_SCSI_READ_E)) 3641.17Snisimura turnoff |= IOASIC_INTR_SCSI_OVRUN | IOASIC_INTR_SCSI_READ_E; 3651.1Sjonathan 3661.7Sjonathan if (intr & IOASIC_INTR_LANCE_READ_E) 3671.17Snisimura turnoff |= IOASIC_INTR_LANCE_READ_E; 3681.17Snisimura 3691.17Snisimura if (turnoff) 3701.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_INTR) = ~turnoff; 3711.1Sjonathan 3721.1Sjonathan if (intr & KMIN_INTR_TIMEOUT) 3731.1Sjonathan kn02ba_errintr(); 3741.12Ssimonb 3751.1Sjonathan if (intr & KMIN_INTR_CLOCK) { 3761.17Snisimura struct clockframe cf; 3771.17Snisimura 3781.22Snisimura __asm __volatile("lbu $0,48(%0)" :: 3791.22Snisimura "r"(ioasic_base + IOASIC_SLOT_8_START)); 3801.6Sjonathan#ifdef MIPS3 3811.6Sjonathan if (CPUISMIPS3) { 3821.6Sjonathan latched_cycle_cnt = mips3_cycle_count(); 3831.6Sjonathan } 3841.6Sjonathan#endif 3851.17Snisimura cf.pc = pc; 3861.17Snisimura cf.sr = status; 3871.1Sjonathan hardclock(&cf); 3881.1Sjonathan intrcnt[HARDCLOCK]++; 3891.1Sjonathan } 3901.10Sjonathan 3911.10Sjonathan /* If clock interrups were enabled, re-enable them ASAP. */ 3921.10Sjonathan if (old_mask & KMIN_INTR_CLOCK) { 3931.17Snisimura /* ioctl interrupt mask to splclock and higher */ 3941.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_IMSK) 3951.17Snisimura = old_mask & 3961.17Snisimura ~(KMIN_INTR_SCC_0|KMIN_INTR_SCC_1 | 3971.17Snisimura IOASIC_INTR_LANCE|IOASIC_INTR_SCSI); 3981.14Snisimura kn02ba_wbflush(); 3991.17Snisimura _splset(MIPS_SR_INT_IE | (status & MIPS_INT_MASK_3)); 4001.10Sjonathan } 4011.10Sjonathan 4021.11Sjonathan if (intr_depth > 1) 4031.11Sjonathan goto done; 4041.11Sjonathan 4051.1Sjonathan if ((intr & KMIN_INTR_SCC_0) && 4061.1Sjonathan tc_slot_info[KMIN_SCC0_SLOT].intr) { 4071.1Sjonathan (*(tc_slot_info[KMIN_SCC0_SLOT].intr)) 4081.1Sjonathan (tc_slot_info[KMIN_SCC0_SLOT].sc); 4091.1Sjonathan intrcnt[SERIAL0_INTR]++; 4101.1Sjonathan } 4111.1Sjonathan 4121.1Sjonathan if ((intr & KMIN_INTR_SCC_1) && 4131.1Sjonathan tc_slot_info[KMIN_SCC1_SLOT].intr) { 4141.1Sjonathan (*(tc_slot_info[KMIN_SCC1_SLOT].intr)) 4151.1Sjonathan (tc_slot_info[KMIN_SCC1_SLOT].sc); 4161.1Sjonathan intrcnt[SERIAL1_INTR]++; 4171.1Sjonathan } 4181.10Sjonathan 4191.10Sjonathan#ifdef notyet /* untested */ 4201.10Sjonathan /* If tty interrupts were enabled, re-enable them ASAP. */ 4211.10Sjonathan if ((old_mask & (KMIN_INTR_SCC_1|KMIN_INTR_SCC_0)) == 4221.10Sjonathan (KMIN_INTR_SCC_1|KMIN_INTR_SCC_0)) { 4231.12Ssimonb *imaskp = old_mask & 4241.10Sjonathan ~(KMIN_INTR_SCC_0|KMIN_INTR_SCC_1 | 4251.10Sjonathan IOASIC_INTR_LANCE|IOASIC_INTR_SCSI); 4261.14Snisimura kn02ba_wbflush(); 4271.10Sjonathan } 4281.10Sjonathan 4291.10Sjonathan /* XXX until we know about SPLs of TC options. */ 4301.10Sjonathan if (intr_depth > 1) 4311.10Sjonathan goto done; 4321.10Sjonathan#endif 4331.9Sjonathan if ((intr & IOASIC_INTR_LANCE) && 4341.9Sjonathan tc_slot_info[KMIN_LANCE_SLOT].intr) { 4351.9Sjonathan (*(tc_slot_info[KMIN_LANCE_SLOT].intr)) 4361.9Sjonathan (tc_slot_info[KMIN_LANCE_SLOT].sc); 4371.9Sjonathan intrcnt[LANCE_INTR]++; 4381.9Sjonathan } 4391.9Sjonathan 4401.7Sjonathan if ((intr & IOASIC_INTR_SCSI) && 4411.1Sjonathan tc_slot_info[KMIN_SCSI_SLOT].intr) { 4421.1Sjonathan (*(tc_slot_info[KMIN_SCSI_SLOT].intr)) 4431.1Sjonathan (tc_slot_info[KMIN_SCSI_SLOT].sc); 4441.1Sjonathan intrcnt[SCSI_INTR]++; 4451.1Sjonathan } 4461.1Sjonathan 4471.1Sjonathan if (user_warned && ((intr & KMIN_INTR_PSWARN) == 0)) { 4481.1Sjonathan printf("%s\n", "Power supply ok now."); 4491.1Sjonathan user_warned = 0; 4501.1Sjonathan } 4511.1Sjonathan if ((intr & KMIN_INTR_PSWARN) && (user_warned < 3)) { 4521.1Sjonathan user_warned++; 4531.1Sjonathan printf("%s\n", "Power supply overheating"); 4541.1Sjonathan } 4551.1Sjonathan } 4561.17Snisimura if ((cpumask & MIPS_INT_MASK_0) && tc_slot_info[0].intr) { 4571.1Sjonathan (*tc_slot_info[0].intr)(tc_slot_info[0].sc); 4581.1Sjonathan intrcnt[SLOT0_INTR]++; 4591.1Sjonathan } 4601.12Ssimonb 4611.17Snisimura if ((cpumask & MIPS_INT_MASK_1) && tc_slot_info[1].intr) { 4621.1Sjonathan (*tc_slot_info[1].intr)(tc_slot_info[1].sc); 4631.1Sjonathan intrcnt[SLOT1_INTR]++; 4641.1Sjonathan } 4651.17Snisimura if ((cpumask & MIPS_INT_MASK_2) && tc_slot_info[2].intr) { 4661.1Sjonathan (*tc_slot_info[2].intr)(tc_slot_info[2].sc); 4671.1Sjonathan intrcnt[SLOT2_INTR]++; 4681.1Sjonathan } 4691.1Sjonathan 4701.10Sjonathandone: 4711.10Sjonathan /* restore entry state */ 4721.10Sjonathan splhigh(); 4731.10Sjonathan intr_depth--; 4741.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_IMSK) = old_mask; 4751.10Sjonathan 4761.14Snisimura 4771.17Snisimura return (MIPS_SR_INT_IE | (status & ~cause & MIPS_HARD_INT_MASK)); 4781.1Sjonathan} 4791.1Sjonathan 4801.1Sjonathan 4811.1Sjonathan 4821.1Sjonathan/* 4831.1Sjonathan ************************************************************************ 4841.1Sjonathan * Extra functions 4851.1Sjonathan ************************************************************************ 4861.1Sjonathan */ 4871.1Sjonathan 4881.1Sjonathan 4891.1Sjonathan 4901.1Sjonathan 4911.1Sjonathan/* 4921.1Sjonathan * Count instructions between 4ms mcclock interrupt requests, 4931.1Sjonathan * using the ioasic clock-interrupt-pending bit to determine 4941.12Ssimonb * when clock ticks occur. 4951.1Sjonathan * Set up iosiac to allow only clock interrupts, then 4961.12Ssimonb * call 4971.1Sjonathan */ 4981.1Sjonathanvoid 4991.1Sjonathandec_3min_mcclock_cpuspeed(mcclock_addr, clockmask) 5001.1Sjonathan volatile struct chiptime *mcclock_addr; 5011.1Sjonathan int clockmask; 5021.1Sjonathan{ 5031.17Snisimura u_int32_t saved_imask; 5041.1Sjonathan 5051.17Snisimura saved_imask = *(u_int32_t *)(ioasic_base + IOASIC_IMSK); 5061.1Sjonathan 5071.1Sjonathan /* Allow only clock interrupts through ioasic. */ 5081.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_IMSK) = KMIN_INTR_CLOCK; 5091.14Snisimura kn02ba_wbflush(); 5101.12Ssimonb 5111.1Sjonathan mc_cpuspeed(mcclock_addr, clockmask); 5121.1Sjonathan 5131.17Snisimura *(u_int32_t *)(ioasic_base + IOASIC_IMSK) = saved_imask; 5141.14Snisimura kn02ba_wbflush(); 5151.14Snisimura} 5161.14Snisimura 5171.14Snisimuravoid 5181.14Snisimurakn02ba_wbflush() 5191.14Snisimura{ 5201.21Snisimura /* read twice IOASIC_IMSK */ 5211.27Ssimonb __asm __volatile("lw $0,%0; lw $0,%0" :: 5221.27Ssimonb "i"(MIPS_PHYS_TO_KSEG1(KMIN_REG_IMSK))); 5231.14Snisimura} 5241.14Snisimura 5251.14Snisimuraunsigned 5261.14Snisimurakn02ba_clkread() 5271.14Snisimura{ 5281.14Snisimura#ifdef MIPS3 5291.14Snisimura if (CPUISMIPS3) { 5301.14Snisimura u_int32_t mips3_cycles; 5311.14Snisimura 5321.14Snisimura mips3_cycles = mips3_cycle_count() - latched_cycle_cnt; 5331.14Snisimura /* XXX divides take 78 cycles: approximate with * 41/2048 */ 5341.14Snisimura return((mips3_cycles >> 6) + (mips3_cycles >> 8) + 5351.14Snisimura (mips3_cycles >> 11)); 5361.14Snisimura } 5371.14Snisimura#endif 5381.14Snisimura return 0; 5391.1Sjonathan} 540