Linux-MIPS Archive on lore.kernel.org
 help / color / Atom feed
From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: linux-mips@vger.kernel.org
Cc: tsbogend@alpha.franken.de, maz@kernel.org, chenhc@lemote.com,
	Jiaxun Yang <jiaxun.yang@flygoat.com>
Subject: [RFC PATCH 1/6] MIPS: irq_cpu: Add a helper to map virq for CPU IRQ
Date: Thu, 26 Mar 2020 14:16:57 +0800
Message-ID: <20200326061704.387483-2-jiaxun.yang@flygoat.com> (raw)
In-Reply-To: <20200326061704.387483-1-jiaxun.yang@flygoat.com>

To care legacy platform without dt, we need this helper
to map virq for cpu_irq in order to deal with legacy drivers
rely on irq number.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/include/asm/irq_cpu.h | 19 ++++++++++++++++++-
 drivers/irqchip/irq-mips-cpu.c  |  8 ++++----
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/arch/mips/include/asm/irq_cpu.h b/arch/mips/include/asm/irq_cpu.h
index 83d7331ab215..231c5dc64c19 100644
--- a/arch/mips/include/asm/irq_cpu.h
+++ b/arch/mips/include/asm/irq_cpu.h
@@ -9,12 +9,29 @@
 #ifndef _ASM_IRQ_CPU_H
 #define _ASM_IRQ_CPU_H
 
+#include <linux/irqdomain.h>
+
 extern void mips_cpu_irq_init(void);
+extern struct irq_domain *mips_cpu_irq_domain;
 
 #ifdef CONFIG_IRQ_DOMAIN
-struct device_node;
 extern int mips_cpu_irq_of_init(struct device_node *of_node,
 				struct device_node *parent);
+
+static inline int mips_cpu_map_virq(int hwirq)
+{
+	struct irq_fwspec fwspec;
+
+	fwspec.fwnode = mips_cpu_irq_domain->fwnode;
+	fwspec.param_count = 1;
+	fwspec.param[0] = hwirq;
+	return irq_create_fwspec_mapping(&fwspec);
+}
+#else
+static inline int mips_cpu_map_virq(int hwirq)
+{
+	return MIPS_CPU_IRQ_BASE + hwirq;
+}
 #endif
 
 #endif /* _ASM_IRQ_CPU_H */
diff --git a/drivers/irqchip/irq-mips-cpu.c b/drivers/irqchip/irq-mips-cpu.c
index 95d4fd8f7a96..19734b11b36d 100644
--- a/drivers/irqchip/irq-mips-cpu.c
+++ b/drivers/irqchip/irq-mips-cpu.c
@@ -34,7 +34,7 @@
 #include <asm/mipsmtregs.h>
 #include <asm/setup.h>
 
-static struct irq_domain *irq_domain;
+struct irq_domain *mips_cpu_irq_domain;
 static struct irq_domain *ipi_domain;
 
 static inline void unmask_mips_irq(struct irq_data *d)
@@ -141,7 +141,7 @@ asmlinkage void __weak plat_irq_dispatch(void)
 		if (IS_ENABLED(CONFIG_GENERIC_IRQ_IPI) && irq < 2)
 			virq = irq_linear_revmap(ipi_domain, irq);
 		else
-			virq = irq_linear_revmap(irq_domain, irq);
+			virq = irq_linear_revmap(mips_cpu_irq_domain, irq);
 		do_IRQ(virq);
 		pending &= ~BIT(irq);
 	}
@@ -251,10 +251,10 @@ static void __init __mips_cpu_irq_init(struct device_node *of_node)
 	clear_c0_status(ST0_IM);
 	clear_c0_cause(CAUSEF_IP);
 
-	irq_domain = irq_domain_add_legacy(of_node, 8, MIPS_CPU_IRQ_BASE, 0,
+	mips_cpu_irq_domain = irq_domain_add_legacy(of_node, 8, MIPS_CPU_IRQ_BASE, 0,
 					   &mips_cpu_intc_irq_domain_ops,
 					   NULL);
-	if (!irq_domain)
+	if (!mips_cpu_irq_domain)
 		panic("Failed to add irqdomain for MIPS CPU");
 
 	/*
-- 
2.26.0.rc2



  reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26  6:16 [RFC PATCH 0/6] MIPS: Handle CPU IRQ in domain's way Jiaxun Yang
2020-03-26  6:16 ` Jiaxun Yang [this message]
2020-03-26  6:16 ` [PATCH 1/2] MIPS: Kill MIPS_GIC_IRQ_BASE Jiaxun Yang
2020-03-26  6:16 ` [RFC PATCH 2/6] irqchip: mips-cpu: Allocate fwnode for non-DT platforms Jiaxun Yang
2020-03-26  6:17 ` [PATCH 2/2] MIPS: Kill RM7K & RM9K IRQ Code Jiaxun Yang
2020-03-26  6:17 ` [RFC PATCH 3/6] irqchip: mips-cpu: Convert to simple domain Jiaxun Yang
2020-03-26  6:17 ` [RFC PATCH 4/6] MIPS: kernel: Use mips_cpu_map_virq helper Jiaxun Yang
2020-03-26  6:17 ` [RFC PATCH 5/6] MIPS: loongson64: " Jiaxun Yang
2020-03-26  6:20 ` [RFC PATCH 6/6] MIPS: ip22: " Jiaxun Yang
2020-03-26 15:38 ` [RFC PATCH 0/6] MIPS: Handle CPU IRQ in domain's way Thomas Bogendoerfer
2020-03-26 15:46   ` Marc Zyngier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200326061704.387483-2-jiaxun.yang@flygoat.com \
    --to=jiaxun.yang@flygoat.com \
    --cc=chenhc@lemote.com \
    --cc=linux-mips@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-MIPS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mips/0 linux-mips/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mips linux-mips/ https://lore.kernel.org/linux-mips \
		linux-mips@vger.kernel.org
	public-inbox-index linux-mips

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-mips


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git