From: Jeremy Kerr <jk@codeconstruct.com.au>
To: linux-i3c@lists.infradead.org
Cc: Matt Johnston <matt@codeconstruct.com.au>,
Vitor Soares <ivitro@gmail.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Jack Chen <zenghuchen@google.com>,
Billy Tsai <billy_tsai@aspeedtech.com>,
Dylan Hung <dylan_hung@aspeedtech.com>,
Joel Stanley <joel@jms.id.au>, Andrew Jeffery <andrew@aj.id.au>
Subject: [PATCH 5/5] i3c: ast2600: enable IBI support
Date: Thu, 30 Mar 2023 15:50:36 +0800 [thread overview]
Message-ID: <ba923b96d6d129024c975e8a0472c5b2fcb3af32.1680161823.git.jk@codeconstruct.com.au> (raw)
In-Reply-To: <cover.1680161823.git.jk@codeconstruct.com.au>
The ast2600 i3c hardware is capable of IBIs, but we need a workaround
for a hardware issue with the I3C state machine handling IBI payloads
of specific lengths when PEC is not enabled. To avoid this, we need to
unconditionally enable PECs, at the consquence of losing a byte of data
when the device does not send a PEC.
Enable IBIs on the ast2600 platform, including an implementation of the
PEC workaround, which prints a warning when triggered.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
---
drivers/i3c/master/ast2600-i3c-master.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/i3c/master/ast2600-i3c-master.c b/drivers/i3c/master/ast2600-i3c-master.c
index d3d7b7d19f22..52d9474a7651 100644
--- a/drivers/i3c/master/ast2600-i3c-master.c
+++ b/drivers/i3c/master/ast2600-i3c-master.c
@@ -36,6 +36,8 @@
#define AST2600_DEFAULT_SDA_PULLUP_OHMS 2000
+#define DEV_ADDR_TABLE_IBI_PEC BIT(11)
+
struct ast2600_i3c_platform_data {
struct regmap *global_regs;
unsigned int global_idx;
@@ -93,8 +95,26 @@ static int ast2600_i3c_init(struct dw_i3c_master *master)
return rc;
}
+static void ast2600_i3c_set_dat_ibi(struct dw_i3c_master *i3c,
+ struct i3c_dev_desc *dev,
+ bool enable, u32 *dat)
+{
+ /*
+ * The ast2600 i3c controller will lock up on receiving 4n+1-byte IBIs
+ * if the PEC is disabled. We have no way to restrict the length of
+ * IBIs sent to the controller, so we need to unconditionally enable
+ * PEC checking, which means we drop a byte of payload data
+ */
+ if (enable && dev->info.bcr & I3C_BCR_IBI_PAYLOAD) {
+ dev_warn_once(&i3c->base.dev,
+ "Enabling PEC workaround. IBI payloads will be truncated\n");
+ *dat |= DEV_ADDR_TABLE_IBI_PEC;
+ }
+}
+
const struct dw_i3c_platform_ops ast2600_i3c_ops = {
.init = ast2600_i3c_init,
+ .set_dat_ibi = ast2600_i3c_set_dat_ibi,
};
static int ast2600_i3c_probe(struct platform_device *pdev)
@@ -136,6 +156,7 @@ static int ast2600_i3c_probe(struct platform_device *pdev)
dw_i3c->platform_ops = &ast2600_i3c_ops;
dw_i3c->platform_data = pdata;
+ dw_i3c->ibi_capable = true;
rc = dw_i3c_common_probe(dw_i3c, pdev);
return rc;
--
2.39.2
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
next prev parent reply other threads:[~2023-03-30 13:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 7:50 [PATCH 0/5] i3c: dw,ast2600: Add In-Band Interrupt support Jeremy Kerr
2023-03-30 7:50 ` [PATCH 1/5] i3c: dw: Create a generic fifo read function Jeremy Kerr
2023-03-30 19:18 ` Ben Dooks
2023-03-31 2:16 ` Jeremy Kerr
2023-03-30 7:50 ` [PATCH 2/5] i3c: dw: Turn DAT array entry into a struct Jeremy Kerr
2023-03-30 7:50 ` [PATCH 3/5] i3c: dw: Add support for in-band interrupts Jeremy Kerr
2023-03-30 7:50 ` [PATCH 4/5] i3c: dw: Add a platform facility for IBI PEC workarounds Jeremy Kerr
2023-03-30 7:50 ` Jeremy Kerr [this message]
2023-04-05 2:27 ` [PATCH 0/5] i3c: dw,ast2600: Add In-Band Interrupt support Joel Stanley
2023-04-27 22:35 ` Alexandre Belloni
2023-04-28 0:01 ` Jeremy Kerr
2023-04-28 6:51 ` Alexandre Belloni
2023-04-28 7:34 ` Jeremy Kerr
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=ba923b96d6d129024c975e8a0472c5b2fcb3af32.1680161823.git.jk@codeconstruct.com.au \
--to=jk@codeconstruct.com.au \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@aj.id.au \
--cc=billy_tsai@aspeedtech.com \
--cc=dylan_hung@aspeedtech.com \
--cc=ivitro@gmail.com \
--cc=joel@jms.id.au \
--cc=linux-i3c@lists.infradead.org \
--cc=matt@codeconstruct.com.au \
--cc=zenghuchen@google.com \
/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