* [PATCH v7 0/5] Add support for Nuvoton npcm845 i3c controller
@ 2025-03-06 7:54 Stanley Chu
2025-03-06 7:54 ` [PATCH v7 1/5] dt-bindings: i3c: silvaco: Add npcm845 compatible string Stanley Chu
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Stanley Chu @ 2025-03-06 7:54 UTC (permalink / raw)
To: frank.li, miquel.raynal, alexandre.belloni, robh, krzk+dt,
conor+dt, linux-i3c
Cc: linux-kernel, devicetree, tomer.maimon, kwliu, yschu
This patchset adds support for the Nuvoton npcm845
Board Management controller (BMC) SoC family.
The Nuvoton npcm845 uses the same Silvico IP but an older version.
This patchset adds fixes for the npcm845 specific hardware issues.
--
v7:
- Fix kernel test robot build warning.
v6:
- Define QUIRK when it is really used in the separate patches.
v5:
- Add default driver data
- Add helper function svc_has_daa_corrupt()
- Revise SVC_I3C_QUIRK_FIFO_EMPTY fix and add comments
v4:
- Fix kernel test robot build warning.
- Add SVC_I3C_QUIRK_DAA_CORRUPT fix
v3:
- Add more description in dt-binging commit message
- Add the svc_i3c_drvdata structure in struct svc_i3c_master
- Improve the do_daa
v2:
- Add a new compatible string in dt-binding doc.
- Add driver data for npcm845 to address the quirks.
- Modify svc_i3c_master_write to be reused by SVC_I3C_QUIRK_FIFO_EMPTY fix
- Fix typo of SVC_I3C_QUIRK_FALSE_SLVSTART fix.
- Remove the code changes in svc_i3c_master_do_daa_locked, will add it in
another patch series for common improvement.
---
Stanley Chu (5):
dt-bindings: i3c: silvaco: Add npcm845 compatible string
i3c: master: svc: Add support for Nuvoton npcm845 i3c
i3c: master: svc: Fix npcm845 FIFO empty issue
i3c: master: svc: Fix npcm845 invalid slvstart event
i3c: master: svc: Fix npcm845 DAA process corruption
.../bindings/i3c/silvaco,i3c-master.yaml | 4 +-
drivers/i3c/master/svc-i3c-master.c | 127 ++++++++++++++++--
2 files changed, 120 insertions(+), 11 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v7 1/5] dt-bindings: i3c: silvaco: Add npcm845 compatible string
2025-03-06 7:54 [PATCH v7 0/5] Add support for Nuvoton npcm845 i3c controller Stanley Chu
@ 2025-03-06 7:54 ` Stanley Chu
2025-03-06 7:54 ` [PATCH v7 2/5] i3c: master: svc: Add support for Nuvoton npcm845 i3c Stanley Chu
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Stanley Chu @ 2025-03-06 7:54 UTC (permalink / raw)
To: frank.li, miquel.raynal, alexandre.belloni, robh, krzk+dt,
conor+dt, linux-i3c
Cc: linux-kernel, devicetree, tomer.maimon, kwliu, yschu
From: Stanley Chu <yschu@nuvoton.com>
Nuvoton npcm845 SoC uses the same Silvico IP but an older version.
Need to add a new compatible string to distinguish between different
hardware versions.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Stanley Chu <yschu@nuvoton.com>
---
Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml b/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml
index c56ff77677f1..4fbdcdac0aee 100644
--- a/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml
+++ b/Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml
@@ -14,7 +14,9 @@ allOf:
properties:
compatible:
- const: silvaco,i3c-master-v1
+ enum:
+ - nuvoton,npcm845-i3c
+ - silvaco,i3c-master-v1
reg:
maxItems: 1
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v7 2/5] i3c: master: svc: Add support for Nuvoton npcm845 i3c
2025-03-06 7:54 [PATCH v7 0/5] Add support for Nuvoton npcm845 i3c controller Stanley Chu
2025-03-06 7:54 ` [PATCH v7 1/5] dt-bindings: i3c: silvaco: Add npcm845 compatible string Stanley Chu
@ 2025-03-06 7:54 ` Stanley Chu
2025-03-06 15:08 ` Frank Li
2025-03-06 7:54 ` [PATCH v7 3/5] i3c: master: svc: Fix npcm845 FIFO empty issue Stanley Chu
` (3 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Stanley Chu @ 2025-03-06 7:54 UTC (permalink / raw)
To: frank.li, miquel.raynal, alexandre.belloni, robh, krzk+dt,
conor+dt, linux-i3c
Cc: linux-kernel, devicetree, tomer.maimon, kwliu, yschu
From: Stanley Chu <yschu@nuvoton.com>
Nuvoton npcm845 SoC uses an older IP version, which has specific
hardware issues that need to be addressed with a different compatible
string.
Add driver data for different compatible strings to define platform
specific quirks.
Add compatible string for npcm845 to define its own driver data.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202503061400.GGr64rkR-lkp@intel.com/
Signed-off-by: Stanley Chu <yschu@nuvoton.com>
---
drivers/i3c/master/svc-i3c-master.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index d6057d8c7dec..40269b692aa8 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -158,6 +158,10 @@ struct svc_i3c_regs_save {
u32 mdynaddr;
};
+struct svc_i3c_drvdata {
+ u32 quirks;
+};
+
/**
* struct svc_i3c_master - Silvaco I3C Master structure
* @base: I3C master controller
@@ -183,6 +187,7 @@ struct svc_i3c_regs_save {
* @ibi.tbq_slot: To be queued IBI slot
* @ibi.lock: IBI lock
* @lock: Transfer lock, protect between IBI work thread and callbacks from master
+ * @drvdata: Driver data
* @enabled_events: Bit masks for enable events (IBI, HotJoin).
* @mctrl_config: Configuration value in SVC_I3C_MCTRL for setting speed back.
*/
@@ -214,6 +219,7 @@ struct svc_i3c_master {
spinlock_t lock;
} ibi;
struct mutex lock;
+ const struct svc_i3c_drvdata *drvdata;
u32 enabled_events;
u32 mctrl_config;
};
@@ -1817,6 +1823,10 @@ static int svc_i3c_master_probe(struct platform_device *pdev)
if (!master)
return -ENOMEM;
+ master->drvdata = of_device_get_match_data(dev);
+ if (!master->drvdata)
+ return -EINVAL;
+
master->regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(master->regs))
return PTR_ERR(master->regs);
@@ -1958,8 +1968,13 @@ static const struct dev_pm_ops svc_i3c_pm_ops = {
svc_i3c_runtime_resume, NULL)
};
+static const struct svc_i3c_drvdata npcm845_drvdata = {};
+
+static const struct svc_i3c_drvdata svc_default_drvdata = {};
+
static const struct of_device_id svc_i3c_master_of_match_tbl[] = {
- { .compatible = "silvaco,i3c-master-v1"},
+ { .compatible = "nuvoton,npcm845-i3c", .data = &npcm845_drvdata },
+ { .compatible = "silvaco,i3c-master-v1", .data = &svc_default_drvdata },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, svc_i3c_master_of_match_tbl);
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v7 3/5] i3c: master: svc: Fix npcm845 FIFO empty issue
2025-03-06 7:54 [PATCH v7 0/5] Add support for Nuvoton npcm845 i3c controller Stanley Chu
2025-03-06 7:54 ` [PATCH v7 1/5] dt-bindings: i3c: silvaco: Add npcm845 compatible string Stanley Chu
2025-03-06 7:54 ` [PATCH v7 2/5] i3c: master: svc: Add support for Nuvoton npcm845 i3c Stanley Chu
@ 2025-03-06 7:54 ` Stanley Chu
2025-03-06 7:54 ` [PATCH v7 4/5] i3c: master: svc: Fix npcm845 invalid slvstart event Stanley Chu
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Stanley Chu @ 2025-03-06 7:54 UTC (permalink / raw)
To: frank.li, miquel.raynal, alexandre.belloni, robh, krzk+dt,
conor+dt, linux-i3c
Cc: linux-kernel, devicetree, tomer.maimon, kwliu, yschu
From: Stanley Chu <yschu@nuvoton.com>
I3C HW stalls the write transfer if the transmit FIFO becomes empty,
when new data is written to FIFO, I3C HW resumes the transfer but the
first transmitted data bit may have the wrong value.
Fill the FIFO in advance to prevent FIFO from becoming empty.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Stanley Chu <yschu@nuvoton.com>
---
drivers/i3c/master/svc-i3c-master.c | 71 +++++++++++++++++++++++++----
1 file changed, 61 insertions(+), 10 deletions(-)
diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index 40269b692aa8..cba89a685e13 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -113,6 +113,7 @@
#define SVC_I3C_MWDATAHE 0x0BC
#define SVC_I3C_MRDATAB 0x0C0
#define SVC_I3C_MRDATAH 0x0C8
+#define SVC_I3C_MWDATAB1 0x0CC
#define SVC_I3C_MWMSG_SDR 0x0D0
#define SVC_I3C_MRMSG_SDR 0x0D4
#define SVC_I3C_MWMSG_DDR 0x0D8
@@ -133,6 +134,16 @@
#define SVC_I3C_EVENT_IBI GENMASK(7, 0)
#define SVC_I3C_EVENT_HOTJOIN BIT(31)
+/*
+ * SVC_I3C_QUIRK_FIFO_EMPTY:
+ * I3C HW stalls the write transfer if the transmit FIFO becomes empty,
+ * when new data is written to FIFO, I3C HW resumes the transfer but
+ * the first transmitted data bit may have the wrong value.
+ * Workaround:
+ * Fill the FIFO in advance to prevent FIFO from becoming empty.
+ */
+#define SVC_I3C_QUIRK_FIFO_EMPTY BIT(0)
+
struct svc_i3c_cmd {
u8 addr;
bool rnw;
@@ -236,6 +247,11 @@ struct svc_i3c_i2c_dev_data {
struct i3c_generic_ibi_pool *ibi_pool;
};
+static inline bool svc_has_quirk(struct svc_i3c_master *master, u32 quirk)
+{
+ return (master->drvdata->quirks & quirk);
+}
+
static inline bool is_events_enabled(struct svc_i3c_master *master, u32 mask)
{
return !!(master->enabled_events & mask);
@@ -894,7 +910,7 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master,
u8 *addrs, unsigned int *count)
{
u64 prov_id[SVC_I3C_MAX_DEVS] = {}, nacking_prov_id = 0;
- unsigned int dev_nb = 0, last_addr = 0;
+ unsigned int dev_nb = 0, last_addr = 0, dyn_addr;
u32 reg;
int ret, i;
@@ -937,6 +953,25 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master,
if (SVC_I3C_MSTATUS_RXPEND(reg)) {
u8 data[6];
+ /*
+ * One slave sends its ID to request for address assignment,
+ * prefilling the dynamic address can reduce SCL clock stalls
+ * and also fix the SVC_I3C_QUIRK_FIFO_EMPTY quirk.
+ *
+ * Ideally, prefilling before the processDAA command is better.
+ * However, it requires an additional check to write the dyn_addr
+ * at the right time because the driver needs to write the processDAA
+ * command twice for one assignment.
+ * Prefilling here is safe and efficient because the FIFO starts
+ * filling within a few hundred nanoseconds, which is significantly
+ * faster compared to the 64 SCL clock cycles.
+ */
+ dyn_addr = i3c_master_get_free_addr(&master->base, last_addr + 1);
+ if (dyn_addr < 0)
+ return -ENOSPC;
+
+ writel(dyn_addr, master->regs + SVC_I3C_MWDATAB);
+
/*
* We only care about the 48-bit provisioned ID yet to
* be sure a device does not nack an address twice.
@@ -1015,21 +1050,16 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master,
if (ret)
break;
- /* Give the slave device a suitable dynamic address */
- ret = i3c_master_get_free_addr(&master->base, last_addr + 1);
- if (ret < 0)
- break;
-
- addrs[dev_nb] = ret;
+ addrs[dev_nb] = dyn_addr;
dev_dbg(master->dev, "DAA: device %d assigned to 0x%02x\n",
dev_nb, addrs[dev_nb]);
-
- writel(addrs[dev_nb], master->regs + SVC_I3C_MWDATAB);
last_addr = addrs[dev_nb++];
}
/* Need manual issue STOP except for Complete condition */
svc_i3c_master_emit_stop(master);
+ svc_i3c_master_flush_fifo(master);
+
return ret;
}
@@ -1226,6 +1256,24 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
SVC_I3C_MCTRL_RDTERM(*actual_len),
master->regs + SVC_I3C_MCTRL);
+ /*
+ * The entire transaction can consist of multiple write transfers.
+ * Prefilling before EmitStartAddr causes the data to be emitted
+ * immediately, becoming part of the previous transfer.
+ * The only way to work around this hardware issue is to let the
+ * FIFO start filling as soon as possible after EmitStartAddr.
+ */
+ if (svc_has_quirk(master, SVC_I3C_QUIRK_FIFO_EMPTY) && !rnw && xfer_len) {
+ u32 end = xfer_len > SVC_I3C_FIFO_SIZE ? 0 : SVC_I3C_MWDATAB_END;
+ u32 len = min_t(u32, xfer_len, SVC_I3C_FIFO_SIZE);
+
+ writesb(master->regs + SVC_I3C_MWDATAB1, out, len - 1);
+ /* Mark END bit if this is the last byte */
+ writel(out[len - 1] | end, master->regs + SVC_I3C_MWDATAB);
+ xfer_len -= len;
+ out += len;
+ }
+
ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg,
SVC_I3C_MSTATUS_MCTRLDONE(reg), 0, 1000);
if (ret)
@@ -1314,6 +1362,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
emit_stop:
svc_i3c_master_emit_stop(master);
svc_i3c_master_clear_merrwarn(master);
+ svc_i3c_master_flush_fifo(master);
return ret;
}
@@ -1968,7 +2017,9 @@ static const struct dev_pm_ops svc_i3c_pm_ops = {
svc_i3c_runtime_resume, NULL)
};
-static const struct svc_i3c_drvdata npcm845_drvdata = {};
+static const struct svc_i3c_drvdata npcm845_drvdata = {
+ .quirks = SVC_I3C_QUIRK_FIFO_EMPTY,
+};
static const struct svc_i3c_drvdata svc_default_drvdata = {};
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v7 4/5] i3c: master: svc: Fix npcm845 invalid slvstart event
2025-03-06 7:54 [PATCH v7 0/5] Add support for Nuvoton npcm845 i3c controller Stanley Chu
` (2 preceding siblings ...)
2025-03-06 7:54 ` [PATCH v7 3/5] i3c: master: svc: Fix npcm845 FIFO empty issue Stanley Chu
@ 2025-03-06 7:54 ` Stanley Chu
2025-03-06 7:54 ` [PATCH v7 5/5] i3c: master: svc: Fix npcm845 DAA process corruption Stanley Chu
2025-03-06 20:55 ` [PATCH v7 0/5] Add support for Nuvoton npcm845 i3c controller Alexandre Belloni
5 siblings, 0 replies; 8+ messages in thread
From: Stanley Chu @ 2025-03-06 7:54 UTC (permalink / raw)
To: frank.li, miquel.raynal, alexandre.belloni, robh, krzk+dt,
conor+dt, linux-i3c
Cc: linux-kernel, devicetree, tomer.maimon, kwliu, yschu
From: Stanley Chu <yschu@nuvoton.com>
I3C HW may generate an invalid SlvStart event when emitting a STOP.
If it is a true SlvStart, the MSTATUS state is SLVREQ. Check the
MSTATUS state to ignore the false event.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Stanley Chu <yschu@nuvoton.com>
---
drivers/i3c/master/svc-i3c-master.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index cba89a685e13..1cab5b8594de 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -58,6 +58,7 @@
#define SVC_I3C_MSTATUS 0x088
#define SVC_I3C_MSTATUS_STATE(x) FIELD_GET(GENMASK(2, 0), (x))
#define SVC_I3C_MSTATUS_STATE_DAA(x) (SVC_I3C_MSTATUS_STATE(x) == 5)
+#define SVC_I3C_MSTATUS_STATE_SLVREQ(x) (SVC_I3C_MSTATUS_STATE(x) == 1)
#define SVC_I3C_MSTATUS_STATE_IDLE(x) (SVC_I3C_MSTATUS_STATE(x) == 0)
#define SVC_I3C_MSTATUS_BETWEEN(x) FIELD_GET(BIT(4), (x))
#define SVC_I3C_MSTATUS_NACKED(x) FIELD_GET(BIT(5), (x))
@@ -143,6 +144,12 @@
* Fill the FIFO in advance to prevent FIFO from becoming empty.
*/
#define SVC_I3C_QUIRK_FIFO_EMPTY BIT(0)
+/*
+ * SVC_I3C_QUIRK_FLASE_SLVSTART:
+ * I3C HW may generate an invalid SlvStart event when emitting a STOP.
+ * If it is a true SlvStart, the MSTATUS state is SLVREQ.
+ */
+#define SVC_I3C_QUIRK_FALSE_SLVSTART BIT(1)
struct svc_i3c_cmd {
u8 addr;
@@ -586,6 +593,11 @@ static irqreturn_t svc_i3c_master_irq_handler(int irq, void *dev_id)
/* Clear the interrupt status */
writel(SVC_I3C_MINT_SLVSTART, master->regs + SVC_I3C_MSTATUS);
+ /* Ignore the false event */
+ if (svc_has_quirk(master, SVC_I3C_QUIRK_FALSE_SLVSTART) &&
+ !SVC_I3C_MSTATUS_STATE_SLVREQ(active))
+ return IRQ_HANDLED;
+
svc_i3c_master_disable_interrupts(master);
/* Handle the interrupt in a non atomic context */
@@ -2018,7 +2030,8 @@ static const struct dev_pm_ops svc_i3c_pm_ops = {
};
static const struct svc_i3c_drvdata npcm845_drvdata = {
- .quirks = SVC_I3C_QUIRK_FIFO_EMPTY,
+ .quirks = SVC_I3C_QUIRK_FIFO_EMPTY |
+ SVC_I3C_QUIRK_FALSE_SLVSTART,
};
static const struct svc_i3c_drvdata svc_default_drvdata = {};
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v7 5/5] i3c: master: svc: Fix npcm845 DAA process corruption
2025-03-06 7:54 [PATCH v7 0/5] Add support for Nuvoton npcm845 i3c controller Stanley Chu
` (3 preceding siblings ...)
2025-03-06 7:54 ` [PATCH v7 4/5] i3c: master: svc: Fix npcm845 invalid slvstart event Stanley Chu
@ 2025-03-06 7:54 ` Stanley Chu
2025-03-06 20:55 ` [PATCH v7 0/5] Add support for Nuvoton npcm845 i3c controller Alexandre Belloni
5 siblings, 0 replies; 8+ messages in thread
From: Stanley Chu @ 2025-03-06 7:54 UTC (permalink / raw)
To: frank.li, miquel.raynal, alexandre.belloni, robh, krzk+dt,
conor+dt, linux-i3c
Cc: linux-kernel, devicetree, tomer.maimon, kwliu, yschu
From: Stanley Chu <yschu@nuvoton.com>
When MCONFIG.SKEW=0 and MCONFIG.ODHPP=0, the ENTDAA transaction gets
corrupted and results in a no repeated-start condition at the end of
address assignment.
Workaround: Set MCONFIG.SKEW to 1 before initiating the DAA process.
After the DAA process is completed, return MCONFIG.SKEW to its previous
value.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Stanley Chu <yschu@nuvoton.com>
---
drivers/i3c/master/svc-i3c-master.c | 30 ++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index 1cab5b8594de..c086e0e38279 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -32,6 +32,7 @@
#define SVC_I3C_MCONFIG_ODBAUD(x) FIELD_PREP(GENMASK(23, 16), (x))
#define SVC_I3C_MCONFIG_ODHPP(x) FIELD_PREP(BIT(24), (x))
#define SVC_I3C_MCONFIG_SKEW(x) FIELD_PREP(GENMASK(27, 25), (x))
+#define SVC_I3C_MCONFIG_SKEW_MASK GENMASK(27, 25)
#define SVC_I3C_MCONFIG_I2CBAUD(x) FIELD_PREP(GENMASK(31, 28), (x))
#define SVC_I3C_MCTRL 0x084
@@ -150,6 +151,16 @@
* If it is a true SlvStart, the MSTATUS state is SLVREQ.
*/
#define SVC_I3C_QUIRK_FALSE_SLVSTART BIT(1)
+/*
+ * SVC_I3C_QUIRK_DAA_CORRUPT:
+ * When MCONFIG.SKEW=0 and MCONFIG.ODHPP=0, the ENTDAA transaction gets
+ * corrupted and results in a no repeated-start condition at the end of
+ * address assignment.
+ * Workaround:
+ * Set MCONFIG.SKEW to 1 before initiating the DAA process. After the DAA
+ * process is completed, return MCONFIG.SKEW to its previous value.
+ */
+#define SVC_I3C_QUIRK_DAA_CORRUPT BIT(2)
struct svc_i3c_cmd {
u8 addr;
@@ -259,6 +270,13 @@ static inline bool svc_has_quirk(struct svc_i3c_master *master, u32 quirk)
return (master->drvdata->quirks & quirk);
}
+static inline bool svc_has_daa_corrupt(struct svc_i3c_master *master)
+{
+ return ((master->drvdata->quirks & SVC_I3C_QUIRK_DAA_CORRUPT) &&
+ !(master->mctrl_config &
+ (SVC_I3C_MCONFIG_SKEW_MASK | SVC_I3C_MCONFIG_ODHPP(1))));
+}
+
static inline bool is_events_enabled(struct svc_i3c_master *master, u32 mask)
{
return !!(master->enabled_events & mask);
@@ -1144,7 +1162,16 @@ static int svc_i3c_master_do_daa(struct i3c_master_controller *m)
}
spin_lock_irqsave(&master->xferqueue.lock, flags);
+
+ if (svc_has_daa_corrupt(master))
+ writel(master->mctrl_config | SVC_I3C_MCONFIG_SKEW(1),
+ master->regs + SVC_I3C_MCONFIG);
+
ret = svc_i3c_master_do_daa_locked(master, addrs, &dev_nb);
+
+ if (svc_has_daa_corrupt(master))
+ writel(master->mctrl_config, master->regs + SVC_I3C_MCONFIG);
+
spin_unlock_irqrestore(&master->xferqueue.lock, flags);
svc_i3c_master_clear_merrwarn(master);
@@ -2031,7 +2058,8 @@ static const struct dev_pm_ops svc_i3c_pm_ops = {
static const struct svc_i3c_drvdata npcm845_drvdata = {
.quirks = SVC_I3C_QUIRK_FIFO_EMPTY |
- SVC_I3C_QUIRK_FALSE_SLVSTART,
+ SVC_I3C_QUIRK_FALSE_SLVSTART |
+ SVC_I3C_QUIRK_DAA_CORRUPT,
};
static const struct svc_i3c_drvdata svc_default_drvdata = {};
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v7 2/5] i3c: master: svc: Add support for Nuvoton npcm845 i3c
2025-03-06 7:54 ` [PATCH v7 2/5] i3c: master: svc: Add support for Nuvoton npcm845 i3c Stanley Chu
@ 2025-03-06 15:08 ` Frank Li
0 siblings, 0 replies; 8+ messages in thread
From: Frank Li @ 2025-03-06 15:08 UTC (permalink / raw)
To: Stanley Chu
Cc: miquel.raynal, alexandre.belloni, robh, krzk+dt, conor+dt,
linux-i3c, linux-kernel, devicetree, tomer.maimon, kwliu, yschu
On Thu, Mar 06, 2025 at 03:54:26PM +0800, Stanley Chu wrote:
> From: Stanley Chu <yschu@nuvoton.com>
>
> Nuvoton npcm845 SoC uses an older IP version, which has specific
> hardware issues that need to be addressed with a different compatible
> string.
>
> Add driver data for different compatible strings to define platform
> specific quirks.
> Add compatible string for npcm845 to define its own driver data.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202503061400.GGr64rkR-lkp@intel.com/
Needn't these for new version. Need such tags only when seperated patch
that fix this issue.
I think alex can drop these when apply. If need respin patches, remove it.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Stanley Chu <yschu@nuvoton.com>
> ---
> drivers/i3c/master/svc-i3c-master.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index d6057d8c7dec..40269b692aa8 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
> @@ -158,6 +158,10 @@ struct svc_i3c_regs_save {
> u32 mdynaddr;
> };
>
> +struct svc_i3c_drvdata {
> + u32 quirks;
> +};
> +
> /**
> * struct svc_i3c_master - Silvaco I3C Master structure
> * @base: I3C master controller
> @@ -183,6 +187,7 @@ struct svc_i3c_regs_save {
> * @ibi.tbq_slot: To be queued IBI slot
> * @ibi.lock: IBI lock
> * @lock: Transfer lock, protect between IBI work thread and callbacks from master
> + * @drvdata: Driver data
> * @enabled_events: Bit masks for enable events (IBI, HotJoin).
> * @mctrl_config: Configuration value in SVC_I3C_MCTRL for setting speed back.
> */
> @@ -214,6 +219,7 @@ struct svc_i3c_master {
> spinlock_t lock;
> } ibi;
> struct mutex lock;
> + const struct svc_i3c_drvdata *drvdata;
> u32 enabled_events;
> u32 mctrl_config;
> };
> @@ -1817,6 +1823,10 @@ static int svc_i3c_master_probe(struct platform_device *pdev)
> if (!master)
> return -ENOMEM;
>
> + master->drvdata = of_device_get_match_data(dev);
> + if (!master->drvdata)
> + return -EINVAL;
> +
> master->regs = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(master->regs))
> return PTR_ERR(master->regs);
> @@ -1958,8 +1968,13 @@ static const struct dev_pm_ops svc_i3c_pm_ops = {
> svc_i3c_runtime_resume, NULL)
> };
>
> +static const struct svc_i3c_drvdata npcm845_drvdata = {};
> +
> +static const struct svc_i3c_drvdata svc_default_drvdata = {};
> +
> static const struct of_device_id svc_i3c_master_of_match_tbl[] = {
> - { .compatible = "silvaco,i3c-master-v1"},
> + { .compatible = "nuvoton,npcm845-i3c", .data = &npcm845_drvdata },
> + { .compatible = "silvaco,i3c-master-v1", .data = &svc_default_drvdata },
> { /* sentinel */ },
> };
> MODULE_DEVICE_TABLE(of, svc_i3c_master_of_match_tbl);
> --
> 2.34.1
>
>
> --
> linux-i3c mailing list
> linux-i3c@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v7 0/5] Add support for Nuvoton npcm845 i3c controller
2025-03-06 7:54 [PATCH v7 0/5] Add support for Nuvoton npcm845 i3c controller Stanley Chu
` (4 preceding siblings ...)
2025-03-06 7:54 ` [PATCH v7 5/5] i3c: master: svc: Fix npcm845 DAA process corruption Stanley Chu
@ 2025-03-06 20:55 ` Alexandre Belloni
5 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2025-03-06 20:55 UTC (permalink / raw)
To: frank.li, miquel.raynal, robh, krzk+dt, conor+dt, linux-i3c,
Stanley Chu
Cc: linux-kernel, devicetree, tomer.maimon, kwliu, yschu
On Thu, 06 Mar 2025 15:54:24 +0800, Stanley Chu wrote:
> This patchset adds support for the Nuvoton npcm845
> Board Management controller (BMC) SoC family.
>
> The Nuvoton npcm845 uses the same Silvico IP but an older version.
> This patchset adds fixes for the npcm845 specific hardware issues.
>
> --
> v7:
> - Fix kernel test robot build warning.
>
> [...]
Applied, thanks!
[1/5] dt-bindings: i3c: silvaco: Add npcm845 compatible string
https://git.kernel.org/abelloni/c/c24a084ab6a2
[2/5] i3c: master: svc: Add support for Nuvoton npcm845 i3c
https://git.kernel.org/abelloni/c/98d87600a04e
[3/5] i3c: master: svc: Fix npcm845 FIFO empty issue
https://git.kernel.org/abelloni/c/4008a74e0f9b
[4/5] i3c: master: svc: Fix npcm845 invalid slvstart event
https://git.kernel.org/abelloni/c/4dd12e944f07
[5/5] i3c: master: svc: Fix npcm845 DAA process corruption
https://git.kernel.org/abelloni/c/2a785307e41b
Best regards,
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-03-06 20:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-06 7:54 [PATCH v7 0/5] Add support for Nuvoton npcm845 i3c controller Stanley Chu
2025-03-06 7:54 ` [PATCH v7 1/5] dt-bindings: i3c: silvaco: Add npcm845 compatible string Stanley Chu
2025-03-06 7:54 ` [PATCH v7 2/5] i3c: master: svc: Add support for Nuvoton npcm845 i3c Stanley Chu
2025-03-06 15:08 ` Frank Li
2025-03-06 7:54 ` [PATCH v7 3/5] i3c: master: svc: Fix npcm845 FIFO empty issue Stanley Chu
2025-03-06 7:54 ` [PATCH v7 4/5] i3c: master: svc: Fix npcm845 invalid slvstart event Stanley Chu
2025-03-06 7:54 ` [PATCH v7 5/5] i3c: master: svc: Fix npcm845 DAA process corruption Stanley Chu
2025-03-06 20:55 ` [PATCH v7 0/5] Add support for Nuvoton npcm845 i3c controller Alexandre Belloni
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).