162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Private structs/constants for PARISC IOSAPIC support 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 2000 Hewlett Packard (Grant Grundler) 662306a36Sopenharmony_ci * Copyright (C) 2000,2003 Grant Grundler (grundler at parisc-linux.org) 762306a36Sopenharmony_ci * Copyright (C) 2002 Matthew Wilcox (willy at parisc-linux.org) 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci/* 1162306a36Sopenharmony_ci** This file is private to iosapic driver. 1262306a36Sopenharmony_ci** If stuff needs to be used by another driver, move it to a common file. 1362306a36Sopenharmony_ci** 1462306a36Sopenharmony_ci** WARNING: fields most data structures here are ordered to make sure 1562306a36Sopenharmony_ci** they pack nicely for 64-bit compilation. (ie sizeof(long) == 8) 1662306a36Sopenharmony_ci*/ 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci/* 2062306a36Sopenharmony_ci** Interrupt Routing Stuff 2162306a36Sopenharmony_ci** ----------------------- 2262306a36Sopenharmony_ci** The interrupt routing table consists of entries derived from 2362306a36Sopenharmony_ci** MP Specification Draft 1.5. There is one interrupt routing 2462306a36Sopenharmony_ci** table per cell. N- and L-class consist of a single cell. 2562306a36Sopenharmony_ci*/ 2662306a36Sopenharmony_cistruct irt_entry { 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci /* Entry Type 139 identifies an I/O SAPIC interrupt entry */ 2962306a36Sopenharmony_ci u8 entry_type; 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci /* Entry Length 16 indicates entry is 16 bytes long */ 3262306a36Sopenharmony_ci u8 entry_length; 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci /* 3562306a36Sopenharmony_ci ** Interrupt Type of 0 indicates a vectored interrupt, 3662306a36Sopenharmony_ci ** all other values are reserved 3762306a36Sopenharmony_ci */ 3862306a36Sopenharmony_ci u8 interrupt_type; 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci /* 4162306a36Sopenharmony_ci ** PO and EL 4262306a36Sopenharmony_ci ** Polarity of SAPIC I/O input signals: 4362306a36Sopenharmony_ci ** 00 = Reserved 4462306a36Sopenharmony_ci ** 01 = Active high 4562306a36Sopenharmony_ci ** 10 = Reserved 4662306a36Sopenharmony_ci ** 11 = Active low 4762306a36Sopenharmony_ci ** Trigger mode of SAPIC I/O input signals: 4862306a36Sopenharmony_ci ** 00 = Reserved 4962306a36Sopenharmony_ci ** 01 = Edge-triggered 5062306a36Sopenharmony_ci ** 10 = Reserved 5162306a36Sopenharmony_ci ** 11 = Level-triggered 5262306a36Sopenharmony_ci */ 5362306a36Sopenharmony_ci u8 polarity_trigger; 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci /* 5662306a36Sopenharmony_ci ** IRQ and DEVNO 5762306a36Sopenharmony_ci ** irq identifies PCI interrupt signal where 5862306a36Sopenharmony_ci ** 0x0 corresponds to INT_A#, 5962306a36Sopenharmony_ci ** 0x1 corresponds to INT_B#, 6062306a36Sopenharmony_ci ** 0x2 corresponds to INT_C# 6162306a36Sopenharmony_ci ** 0x3 corresponds to INT_D# 6262306a36Sopenharmony_ci ** PCI device number where interrupt originates 6362306a36Sopenharmony_ci */ 6462306a36Sopenharmony_ci u8 src_bus_irq_devno; 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci /* Source Bus ID identifies the bus where interrupt signal comes from */ 6762306a36Sopenharmony_ci u8 src_bus_id; 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci /* 7062306a36Sopenharmony_ci ** Segment ID is unique across a protection domain and 7162306a36Sopenharmony_ci ** identifies a segment of PCI buses (reserved in 7262306a36Sopenharmony_ci ** MP Specification Draft 1.5) 7362306a36Sopenharmony_ci */ 7462306a36Sopenharmony_ci u8 src_seg_id; 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci /* 7762306a36Sopenharmony_ci ** Destination I/O SAPIC INTIN# identifies the INTIN n pin 7862306a36Sopenharmony_ci ** to which the signal is connected 7962306a36Sopenharmony_ci */ 8062306a36Sopenharmony_ci u8 dest_iosapic_intin; 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci /* 8362306a36Sopenharmony_ci ** Destination I/O SAPIC Address identifies the I/O SAPIC 8462306a36Sopenharmony_ci ** to which the signal is connected 8562306a36Sopenharmony_ci */ 8662306a36Sopenharmony_ci u64 dest_iosapic_addr; 8762306a36Sopenharmony_ci}; 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci#define IRT_IOSAPIC_TYPE 139 9062306a36Sopenharmony_ci#define IRT_IOSAPIC_LENGTH 16 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci#define IRT_VECTORED_INTR 0 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci#define IRT_PO_MASK 0x3 9562306a36Sopenharmony_ci#define IRT_ACTIVE_HI 1 9662306a36Sopenharmony_ci#define IRT_ACTIVE_LO 3 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci#define IRT_EL_MASK 0x3 9962306a36Sopenharmony_ci#define IRT_EL_SHIFT 2 10062306a36Sopenharmony_ci#define IRT_EDGE_TRIG 1 10162306a36Sopenharmony_ci#define IRT_LEVEL_TRIG 3 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci#define IRT_IRQ_MASK 0x3 10462306a36Sopenharmony_ci#define IRT_DEV_MASK 0x1f 10562306a36Sopenharmony_ci#define IRT_DEV_SHIFT 2 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci#define IRT_IRQ_DEVNO_MASK ((IRT_DEV_MASK << IRT_DEV_SHIFT) | IRT_IRQ_MASK) 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci#ifdef SUPPORT_MULTI_CELL 11062306a36Sopenharmony_cistruct iosapic_irt { 11162306a36Sopenharmony_ci struct iosapic_irt *irt_next; /* next routing table */ 11262306a36Sopenharmony_ci struct irt_entry *irt_base; /* intr routing table address */ 11362306a36Sopenharmony_ci size_t irte_count; /* number of entries in the table */ 11462306a36Sopenharmony_ci size_t irte_size; /* size (bytes) of each entry */ 11562306a36Sopenharmony_ci}; 11662306a36Sopenharmony_ci#endif 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_cistruct vector_info { 11962306a36Sopenharmony_ci struct iosapic_info *iosapic; /* I/O SAPIC this vector is on */ 12062306a36Sopenharmony_ci struct irt_entry *irte; /* IRT entry */ 12162306a36Sopenharmony_ci __le32 __iomem *eoi_addr; /* precalculate EOI reg address */ 12262306a36Sopenharmony_ci __le32 eoi_data; /* IA64: ? PA: swapped txn_data */ 12362306a36Sopenharmony_ci int txn_irq; /* virtual IRQ number for processor */ 12462306a36Sopenharmony_ci ulong txn_addr; /* IA64: id_eid PA: partial HPA */ 12562306a36Sopenharmony_ci u32 txn_data; /* CPU interrupt bit */ 12662306a36Sopenharmony_ci u8 status; /* status/flags */ 12762306a36Sopenharmony_ci u8 irqline; /* INTINn(IRQ) */ 12862306a36Sopenharmony_ci}; 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_cistruct iosapic_info { 13262306a36Sopenharmony_ci struct iosapic_info * isi_next; /* list of I/O SAPIC */ 13362306a36Sopenharmony_ci void __iomem * addr; /* remapped address */ 13462306a36Sopenharmony_ci unsigned long isi_hpa; /* physical base address */ 13562306a36Sopenharmony_ci struct vector_info * isi_vector; /* IRdT (IRQ line) array */ 13662306a36Sopenharmony_ci int isi_num_vectors; /* size of IRdT array */ 13762306a36Sopenharmony_ci int isi_status; /* status/flags */ 13862306a36Sopenharmony_ci unsigned int isi_version; /* DEBUG: data fr version reg */ 13962306a36Sopenharmony_ci}; 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_ci#ifdef __IA64__ 14462306a36Sopenharmony_ci/* 14562306a36Sopenharmony_ci** PA risc does NOT have any local sapics. IA64 does. 14662306a36Sopenharmony_ci** PIB (Processor Interrupt Block) is handled by Astro or Dew (Stretch CEC). 14762306a36Sopenharmony_ci** 14862306a36Sopenharmony_ci** PA: Get id_eid from IRT and hardcode PIB to 0xfeeNNNN0 14962306a36Sopenharmony_ci** Emulate the data on PAT platforms. 15062306a36Sopenharmony_ci*/ 15162306a36Sopenharmony_cistruct local_sapic_info { 15262306a36Sopenharmony_ci struct local_sapic_info *lsi_next; /* point to next CPU info */ 15362306a36Sopenharmony_ci int *lsi_cpu_id; /* point to logical CPU id */ 15462306a36Sopenharmony_ci unsigned long *lsi_id_eid; /* point to IA-64 CPU id */ 15562306a36Sopenharmony_ci int *lsi_status; /* point to CPU status */ 15662306a36Sopenharmony_ci void *lsi_private; /* point to special info */ 15762306a36Sopenharmony_ci}; 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ci/* 16062306a36Sopenharmony_ci** "root" data structure which ties everything together. 16162306a36Sopenharmony_ci** Should always be able to start with sapic_root and locate 16262306a36Sopenharmony_ci** the desired information. 16362306a36Sopenharmony_ci*/ 16462306a36Sopenharmony_cistruct sapic_info { 16562306a36Sopenharmony_ci struct sapic_info *si_next; /* info is per cell */ 16662306a36Sopenharmony_ci int si_cellid; /* cell id */ 16762306a36Sopenharmony_ci unsigned int si_status; /* status */ 16862306a36Sopenharmony_ci char *si_pib_base; /* intr blk base address */ 16962306a36Sopenharmony_ci local_sapic_info_t *si_local_info; 17062306a36Sopenharmony_ci io_sapic_info_t *si_io_info; 17162306a36Sopenharmony_ci extint_info_t *si_extint_info;/* External Intr info */ 17262306a36Sopenharmony_ci}; 17362306a36Sopenharmony_ci#endif 17462306a36Sopenharmony_ci 175