mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jelly Jia <Jelly.Jia@cixtech.com>
To: vkoul@kernel.org, Frank.Li@kernel.org, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org, robin.murphy@arm.com,
	sboyd@kernel.org, bmasney+clk@redhat.com,
	jbrunet+clk@baylibre.com, tglx@kernel.org
Cc: devicetree@vger.kernel.org, cix-kernel-upstream@cixtech.com,
	dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Jelly.Jia@cixtech.com,
	linux-clk@vger.kernel.org, joakim.zhang@cixtech.com,
	radu@rendec.net
Subject: [PATCH v4 2/5] irqchip: Add the Sky1 AUDSS auxiliary interrupt controller
Date: Tue, 17 Nov 2026 17:44:05 +0800	[thread overview]
Message-ID: <20261117094408.1393837-3-Jelly.Jia@cixtech.com> (raw)
In-Reply-To: <20261117094408.1393837-1-Jelly.Jia@cixtech.com>

The AUDSS CRU gates eight DMA channel interrupts onto a shared parent line.
Implement its irqchip, domain and chained handler in an auxiliary driver
under drivers/irqchip rather than the clock subsystem.

Reuse the parent CRU regmap and firmware node. Retain level/polled child
flow, explicit disable masking, mapping disposal and powered teardown. Keep
clock/reset control in the parent. Coordinate the parent IRQ's quiescing
with runtime PM and noirq system sleep, keeping sleepable power management
out of hard IRQ callbacks.

Signed-off-by: Jelly Jia <Jelly.Jia@cixtech.com>
---
 MAINTAINERS                      |   1 +
 drivers/irqchip/Kconfig          |  16 ++
 drivers/irqchip/Makefile         |   1 +
 drivers/irqchip/irq-sky1-audss.c | 255 +++++++++++++++++++++++++++++++
 4 files changed, 273 insertions(+)
 create mode 100644 drivers/irqchip/irq-sky1-audss.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 93abbb315065..bd966600deb0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2904,6 +2904,7 @@ T:	git https://github.com/cixtech/linux-mainline.git
 F:	Documentation/devicetree/bindings/arm/cix.yaml
 F:	Documentation/devicetree/bindings/mailbox/cix,sky1-mbox.yaml
 F:	arch/arm64/boot/dts/cix/
+F:	drivers/irqchip/irq-sky1-audss.c
 F:	drivers/mailbox/cix-mailbox.c
 K:	\bcix\b
 
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 136bab41f801..1275622851c1 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -233,6 +233,22 @@ config LAN966X_OIC
 config MADERA_IRQ
 	tristate
 
+config IRQ_SKY1_AUDSS
+	tristate "CIX Sky1 AUDSS DMA interrupt controller"
+	depends on ARCH_CIX || COMPILE_TEST
+	depends on OF
+	select AUXILIARY_BUS
+	select IRQ_DOMAIN
+	select REGMAP
+	default CLK_SKY1_AUDSS
+	help
+	  Support the DMA channel interrupt gates in the CIX Sky1 audio
+	  subsystem CRU. This auxiliary driver shares the clock controller's
+	  register map and combines the channel interrupts onto a parent IRQ.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called irq-sky1-audss.
+
 config IRQ_MIPS_CPU
 	bool
 	select GENERIC_IRQ_CHIP
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 16a5fd126c9a..2862a0335082 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_IRQCHIP)			+= irqchip.o
+obj-$(CONFIG_IRQ_SKY1_AUDSS)		+= irq-sky1-audss.o
 
 obj-$(CONFIG_AL_FIC)			+= irq-al-fic.o
 obj-$(CONFIG_ALPINE_MSI)		+= irq-alpine-msi.o
