18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *    Private structs/constants for PARISC IOSAPIC support
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *    Copyright (C) 2000 Hewlett Packard (Grant Grundler)
68c2ecf20Sopenharmony_ci *    Copyright (C) 2000,2003 Grant Grundler (grundler at parisc-linux.org)
78c2ecf20Sopenharmony_ci *    Copyright (C) 2002 Matthew Wilcox (willy at parisc-linux.org)
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci/*
118c2ecf20Sopenharmony_ci** This file is private to iosapic driver.
128c2ecf20Sopenharmony_ci** If stuff needs to be used by another driver, move it to a common file.
138c2ecf20Sopenharmony_ci**
148c2ecf20Sopenharmony_ci** WARNING: fields most data structures here are ordered to make sure
158c2ecf20Sopenharmony_ci**          they pack nicely for 64-bit compilation. (ie sizeof(long) == 8)
168c2ecf20Sopenharmony_ci*/
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci/*
208c2ecf20Sopenharmony_ci** Interrupt Routing Stuff
218c2ecf20Sopenharmony_ci** -----------------------
228c2ecf20Sopenharmony_ci** The interrupt routing table consists of entries derived from
238c2ecf20Sopenharmony_ci** MP Specification Draft 1.5. There is one interrupt routing
248c2ecf20Sopenharmony_ci** table per cell.  N- and L-class consist of a single cell.
258c2ecf20Sopenharmony_ci*/
268c2ecf20Sopenharmony_cistruct irt_entry {
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci	/* Entry Type 139 identifies an I/O SAPIC interrupt entry */
298c2ecf20Sopenharmony_ci	u8 entry_type;
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci	/* Entry Length 16 indicates entry is 16 bytes long */
328c2ecf20Sopenharmony_ci	u8 entry_length;
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci	/*
358c2ecf20Sopenharmony_ci	** Interrupt Type of 0 indicates a vectored interrupt,
368c2ecf20Sopenharmony_ci	** all other values are reserved
378c2ecf20Sopenharmony_ci	*/
388c2ecf20Sopenharmony_ci	u8 interrupt_type;
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci	/*
418c2ecf20Sopenharmony_ci	** PO and EL
428c2ecf20Sopenharmony_ci	** Polarity of SAPIC I/O input signals:
438c2ecf20Sopenharmony_ci	**    00 = Reserved
448c2ecf20Sopenharmony_ci	**    01 = Active high
458c2ecf20Sopenharmony_ci	**    10 = Reserved
468c2ecf20Sopenharmony_ci	**    11 = Active low
478c2ecf20Sopenharmony_ci	** Trigger mode of SAPIC I/O input signals:
488c2ecf20Sopenharmony_ci	**    00 = Reserved
498c2ecf20Sopenharmony_ci	**    01 = Edge-triggered
508c2ecf20Sopenharmony_ci	**    10 = Reserved
518c2ecf20Sopenharmony_ci	**    11 = Level-triggered
528c2ecf20Sopenharmony_ci	*/
538c2ecf20Sopenharmony_ci	u8 polarity_trigger;
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci	/*
568c2ecf20Sopenharmony_ci	** IRQ and DEVNO
578c2ecf20Sopenharmony_ci	** irq identifies PCI interrupt signal where
588c2ecf20Sopenharmony_ci	**    0x0 corresponds to INT_A#,
598c2ecf20Sopenharmony_ci	**    0x1 corresponds to INT_B#,
608c2ecf20Sopenharmony_ci	**    0x2 corresponds to INT_C#
618c2ecf20Sopenharmony_ci	**    0x3 corresponds to INT_D#
628c2ecf20Sopenharmony_ci	** PCI device number where interrupt originates
638c2ecf20Sopenharmony_ci	*/
648c2ecf20Sopenharmony_ci	u8 src_bus_irq_devno;
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci	/* Source Bus ID identifies the bus where interrupt signal comes from */
678c2ecf20Sopenharmony_ci	u8 src_bus_id;
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci	/*
708c2ecf20Sopenharmony_ci	** Segment ID is unique across a protection domain and
718c2ecf20Sopenharmony_ci	** identifies a segment of PCI buses (reserved in
728c2ecf20Sopenharmony_ci	** MP Specification Draft 1.5)
738c2ecf20Sopenharmony_ci	*/
748c2ecf20Sopenharmony_ci	u8 src_seg_id;
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci	/*
778c2ecf20Sopenharmony_ci	** Destination I/O SAPIC INTIN# identifies the INTIN n pin
788c2ecf20Sopenharmony_ci	** to which the signal is connected
798c2ecf20Sopenharmony_ci	*/
808c2ecf20Sopenharmony_ci	u8 dest_iosapic_intin;
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci	/*
838c2ecf20Sopenharmony_ci	** Destination I/O SAPIC Address identifies the I/O SAPIC
848c2ecf20Sopenharmony_ci	** to which the signal is connected
858c2ecf20Sopenharmony_ci	*/
868c2ecf20Sopenharmony_ci	u64 dest_iosapic_addr;
878c2ecf20Sopenharmony_ci};
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#define IRT_IOSAPIC_TYPE   139
908c2ecf20Sopenharmony_ci#define IRT_IOSAPIC_LENGTH 16
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci#define IRT_VECTORED_INTR  0
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci#define IRT_PO_MASK        0x3
958c2ecf20Sopenharmony_ci#define IRT_ACTIVE_HI      1
968c2ecf20Sopenharmony_ci#define IRT_ACTIVE_LO      3
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define IRT_EL_MASK        0x3
998c2ecf20Sopenharmony_ci#define IRT_EL_SHIFT       2
1008c2ecf20Sopenharmony_ci#define IRT_EDGE_TRIG      1
1018c2ecf20Sopenharmony_ci#define IRT_LEVEL_TRIG     3
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci#define IRT_IRQ_MASK       0x3
1048c2ecf20Sopenharmony_ci#define IRT_DEV_MASK       0x1f
1058c2ecf20Sopenharmony_ci#define IRT_DEV_SHIFT      2
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci#define IRT_IRQ_DEVNO_MASK	((IRT_DEV_MASK << IRT_DEV_SHIFT) | IRT_IRQ_MASK)
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#ifdef SUPPORT_MULTI_CELL
1108c2ecf20Sopenharmony_cistruct iosapic_irt {
1118c2ecf20Sopenharmony_ci        struct iosapic_irt *irt_next;  /* next routing table */
1128c2ecf20Sopenharmony_ci        struct irt_entry *irt_base;             /* intr routing table address */
1138c2ecf20Sopenharmony_ci        size_t  irte_count;            /* number of entries in the table */
1148c2ecf20Sopenharmony_ci        size_t  irte_size;             /* size (bytes) of each entry */
1158c2ecf20Sopenharmony_ci};
1168c2ecf20Sopenharmony_ci#endif
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_cistruct vector_info {
1198c2ecf20Sopenharmony_ci	struct iosapic_info *iosapic;	/* I/O SAPIC this vector is on */
1208c2ecf20Sopenharmony_ci	struct irt_entry *irte;		/* IRT entry */
1218c2ecf20Sopenharmony_ci	__le32 __iomem *eoi_addr;	/* precalculate EOI reg address */
1228c2ecf20Sopenharmony_ci	__le32	eoi_data;		/* IA64: ?       PA: swapped txn_data */
1238c2ecf20Sopenharmony_ci	int	txn_irq;		/* virtual IRQ number for processor */
1248c2ecf20Sopenharmony_ci	ulong	txn_addr;		/* IA64: id_eid  PA: partial HPA */
1258c2ecf20Sopenharmony_ci	u32	txn_data;		/* CPU interrupt bit */
1268c2ecf20Sopenharmony_ci	u8	status;			/* status/flags */
1278c2ecf20Sopenharmony_ci	u8	irqline;		/* INTINn(IRQ) */
1288c2ecf20Sopenharmony_ci};
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_cistruct iosapic_info {
1328c2ecf20Sopenharmony_ci	struct iosapic_info *	isi_next;	/* list of I/O SAPIC */
1338c2ecf20Sopenharmony_ci	void __iomem *		addr;		/* remapped address */
1348c2ecf20Sopenharmony_ci	unsigned long		isi_hpa;	/* physical base address */
1358c2ecf20Sopenharmony_ci	struct vector_info *	isi_vector;	/* IRdT (IRQ line) array */
1368c2ecf20Sopenharmony_ci	int			isi_num_vectors; /* size of IRdT array */
1378c2ecf20Sopenharmony_ci	int			isi_status;	/* status/flags */
1388c2ecf20Sopenharmony_ci	unsigned int		isi_version;	/* DEBUG: data fr version reg */
1398c2ecf20Sopenharmony_ci};
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci#ifdef __IA64__
1448c2ecf20Sopenharmony_ci/*
1458c2ecf20Sopenharmony_ci** PA risc does NOT have any local sapics. IA64 does.
1468c2ecf20Sopenharmony_ci** PIB (Processor Interrupt Block) is handled by Astro or Dew (Stretch CEC).
1478c2ecf20Sopenharmony_ci**
1488c2ecf20Sopenharmony_ci** PA: Get id_eid from IRT and hardcode PIB to 0xfeeNNNN0
1498c2ecf20Sopenharmony_ci**     Emulate the data on PAT platforms.
1508c2ecf20Sopenharmony_ci*/
1518c2ecf20Sopenharmony_cistruct local_sapic_info {
1528c2ecf20Sopenharmony_ci	struct local_sapic_info *lsi_next;      /* point to next CPU info */
1538c2ecf20Sopenharmony_ci	int                     *lsi_cpu_id;    /* point to logical CPU id */
1548c2ecf20Sopenharmony_ci	unsigned long           *lsi_id_eid;    /* point to IA-64 CPU id */
1558c2ecf20Sopenharmony_ci	int                     *lsi_status;    /* point to CPU status   */
1568c2ecf20Sopenharmony_ci	void                    *lsi_private;   /* point to special info */
1578c2ecf20Sopenharmony_ci};
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci/*
1608c2ecf20Sopenharmony_ci** "root" data structure which ties everything together.
1618c2ecf20Sopenharmony_ci** Should always be able to start with sapic_root and locate
1628c2ecf20Sopenharmony_ci** the desired information.
1638c2ecf20Sopenharmony_ci*/
1648c2ecf20Sopenharmony_cistruct sapic_info {
1658c2ecf20Sopenharmony_ci	struct sapic_info	*si_next;	/* info is per cell */
1668c2ecf20Sopenharmony_ci	int                     si_cellid;      /* cell id */
1678c2ecf20Sopenharmony_ci	unsigned int            si_status;       /* status  */
1688c2ecf20Sopenharmony_ci	char                    *si_pib_base;   /* intr blk base address */
1698c2ecf20Sopenharmony_ci	local_sapic_info_t      *si_local_info;
1708c2ecf20Sopenharmony_ci	io_sapic_info_t         *si_io_info;
1718c2ecf20Sopenharmony_ci	extint_info_t           *si_extint_info;/* External Intr info      */
1728c2ecf20Sopenharmony_ci};
1738c2ecf20Sopenharmony_ci#endif
1748c2ecf20Sopenharmony_ci
175