162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef ASM_CELL_PIC_H
362306a36Sopenharmony_ci#define ASM_CELL_PIC_H
462306a36Sopenharmony_ci#ifdef __KERNEL__
562306a36Sopenharmony_ci/*
662306a36Sopenharmony_ci * Mapping of IIC pending bits into per-node interrupt numbers.
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * Interrupt numbers are in the range 0...0x1ff where the top bit
962306a36Sopenharmony_ci * (0x100) represent the source node. Only 2 nodes are supported with
1062306a36Sopenharmony_ci * the current code though it's trivial to extend that if necessary using
1162306a36Sopenharmony_ci * higher level bits
1262306a36Sopenharmony_ci *
1362306a36Sopenharmony_ci * The bottom 8 bits are split into 2 type bits and 6 data bits that
1462306a36Sopenharmony_ci * depend on the type:
1562306a36Sopenharmony_ci *
1662306a36Sopenharmony_ci * 00 (0x00 | data) : normal interrupt. data is (class << 4) | source
1762306a36Sopenharmony_ci * 01 (0x40 | data) : IO exception. data is the exception number as
1862306a36Sopenharmony_ci *                    defined by bit numbers in IIC_SR
1962306a36Sopenharmony_ci * 10 (0x80 | data) : IPI. data is the IPI number (obtained from the priority)
2062306a36Sopenharmony_ci *                    and node is always 0 (IPIs are per-cpu, their source is
2162306a36Sopenharmony_ci *                    not relevant)
2262306a36Sopenharmony_ci * 11 (0xc0 | data) : reserved
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci * In addition, interrupt number 0x80000000 is defined as always invalid
2562306a36Sopenharmony_ci * (that is the node field is expected to never extend to move than 23 bits)
2662306a36Sopenharmony_ci *
2762306a36Sopenharmony_ci */
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_cienum {
3062306a36Sopenharmony_ci	IIC_IRQ_INVALID		= 0x80000000u,
3162306a36Sopenharmony_ci	IIC_IRQ_NODE_MASK	= 0x100,
3262306a36Sopenharmony_ci	IIC_IRQ_NODE_SHIFT	= 8,
3362306a36Sopenharmony_ci	IIC_IRQ_MAX		= 0x1ff,
3462306a36Sopenharmony_ci	IIC_IRQ_TYPE_MASK	= 0xc0,
3562306a36Sopenharmony_ci	IIC_IRQ_TYPE_NORMAL	= 0x00,
3662306a36Sopenharmony_ci	IIC_IRQ_TYPE_IOEXC	= 0x40,
3762306a36Sopenharmony_ci	IIC_IRQ_TYPE_IPI	= 0x80,
3862306a36Sopenharmony_ci	IIC_IRQ_CLASS_SHIFT	= 4,
3962306a36Sopenharmony_ci	IIC_IRQ_CLASS_0		= 0x00,
4062306a36Sopenharmony_ci	IIC_IRQ_CLASS_1		= 0x10,
4162306a36Sopenharmony_ci	IIC_IRQ_CLASS_2		= 0x20,
4262306a36Sopenharmony_ci	IIC_SOURCE_COUNT	= 0x200,
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci	/* Here are defined the various source/dest units. Avoid using those
4562306a36Sopenharmony_ci	 * definitions if you can, they are mostly here for reference
4662306a36Sopenharmony_ci	 */
4762306a36Sopenharmony_ci	IIC_UNIT_SPU_0		= 0x4,
4862306a36Sopenharmony_ci	IIC_UNIT_SPU_1		= 0x7,
4962306a36Sopenharmony_ci	IIC_UNIT_SPU_2		= 0x3,
5062306a36Sopenharmony_ci	IIC_UNIT_SPU_3		= 0x8,
5162306a36Sopenharmony_ci	IIC_UNIT_SPU_4		= 0x2,
5262306a36Sopenharmony_ci	IIC_UNIT_SPU_5		= 0x9,
5362306a36Sopenharmony_ci	IIC_UNIT_SPU_6		= 0x1,
5462306a36Sopenharmony_ci	IIC_UNIT_SPU_7		= 0xa,
5562306a36Sopenharmony_ci	IIC_UNIT_IOC_0		= 0x0,
5662306a36Sopenharmony_ci	IIC_UNIT_IOC_1		= 0xb,
5762306a36Sopenharmony_ci	IIC_UNIT_THREAD_0	= 0xe, /* target only */
5862306a36Sopenharmony_ci	IIC_UNIT_THREAD_1	= 0xf, /* target only */
5962306a36Sopenharmony_ci	IIC_UNIT_IIC		= 0xe, /* source only (IO exceptions) */
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci	/* Base numbers for the external interrupts */
6262306a36Sopenharmony_ci	IIC_IRQ_EXT_IOIF0	=
6362306a36Sopenharmony_ci		IIC_IRQ_TYPE_NORMAL | IIC_IRQ_CLASS_2 | IIC_UNIT_IOC_0,
6462306a36Sopenharmony_ci	IIC_IRQ_EXT_IOIF1	=
6562306a36Sopenharmony_ci		IIC_IRQ_TYPE_NORMAL | IIC_IRQ_CLASS_2 | IIC_UNIT_IOC_1,
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci	/* Base numbers for the IIC_ISR interrupts */
6862306a36Sopenharmony_ci	IIC_IRQ_IOEX_TMI	= IIC_IRQ_TYPE_IOEXC | IIC_IRQ_CLASS_1 | 63,
6962306a36Sopenharmony_ci	IIC_IRQ_IOEX_PMI	= IIC_IRQ_TYPE_IOEXC | IIC_IRQ_CLASS_1 | 62,
7062306a36Sopenharmony_ci	IIC_IRQ_IOEX_ATI	= IIC_IRQ_TYPE_IOEXC | IIC_IRQ_CLASS_1 | 61,
7162306a36Sopenharmony_ci	IIC_IRQ_IOEX_MATBFI	= IIC_IRQ_TYPE_IOEXC | IIC_IRQ_CLASS_1 | 60,
7262306a36Sopenharmony_ci	IIC_IRQ_IOEX_ELDI	= IIC_IRQ_TYPE_IOEXC | IIC_IRQ_CLASS_1 | 59,
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci	/* Which bits in IIC_ISR are edge sensitive */
7562306a36Sopenharmony_ci	IIC_ISR_EDGE_MASK	= 0x4ul,
7662306a36Sopenharmony_ci};
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ciextern void iic_init_IRQ(void);
7962306a36Sopenharmony_ciextern void iic_message_pass(int cpu, int msg);
8062306a36Sopenharmony_ciextern void iic_request_IPIs(void);
8162306a36Sopenharmony_ciextern void iic_setup_cpu(void);
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ciextern u8 iic_get_target_id(int cpu);
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ciextern void spider_init_IRQ(void);
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ciextern void iic_set_interrupt_routing(int cpu, int thread, int priority);
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci#endif
9062306a36Sopenharmony_ci#endif /* ASM_CELL_PIC_H */
91