From: Eddie James <eajames@linux.ibm.com>
To: linux-fsi@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
devicetree@vger.kernel.org, andi.shyti@kernel.org,
eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au,
jk@ozlabs.org, robh@kernel.org,
krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
lakshmiy@us.ibmcom
Subject: [PATCH v2 23/31] fsi: aspeed: Add interrupt support
Date: Mon, 26 Feb 2024 10:53:13 -0600 [thread overview]
Message-ID: <20240226165321.91976-24-eajames@linux.ibm.com> (raw)
In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com>
Handle slave interrupts and pass them to the FSI core.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
drivers/fsi/fsi-master-aspeed.c | 104 ++++++++++++++++++++++-
include/trace/events/fsi_master_aspeed.h | 12 +++
2 files changed, 114 insertions(+), 2 deletions(-)
diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c
index ac8835e4d1f8..ce16ea65f65d 100644
--- a/drivers/fsi/fsi-master-aspeed.c
+++ b/drivers/fsi/fsi-master-aspeed.c
@@ -6,6 +6,8 @@
#include <linux/delay.h>
#include <linux/fsi.h>
#include <linux/io.h>
+#include <linux/irqchip/chained_irq.h>
+#include <linux/irqdomain.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -25,10 +27,12 @@ struct fsi_master_aspeed_data {
struct fsi_master_aspeed {
struct fsi_master master;
spinlock_t lock; /* protect HW access */
+ struct irq_domain *irq_domain;
struct device *dev;
void __iomem *base;
struct clk *clk;
struct gpio_desc *cfam_reset_gpio;
+ u32 irq_mask;
};
#define to_fsi_master_aspeed(m) \
@@ -80,6 +84,11 @@ static const u32 fsi_base = 0xa0000000;
#define STATUS_TIMEOUT BIT(4)
/* OPB_IRQ_MASK */
+#define FSI_MASTER_ERROR_IRQ BIT(28)
+#define FSI_PORT_ERROR_IRQ BIT(27)
+#define FSI_HOTPLUG_IRQ BIT(26)
+#define FSI_REMOTE_SLV_IRQ(l) (BIT(FSI_REMOTE_SLV_IRQ_BIT) << (l))
+#define FSI_REMOTE_SLV_IRQ_BIT 18
#define OPB1_XFER_ACK_EN BIT(17)
#define OPB0_XFER_ACK_EN BIT(16)
@@ -316,11 +325,76 @@ static int aspeed_master_break(struct fsi_master *master, int link)
return aspeed_master_write(master, link, 0, addr, &cmd, 4);
}
+static int aspeed_master_link_enable(struct fsi_master *master, int link, bool enable)
+{
+ struct fsi_master_aspeed *aspeed = to_fsi_master_aspeed(master);
+ unsigned long flags;
+ int rc;
+
+ spin_lock_irqsave(&aspeed->lock, flags);
+ if (enable) {
+ rc = fsi_master_link_enable(master, link, enable);
+ if (rc)
+ goto done;
+
+ aspeed->irq_mask |= FSI_REMOTE_SLV_IRQ(link);
+ writel(aspeed->irq_mask, aspeed->base + OPB_IRQ_MASK);
+ } else {
+ aspeed->irq_mask &= ~FSI_REMOTE_SLV_IRQ(link);
+ writel(aspeed->irq_mask, aspeed->base + OPB_IRQ_MASK);
+
+ rc = fsi_master_link_enable(master, link, enable);
+ }
+
+done:
+ spin_unlock_irqrestore(&aspeed->lock, flags);
+ return rc;
+}
+
+static irqreturn_t aspeed_master_irq(int irq, void *data)
+{
+ struct fsi_master_aspeed *aspeed = data;
+ unsigned long size = FSI_REMOTE_SLV_IRQ_BIT + aspeed->master.n_links;
+ unsigned long bit = FSI_REMOTE_SLV_IRQ_BIT;
+ unsigned long status;
+
+ status = readl(aspeed->base + OPB_IRQ_STATUS);
+ writel(0, aspeed->base + OPB_IRQ_MASK);
+
+ for_each_set_bit_from(bit, &status, size)
+ fsi_master_irq(&aspeed->master, aspeed->irq_domain, bit - FSI_REMOTE_SLV_IRQ_BIT);
+
+ writel(status, aspeed->base + OPB_IRQ_STATUS);
+ writel(0, aspeed->base + OPB_IRQ_STATUS);
+ writel(aspeed->irq_mask, aspeed->base + OPB_IRQ_MASK);
+
+ trace_fsi_master_aspeed_irq(status);
+ return IRQ_HANDLED;
+}
+
+static int aspeed_master_irqd_map(struct irq_domain *domain, unsigned int irq,
+ irq_hw_number_t hwirq)
+{
+ struct fsi_master_aspeed *aspeed = domain->host_data;
+
+ irq_set_chip_and_handler(irq, &aspeed->master.irq_chip, handle_simple_irq);
+ irq_set_chip_data(irq, &aspeed->master);
+
+ return 0;
+}
+
+static const struct irq_domain_ops aspeed_master_irq_domain_ops = {
+ .map = aspeed_master_irqd_map,
+};
+
static void aspeed_master_release(struct device *dev)
{
struct fsi_master_aspeed *aspeed =
to_fsi_master_aspeed(to_fsi_master(dev));
+ if (aspeed->irq_domain)
+ irq_domain_remove(aspeed->irq_domain);
+
regmap_exit(aspeed->master.map);
kfree(aspeed);
}
@@ -447,6 +521,7 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev)
struct fsi_master_aspeed *aspeed;
unsigned int reg;
int rc, links;
+ int irq;
rc = tacoma_cabled_fsi_fixup(&pdev->dev);
if (rc) {
@@ -527,11 +602,12 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev)
aspeed->master.dev.of_node = of_node_get(dev_of_node(&pdev->dev));
aspeed->master.n_links = links;
- aspeed->master.flags = FSI_MASTER_FLAG_RELA;
+ aspeed->master.flags = FSI_MASTER_FLAG_INTERRUPT | FSI_MASTER_FLAG_RELA;
aspeed->master.read = aspeed_master_read;
aspeed->master.write = aspeed_master_write;
aspeed->master.send_break = aspeed_master_break;
aspeed->master.term = aspeed_master_term;
+ aspeed->master.link_enable = aspeed_master_link_enable;
dev_set_drvdata(&pdev->dev, aspeed);
@@ -539,9 +615,30 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev)
if (rc)
goto err_regmap;
+ irq = platform_get_irq(pdev, 0);
+ if (irq > 0) {
+ unsigned int size = links * FSI_IRQ_COUNT;
+
+ aspeed->irq_domain = irq_domain_add_linear(aspeed->dev->of_node, size,
+ &aspeed_master_irq_domain_ops, aspeed);
+ if (aspeed->irq_domain) {
+ rc = devm_request_irq(aspeed->dev, irq, aspeed_master_irq, 0,
+ dev_name(aspeed->dev), aspeed);
+ if (rc) {
+ dev_warn(aspeed->dev, "failed to request irq:%d\n", irq);
+ irq_domain_remove(aspeed->irq_domain);
+ aspeed->irq_domain = NULL;
+ } else {
+ dev_info(aspeed->dev, "enabling interrupts irq:%d\n", irq);
+ }
+ } else {
+ dev_warn(aspeed->dev, "failed to create irq domain\n");
+ }
+ }
+
rc = fsi_master_register(&aspeed->master);
if (rc)
- goto err_regmap;
+ goto err_irq;
/* At this point, fsi_master_register performs the device_initialize(),
* and holds the sole reference on master.dev. This means the device
@@ -553,6 +650,9 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev)
get_device(&aspeed->master.dev);
return 0;
+err_irq:
+ if (aspeed->irq_domain)
+ irq_domain_remove(aspeed->irq_domain);
err_regmap:
regmap_exit(aspeed->master.map);
err_release:
diff --git a/include/trace/events/fsi_master_aspeed.h b/include/trace/events/fsi_master_aspeed.h
index 7eeecbfec7f0..dba1776334a0 100644
--- a/include/trace/events/fsi_master_aspeed.h
+++ b/include/trace/events/fsi_master_aspeed.h
@@ -8,6 +8,18 @@
#include <linux/tracepoint.h>
+TRACE_EVENT(fsi_master_aspeed_irq,
+ TP_PROTO(uint32_t status),
+ TP_ARGS(status),
+ TP_STRUCT__entry(
+ __field(uint32_t, status)
+ ),
+ TP_fast_assign(
+ __entry->status = status;
+ ),
+ TP_printk("status %08x", __entry->status)
+);
+
TRACE_EVENT(fsi_master_aspeed_opb_xfer,
TP_PROTO(uint32_t addr, uint32_t size, uint32_t data, bool read),
TP_ARGS(addr, size, data, read),
--
2.39.3
next prev parent reply other threads:[~2024-02-26 16:53 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-26 16:52 [PATCH v2 00/31] fsi: Interrupt support Eddie James
2024-02-26 16:52 ` [PATCH v2 01/31] fsi: Move slave definitions to fsi-slave.h Eddie James
2024-02-26 16:52 ` [PATCH v2 02/31] fsi: Improve master indexing Eddie James
2024-02-26 16:52 ` [PATCH v2 03/31] fsi: Use a defined value for default echo delay Eddie James
2024-02-26 16:52 ` [PATCH v2 04/31] fsi: Expose master-specific local bus clock divider Eddie James
2024-02-26 16:52 ` [PATCH v2 05/31] ARM: dts: aspeed: p10 and tacoma: Set FSI clock frequency Eddie James
2024-02-26 16:52 ` [PATCH v2 06/31] fsi: core: Improve master read/write/error traces Eddie James
2024-02-26 16:52 ` [PATCH v2 07/31] fsi: core: Add slave error trace Eddie James
2024-02-26 16:52 ` [PATCH v2 08/31] dt-bindings: fsi: Add AST2700 compatible Eddie James
2024-02-27 7:14 ` Krzysztof Kozlowski
2024-02-28 15:47 ` Rob Herring
2024-02-26 16:52 ` [PATCH v2 09/31] fsi: aspeed: Add AST2700 support Eddie James
2024-02-26 16:53 ` [PATCH v2 10/31] fsi: core: Add slave spinlock Eddie James
2024-02-26 16:53 ` [PATCH v2 11/31] fsi: core: Allow cfam device type aliases Eddie James
2024-02-26 16:53 ` [PATCH v2 12/31] fsi: core: Add common regmap master functions Eddie James
2024-02-26 16:53 ` [PATCH v2 13/31] fsi: hub: Use common initialization and link enable Eddie James
2024-02-26 16:53 ` [PATCH v2 14/31] fsi: aspeed: " Eddie James
2024-02-26 16:53 ` [PATCH v2 15/31] fsi: aspeed: Remove cfam reset sysfs file in error path and remove Eddie James
2024-02-26 16:53 ` [PATCH v2 16/31] fsi: aspeed: Refactor trace functions Eddie James
2024-02-26 16:53 ` [PATCH v2 17/31] fsi: aspeed: Don't clear all IRQs during OPB transfers Eddie James
2024-02-26 16:53 ` [PATCH v2 18/31] fsi: aspeed: Only read result register for successful read Eddie James
2024-02-26 16:53 ` [PATCH v2 19/31] fsi: aspeed: Switch to spinlock Eddie James
2024-02-26 16:53 ` [PATCH v2 20/31] fsi: aspeed: Disable relative addressing and IPOLL for cfam reset Eddie James
2024-02-26 16:53 ` [PATCH v2 21/31] fsi: aspeed: Use common master error handler Eddie James
2024-02-26 16:53 ` [PATCH v2 22/31] fsi: core: Add interrupt support Eddie James
2024-02-26 16:53 ` Eddie James [this message]
2024-02-26 16:53 ` [PATCH v2 24/31] fsi: hub: " Eddie James
2024-02-26 16:53 ` [PATCH v2 25/31] i2c: fsi: Calculate clock divider from local bus frequency Eddie James
2024-04-15 22:11 ` Andi Shyti
2024-04-16 18:09 ` Eddie James
2024-04-16 21:20 ` Guenter Roeck
2024-04-17 13:50 ` Eddie James
2024-02-26 16:53 ` [PATCH v2 26/31] i2c: fsi: Improve formatting Eddie James
2024-04-15 22:13 ` Andi Shyti
2024-02-26 16:53 ` [PATCH v2 27/31] i2c: fsi: Change fsi_i2c_write_reg to accept data instead of a pointer Eddie James
2024-02-26 16:53 ` [PATCH v2 28/31] i2c: fsi: Remove list structure of ports Eddie James
2024-02-26 16:53 ` [PATCH v2 29/31] i2c: fsi: Define a function to check status error bits Eddie James
2024-02-26 16:53 ` [PATCH v2 30/31] i2c: fsi: Add boolean for skip stop command on abort Eddie James
2024-02-26 16:53 ` [PATCH v2 31/31] i2c: fsi: Add interrupt support Eddie James
2024-02-27 13:44 ` [PATCH v2 00/31] fsi: Interrupt support Rob Herring
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=20240226165321.91976-24-eajames@linux.ibm.com \
--to=eajames@linux.ibm.com \
--cc=alistair@popple.id.au \
--cc=andi.shyti@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jk@ozlabs.org \
--cc=joel@jms.id.au \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lakshmiy@us.ibmcom \
--cc=linux-fsi@lists.ozlabs.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@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;
as well as URLs for NNTP newsgroup(s).