18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* irq.h: IRQ registers on the 64-bit Sparc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
58c2ecf20Sopenharmony_ci * Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz)
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _SPARC64_IRQ_H
98c2ecf20Sopenharmony_ci#define _SPARC64_IRQ_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/linkage.h>
128c2ecf20Sopenharmony_ci#include <linux/kernel.h>
138c2ecf20Sopenharmony_ci#include <linux/errno.h>
148c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
158c2ecf20Sopenharmony_ci#include <asm/pil.h>
168c2ecf20Sopenharmony_ci#include <asm/ptrace.h>
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci/* IMAP/ICLR register defines */
198c2ecf20Sopenharmony_ci#define IMAP_VALID		0x80000000UL	/* IRQ Enabled		*/
208c2ecf20Sopenharmony_ci#define IMAP_TID_UPA		0x7c000000UL	/* UPA TargetID		*/
218c2ecf20Sopenharmony_ci#define IMAP_TID_JBUS		0x7c000000UL	/* JBUS TargetID	*/
228c2ecf20Sopenharmony_ci#define IMAP_TID_SHIFT		26
238c2ecf20Sopenharmony_ci#define IMAP_AID_SAFARI		0x7c000000UL	/* Safari AgentID	*/
248c2ecf20Sopenharmony_ci#define IMAP_AID_SHIFT		26
258c2ecf20Sopenharmony_ci#define IMAP_NID_SAFARI		0x03e00000UL	/* Safari NodeID	*/
268c2ecf20Sopenharmony_ci#define IMAP_NID_SHIFT		21
278c2ecf20Sopenharmony_ci#define IMAP_IGN		0x000007c0UL	/* IRQ Group Number	*/
288c2ecf20Sopenharmony_ci#define IMAP_INO		0x0000003fUL	/* IRQ Number		*/
298c2ecf20Sopenharmony_ci#define IMAP_INR		0x000007ffUL	/* Full interrupt number*/
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define ICLR_IDLE		0x00000000UL	/* Idle state		*/
328c2ecf20Sopenharmony_ci#define ICLR_TRANSMIT		0x00000001UL	/* Transmit state	*/
338c2ecf20Sopenharmony_ci#define ICLR_PENDING		0x00000003UL	/* Pending state	*/
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci/* The largest number of unique interrupt sources we support.
368c2ecf20Sopenharmony_ci * If this needs to ever be larger than 255, you need to change
378c2ecf20Sopenharmony_ci * the type of ino_bucket->irq as appropriate.
388c2ecf20Sopenharmony_ci *
398c2ecf20Sopenharmony_ci * ino_bucket->irq allocation is made during {sun4v_,}build_irq().
408c2ecf20Sopenharmony_ci */
418c2ecf20Sopenharmony_ci#define NR_IRQS		(2048)
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_civoid irq_install_pre_handler(int irq,
448c2ecf20Sopenharmony_ci			     void (*func)(unsigned int, void *, void *),
458c2ecf20Sopenharmony_ci			     void *arg1, void *arg2);
468c2ecf20Sopenharmony_ci#define irq_canonicalize(irq)	(irq)
478c2ecf20Sopenharmony_ciunsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap);
488c2ecf20Sopenharmony_ciunsigned int sun4v_build_irq(u32 devhandle, unsigned int devino);
498c2ecf20Sopenharmony_ciunsigned int sun4v_build_virq(u32 devhandle, unsigned int devino);
508c2ecf20Sopenharmony_ciunsigned int sun4v_build_msi(u32 devhandle, unsigned int *irq_p,
518c2ecf20Sopenharmony_ci			     unsigned int msi_devino_start,
528c2ecf20Sopenharmony_ci			     unsigned int msi_devino_end);
538c2ecf20Sopenharmony_civoid sun4v_destroy_msi(unsigned int irq);
548c2ecf20Sopenharmony_ciunsigned int sun4u_build_msi(u32 portid, unsigned int *irq_p,
558c2ecf20Sopenharmony_ci			     unsigned int msi_devino_start,
568c2ecf20Sopenharmony_ci			     unsigned int msi_devino_end,
578c2ecf20Sopenharmony_ci			     unsigned long imap_base,
588c2ecf20Sopenharmony_ci			     unsigned long iclr_base);
598c2ecf20Sopenharmony_civoid sun4u_destroy_msi(unsigned int irq);
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ciunsigned int irq_alloc(unsigned int dev_handle, unsigned int dev_ino);
628c2ecf20Sopenharmony_civoid irq_free(unsigned int irq);
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_civoid __init init_IRQ(void);
658c2ecf20Sopenharmony_civoid fixup_irqs(void);
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_cistatic inline void set_softint(unsigned long bits)
688c2ecf20Sopenharmony_ci{
698c2ecf20Sopenharmony_ci	__asm__ __volatile__("wr	%0, 0x0, %%set_softint"
708c2ecf20Sopenharmony_ci			     : /* No outputs */
718c2ecf20Sopenharmony_ci			     : "r" (bits));
728c2ecf20Sopenharmony_ci}
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_cistatic inline void clear_softint(unsigned long bits)
758c2ecf20Sopenharmony_ci{
768c2ecf20Sopenharmony_ci	__asm__ __volatile__("wr	%0, 0x0, %%clear_softint"
778c2ecf20Sopenharmony_ci			     : /* No outputs */
788c2ecf20Sopenharmony_ci			     : "r" (bits));
798c2ecf20Sopenharmony_ci}
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cistatic inline unsigned long get_softint(void)
828c2ecf20Sopenharmony_ci{
838c2ecf20Sopenharmony_ci	unsigned long retval;
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci	__asm__ __volatile__("rd	%%softint, %0"
868c2ecf20Sopenharmony_ci			     : "=r" (retval));
878c2ecf20Sopenharmony_ci	return retval;
888c2ecf20Sopenharmony_ci}
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_civoid arch_trigger_cpumask_backtrace(const struct cpumask *mask,
918c2ecf20Sopenharmony_ci				    bool exclude_self);
928c2ecf20Sopenharmony_ci#define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ciextern void *hardirq_stack[NR_CPUS];
958c2ecf20Sopenharmony_ciextern void *softirq_stack[NR_CPUS];
968c2ecf20Sopenharmony_ci#define __ARCH_HAS_DO_SOFTIRQ
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define NO_IRQ		0xffffffff
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci#endif
101