160727d8bSWarner Losh /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 371e3c308SPedro F. Giffuni * 4ca019208SBenno Rice * Copyright (C) 2002 Benno Rice. 5ca019208SBenno Rice * All rights reserved. 6ca019208SBenno Rice * 7ca019208SBenno Rice * Redistribution and use in source and binary forms, with or without 8ca019208SBenno Rice * modification, are permitted provided that the following conditions 9ca019208SBenno Rice * are met: 10ca019208SBenno Rice * 1. Redistributions of source code must retain the above copyright 11ca019208SBenno Rice * notice, this list of conditions and the following disclaimer. 12ca019208SBenno Rice * 2. Redistributions in binary form must reproduce the above copyright 13ca019208SBenno Rice * notice, this list of conditions and the following disclaimer in the 14ca019208SBenno Rice * documentation and/or other materials provided with the distribution. 15ca019208SBenno Rice * 16ca019208SBenno Rice * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR 17ca019208SBenno Rice * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18ca019208SBenno Rice * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19ca019208SBenno Rice * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20ca019208SBenno Rice * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21ca019208SBenno Rice * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22ca019208SBenno Rice * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23ca019208SBenno Rice * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24ca019208SBenno Rice * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25ca019208SBenno Rice * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26ca019208SBenno Rice */ 27ca019208SBenno Rice 28ca019208SBenno Rice #ifndef _POWERPC_OPENPICVAR_H_ 29ca019208SBenno Rice #define _POWERPC_OPENPICVAR_H_ 30ca019208SBenno Rice 31739af9bcSPeter Grehan #define OPENPIC_DEVSTR "OpenPIC Interrupt Controller" 32739af9bcSPeter Grehan 33739af9bcSPeter Grehan #define OPENPIC_IRQMAX 256 /* h/w allows more */ 34739af9bcSPeter Grehan 354290b4b8SJustin Hibbits #define OPENPIC_QUIRK_SINGLE_BIND 1 /* Bind interrupts to only 1 CPU */ 369e2b2d69SJustin Hibbits #define OPENPIC_QUIRK_HIDDEN_IRQS 2 /* May have IRQs beyond FRR[NIRQ] */ 374290b4b8SJustin Hibbits 389a2edf01SJustin Hibbits /* Names match the macros in openpicreg.h. */ 399a2edf01SJustin Hibbits struct openpic_timer { 409a2edf01SJustin Hibbits uint32_t tcnt; 419a2edf01SJustin Hibbits uint32_t tbase; 429a2edf01SJustin Hibbits uint32_t tvec; 439a2edf01SJustin Hibbits uint32_t tdst; 449a2edf01SJustin Hibbits }; 459a2edf01SJustin Hibbits 46ca019208SBenno Rice struct openpic_softc { 4777d40ffdSMarcel Moolenaar device_t sc_dev; 4877d40ffdSMarcel Moolenaar struct resource *sc_memr; 49eaef5f0aSNathan Whitehorn struct resource *sc_intr; 5077d40ffdSMarcel Moolenaar bus_space_tag_t sc_bt; 5177d40ffdSMarcel Moolenaar bus_space_handle_t sc_bh; 52ca019208SBenno Rice char *sc_version; 5377d40ffdSMarcel Moolenaar int sc_rid; 54eaef5f0aSNathan Whitehorn int sc_irq; 55eaef5f0aSNathan Whitehorn void *sc_icookie; 56ca019208SBenno Rice u_int sc_ncpu; 57ca019208SBenno Rice u_int sc_nirq; 58c94c0cf8SPeter Grehan int sc_psim; 594290b4b8SJustin Hibbits u_int sc_quirks; 609a2edf01SJustin Hibbits 619a2edf01SJustin Hibbits /* Saved states. */ 629a2edf01SJustin Hibbits uint32_t sc_saved_config; 639a2edf01SJustin Hibbits uint32_t sc_saved_ipis[4]; 649a2edf01SJustin Hibbits uint32_t sc_saved_prios[4]; 659a2edf01SJustin Hibbits struct openpic_timer sc_saved_timers[OPENPIC_TIMERS]; 669a2edf01SJustin Hibbits uint32_t sc_saved_vectors[OPENPIC_SRC_VECTOR_COUNT]; 679a2edf01SJustin Hibbits 68ca019208SBenno Rice }; 69ca019208SBenno Rice 70739af9bcSPeter Grehan /* 71739af9bcSPeter Grehan * Bus-independent attach i/f 72739af9bcSPeter Grehan */ 736d2d7b8cSMarcel Moolenaar int openpic_common_attach(device_t, uint32_t); 74739af9bcSPeter Grehan 75739af9bcSPeter Grehan /* 76739af9bcSPeter Grehan * PIC interface. 77739af9bcSPeter Grehan */ 7856505ec0SJustin Hibbits void openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **); 79d6f59297SMarcel Moolenaar void openpic_config(device_t, u_int, enum intr_trigger, enum intr_polarity); 8077d40ffdSMarcel Moolenaar void openpic_dispatch(device_t, struct trapframe *); 8156505ec0SJustin Hibbits void openpic_enable(device_t, u_int, u_int, void **); 8256505ec0SJustin Hibbits void openpic_eoi(device_t, u_int, void *); 8305c62b81SMarcel Moolenaar void openpic_ipi(device_t, u_int); 8456505ec0SJustin Hibbits void openpic_mask(device_t, u_int, void *); 8556505ec0SJustin Hibbits void openpic_unmask(device_t, u_int, void *); 86739af9bcSPeter Grehan 879a2edf01SJustin Hibbits int openpic_suspend(device_t dev); 889a2edf01SJustin Hibbits int openpic_resume(device_t dev); 899a2edf01SJustin Hibbits 90ca019208SBenno Rice #endif /* _POWERPC_OPENPICVAR_H_ */ 91