18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef ASM_CELL_PIC_H
38c2ecf20Sopenharmony_ci#define ASM_CELL_PIC_H
48c2ecf20Sopenharmony_ci#ifdef __KERNEL__
58c2ecf20Sopenharmony_ci/*
68c2ecf20Sopenharmony_ci * Mapping of IIC pending bits into per-node interrupt numbers.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Interrupt numbers are in the range 0...0x1ff where the top bit
98c2ecf20Sopenharmony_ci * (0x100) represent the source node. Only 2 nodes are supported with
108c2ecf20Sopenharmony_ci * the current code though it's trivial to extend that if necessary using
118c2ecf20Sopenharmony_ci * higher level bits
128c2ecf20Sopenharmony_ci *
138c2ecf20Sopenharmony_ci * The bottom 8 bits are split into 2 type bits and 6 data bits that
148c2ecf20Sopenharmony_ci * depend on the type:
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci * 00 (0x00 | data) : normal interrupt. data is (class << 4) | source
178c2ecf20Sopenharmony_ci * 01 (0x40 | data) : IO exception. data is the exception number as
188c2ecf20Sopenharmony_ci *                    defined by bit numbers in IIC_SR
198c2ecf20Sopenharmony_ci * 10 (0x80 | data) : IPI. data is the IPI number (obtained from the priority)
208c2ecf20Sopenharmony_ci *                    and node is always 0 (IPIs are per-cpu, their source is
218c2ecf20Sopenharmony_ci *                    not relevant)
228c2ecf20Sopenharmony_ci * 11 (0xc0 | data) : reserved
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci * In addition, interrupt number 0x80000000 is defined as always invalid
258c2ecf20Sopenharmony_ci * (that is the node field is expected to never extend to move than 23 bits)
268c2ecf20Sopenharmony_ci *
278c2ecf20Sopenharmony_ci */
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cienum {
308c2ecf20Sopenharmony_ci	IIC_IRQ_INVALID		= 0x80000000u,
318c2ecf20Sopenharmony_ci	IIC_IRQ_NODE_MASK	= 0x100,
328c2ecf20Sopenharmony_ci	IIC_IRQ_NODE_SHIFT	= 8,
338c2ecf20Sopenharmony_ci	IIC_IRQ_MAX		= 0x1ff,
348c2ecf20Sopenharmony_ci	IIC_IRQ_TYPE_MASK	= 0xc0,
358c2ecf20Sopenharmony_ci	IIC_IRQ_TYPE_NORMAL	= 0x00,
368c2ecf20Sopenharmony_ci	IIC_IRQ_TYPE_IOEXC	= 0x40,
378c2ecf20Sopenharmony_ci	IIC_IRQ_TYPE_IPI	= 0x80,
388c2ecf20Sopenharmony_ci	IIC_IRQ_CLASS_SHIFT	= 4,
398c2ecf20Sopenharmony_ci	IIC_IRQ_CLASS_0		= 0x00,
408c2ecf20Sopenharmony_ci	IIC_IRQ_CLASS_1		= 0x10,
418c2ecf20Sopenharmony_ci	IIC_IRQ_CLASS_2		= 0x20,
428c2ecf20Sopenharmony_ci	IIC_SOURCE_COUNT	= 0x200,
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci	/* Here are defined the various source/dest units. Avoid using those
458c2ecf20Sopenharmony_ci	 * definitions if you can, they are mostly here for reference
468c2ecf20Sopenharmony_ci	 */
478c2ecf20Sopenharmony_ci	IIC_UNIT_SPU_0		= 0x4,
488c2ecf20Sopenharmony_ci	IIC_UNIT_SPU_1		= 0x7,
498c2ecf20Sopenharmony_ci	IIC_UNIT_SPU_2		= 0x3,
508c2ecf20Sopenharmony_ci	IIC_UNIT_SPU_3		= 0x8,
518c2ecf20Sopenharmony_ci	IIC_UNIT_SPU_4		= 0x2,
528c2ecf20Sopenharmony_ci	IIC_UNIT_SPU_5		= 0x9,
538c2ecf20Sopenharmony_ci	IIC_UNIT_SPU_6		= 0x1,
548c2ecf20Sopenharmony_ci	IIC_UNIT_SPU_7		= 0xa,
558c2ecf20Sopenharmony_ci	IIC_UNIT_IOC_0		= 0x0,
568c2ecf20Sopenharmony_ci	IIC_UNIT_IOC_1		= 0xb,
578c2ecf20Sopenharmony_ci	IIC_UNIT_THREAD_0	= 0xe, /* target only */
588c2ecf20Sopenharmony_ci	IIC_UNIT_THREAD_1	= 0xf, /* target only */
598c2ecf20Sopenharmony_ci	IIC_UNIT_IIC		= 0xe, /* source only (IO exceptions) */
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci	/* Base numbers for the external interrupts */
628c2ecf20Sopenharmony_ci	IIC_IRQ_EXT_IOIF0	=
638c2ecf20Sopenharmony_ci		IIC_IRQ_TYPE_NORMAL | IIC_IRQ_CLASS_2 | IIC_UNIT_IOC_0,
648c2ecf20Sopenharmony_ci	IIC_IRQ_EXT_IOIF1	=
658c2ecf20Sopenharmony_ci		IIC_IRQ_TYPE_NORMAL | IIC_IRQ_CLASS_2 | IIC_UNIT_IOC_1,
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci	/* Base numbers for the IIC_ISR interrupts */
688c2ecf20Sopenharmony_ci	IIC_IRQ_IOEX_TMI	= IIC_IRQ_TYPE_IOEXC | IIC_IRQ_CLASS_1 | 63,
698c2ecf20Sopenharmony_ci	IIC_IRQ_IOEX_PMI	= IIC_IRQ_TYPE_IOEXC | IIC_IRQ_CLASS_1 | 62,
708c2ecf20Sopenharmony_ci	IIC_IRQ_IOEX_ATI	= IIC_IRQ_TYPE_IOEXC | IIC_IRQ_CLASS_1 | 61,
718c2ecf20Sopenharmony_ci	IIC_IRQ_IOEX_MATBFI	= IIC_IRQ_TYPE_IOEXC | IIC_IRQ_CLASS_1 | 60,
728c2ecf20Sopenharmony_ci	IIC_IRQ_IOEX_ELDI	= IIC_IRQ_TYPE_IOEXC | IIC_IRQ_CLASS_1 | 59,
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	/* Which bits in IIC_ISR are edge sensitive */
758c2ecf20Sopenharmony_ci	IIC_ISR_EDGE_MASK	= 0x4ul,
768c2ecf20Sopenharmony_ci};
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ciextern void iic_init_IRQ(void);
798c2ecf20Sopenharmony_ciextern void iic_message_pass(int cpu, int msg);
808c2ecf20Sopenharmony_ciextern void iic_request_IPIs(void);
818c2ecf20Sopenharmony_ciextern void iic_setup_cpu(void);
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ciextern u8 iic_get_target_id(int cpu);
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ciextern void spider_init_IRQ(void);
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ciextern void iic_set_interrupt_routing(int cpu, int thread, int priority);
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#endif
908c2ecf20Sopenharmony_ci#endif /* ASM_CELL_PIC_H */
91