Linux-i3c Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Manikandan Muralidharan <manikandan.m@microchip.com>
To: <alexandre.belloni@bootlin.com>, <Frank.Li@nxp.com>,
	<adrian.hunter@intel.com>, <Jm_Liao@asmedia.com.tw>,
	<Patrick_Yen@asmedia.com.tw>, <linux-kernel@vger.kernel.org>,
	<linux-i3c@lists.infradead.org>
Cc: <manikandan.m@microchip.com>
Subject: [PATCH 3/3] i3c: mipi-i3c-hci: add Microchip quirk to set response buffer threshold
Date: Fri, 4 Dec 2026 14:04:49 +0530	[thread overview]
Message-ID: <20261204083449.933526-4-manikandan.m@microchip.com> (raw)
In-Reply-To: <20261204083449.933526-1-manikandan.m@microchip.com>

The SAMA7D65 I3C controller interprets RESP_BUF_THLD in QUEUE_THLD_CTRL
as N+1 entries, so the default threshold of 1 delays the response
interrupt until two responses are queued. It must be set to 0 to get an
interrupt after every transfer completion.

Add HCI_QUIRK_MCHP_RESP_BUF_THLD and select the response threshold
directly in __hci_pio_init(), so that the register and its cached copy
stay consistent across IBI threshold updates, runtime resume and
controller reset and restore.

Signed-off-by: Manikandan Muralidharan <manikandan.m@microchip.com>
---
 drivers/i3c/master/mipi-i3c-hci/core.c | 2 +-
 drivers/i3c/master/mipi-i3c-hci/hci.h  | 1 +
 drivers/i3c/master/mipi-i3c-hci/pio.c  | 8 ++++++--
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/i3c/master/mipi-i3c-hci/core.c b/drivers/i3c/master/mipi-i3c-hci/core.c
index bc71871be2f0..159645b21362 100644
--- a/drivers/i3c/master/mipi-i3c-hci/core.c
+++ b/drivers/i3c/master/mipi-i3c-hci/core.c
@@ -1284,7 +1284,7 @@ static const __maybe_unused struct of_device_id i3c_hci_of_match[] = {
 	{ .compatible = "mipi-i3c-hci", },
 	{ .compatible = "microchip,sama7d65-i3c-hci",
 	  .data = (void *)(ulong)(HCI_QUIRK_PIO_MODE | HCI_QUIRK_MCHP_OD_PP_TIMING |
-				  HCI_QUIRK_RESP_BUF_THLD) },
+				  HCI_QUIRK_MCHP_RESP_BUF_THLD) },
 	{},
 };
 MODULE_DEVICE_TABLE(of, i3c_hci_of_match);
diff --git a/drivers/i3c/master/mipi-i3c-hci/hci.h b/drivers/i3c/master/mipi-i3c-hci/hci.h
index 0137c91e84cf..10015a43cc7e 100644
--- a/drivers/i3c/master/mipi-i3c-hci/hci.h
+++ b/drivers/i3c/master/mipi-i3c-hci/hci.h
@@ -181,6 +181,7 @@ struct i3c_hci_dev_data {
 #define HCI_QUIRK_DMA_ABORT_REQUIRES_PIO_RESET	BIT(8)  /* Do PIO queue SW resets after DMA abort */
 #define HCI_QUIRK_DMA_REQUIRES_HC_ABORT		BIT(9)  /* Use HC_CONTROL ABORT to abort DMA */
 #define HCI_QUIRK_MCHP_OD_PP_TIMING	BIT(10) /* Set OD and PP timings from gclk for Microchip */
+#define HCI_QUIRK_MCHP_RESP_BUF_THLD	BIT(11) /* Set resp buf thld to 0 for Microchip platforms */
 
 /* Vendor-specific SCL timing registers shared by the quirk files */
 #define HCI_SCL_I3C_OD_TIMING		0x214
diff --git a/drivers/i3c/master/mipi-i3c-hci/pio.c b/drivers/i3c/master/mipi-i3c-hci/pio.c
index 439578a6eb54..cf6e97711ea2 100644
--- a/drivers/i3c/master/mipi-i3c-hci/pio.c
+++ b/drivers/i3c/master/mipi-i3c-hci/pio.c
@@ -146,7 +146,7 @@ struct hci_pio_data {
 
 static void __hci_pio_init(struct i3c_hci *hci, u32 *size_val_ptr)
 {
-	u32 val, size_val, rx_thresh, tx_thresh, ibi_val;
+	u32 val, size_val, rx_thresh, tx_thresh, resp_thresh, ibi_val;
 	struct hci_pio_data *pio = hci->io_data;
 
 	size_val = pio_reg_read(QUEUE_SIZE);
@@ -192,9 +192,13 @@ static void __hci_pio_init(struct i3c_hci *hci, u32 *size_val_ptr)
 	}
 
 	pio->max_ibi_thresh = clamp_val(ibi_val/2, 1, 63);
+
+	/* Microchip encodes RESP_BUF_THLD as N+1, so 0 means one response */
+	resp_thresh = (hci->quirks & HCI_QUIRK_MCHP_RESP_BUF_THLD) ? 0 : 1;
+
 	val = FIELD_PREP(QUEUE_IBI_STATUS_THLD, 1) |
 	      FIELD_PREP(QUEUE_IBI_DATA_THLD, pio->max_ibi_thresh) |
-	      FIELD_PREP(QUEUE_RESP_BUF_THLD, 1) |
+	      FIELD_PREP(QUEUE_RESP_BUF_THLD, resp_thresh) |
 	      FIELD_PREP(QUEUE_CMD_EMPTY_BUF_THLD, 1);
 	pio_reg_write(QUEUE_THLD_CTRL, val);
 	pio->reg_queue_thresh = val;
-- 
2.43.0


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

  parent reply	other threads:[~2026-12-04  8:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  8:34 [PATCH 0/3] i3c: mipi-i3c-hci: derive SAMA7D65 SCL timings from gclk Manikandan Muralidharan
2026-12-04  8:34 ` [PATCH 1/3] i3c: mipi-i3c-hci: move shared SCL timing register offsets to hci.h Manikandan Muralidharan
2026-12-04 20:22   ` Frank Li
2026-12-04  8:34 ` [PATCH 2/3] i3c: mipi-i3c-hci: add Microchip quirk to derive SCL timings from gclk Manikandan Muralidharan
2026-12-04  8:57   ` sashiko-bot
2026-12-04 20:30     ` Frank Li
2026-12-04 20:29   ` Frank Li
2026-12-04  8:34 ` Manikandan Muralidharan [this message]
2026-12-04  8:48   ` [PATCH 3/3] i3c: mipi-i3c-hci: add Microchip quirk to set response buffer threshold sashiko-bot
2026-12-04 20:34   ` Frank Li

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=20261204083449.933526-4-manikandan.m@microchip.com \
    --to=manikandan.m@microchip.com \
    --cc=Frank.Li@nxp.com \
    --cc=Jm_Liao@asmedia.com.tw \
    --cc=Patrick_Yen@asmedia.com.tw \
    --cc=adrian.hunter@intel.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-i3c@lists.infradead.org \
    --cc=linux-kernel@vger.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