18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_MPIC_H 38c2ecf20Sopenharmony_ci#define _ASM_POWERPC_MPIC_H 48c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <linux/irq.h> 78c2ecf20Sopenharmony_ci#include <asm/dcr.h> 88c2ecf20Sopenharmony_ci#include <asm/msi_bitmap.h> 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/* 118c2ecf20Sopenharmony_ci * Global registers 128c2ecf20Sopenharmony_ci */ 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#define MPIC_GREG_BASE 0x01000 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#define MPIC_GREG_FEATURE_0 0x00000 178c2ecf20Sopenharmony_ci#define MPIC_GREG_FEATURE_LAST_SRC_MASK 0x07ff0000 188c2ecf20Sopenharmony_ci#define MPIC_GREG_FEATURE_LAST_SRC_SHIFT 16 198c2ecf20Sopenharmony_ci#define MPIC_GREG_FEATURE_LAST_CPU_MASK 0x00001f00 208c2ecf20Sopenharmony_ci#define MPIC_GREG_FEATURE_LAST_CPU_SHIFT 8 218c2ecf20Sopenharmony_ci#define MPIC_GREG_FEATURE_VERSION_MASK 0xff 228c2ecf20Sopenharmony_ci#define MPIC_GREG_FEATURE_1 0x00010 238c2ecf20Sopenharmony_ci#define MPIC_GREG_GLOBAL_CONF_0 0x00020 248c2ecf20Sopenharmony_ci#define MPIC_GREG_GCONF_RESET 0x80000000 258c2ecf20Sopenharmony_ci/* On the FSL mpic implementations the Mode field is expand to be 268c2ecf20Sopenharmony_ci * 2 bits wide: 278c2ecf20Sopenharmony_ci * 0b00 = pass through (interrupts routed to IRQ0) 288c2ecf20Sopenharmony_ci * 0b01 = Mixed mode 298c2ecf20Sopenharmony_ci * 0b10 = reserved 308c2ecf20Sopenharmony_ci * 0b11 = External proxy / coreint 318c2ecf20Sopenharmony_ci */ 328c2ecf20Sopenharmony_ci#define MPIC_GREG_GCONF_COREINT 0x60000000 338c2ecf20Sopenharmony_ci#define MPIC_GREG_GCONF_8259_PTHROU_DIS 0x20000000 348c2ecf20Sopenharmony_ci#define MPIC_GREG_GCONF_NO_BIAS 0x10000000 358c2ecf20Sopenharmony_ci#define MPIC_GREG_GCONF_BASE_MASK 0x000fffff 368c2ecf20Sopenharmony_ci#define MPIC_GREG_GCONF_MCK 0x08000000 378c2ecf20Sopenharmony_ci#define MPIC_GREG_GLOBAL_CONF_1 0x00030 388c2ecf20Sopenharmony_ci#define MPIC_GREG_VENDOR_0 0x00040 398c2ecf20Sopenharmony_ci#define MPIC_GREG_VENDOR_1 0x00050 408c2ecf20Sopenharmony_ci#define MPIC_GREG_VENDOR_2 0x00060 418c2ecf20Sopenharmony_ci#define MPIC_GREG_VENDOR_3 0x00070 428c2ecf20Sopenharmony_ci#define MPIC_GREG_VENDOR_ID 0x00080 438c2ecf20Sopenharmony_ci#define MPIC_GREG_VENDOR_ID_STEPPING_MASK 0x00ff0000 448c2ecf20Sopenharmony_ci#define MPIC_GREG_VENDOR_ID_STEPPING_SHIFT 16 458c2ecf20Sopenharmony_ci#define MPIC_GREG_VENDOR_ID_DEVICE_ID_MASK 0x0000ff00 468c2ecf20Sopenharmony_ci#define MPIC_GREG_VENDOR_ID_DEVICE_ID_SHIFT 8 478c2ecf20Sopenharmony_ci#define MPIC_GREG_VENDOR_ID_VENDOR_ID_MASK 0x000000ff 488c2ecf20Sopenharmony_ci#define MPIC_GREG_PROCESSOR_INIT 0x00090 498c2ecf20Sopenharmony_ci#define MPIC_GREG_IPI_VECTOR_PRI_0 0x000a0 508c2ecf20Sopenharmony_ci#define MPIC_GREG_IPI_VECTOR_PRI_1 0x000b0 518c2ecf20Sopenharmony_ci#define MPIC_GREG_IPI_VECTOR_PRI_2 0x000c0 528c2ecf20Sopenharmony_ci#define MPIC_GREG_IPI_VECTOR_PRI_3 0x000d0 538c2ecf20Sopenharmony_ci#define MPIC_GREG_IPI_STRIDE 0x10 548c2ecf20Sopenharmony_ci#define MPIC_GREG_SPURIOUS 0x000e0 558c2ecf20Sopenharmony_ci#define MPIC_GREG_TIMER_FREQ 0x000f0 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci/* 588c2ecf20Sopenharmony_ci * 598c2ecf20Sopenharmony_ci * Timer registers 608c2ecf20Sopenharmony_ci */ 618c2ecf20Sopenharmony_ci#define MPIC_TIMER_BASE 0x01100 628c2ecf20Sopenharmony_ci#define MPIC_TIMER_STRIDE 0x40 638c2ecf20Sopenharmony_ci#define MPIC_TIMER_GROUP_STRIDE 0x1000 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci#define MPIC_TIMER_CURRENT_CNT 0x00000 668c2ecf20Sopenharmony_ci#define MPIC_TIMER_BASE_CNT 0x00010 678c2ecf20Sopenharmony_ci#define MPIC_TIMER_VECTOR_PRI 0x00020 688c2ecf20Sopenharmony_ci#define MPIC_TIMER_DESTINATION 0x00030 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci/* 718c2ecf20Sopenharmony_ci * Per-Processor registers 728c2ecf20Sopenharmony_ci */ 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#define MPIC_CPU_THISBASE 0x00000 758c2ecf20Sopenharmony_ci#define MPIC_CPU_BASE 0x20000 768c2ecf20Sopenharmony_ci#define MPIC_CPU_STRIDE 0x01000 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#define MPIC_CPU_IPI_DISPATCH_0 0x00040 798c2ecf20Sopenharmony_ci#define MPIC_CPU_IPI_DISPATCH_1 0x00050 808c2ecf20Sopenharmony_ci#define MPIC_CPU_IPI_DISPATCH_2 0x00060 818c2ecf20Sopenharmony_ci#define MPIC_CPU_IPI_DISPATCH_3 0x00070 828c2ecf20Sopenharmony_ci#define MPIC_CPU_IPI_DISPATCH_STRIDE 0x00010 838c2ecf20Sopenharmony_ci#define MPIC_CPU_CURRENT_TASK_PRI 0x00080 848c2ecf20Sopenharmony_ci#define MPIC_CPU_TASKPRI_MASK 0x0000000f 858c2ecf20Sopenharmony_ci#define MPIC_CPU_WHOAMI 0x00090 868c2ecf20Sopenharmony_ci#define MPIC_CPU_WHOAMI_MASK 0x0000001f 878c2ecf20Sopenharmony_ci#define MPIC_CPU_INTACK 0x000a0 888c2ecf20Sopenharmony_ci#define MPIC_CPU_EOI 0x000b0 898c2ecf20Sopenharmony_ci#define MPIC_CPU_MCACK 0x000c0 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* 928c2ecf20Sopenharmony_ci * Per-source registers 938c2ecf20Sopenharmony_ci */ 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci#define MPIC_IRQ_BASE 0x10000 968c2ecf20Sopenharmony_ci#define MPIC_IRQ_STRIDE 0x00020 978c2ecf20Sopenharmony_ci#define MPIC_IRQ_VECTOR_PRI 0x00000 988c2ecf20Sopenharmony_ci#define MPIC_VECPRI_MASK 0x80000000 998c2ecf20Sopenharmony_ci#define MPIC_VECPRI_ACTIVITY 0x40000000 /* Read Only */ 1008c2ecf20Sopenharmony_ci#define MPIC_VECPRI_PRIORITY_MASK 0x000f0000 1018c2ecf20Sopenharmony_ci#define MPIC_VECPRI_PRIORITY_SHIFT 16 1028c2ecf20Sopenharmony_ci#define MPIC_VECPRI_VECTOR_MASK 0x000007ff 1038c2ecf20Sopenharmony_ci#define MPIC_VECPRI_POLARITY_POSITIVE 0x00800000 1048c2ecf20Sopenharmony_ci#define MPIC_VECPRI_POLARITY_NEGATIVE 0x00000000 1058c2ecf20Sopenharmony_ci#define MPIC_VECPRI_POLARITY_MASK 0x00800000 1068c2ecf20Sopenharmony_ci#define MPIC_VECPRI_SENSE_LEVEL 0x00400000 1078c2ecf20Sopenharmony_ci#define MPIC_VECPRI_SENSE_EDGE 0x00000000 1088c2ecf20Sopenharmony_ci#define MPIC_VECPRI_SENSE_MASK 0x00400000 1098c2ecf20Sopenharmony_ci#define MPIC_IRQ_DESTINATION 0x00010 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#define MPIC_FSL_BRR1 0x00000 1128c2ecf20Sopenharmony_ci#define MPIC_FSL_BRR1_VER 0x0000ffff 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci#define MPIC_MAX_IRQ_SOURCES 2048 1158c2ecf20Sopenharmony_ci#define MPIC_MAX_CPUS 32 1168c2ecf20Sopenharmony_ci#define MPIC_MAX_ISU 32 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci#define MPIC_MAX_ERR 32 1198c2ecf20Sopenharmony_ci#define MPIC_FSL_ERR_INT 16 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci/* 1228c2ecf20Sopenharmony_ci * Tsi108 implementation of MPIC has many differences from the original one 1238c2ecf20Sopenharmony_ci */ 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci/* 1268c2ecf20Sopenharmony_ci * Global registers 1278c2ecf20Sopenharmony_ci */ 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci#define TSI108_GREG_BASE 0x00000 1308c2ecf20Sopenharmony_ci#define TSI108_GREG_FEATURE_0 0x00000 1318c2ecf20Sopenharmony_ci#define TSI108_GREG_GLOBAL_CONF_0 0x00004 1328c2ecf20Sopenharmony_ci#define TSI108_GREG_VENDOR_ID 0x0000c 1338c2ecf20Sopenharmony_ci#define TSI108_GREG_IPI_VECTOR_PRI_0 0x00204 /* Doorbell 0 */ 1348c2ecf20Sopenharmony_ci#define TSI108_GREG_IPI_STRIDE 0x0c 1358c2ecf20Sopenharmony_ci#define TSI108_GREG_SPURIOUS 0x00010 1368c2ecf20Sopenharmony_ci#define TSI108_GREG_TIMER_FREQ 0x00014 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci/* 1398c2ecf20Sopenharmony_ci * Timer registers 1408c2ecf20Sopenharmony_ci */ 1418c2ecf20Sopenharmony_ci#define TSI108_TIMER_BASE 0x0030 1428c2ecf20Sopenharmony_ci#define TSI108_TIMER_STRIDE 0x10 1438c2ecf20Sopenharmony_ci#define TSI108_TIMER_CURRENT_CNT 0x00000 1448c2ecf20Sopenharmony_ci#define TSI108_TIMER_BASE_CNT 0x00004 1458c2ecf20Sopenharmony_ci#define TSI108_TIMER_VECTOR_PRI 0x00008 1468c2ecf20Sopenharmony_ci#define TSI108_TIMER_DESTINATION 0x0000c 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci/* 1498c2ecf20Sopenharmony_ci * Per-Processor registers 1508c2ecf20Sopenharmony_ci */ 1518c2ecf20Sopenharmony_ci#define TSI108_CPU_BASE 0x00300 1528c2ecf20Sopenharmony_ci#define TSI108_CPU_STRIDE 0x00040 1538c2ecf20Sopenharmony_ci#define TSI108_CPU_IPI_DISPATCH_0 0x00200 1548c2ecf20Sopenharmony_ci#define TSI108_CPU_IPI_DISPATCH_STRIDE 0x00000 1558c2ecf20Sopenharmony_ci#define TSI108_CPU_CURRENT_TASK_PRI 0x00000 1568c2ecf20Sopenharmony_ci#define TSI108_CPU_WHOAMI 0xffffffff 1578c2ecf20Sopenharmony_ci#define TSI108_CPU_INTACK 0x00004 1588c2ecf20Sopenharmony_ci#define TSI108_CPU_EOI 0x00008 1598c2ecf20Sopenharmony_ci#define TSI108_CPU_MCACK 0x00004 /* Doesn't really exist here */ 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci/* 1628c2ecf20Sopenharmony_ci * Per-source registers 1638c2ecf20Sopenharmony_ci */ 1648c2ecf20Sopenharmony_ci#define TSI108_IRQ_BASE 0x00100 1658c2ecf20Sopenharmony_ci#define TSI108_IRQ_STRIDE 0x00008 1668c2ecf20Sopenharmony_ci#define TSI108_IRQ_VECTOR_PRI 0x00000 1678c2ecf20Sopenharmony_ci#define TSI108_VECPRI_VECTOR_MASK 0x000000ff 1688c2ecf20Sopenharmony_ci#define TSI108_VECPRI_POLARITY_POSITIVE 0x01000000 1698c2ecf20Sopenharmony_ci#define TSI108_VECPRI_POLARITY_NEGATIVE 0x00000000 1708c2ecf20Sopenharmony_ci#define TSI108_VECPRI_SENSE_LEVEL 0x02000000 1718c2ecf20Sopenharmony_ci#define TSI108_VECPRI_SENSE_EDGE 0x00000000 1728c2ecf20Sopenharmony_ci#define TSI108_VECPRI_POLARITY_MASK 0x01000000 1738c2ecf20Sopenharmony_ci#define TSI108_VECPRI_SENSE_MASK 0x02000000 1748c2ecf20Sopenharmony_ci#define TSI108_IRQ_DESTINATION 0x00004 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci/* weird mpic register indices and mask bits in the HW info array */ 1778c2ecf20Sopenharmony_cienum { 1788c2ecf20Sopenharmony_ci MPIC_IDX_GREG_BASE = 0, 1798c2ecf20Sopenharmony_ci MPIC_IDX_GREG_FEATURE_0, 1808c2ecf20Sopenharmony_ci MPIC_IDX_GREG_GLOBAL_CONF_0, 1818c2ecf20Sopenharmony_ci MPIC_IDX_GREG_VENDOR_ID, 1828c2ecf20Sopenharmony_ci MPIC_IDX_GREG_IPI_VECTOR_PRI_0, 1838c2ecf20Sopenharmony_ci MPIC_IDX_GREG_IPI_STRIDE, 1848c2ecf20Sopenharmony_ci MPIC_IDX_GREG_SPURIOUS, 1858c2ecf20Sopenharmony_ci MPIC_IDX_GREG_TIMER_FREQ, 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci MPIC_IDX_TIMER_BASE, 1888c2ecf20Sopenharmony_ci MPIC_IDX_TIMER_STRIDE, 1898c2ecf20Sopenharmony_ci MPIC_IDX_TIMER_CURRENT_CNT, 1908c2ecf20Sopenharmony_ci MPIC_IDX_TIMER_BASE_CNT, 1918c2ecf20Sopenharmony_ci MPIC_IDX_TIMER_VECTOR_PRI, 1928c2ecf20Sopenharmony_ci MPIC_IDX_TIMER_DESTINATION, 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci MPIC_IDX_CPU_BASE, 1958c2ecf20Sopenharmony_ci MPIC_IDX_CPU_STRIDE, 1968c2ecf20Sopenharmony_ci MPIC_IDX_CPU_IPI_DISPATCH_0, 1978c2ecf20Sopenharmony_ci MPIC_IDX_CPU_IPI_DISPATCH_STRIDE, 1988c2ecf20Sopenharmony_ci MPIC_IDX_CPU_CURRENT_TASK_PRI, 1998c2ecf20Sopenharmony_ci MPIC_IDX_CPU_WHOAMI, 2008c2ecf20Sopenharmony_ci MPIC_IDX_CPU_INTACK, 2018c2ecf20Sopenharmony_ci MPIC_IDX_CPU_EOI, 2028c2ecf20Sopenharmony_ci MPIC_IDX_CPU_MCACK, 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci MPIC_IDX_IRQ_BASE, 2058c2ecf20Sopenharmony_ci MPIC_IDX_IRQ_STRIDE, 2068c2ecf20Sopenharmony_ci MPIC_IDX_IRQ_VECTOR_PRI, 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci MPIC_IDX_VECPRI_VECTOR_MASK, 2098c2ecf20Sopenharmony_ci MPIC_IDX_VECPRI_POLARITY_POSITIVE, 2108c2ecf20Sopenharmony_ci MPIC_IDX_VECPRI_POLARITY_NEGATIVE, 2118c2ecf20Sopenharmony_ci MPIC_IDX_VECPRI_SENSE_LEVEL, 2128c2ecf20Sopenharmony_ci MPIC_IDX_VECPRI_SENSE_EDGE, 2138c2ecf20Sopenharmony_ci MPIC_IDX_VECPRI_POLARITY_MASK, 2148c2ecf20Sopenharmony_ci MPIC_IDX_VECPRI_SENSE_MASK, 2158c2ecf20Sopenharmony_ci MPIC_IDX_IRQ_DESTINATION, 2168c2ecf20Sopenharmony_ci MPIC_IDX_END 2178c2ecf20Sopenharmony_ci}; 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci#ifdef CONFIG_MPIC_U3_HT_IRQS 2218c2ecf20Sopenharmony_ci/* Fixup table entry */ 2228c2ecf20Sopenharmony_cistruct mpic_irq_fixup 2238c2ecf20Sopenharmony_ci{ 2248c2ecf20Sopenharmony_ci u8 __iomem *base; 2258c2ecf20Sopenharmony_ci u8 __iomem *applebase; 2268c2ecf20Sopenharmony_ci u32 data; 2278c2ecf20Sopenharmony_ci unsigned int index; 2288c2ecf20Sopenharmony_ci}; 2298c2ecf20Sopenharmony_ci#endif /* CONFIG_MPIC_U3_HT_IRQS */ 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_cienum mpic_reg_type { 2338c2ecf20Sopenharmony_ci mpic_access_mmio_le, 2348c2ecf20Sopenharmony_ci mpic_access_mmio_be, 2358c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_DCR 2368c2ecf20Sopenharmony_ci mpic_access_dcr 2378c2ecf20Sopenharmony_ci#endif 2388c2ecf20Sopenharmony_ci}; 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_cistruct mpic_reg_bank { 2418c2ecf20Sopenharmony_ci u32 __iomem *base; 2428c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_DCR 2438c2ecf20Sopenharmony_ci dcr_host_t dhost; 2448c2ecf20Sopenharmony_ci#endif /* CONFIG_PPC_DCR */ 2458c2ecf20Sopenharmony_ci}; 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_cistruct mpic_irq_save { 2488c2ecf20Sopenharmony_ci u32 vecprio, 2498c2ecf20Sopenharmony_ci dest; 2508c2ecf20Sopenharmony_ci#ifdef CONFIG_MPIC_U3_HT_IRQS 2518c2ecf20Sopenharmony_ci u32 fixup_data; 2528c2ecf20Sopenharmony_ci#endif 2538c2ecf20Sopenharmony_ci}; 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci/* The instance data of a given MPIC */ 2568c2ecf20Sopenharmony_cistruct mpic 2578c2ecf20Sopenharmony_ci{ 2588c2ecf20Sopenharmony_ci /* The OpenFirmware dt node for this MPIC */ 2598c2ecf20Sopenharmony_ci struct device_node *node; 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci /* The remapper for this MPIC */ 2628c2ecf20Sopenharmony_ci struct irq_domain *irqhost; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci /* The "linux" controller struct */ 2658c2ecf20Sopenharmony_ci struct irq_chip hc_irq; 2668c2ecf20Sopenharmony_ci#ifdef CONFIG_MPIC_U3_HT_IRQS 2678c2ecf20Sopenharmony_ci struct irq_chip hc_ht_irq; 2688c2ecf20Sopenharmony_ci#endif 2698c2ecf20Sopenharmony_ci#ifdef CONFIG_SMP 2708c2ecf20Sopenharmony_ci struct irq_chip hc_ipi; 2718c2ecf20Sopenharmony_ci#endif 2728c2ecf20Sopenharmony_ci struct irq_chip hc_tm; 2738c2ecf20Sopenharmony_ci struct irq_chip hc_err; 2748c2ecf20Sopenharmony_ci const char *name; 2758c2ecf20Sopenharmony_ci /* Flags */ 2768c2ecf20Sopenharmony_ci unsigned int flags; 2778c2ecf20Sopenharmony_ci /* How many irq sources in a given ISU */ 2788c2ecf20Sopenharmony_ci unsigned int isu_size; 2798c2ecf20Sopenharmony_ci unsigned int isu_shift; 2808c2ecf20Sopenharmony_ci unsigned int isu_mask; 2818c2ecf20Sopenharmony_ci /* Number of sources */ 2828c2ecf20Sopenharmony_ci unsigned int num_sources; 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci /* vector numbers used for internal sources (ipi/timers) */ 2858c2ecf20Sopenharmony_ci unsigned int ipi_vecs[4]; 2868c2ecf20Sopenharmony_ci unsigned int timer_vecs[8]; 2878c2ecf20Sopenharmony_ci /* vector numbers used for FSL MPIC error interrupts */ 2888c2ecf20Sopenharmony_ci unsigned int err_int_vecs[MPIC_MAX_ERR]; 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci /* Spurious vector to program into unused sources */ 2918c2ecf20Sopenharmony_ci unsigned int spurious_vec; 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci#ifdef CONFIG_MPIC_U3_HT_IRQS 2948c2ecf20Sopenharmony_ci /* The fixup table */ 2958c2ecf20Sopenharmony_ci struct mpic_irq_fixup *fixups; 2968c2ecf20Sopenharmony_ci raw_spinlock_t fixup_lock; 2978c2ecf20Sopenharmony_ci#endif 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci /* Register access method */ 3008c2ecf20Sopenharmony_ci enum mpic_reg_type reg_type; 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_ci /* The physical base address of the MPIC */ 3038c2ecf20Sopenharmony_ci phys_addr_t paddr; 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_ci /* The various ioremap'ed bases */ 3068c2ecf20Sopenharmony_ci struct mpic_reg_bank thiscpuregs; 3078c2ecf20Sopenharmony_ci struct mpic_reg_bank gregs; 3088c2ecf20Sopenharmony_ci struct mpic_reg_bank tmregs; 3098c2ecf20Sopenharmony_ci struct mpic_reg_bank cpuregs[MPIC_MAX_CPUS]; 3108c2ecf20Sopenharmony_ci struct mpic_reg_bank isus[MPIC_MAX_ISU]; 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci /* ioremap'ed base for error interrupt registers */ 3138c2ecf20Sopenharmony_ci u32 __iomem *err_regs; 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci /* Protected sources */ 3168c2ecf20Sopenharmony_ci unsigned long *protected; 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ci#ifdef CONFIG_MPIC_WEIRD 3198c2ecf20Sopenharmony_ci /* Pointer to HW info array */ 3208c2ecf20Sopenharmony_ci u32 *hw_set; 3218c2ecf20Sopenharmony_ci#endif 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI_MSI 3248c2ecf20Sopenharmony_ci struct msi_bitmap msi_bitmap; 3258c2ecf20Sopenharmony_ci#endif 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci#ifdef CONFIG_MPIC_BROKEN_REGREAD 3288c2ecf20Sopenharmony_ci u32 isu_reg0_shadow[MPIC_MAX_IRQ_SOURCES]; 3298c2ecf20Sopenharmony_ci#endif 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci /* link */ 3328c2ecf20Sopenharmony_ci struct mpic *next; 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ci#ifdef CONFIG_PM 3358c2ecf20Sopenharmony_ci struct mpic_irq_save *save_data; 3368c2ecf20Sopenharmony_ci#endif 3378c2ecf20Sopenharmony_ci}; 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ciextern struct bus_type mpic_subsys; 3408c2ecf20Sopenharmony_ci 3418c2ecf20Sopenharmony_ci/* 3428c2ecf20Sopenharmony_ci * MPIC flags (passed to mpic_alloc) 3438c2ecf20Sopenharmony_ci * 3448c2ecf20Sopenharmony_ci * The top 4 bits contain an MPIC bhw id that is used to index the 3458c2ecf20Sopenharmony_ci * register offsets and some masks when CONFIG_MPIC_WEIRD is set. 3468c2ecf20Sopenharmony_ci * Note setting any ID (leaving those bits to 0) means standard MPIC 3478c2ecf20Sopenharmony_ci */ 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci/* 3508c2ecf20Sopenharmony_ci * This is a secondary ("chained") controller; it only uses the CPU0 3518c2ecf20Sopenharmony_ci * registers. Primary controllers have IPIs and affinity control. 3528c2ecf20Sopenharmony_ci */ 3538c2ecf20Sopenharmony_ci#define MPIC_SECONDARY 0x00000001 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_ci/* Set this for a big-endian MPIC */ 3568c2ecf20Sopenharmony_ci#define MPIC_BIG_ENDIAN 0x00000002 3578c2ecf20Sopenharmony_ci/* Broken U3 MPIC */ 3588c2ecf20Sopenharmony_ci#define MPIC_U3_HT_IRQS 0x00000004 3598c2ecf20Sopenharmony_ci/* Broken IPI registers (autodetected) */ 3608c2ecf20Sopenharmony_ci#define MPIC_BROKEN_IPI 0x00000008 3618c2ecf20Sopenharmony_ci/* Spurious vector requires EOI */ 3628c2ecf20Sopenharmony_ci#define MPIC_SPV_EOI 0x00000020 3638c2ecf20Sopenharmony_ci/* No passthrough disable */ 3648c2ecf20Sopenharmony_ci#define MPIC_NO_PTHROU_DIS 0x00000040 3658c2ecf20Sopenharmony_ci/* DCR based MPIC */ 3668c2ecf20Sopenharmony_ci#define MPIC_USES_DCR 0x00000080 3678c2ecf20Sopenharmony_ci/* MPIC has 11-bit vector fields (or larger) */ 3688c2ecf20Sopenharmony_ci#define MPIC_LARGE_VECTORS 0x00000100 3698c2ecf20Sopenharmony_ci/* Enable delivery of prio 15 interrupts as MCK instead of EE */ 3708c2ecf20Sopenharmony_ci#define MPIC_ENABLE_MCK 0x00000200 3718c2ecf20Sopenharmony_ci/* Disable bias among target selection, spread interrupts evenly */ 3728c2ecf20Sopenharmony_ci#define MPIC_NO_BIAS 0x00000400 3738c2ecf20Sopenharmony_ci/* Destination only supports a single CPU at a time */ 3748c2ecf20Sopenharmony_ci#define MPIC_SINGLE_DEST_CPU 0x00001000 3758c2ecf20Sopenharmony_ci/* Enable CoreInt delivery of interrupts */ 3768c2ecf20Sopenharmony_ci#define MPIC_ENABLE_COREINT 0x00002000 3778c2ecf20Sopenharmony_ci/* Do not reset the MPIC during initialization */ 3788c2ecf20Sopenharmony_ci#define MPIC_NO_RESET 0x00004000 3798c2ecf20Sopenharmony_ci/* Freescale MPIC (compatible includes "fsl,mpic") */ 3808c2ecf20Sopenharmony_ci#define MPIC_FSL 0x00008000 3818c2ecf20Sopenharmony_ci/* Freescale MPIC supports EIMR (error interrupt mask register). 3828c2ecf20Sopenharmony_ci * This flag is set for MPIC version >= 4.1 (version determined 3838c2ecf20Sopenharmony_ci * from the BRR1 register). 3848c2ecf20Sopenharmony_ci*/ 3858c2ecf20Sopenharmony_ci#define MPIC_FSL_HAS_EIMR 0x00010000 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_ci/* MPIC HW modification ID */ 3888c2ecf20Sopenharmony_ci#define MPIC_REGSET_MASK 0xf0000000 3898c2ecf20Sopenharmony_ci#define MPIC_REGSET(val) (((val) & 0xf ) << 28) 3908c2ecf20Sopenharmony_ci#define MPIC_GET_REGSET(flags) (((flags) >> 28) & 0xf) 3918c2ecf20Sopenharmony_ci 3928c2ecf20Sopenharmony_ci#define MPIC_REGSET_STANDARD MPIC_REGSET(0) /* Original MPIC */ 3938c2ecf20Sopenharmony_ci#define MPIC_REGSET_TSI108 MPIC_REGSET(1) /* Tsi108/109 PIC */ 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_ci/* Get the version of primary MPIC */ 3968c2ecf20Sopenharmony_ci#ifdef CONFIG_MPIC 3978c2ecf20Sopenharmony_ciextern u32 fsl_mpic_primary_get_version(void); 3988c2ecf20Sopenharmony_ci#else 3998c2ecf20Sopenharmony_cistatic inline u32 fsl_mpic_primary_get_version(void) 4008c2ecf20Sopenharmony_ci{ 4018c2ecf20Sopenharmony_ci return 0; 4028c2ecf20Sopenharmony_ci} 4038c2ecf20Sopenharmony_ci#endif 4048c2ecf20Sopenharmony_ci 4058c2ecf20Sopenharmony_ci/* Allocate the controller structure and setup the linux irq descs 4068c2ecf20Sopenharmony_ci * for the range if interrupts passed in. No HW initialization is 4078c2ecf20Sopenharmony_ci * actually performed. 4088c2ecf20Sopenharmony_ci * 4098c2ecf20Sopenharmony_ci * @phys_addr: physial base address of the MPIC 4108c2ecf20Sopenharmony_ci * @flags: flags, see constants above 4118c2ecf20Sopenharmony_ci * @isu_size: number of interrupts in an ISU. Use 0 to use a 4128c2ecf20Sopenharmony_ci * standard ISU-less setup (aka powermac) 4138c2ecf20Sopenharmony_ci * @irq_offset: first irq number to assign to this mpic 4148c2ecf20Sopenharmony_ci * @irq_count: number of irqs to use with this mpic IRQ sources. Pass 0 4158c2ecf20Sopenharmony_ci * to match the number of sources 4168c2ecf20Sopenharmony_ci * @ipi_offset: first irq number to assign to this mpic IPI sources, 4178c2ecf20Sopenharmony_ci * used only on primary mpic 4188c2ecf20Sopenharmony_ci * @senses: array of sense values 4198c2ecf20Sopenharmony_ci * @senses_num: number of entries in the array 4208c2ecf20Sopenharmony_ci * 4218c2ecf20Sopenharmony_ci * Note about the sense array. If none is passed, all interrupts are 4228c2ecf20Sopenharmony_ci * setup to be level negative unless MPIC_U3_HT_IRQS is set in which 4238c2ecf20Sopenharmony_ci * case they are edge positive (and the array is ignored anyway). 4248c2ecf20Sopenharmony_ci * The values in the array start at the first source of the MPIC, 4258c2ecf20Sopenharmony_ci * that is senses[0] correspond to linux irq "irq_offset". 4268c2ecf20Sopenharmony_ci */ 4278c2ecf20Sopenharmony_ciextern struct mpic *mpic_alloc(struct device_node *node, 4288c2ecf20Sopenharmony_ci phys_addr_t phys_addr, 4298c2ecf20Sopenharmony_ci unsigned int flags, 4308c2ecf20Sopenharmony_ci unsigned int isu_size, 4318c2ecf20Sopenharmony_ci unsigned int irq_count, 4328c2ecf20Sopenharmony_ci const char *name); 4338c2ecf20Sopenharmony_ci 4348c2ecf20Sopenharmony_ci/* Assign ISUs, to call before mpic_init() 4358c2ecf20Sopenharmony_ci * 4368c2ecf20Sopenharmony_ci * @mpic: controller structure as returned by mpic_alloc() 4378c2ecf20Sopenharmony_ci * @isu_num: ISU number 4388c2ecf20Sopenharmony_ci * @phys_addr: physical address of the ISU 4398c2ecf20Sopenharmony_ci */ 4408c2ecf20Sopenharmony_ciextern void mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, 4418c2ecf20Sopenharmony_ci phys_addr_t phys_addr); 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci 4448c2ecf20Sopenharmony_ci/* Initialize the controller. After this has been called, none of the above 4458c2ecf20Sopenharmony_ci * should be called again for this mpic 4468c2ecf20Sopenharmony_ci */ 4478c2ecf20Sopenharmony_ciextern void mpic_init(struct mpic *mpic); 4488c2ecf20Sopenharmony_ci 4498c2ecf20Sopenharmony_ci/* 4508c2ecf20Sopenharmony_ci * All of the following functions must only be used after the 4518c2ecf20Sopenharmony_ci * ISUs have been assigned and the controller fully initialized 4528c2ecf20Sopenharmony_ci * with mpic_init() 4538c2ecf20Sopenharmony_ci */ 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci 4568c2ecf20Sopenharmony_ci/* Change the priority of an interrupt. Default is 8 for irqs and 4578c2ecf20Sopenharmony_ci * 10 for IPIs. You can call this on both IPIs and IRQ numbers, but the 4588c2ecf20Sopenharmony_ci * IPI number is then the offset'ed (linux irq number mapped to the IPI) 4598c2ecf20Sopenharmony_ci */ 4608c2ecf20Sopenharmony_ciextern void mpic_irq_set_priority(unsigned int irq, unsigned int pri); 4618c2ecf20Sopenharmony_ci 4628c2ecf20Sopenharmony_ci/* Setup a non-boot CPU */ 4638c2ecf20Sopenharmony_ciextern void mpic_setup_this_cpu(void); 4648c2ecf20Sopenharmony_ci 4658c2ecf20Sopenharmony_ci/* Clean up for kexec (or cpu offline or ...) */ 4668c2ecf20Sopenharmony_ciextern void mpic_teardown_this_cpu(int secondary); 4678c2ecf20Sopenharmony_ci 4688c2ecf20Sopenharmony_ci/* Get the current cpu priority for this cpu (0..15) */ 4698c2ecf20Sopenharmony_ciextern int mpic_cpu_get_priority(void); 4708c2ecf20Sopenharmony_ci 4718c2ecf20Sopenharmony_ci/* Set the current cpu priority for this cpu */ 4728c2ecf20Sopenharmony_ciextern void mpic_cpu_set_priority(int prio); 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_ci/* Request IPIs on primary mpic */ 4758c2ecf20Sopenharmony_ciextern void mpic_request_ipis(void); 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci/* Send a message (IPI) to a given target (cpu number or MSG_*) */ 4788c2ecf20Sopenharmony_civoid smp_mpic_message_pass(int target, int msg); 4798c2ecf20Sopenharmony_ci 4808c2ecf20Sopenharmony_ci/* Unmask a specific virq */ 4818c2ecf20Sopenharmony_ciextern void mpic_unmask_irq(struct irq_data *d); 4828c2ecf20Sopenharmony_ci/* Mask a specific virq */ 4838c2ecf20Sopenharmony_ciextern void mpic_mask_irq(struct irq_data *d); 4848c2ecf20Sopenharmony_ci/* EOI a specific virq */ 4858c2ecf20Sopenharmony_ciextern void mpic_end_irq(struct irq_data *d); 4868c2ecf20Sopenharmony_ci 4878c2ecf20Sopenharmony_ci/* Fetch interrupt from a given mpic */ 4888c2ecf20Sopenharmony_ciextern unsigned int mpic_get_one_irq(struct mpic *mpic); 4898c2ecf20Sopenharmony_ci/* This one gets from the primary mpic */ 4908c2ecf20Sopenharmony_ciextern unsigned int mpic_get_irq(void); 4918c2ecf20Sopenharmony_ci/* This one gets from the primary mpic via CoreInt*/ 4928c2ecf20Sopenharmony_ciextern unsigned int mpic_get_coreint_irq(void); 4938c2ecf20Sopenharmony_ci/* Fetch Machine Check interrupt from primary mpic */ 4948c2ecf20Sopenharmony_ciextern unsigned int mpic_get_mcirq(void); 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 4978c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_MPIC_H */ 498