diff --git a/drivers/irqchip/irq-sky1-audss.c b/drivers/irqchip/irq-sky1-audss.c
new file mode 100644
index 000000000000..df2063f0d771
--- /dev/null
+++ b/drivers/irqchip/irq-sky1-audss.c
@@ -0,0 +1,255 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright 2026 Cix Technology Group Co., Ltd. */
+
+#include <linux/auxiliary_bus.h>
+#include <linux/bitops.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/irqchip/chained_irq.h>
+#include <linux/irqdomain.h>
+#include <linux/module.h>
+#include <linux/of_irq.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#define INFO_AP_IRQC		0x54
+#define INFO_AP_IRQC_DMAC_MASK	GENMASK(7, 0)
+#define SKY1_AUDSS_DMAC_IRQS	8
+
+struct sky1_audss_irq {
+	struct regmap *regmap;
+	struct irq_domain *domain;
+	int parent_irq;
+};
+
+static void sky1_audss_irq_mask(struct irq_data *d)
+{
+	struct sky1_audss_irq *priv = irq_data_get_irq_chip_data(d);
+
+	regmap_update_bits(priv->regmap, INFO_AP_IRQC, BIT(d->hwirq), 0);
+}
+
+static void sky1_audss_irq_unmask(struct irq_data *d)
+{
+	struct sky1_audss_irq *priv = irq_data_get_irq_chip_data(d);
+
+	regmap_update_bits(priv->regmap, INFO_AP_IRQC,
+			   BIT(d->hwirq), BIT(d->hwirq));
+}
+
+static int sky1_audss_irq_request_resources(struct irq_data *d)
+{
+	return try_module_get(THIS_MODULE) ? 0 : -ENODEV;
+}
+
+static void sky1_audss_irq_release_resources(struct irq_data *d)
+{
+	module_put(THIS_MODULE);
+}
+
+static struct irq_chip sky1_audss_irq_chip = {
+	.name			= "sky1-audss-dmac",
+	.irq_mask		= sky1_audss_irq_mask,
+	.irq_unmask		= sky1_audss_irq_unmask,
+	.irq_disable		= sky1_audss_irq_mask,
+	.irq_request_resources	= sky1_audss_irq_request_resources,
+	.irq_release_resources	= sky1_audss_irq_release_resources,
+	.flags			= IRQCHIP_SKIP_SET_WAKE,
+};
+
+static int sky1_audss_irq_map(struct irq_domain *d, unsigned int irq,
+			      irq_hw_number_t hwirq)
+{
+	if (hwirq >= SKY1_AUDSS_DMAC_IRQS)
+		return -EINVAL;
+
+	irq_set_chip_data(irq, d->host_data);
+	irq_set_chip_and_handler(irq, &sky1_audss_irq_chip, handle_level_irq);
+	/*
+	 * There is no per-channel pending status in the CRU. Poll enabled
+	 * children without spurious-IRQ accounting, but retain level flow
+	 * control so disabled and oneshot-threaded children stay masked.
+	 */
+	irq_set_status_flags(irq, IRQ_LEVEL | IRQ_IS_POLLED);
+	irq_set_noprobe(irq);
+
+	return 0;
+}
+
+static const struct irq_domain_ops sky1_audss_irq_ops = {
+	.map	= sky1_audss_irq_map,
+	.xlate	= irq_domain_xlate_onecell,
+};
+
+static void sky1_audss_irq_handler(struct irq_desc *desc)
+{
+	struct sky1_audss_irq *priv = irq_desc_get_handler_data(desc);
+	struct irq_chip *chip = irq_desc_get_chip(desc);
+	unsigned long enabled;
+	unsigned int hwirq;
+	u32 val;
+
+	chained_irq_enter(chip, desc);
+
+	if (!regmap_read(priv->regmap, INFO_AP_IRQC, &val)) {
+		enabled = val & INFO_AP_IRQC_DMAC_MASK;
+		for_each_set_bit(hwirq, &enabled, SKY1_AUDSS_DMAC_IRQS)
+			generic_handle_domain_irq(priv->domain, hwirq);
+	}
+
+	chained_irq_exit(chip, desc);
+}
+
+static int sky1_audss_irq_runtime_suspend(struct device *dev)
+{
+	struct sky1_audss_irq *priv = dev_get_drvdata(dev);
+
+	/* The parent CRU may turn its clocks off after the child suspends. */
+	disable_irq(priv->parent_irq);
+
+	return 0;
+}
+
+static int sky1_audss_irq_runtime_resume(struct device *dev)
+{
+	struct sky1_audss_irq *priv = dev_get_drvdata(dev);
+
+	/* Parent resume has already restored the CRU registers. */
+	enable_irq(priv->parent_irq);
+
+	return 0;
+}
+
+static const struct dev_pm_ops sky1_audss_irq_pm_ops = {
+	RUNTIME_PM_OPS(sky1_audss_irq_runtime_suspend,
+		       sky1_audss_irq_runtime_resume, NULL)
+	NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+				  pm_runtime_force_resume)
+};
+
+static int sky1_audss_irq_probe(struct auxiliary_device *adev,
+				const struct auxiliary_device_id *id)
+{
+	struct device *dev = &adev->dev;
+	struct sky1_audss_irq *priv;
+	int ret;
+
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->regmap = dev_get_regmap(dev->parent, NULL);
+	if (!priv->regmap)
+		return dev_err_probe(dev, -ENODEV, "failed to get CRU regmap\n");
+
+	priv->parent_irq = of_irq_get(dev->of_node, 0);
+	if (priv->parent_irq < 0)
+		return dev_err_probe(dev, priv->parent_irq,
+				     "failed to get parent IRQ\n");
+	if (!priv->parent_irq)
+		return -EINVAL;
+
+	ret = pm_runtime_resume_and_get(dev->parent);
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "failed to resume CRU\n");
+
+	ret = regmap_update_bits(priv->regmap, INFO_AP_IRQC,
+				 INFO_AP_IRQC_DMAC_MASK, 0);
+	if (ret)
+		goto out_put_parent;
+
+	dev_set_drvdata(dev, priv);
+	pm_runtime_get_noresume(dev);
+	ret = pm_runtime_set_active(dev);
+	if (ret)
+		goto out_put_child;
+	pm_runtime_enable(dev);
+
+	priv->domain = irq_domain_create_linear(dev_fwnode(dev),
+						SKY1_AUDSS_DMAC_IRQS,
+						&sky1_audss_irq_ops, priv);
+	if (!priv->domain) {
+		ret = -ENOMEM;
+		goto out_disable_pm;
+	}
+	irq_domain_set_pm_device(priv->domain, dev);
+
+	/* A chained handler cannot implement lazy-disable masking. */
+	irq_set_status_flags(priv->parent_irq, IRQ_DISABLE_UNLAZY);
+	irq_set_chained_handler_and_data(priv->parent_irq,
+					 sky1_audss_irq_handler, priv);
+
+	pm_runtime_put_sync(dev);
+	pm_runtime_put_sync(dev->parent);
+
+	return 0;
+
+out_disable_pm:
+	pm_runtime_disable(dev);
+	pm_runtime_set_suspended(dev);
+out_put_child:
+	pm_runtime_put_noidle(dev);
+out_put_parent:
+	pm_runtime_put_sync(dev->parent);
+	return ret;
+}
+
+static void sky1_audss_irq_remove(struct auxiliary_device *adev)
+{
+	struct device *dev = &adev->dev;
+	struct sky1_audss_irq *priv = dev_get_drvdata(dev);
+	unsigned int hwirq;
+	unsigned int virq;
+	int ret;
+
+	ret = pm_runtime_resume_and_get(dev);
+	if (ret < 0)
+		dev_warn(dev, "failed to resume CRU for IRQ teardown: %d\n", ret);
+
+	disable_irq(priv->parent_irq);
+	if (ret >= 0)
+		regmap_update_bits(priv->regmap, INFO_AP_IRQC,
+				   INFO_AP_IRQC_DMAC_MASK, 0);
+	irq_set_chained_handler_and_data(priv->parent_irq, NULL, NULL);
+	synchronize_irq(priv->parent_irq);
+	irq_clear_status_flags(priv->parent_irq, IRQ_DISABLE_UNLAZY);
+
+	for (hwirq = 0; hwirq < SKY1_AUDSS_DMAC_IRQS; hwirq++) {
+		virq = irq_find_mapping(priv->domain, hwirq);
+		if (!virq)
+			continue;
+
+		/* Disassociation must not access an unpowered CRU either. */
+		if (ret < 0)
+			irq_set_chip(virq, NULL);
+		irq_dispose_mapping(virq);
+	}
+	irq_domain_remove(priv->domain);
+
+	pm_runtime_disable(dev);
+	if (ret >= 0)
+		pm_runtime_put_noidle(dev);
+	pm_runtime_set_suspended(dev);
+}
+
+static const struct auxiliary_device_id sky1_audss_irq_ids[] = {
+	{ .name = "clk_sky1_audss.irq" },
+	{ }
+};
+MODULE_DEVICE_TABLE(auxiliary, sky1_audss_irq_ids);
+
+static struct auxiliary_driver sky1_audss_irq_driver = {
+	.probe = sky1_audss_irq_probe,
+	.remove = sky1_audss_irq_remove,
+	.id_table = sky1_audss_irq_ids,
+	.driver = {
+		.pm = pm_ptr(&sky1_audss_irq_pm_ops),
+		.suppress_bind_attrs = true,
+	},
+};
+module_auxiliary_driver(sky1_audss_irq_driver);
+
+MODULE_AUTHOR("Jelly Jia <Jelly.Jia@cixtech.com>");
+MODULE_DESCRIPTION("CIX Sky1 AUDSS DMA interrupt controller");
+MODULE_LICENSE("GPL");
-- 
2.54.0


  parent reply	other threads:[~2026-11-17  9:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  9:44 [PATCH v4 0/5] soc: cix: Add the Sky1 AUDSS DMA-350 interrupt path Jelly Jia
2026-11-17  9:44 ` [PATCH v4 1/5] dt-bindings: soc: cix: Describe the Sky1 AUDSS DMA IRQ controller Jelly Jia
2026-11-17  9:44 ` Jelly Jia [this message]
2026-11-17  9:44 ` [PATCH v4 3/5] clk: cix: Register the Sky1 AUDSS IRQ auxiliary device Jelly Jia
2026-11-17  9:44 ` [PATCH v4 4/5] dt-bindings: dma: arm,dma-350: Document dma-channel-mask Jelly Jia
2026-11-17  9:44 ` [PATCH v4 5/5] dmaengine: arm-dma350: Honour dma-channel-mask Jelly Jia

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=20261117094408.1393837-3-Jelly.Jia@cixtech.com \
    --to=jelly.jia@cixtech.com \
    --cc=Frank.Li@kernel.org \
    --cc=bmasney+clk@redhat.com \
    --cc=cix-kernel-upstream@cixtech.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=jbrunet+clk@baylibre.com \
    --cc=joakim.zhang@cixtech.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=radu@rendec.net \
    --cc=robh@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=sboyd@kernel.org \
    --cc=tglx@kernel.org \
    --cc=vkoul@kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®