1b7ac1056SBenno Rice /*- 2*71e3c308SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 3*71e3c308SPedro F. Giffuni * 4b7ac1056SBenno Rice * Copyright (c) 2000 Tsubai Masanari. All rights reserved. 5b7ac1056SBenno Rice * 6b7ac1056SBenno Rice * Redistribution and use in source and binary forms, with or without 7b7ac1056SBenno Rice * modification, are permitted provided that the following conditions 8b7ac1056SBenno Rice * are met: 9b7ac1056SBenno Rice * 1. Redistributions of source code must retain the above copyright 10b7ac1056SBenno Rice * notice, this list of conditions and the following disclaimer. 11b7ac1056SBenno Rice * 2. Redistributions in binary form must reproduce the above copyright 12b7ac1056SBenno Rice * notice, this list of conditions and the following disclaimer in the 13b7ac1056SBenno Rice * documentation and/or other materials provided with the distribution. 14b7ac1056SBenno Rice * 3. The name of the author may not be used to endorse or promote products 15b7ac1056SBenno Rice * derived from this software without specific prior written permission. 16b7ac1056SBenno Rice * 17b7ac1056SBenno Rice * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18b7ac1056SBenno Rice * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19b7ac1056SBenno Rice * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20b7ac1056SBenno Rice * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21b7ac1056SBenno Rice * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22b7ac1056SBenno Rice * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23b7ac1056SBenno Rice * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24b7ac1056SBenno Rice * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25b7ac1056SBenno Rice * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26b7ac1056SBenno Rice * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27b7ac1056SBenno Rice * 28ca019208SBenno Rice * from NetBSD: openpicreg.h,v 1.3 2001/08/30 03:08:52 briggs Exp 29b7ac1056SBenno Rice */ 30b7ac1056SBenno Rice 31b7ac1056SBenno Rice /* 32ca019208SBenno Rice * Size of OpenPIC register space 33ca019208SBenno Rice */ 34ca019208SBenno Rice #define OPENPIC_SIZE 0x40000 35ca019208SBenno Rice 36ca019208SBenno Rice /* 3705c62b81SMarcel Moolenaar * Per Processor Registers [private access] (0x00000 - 0x00fff) 3805c62b81SMarcel Moolenaar */ 3905c62b81SMarcel Moolenaar 4005c62b81SMarcel Moolenaar /* IPI dispatch command reg */ 4105c62b81SMarcel Moolenaar #define OPENPIC_IPI_DISPATCH(ipi) (0x40 + (ipi) * 0x10) 4205c62b81SMarcel Moolenaar 4305c62b81SMarcel Moolenaar /* current task priority reg */ 4405c62b81SMarcel Moolenaar #define OPENPIC_TPR 0x80 4505c62b81SMarcel Moolenaar #define OPENPIC_TPR_MASK 0x0000000f 4605c62b81SMarcel Moolenaar 4705c62b81SMarcel Moolenaar #define OPENPIC_WHOAMI 0x90 4805c62b81SMarcel Moolenaar 4905c62b81SMarcel Moolenaar /* interrupt acknowledge reg */ 5005c62b81SMarcel Moolenaar #define OPENPIC_IACK 0xa0 5105c62b81SMarcel Moolenaar 5205c62b81SMarcel Moolenaar /* end of interrupt reg */ 5305c62b81SMarcel Moolenaar #define OPENPIC_EOI 0xb0 5405c62b81SMarcel Moolenaar 5505c62b81SMarcel Moolenaar /* 5605c62b81SMarcel Moolenaar * Global registers (0x01000-0x0ffff) 57b7ac1056SBenno Rice */ 58b7ac1056SBenno Rice 59b7ac1056SBenno Rice /* feature reporting reg 0 */ 60b7ac1056SBenno Rice #define OPENPIC_FEATURE 0x1000 61ca019208SBenno Rice #define OPENPIC_FEATURE_VERSION_MASK 0x000000ff 62ca019208SBenno Rice #define OPENPIC_FEATURE_LAST_CPU_MASK 0x00001f00 63ca019208SBenno Rice #define OPENPIC_FEATURE_LAST_CPU_SHIFT 8 64ca019208SBenno Rice #define OPENPIC_FEATURE_LAST_IRQ_MASK 0x07ff0000 65ca019208SBenno Rice #define OPENPIC_FEATURE_LAST_IRQ_SHIFT 16 66b7ac1056SBenno Rice 67b7ac1056SBenno Rice /* global config reg 0 */ 68b7ac1056SBenno Rice #define OPENPIC_CONFIG 0x1020 69b7ac1056SBenno Rice #define OPENPIC_CONFIG_RESET 0x80000000 70b7ac1056SBenno Rice #define OPENPIC_CONFIG_8259_PASSTHRU_DISABLE 0x20000000 71b7ac1056SBenno Rice 72ca019208SBenno Rice /* interrupt configuration mode (direct or serial) */ 73ca019208SBenno Rice #define OPENPIC_ICR 0x1030 74ca019208SBenno Rice #define OPENPIC_ICR_SERIAL_MODE (1 << 27) 75ca019208SBenno Rice #define OPENPIC_ICR_SERIAL_RATIO_MASK (0x7 << 28) 76ca019208SBenno Rice #define OPENPIC_ICR_SERIAL_RATIO_SHIFT 28 77ca019208SBenno Rice 78b7ac1056SBenno Rice /* vendor ID */ 79b7ac1056SBenno Rice #define OPENPIC_VENDOR_ID 0x1080 80b7ac1056SBenno Rice 81b7ac1056SBenno Rice /* processor initialization reg */ 82b7ac1056SBenno Rice #define OPENPIC_PROC_INIT 0x1090 83b7ac1056SBenno Rice 84b7ac1056SBenno Rice /* IPI vector/priority reg */ 85b7ac1056SBenno Rice #define OPENPIC_IPI_VECTOR(ipi) (0x10a0 + (ipi) * 0x10) 86b7ac1056SBenno Rice 87b7ac1056SBenno Rice /* spurious intr. vector */ 88b7ac1056SBenno Rice #define OPENPIC_SPURIOUS_VECTOR 0x10e0 89b7ac1056SBenno Rice 9005c62b81SMarcel Moolenaar /* Timer registers */ 9105c62b81SMarcel Moolenaar #define OPENPIC_TIMERS 4 9205c62b81SMarcel Moolenaar #define OPENPIC_TFREQ 0x10f0 9305c62b81SMarcel Moolenaar #define OPENPIC_TCNT(t) (0x1100 + (t) * 0x40) 9405c62b81SMarcel Moolenaar #define OPENPIC_TBASE(t) (0x1110 + (t) * 0x40) 9505c62b81SMarcel Moolenaar #define OPENPIC_TVEC(t) (0x1120 + (t) * 0x40) 9605c62b81SMarcel Moolenaar #define OPENPIC_TDST(t) (0x1130 + (t) * 0x40) 97b7ac1056SBenno Rice 98b7ac1056SBenno Rice /* 9905c62b81SMarcel Moolenaar * Interrupt Source Configuration Registers (0x10000 - 0x1ffff) 100b7ac1056SBenno Rice */ 101b7ac1056SBenno Rice 102b7ac1056SBenno Rice /* interrupt vector/priority reg */ 1039a2edf01SJustin Hibbits #define OPENPIC_SRC_VECTOR_COUNT 64 104b7ac1056SBenno Rice #ifndef OPENPIC_SRC_VECTOR 105b7ac1056SBenno Rice #define OPENPIC_SRC_VECTOR(irq) (0x10000 + (irq) * 0x20) 106b7ac1056SBenno Rice #endif 107b7ac1056SBenno Rice #define OPENPIC_SENSE_LEVEL 0x00400000 108b7ac1056SBenno Rice #define OPENPIC_SENSE_EDGE 0x00000000 109b7ac1056SBenno Rice #define OPENPIC_POLARITY_POSITIVE 0x00800000 110b7ac1056SBenno Rice #define OPENPIC_POLARITY_NEGATIVE 0x00000000 111b7ac1056SBenno Rice #define OPENPIC_IMASK 0x80000000 112b7ac1056SBenno Rice #define OPENPIC_ACTIVITY 0x40000000 113b7ac1056SBenno Rice #define OPENPIC_PRIORITY_MASK 0x000f0000 114b7ac1056SBenno Rice #define OPENPIC_PRIORITY_SHIFT 16 115b7ac1056SBenno Rice #define OPENPIC_VECTOR_MASK 0x000000ff 116b7ac1056SBenno Rice 117b7ac1056SBenno Rice /* interrupt destination cpu */ 118b7ac1056SBenno Rice #ifndef OPENPIC_IDEST 119b7ac1056SBenno Rice #define OPENPIC_IDEST(irq) (0x10010 + (irq) * 0x20) 120b7ac1056SBenno Rice #endif 121b7ac1056SBenno Rice 122b7ac1056SBenno Rice /* 12305c62b81SMarcel Moolenaar * Per Processor Registers [global access] (0x20000 - 0x3ffff) 124b7ac1056SBenno Rice */ 125b7ac1056SBenno Rice 12605c62b81SMarcel Moolenaar #define OPENPIC_PCPU_BASE(cpu) (0x20000 + (cpu) * 0x1000) 127b7ac1056SBenno Rice 12805c62b81SMarcel Moolenaar #define OPENPIC_PCPU_IPI_DISPATCH(cpu, ipi) \ 12905c62b81SMarcel Moolenaar (OPENPIC_PCPU_BASE(cpu) + OPENPIC_IPI_DISPATCH(ipi)) 130b7ac1056SBenno Rice 13105c62b81SMarcel Moolenaar #define OPENPIC_PCPU_TPR(cpu) \ 13205c62b81SMarcel Moolenaar (OPENPIC_PCPU_BASE(cpu) + OPENPIC_TPR) 133b7ac1056SBenno Rice 13405c62b81SMarcel Moolenaar #define OPENPIC_PCPU_WHOAMI(cpu) \ 13505c62b81SMarcel Moolenaar (OPENPIC_PCPU_BASE(cpu) + OPENPIC_WHOAMI) 13605c62b81SMarcel Moolenaar 13705c62b81SMarcel Moolenaar #define OPENPIC_PCPU_IACK(cpu) \ 13805c62b81SMarcel Moolenaar (OPENPIC_PCPU_BASE(cpu) + OPENPIC_IACK) 13905c62b81SMarcel Moolenaar 14005c62b81SMarcel Moolenaar #define OPENPIC_PCPU_EOI(cpu) \ 14105c62b81SMarcel Moolenaar (OPENPIC_PCPU_BASE(cpu) + OPENPIC_EOI) 142