* [PATCH 1/1] i3c: master: svc: adjust SDR timing according to i3c spec
@ 2024-07-12 16:46 Frank Li
2024-07-17 7:56 ` Miquel Raynal
0 siblings, 1 reply; 2+ messages in thread
From: Frank Li @ 2024-07-12 16:46 UTC (permalink / raw)
To: Miquel Raynal, Conor Culhane, Alexandre Belloni,
moderated list:SILVACO I3C DUAL-ROLE MASTER, open list
Cc: imx
From: Carlos Song <carlos.song@nxp.com>
According to I3C Specification(Version 1.1) 5.1.2.4 "Use of Clock
Speed to Prevent Legacy I2C Devices From Seeing I3C traffic", when
slow i2c devices(FM/FM+ rate i2c frequency without 50ns filter)
works on i3c bus, i3c SDR should work at FM/FM+ rate.
Adjust timing for difference mode.
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Signed-off-by: Carlos Song <carlos.song@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
drivers/i3c/master/svc-i3c-master.c | 66 +++++++++++++++++------------
1 file changed, 40 insertions(+), 26 deletions(-)
diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index bb299ce02cccb..26dc6d833c6e3 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -127,6 +127,8 @@
/* This parameter depends on the implementation and may be tuned */
#define SVC_I3C_FIFO_SIZE 16
+#define SVC_I3C_PPBAUD_MAX 15
+#define SVC_I3C_QUICK_I2C_CLK 4170000
#define SVC_I3C_EVENT_IBI BIT(0)
#define SVC_I3C_EVENT_HOTJOIN BIT(1)
@@ -535,6 +537,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m)
struct i3c_bus *bus = i3c_master_get_bus(m);
struct i3c_device_info info = {};
unsigned long fclk_rate, fclk_period_ns;
+ unsigned long i2c_period_ns, i2c_scl_rate, i3c_scl_rate;
unsigned int high_period_ns, od_low_period_ns;
u32 ppbaud, pplow, odhpp, odbaud, odstop, i2cbaud, reg;
int ret;
@@ -555,44 +558,55 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m)
}
fclk_period_ns = DIV_ROUND_UP(1000000000, fclk_rate);
-
- /*
- * Using I3C Push-Pull mode, target is 12.5MHz/80ns period.
- * Simplest configuration is using a 50% duty-cycle of 40ns.
- */
- ppbaud = DIV_ROUND_UP(40, fclk_period_ns) - 1;
- pplow = 0;
-
- /*
- * Using I3C Open-Drain mode, target is 4.17MHz/240ns with a
- * duty-cycle tuned so that high levels are filetered out by
- * the 50ns filter (target being 40ns).
- */
- odhpp = 1;
- high_period_ns = (ppbaud + 1) * fclk_period_ns;
- odbaud = DIV_ROUND_UP(240 - high_period_ns, high_period_ns) - 1;
- od_low_period_ns = (odbaud + 1) * high_period_ns;
+ i2c_period_ns = DIV_ROUND_UP(1000000000, bus->scl_rate.i2c);
+ i2c_scl_rate = bus->scl_rate.i2c;
+ i3c_scl_rate = bus->scl_rate.i3c;
switch (bus->mode) {
case I3C_BUS_MODE_PURE:
+ /* Using I3C Push-Pull mode and I2C OP 50% duty-cycle. */
+ pplow = 0;
+ ppbaud = DIV_ROUND_UP(fclk_rate / 2, i3c_scl_rate) - 1;
+ high_period_ns = (ppbaud + 1) * fclk_period_ns;
+ odbaud = DIV_ROUND_UP(fclk_rate, SVC_I3C_QUICK_I2C_CLK * (1 + ppbaud)) - 2;
+ od_low_period_ns = (odbaud + 1) * high_period_ns;
i2cbaud = 0;
odstop = 0;
break;
case I3C_BUS_MODE_MIXED_FAST:
- case I3C_BUS_MODE_MIXED_LIMITED:
/*
- * Using I2C Fm+ mode, target is 1MHz/1000ns, the difference
- * between the high and low period does not really matter.
+ * I3C in <= 12.5M PP + I3C OP + I2C OP in clk rate
+ * keep I3C OD clk high period <= 40ns and use odbaud and pplow
+ * to adjust the i2c/i3c duty cycle.
*/
- i2cbaud = DIV_ROUND_UP(1000, od_low_period_ns) - 2;
+ ppbaud = DIV_ROUND_UP(fclk_rate / 2, I3C_BUS_TYP_I3C_SCL_RATE) - 1;
+ high_period_ns = (ppbaud + 1) * fclk_period_ns;
+ pplow = DIV_ROUND_UP(fclk_rate, i3c_scl_rate) - (2 + 2 * ppbaud);
+
+ odhpp = 1;
+ odbaud = DIV_ROUND_UP(fclk_rate, SVC_I3C_QUICK_I2C_CLK * (1 + ppbaud)) - 2;
+
+ /* i2c FM/FM+ */
+ od_low_period_ns = (odbaud + 1) * high_period_ns;
+ i2cbaud = DIV_ROUND_UP(i2c_period_ns, od_low_period_ns) - 2;
odstop = 1;
break;
+ case I3C_BUS_MODE_MIXED_LIMITED:
case I3C_BUS_MODE_MIXED_SLOW:
- /*
- * Using I2C Fm mode, target is 0.4MHz/2500ns, with the same
- * constraints as the FM+ mode.
- */
- i2cbaud = DIV_ROUND_UP(2500, od_low_period_ns) - 2;
+ /* I3C PP + I3C OP + I2C OP both use i2c clk rate */
+ ppbaud = DIV_ROUND_UP(fclk_rate / 2, i3c_scl_rate) - 1;
+ pplow = 0;
+ if (ppbaud > SVC_I3C_PPBAUD_MAX) {
+ ppbaud = SVC_I3C_PPBAUD_MAX;
+ pplow = DIV_ROUND_UP(fclk_rate, i3c_scl_rate) - (2 + 2 * ppbaud);
+ }
+
+ high_period_ns = (ppbaud + 1) * fclk_period_ns;
+ odhpp = 0;
+ odbaud = DIV_ROUND_UP(fclk_rate, i2c_scl_rate * (2 + 2 * ppbaud)) - 1;
+
+ od_low_period_ns = (odbaud + 1) * high_period_ns;
+ i2cbaud = DIV_ROUND_UP(i2c_period_ns, od_low_period_ns) - 2;
odstop = 1;
break;
default:
--
2.34.1
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH 1/1] i3c: master: svc: adjust SDR timing according to i3c spec
2024-07-12 16:46 [PATCH 1/1] i3c: master: svc: adjust SDR timing according to i3c spec Frank Li
@ 2024-07-17 7:56 ` Miquel Raynal
0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2024-07-17 7:56 UTC (permalink / raw)
To: Frank Li
Cc: Conor Culhane, Alexandre Belloni,
moderated list:SILVACO I3C DUAL-ROLE MASTER, open list, imx
Hi Frank,
Frank.Li@nxp.com wrote on Fri, 12 Jul 2024 12:46:02 -0400:
> From: Carlos Song <carlos.song@nxp.com>
>
> According to I3C Specification(Version 1.1) 5.1.2.4 "Use of Clock
> Speed to Prevent Legacy I2C Devices From Seeing I3C traffic", when
> slow i2c devices(FM/FM+ rate i2c frequency without 50ns filter)
> works on i3c bus, i3c SDR should work at FM/FM+ rate.
>
> Adjust timing for difference mode.
The calculations below look quite complex, but if you believe this is
right, I'm fine with it.
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
>
> Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
Thanks,
Miquèl
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-17 7:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-12 16:46 [PATCH 1/1] i3c: master: svc: adjust SDR timing according to i3c spec Frank Li
2024-07-17 7:56 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox