* [PATCH RESEND v2 0/4] Add support for Nuvoton npcm845 i3c controller
@ 2025-02-20 6:11 Stanley Chu
2025-02-20 6:11 ` [PATCH RESEND v2 1/4] dt-bindings: i3c: silvaco: Add npcm845 compatible string Stanley Chu
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Stanley Chu @ 2025-02-20 6:11 UTC (permalink / raw)
To: frank.li, miquel.raynal, alexandre.belloni, 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.
---
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 (4):
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
.../bindings/i3c/silvaco,i3c-master.yaml | 4 +-
drivers/i3c/master/svc-i3c-master.c | 57 +++++++++++++++++--
2 files changed, 56 insertions(+), 5 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH RESEND v2 1/4] dt-bindings: i3c: silvaco: Add npcm845 compatible string
2025-02-20 6:11 [PATCH RESEND v2 0/4] Add support for Nuvoton npcm845 i3c controller Stanley Chu
@ 2025-02-20 6:11 ` Stanley Chu
2025-02-20 8:19 ` Krzysztof Kozlowski
2025-02-20 6:11 ` [PATCH RESEND v2 2/4] i3c: master: svc: Add support for Nuvoton npcm845 i3c Stanley Chu
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Stanley Chu @ 2025-02-20 6:11 UTC (permalink / raw)
To: frank.li, miquel.raynal, alexandre.belloni, linux-i3c
Cc: linux-kernel, devicetree, tomer.maimon, kwliu, yschu
From: Stanley Chu <yschu@nuvoton.com>
Add a compatible string for Nuvoton BMC NPCM845 i3c controller.
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..9be4bc4cc482 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:
+ - silvaco,i3c-master-v1
+ - nuvoton,npcm845-i3c
reg:
maxItems: 1
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH RESEND v2 2/4] i3c: master: svc: Add support for Nuvoton npcm845 i3c
2025-02-20 6:11 [PATCH RESEND v2 0/4] Add support for Nuvoton npcm845 i3c controller Stanley Chu
2025-02-20 6:11 ` [PATCH RESEND v2 1/4] dt-bindings: i3c: silvaco: Add npcm845 compatible string Stanley Chu
@ 2025-02-20 6:11 ` Stanley Chu
2025-02-20 17:40 ` Frank Li
2025-02-20 6:11 ` [PATCH RESEND v2 3/4] i3c: master: svc: Fix npcm845 FIFO empty issue Stanley Chu
2025-02-20 6:11 ` [PATCH RESEND v2 4/4] i3c: master: svc: Fix npcm845 invalid slvstart event Stanley Chu
3 siblings, 1 reply; 9+ messages in thread
From: Stanley Chu @ 2025-02-20 6:11 UTC (permalink / raw)
To: frank.li, miquel.raynal, alexandre.belloni, 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.
Add npcm845 specific quirks.
Signed-off-by: Stanley Chu <yschu@nuvoton.com>
---
drivers/i3c/master/svc-i3c-master.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index d6057d8c7dec..c58440061d5a 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -133,6 +133,22 @@
#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)
+/*
+ * 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 should be SLVREQ.
+ */
+#define SVC_I3C_QUIRK_FALSE_SLVSTART BIT(1)
+
struct svc_i3c_cmd {
u8 addr;
bool rnw;
@@ -216,6 +232,7 @@ struct svc_i3c_master {
struct mutex lock;
u32 enabled_events;
u32 mctrl_config;
+ u32 quirks;
};
/**
@@ -230,6 +247,14 @@ struct svc_i3c_i2c_dev_data {
struct i3c_generic_ibi_pool *ibi_pool;
};
+struct svc_i3c_drvdata {
+ u32 quirks;
+};
+
+const struct svc_i3c_drvdata npcm845_drvdata = {
+ .quirks = SVC_I3C_QUIRK_FIFO_EMPTY | SVC_I3C_QUIRK_FALSE_SLVSTART,
+};
+
static inline bool is_events_enabled(struct svc_i3c_master *master, u32 mask)
{
return !!(master->enabled_events & mask);
@@ -1811,6 +1836,7 @@ static int svc_i3c_master_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct svc_i3c_master *master;
+ const struct svc_i3c_drvdata *data = of_device_get_match_data(dev);
int ret;
master = devm_kzalloc(dev, sizeof(*master), GFP_KERNEL);
@@ -1868,6 +1894,8 @@ static int svc_i3c_master_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, master);
+ if (data)
+ master->quirks = data->quirks;
pm_runtime_set_autosuspend_delay(&pdev->dev, SVC_I3C_PM_TIMEOUT_MS);
pm_runtime_use_autosuspend(&pdev->dev);
@@ -1960,6 +1988,7 @@ static const struct dev_pm_ops svc_i3c_pm_ops = {
static const struct of_device_id svc_i3c_master_of_match_tbl[] = {
{ .compatible = "silvaco,i3c-master-v1"},
+ { .compatible = "nuvoton,npcm845-i3c", .data = &npcm845_drvdata },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, svc_i3c_master_of_match_tbl);
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH RESEND v2 3/4] i3c: master: svc: Fix npcm845 FIFO empty issue
2025-02-20 6:11 [PATCH RESEND v2 0/4] Add support for Nuvoton npcm845 i3c controller Stanley Chu
2025-02-20 6:11 ` [PATCH RESEND v2 1/4] dt-bindings: i3c: silvaco: Add npcm845 compatible string Stanley Chu
2025-02-20 6:11 ` [PATCH RESEND v2 2/4] i3c: master: svc: Add support for Nuvoton npcm845 i3c Stanley Chu
@ 2025-02-20 6:11 ` Stanley Chu
2025-02-20 17:56 ` Frank Li
2025-02-20 6:11 ` [PATCH RESEND v2 4/4] i3c: master: svc: Fix npcm845 invalid slvstart event Stanley Chu
3 siblings, 1 reply; 9+ messages in thread
From: Stanley Chu @ 2025-02-20 6:11 UTC (permalink / raw)
To: frank.li, miquel.raynal, alexandre.belloni, 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.
Signed-off-by: Stanley Chu <yschu@nuvoton.com>
---
drivers/i3c/master/svc-i3c-master.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index c58440061d5a..2140da3f5187 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -1196,8 +1196,8 @@ static int svc_i3c_master_read(struct svc_i3c_master *master,
return offset;
}
-static int svc_i3c_master_write(struct svc_i3c_master *master,
- const u8 *out, unsigned int len)
+static int svc_i3c_master_write(struct svc_i3c_master *master, const u8 *out,
+ unsigned int len, bool last)
{
int offset = 0, ret;
u32 mdctrl;
@@ -1214,7 +1214,7 @@ static int svc_i3c_master_write(struct svc_i3c_master *master,
* The last byte to be sent over the bus must either have the
* "end" bit set or be written in MWDATABE.
*/
- if (likely(offset < (len - 1)))
+ if (likely(offset < (len - 1)) || !last)
writel(out[offset++], master->regs + SVC_I3C_MWDATAB);
else
writel(out[offset++], master->regs + SVC_I3C_MWDATABE);
@@ -1245,6 +1245,19 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
SVC_I3C_MCTRL_RDTERM(*actual_len),
master->regs + SVC_I3C_MCTRL);
+ if ((master->quirks & SVC_I3C_QUIRK_FIFO_EMPTY) && !rnw && xfer_len) {
+ unsigned int len = xfer_len;
+
+ if (xfer_len > SVC_I3C_FIFO_SIZE)
+ len = SVC_I3C_FIFO_SIZE;
+ ret = svc_i3c_master_write(master, out, len,
+ xfer_len <= SVC_I3C_FIFO_SIZE);
+ if (ret < 0)
+ goto emit_stop;
+ xfer_len -= len;
+ out += len;
+ }
+
ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg,
SVC_I3C_MSTATUS_MCTRLDONE(reg), 0, 1000);
if (ret)
@@ -1306,7 +1319,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
if (rnw)
ret = svc_i3c_master_read(master, in, xfer_len);
else
- ret = svc_i3c_master_write(master, out, xfer_len);
+ ret = svc_i3c_master_write(master, out, xfer_len, true);
if (ret < 0)
goto emit_stop;
@@ -1333,6 +1346,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;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH RESEND v2 4/4] i3c: master: svc: Fix npcm845 invalid slvstart event
2025-02-20 6:11 [PATCH RESEND v2 0/4] Add support for Nuvoton npcm845 i3c controller Stanley Chu
` (2 preceding siblings ...)
2025-02-20 6:11 ` [PATCH RESEND v2 3/4] i3c: master: svc: Fix npcm845 FIFO empty issue Stanley Chu
@ 2025-02-20 6:11 ` Stanley Chu
2025-02-20 17:43 ` Frank Li
3 siblings, 1 reply; 9+ messages in thread
From: Stanley Chu @ 2025-02-20 6:11 UTC (permalink / raw)
To: frank.li, miquel.raynal, alexandre.belloni, 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 should be SLVREQ. Check
the MSTATUS state to ignore the false event.
Signed-off-by: Stanley Chu <yschu@nuvoton.com>
---
drivers/i3c/master/svc-i3c-master.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index 2140da3f5187..5861358eb9e5 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))
@@ -589,6 +590,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 ((master->quirks & 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 */
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH RESEND v2 1/4] dt-bindings: i3c: silvaco: Add npcm845 compatible string
2025-02-20 6:11 ` [PATCH RESEND v2 1/4] dt-bindings: i3c: silvaco: Add npcm845 compatible string Stanley Chu
@ 2025-02-20 8:19 ` Krzysztof Kozlowski
0 siblings, 0 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2025-02-20 8:19 UTC (permalink / raw)
To: Stanley Chu, frank.li, miquel.raynal, alexandre.belloni,
linux-i3c
Cc: linux-kernel, devicetree, tomer.maimon, kwliu, yschu
On 20/02/2025 07:11, Stanley Chu wrote:
> From: Stanley Chu <yschu@nuvoton.com>
>
> Add a compatible string for Nuvoton BMC NPCM845 i3c controller.
This we see from the diff. Say something useful, is it compatible with
other? Why is it in the same binding?
<form letter>
Please use scripts/get_maintainers.pl to get a list of necessary people
and lists to CC (and consider --no-git-fallback argument, so you will
not CC people just because they made one commit years ago). It might
happen, that command when run on an older kernel, gives you outdated
entries. Therefore please be sure you base your patches on recent Linux
kernel.
Tools like b4 or scripts/get_maintainer.pl provide you proper list of
people, so fix your workflow. Tools might also fail if you work on some
ancient tree (don't, instead use mainline) or work on fork of kernel
(don't, instead use mainline). Just use b4 and everything should be
fine, although remember about `b4 prep --auto-to-cc` if you added new
patches to the patchset.
</form letter>
>
> 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..9be4bc4cc482 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:
> + - silvaco,i3c-master-v1
> + - nuvoton,npcm845-i3c
Keep alphabetical order.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH RESEND v2 2/4] i3c: master: svc: Add support for Nuvoton npcm845 i3c
2025-02-20 6:11 ` [PATCH RESEND v2 2/4] i3c: master: svc: Add support for Nuvoton npcm845 i3c Stanley Chu
@ 2025-02-20 17:40 ` Frank Li
0 siblings, 0 replies; 9+ messages in thread
From: Frank Li @ 2025-02-20 17:40 UTC (permalink / raw)
To: Stanley Chu
Cc: miquel.raynal, alexandre.belloni, linux-i3c, linux-kernel,
devicetree, tomer.maimon, kwliu, yschu
On Thu, Feb 20, 2025 at 02:11:05PM +0800, Stanley Chu wrote:
> From: Stanley Chu <yschu@nuvoton.com>
>
> Nuvoton npcm845 SoC uses the same Silvico IP but an older version.
> Add npcm845 specific quirks.
>
> Signed-off-by: Stanley Chu <yschu@nuvoton.com>
> ---
> drivers/i3c/master/svc-i3c-master.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index d6057d8c7dec..c58440061d5a 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
> @@ -133,6 +133,22 @@
> #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)
> +/*
> + * 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 should be SLVREQ.
> + */
> +#define SVC_I3C_QUIRK_FALSE_SLVSTART BIT(1)
> +
> struct svc_i3c_cmd {
> u8 addr;
> bool rnw;
> @@ -216,6 +232,7 @@ struct svc_i3c_master {
> struct mutex lock;
> u32 enabled_events;
> u32 mctrl_config;
> + u32 quirks;
struct svc_i3c_drvdata *drvdata;
> };
>
> /**
> @@ -230,6 +247,14 @@ struct svc_i3c_i2c_dev_data {
> struct i3c_generic_ibi_pool *ibi_pool;
> };
>
> +struct svc_i3c_drvdata {
> + u32 quirks;
> +};
> +
> +const struct svc_i3c_drvdata npcm845_drvdata = {
> + .quirks = SVC_I3C_QUIRK_FIFO_EMPTY | SVC_I3C_QUIRK_FALSE_SLVSTART,
> +};
> +
> static inline bool is_events_enabled(struct svc_i3c_master *master, u32 mask)
> {
> return !!(master->enabled_events & mask);
> @@ -1811,6 +1836,7 @@ static int svc_i3c_master_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> struct svc_i3c_master *master;
> + const struct svc_i3c_drvdata *data = of_device_get_match_data(dev);
> int ret;
>
> master = devm_kzalloc(dev, sizeof(*master), GFP_KERNEL);
> @@ -1868,6 +1894,8 @@ static int svc_i3c_master_probe(struct platform_device *pdev)
> }
>
> platform_set_drvdata(pdev, master);
> + if (data)
> + master->quirks = data->quirks;
master->drvdata = of_device_get_match_data(dev);
>
> pm_runtime_set_autosuspend_delay(&pdev->dev, SVC_I3C_PM_TIMEOUT_MS);
> pm_runtime_use_autosuspend(&pdev->dev);
> @@ -1960,6 +1988,7 @@ static const struct dev_pm_ops svc_i3c_pm_ops = {
>
> static const struct of_device_id svc_i3c_master_of_match_tbl[] = {
> { .compatible = "silvaco,i3c-master-v1"},
> + { .compatible = "nuvoton,npcm845-i3c", .data = &npcm845_drvdata },
> { /* sentinel */ },
> };
> MODULE_DEVICE_TABLE(of, svc_i3c_master_of_match_tbl);
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH RESEND v2 4/4] i3c: master: svc: Fix npcm845 invalid slvstart event
2025-02-20 6:11 ` [PATCH RESEND v2 4/4] i3c: master: svc: Fix npcm845 invalid slvstart event Stanley Chu
@ 2025-02-20 17:43 ` Frank Li
0 siblings, 0 replies; 9+ messages in thread
From: Frank Li @ 2025-02-20 17:43 UTC (permalink / raw)
To: Stanley Chu
Cc: miquel.raynal, alexandre.belloni, linux-i3c, linux-kernel,
devicetree, tomer.maimon, kwliu, yschu
On Thu, Feb 20, 2025 at 02:11:07PM +0800, Stanley Chu wrote:
> 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 should be SLVREQ. Check
^^^ is? "should be"
look like unconfirmed.
> the MSTATUS state to ignore the false event.
>
> Signed-off-by: Stanley Chu <yschu@nuvoton.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/i3c/master/svc-i3c-master.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index 2140da3f5187..5861358eb9e5 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))
> @@ -589,6 +590,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 ((master->quirks & 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 */
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH RESEND v2 3/4] i3c: master: svc: Fix npcm845 FIFO empty issue
2025-02-20 6:11 ` [PATCH RESEND v2 3/4] i3c: master: svc: Fix npcm845 FIFO empty issue Stanley Chu
@ 2025-02-20 17:56 ` Frank Li
0 siblings, 0 replies; 9+ messages in thread
From: Frank Li @ 2025-02-20 17:56 UTC (permalink / raw)
To: Stanley Chu
Cc: miquel.raynal, alexandre.belloni, linux-i3c, linux-kernel,
devicetree, tomer.maimon, kwliu, yschu
On Thu, Feb 20, 2025 at 02:11:06PM +0800, Stanley Chu wrote:
> 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.
>
> Signed-off-by: Stanley Chu <yschu@nuvoton.com>
> ---
You missed do_daa part.
> drivers/i3c/master/svc-i3c-master.c | 22 ++++++++++++++++++----
> 1 file changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index c58440061d5a..2140da3f5187 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
> @@ -1196,8 +1196,8 @@ static int svc_i3c_master_read(struct svc_i3c_master *master,
> return offset;
> }
>
> -static int svc_i3c_master_write(struct svc_i3c_master *master,
> - const u8 *out, unsigned int len)
> +static int svc_i3c_master_write(struct svc_i3c_master *master, const u8 *out,
> + unsigned int len, bool last)
> {
> int offset = 0, ret;
> u32 mdctrl;
> @@ -1214,7 +1214,7 @@ static int svc_i3c_master_write(struct svc_i3c_master *master,
> * The last byte to be sent over the bus must either have the
> * "end" bit set or be written in MWDATABE.
> */
> - if (likely(offset < (len - 1)))
> + if (likely(offset < (len - 1)) || !last)
> writel(out[offset++], master->regs + SVC_I3C_MWDATAB);
> else
> writel(out[offset++], master->regs + SVC_I3C_MWDATABE);
> @@ -1245,6 +1245,19 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
> SVC_I3C_MCTRL_RDTERM(*actual_len),
> master->regs + SVC_I3C_MCTRL);
>
> + if ((master->quirks & SVC_I3C_QUIRK_FIFO_EMPTY) && !rnw && xfer_len) {
> + unsigned int len = xfer_len;
len = max_t(u32, xfer_len, SVC_I3C_FIFO_SIZE);
> +
> + if (xfer_len > SVC_I3C_FIFO_SIZE)
> + len = SVC_I3C_FIFO_SIZE;
> + ret = svc_i3c_master_write(master, out, len,
> + xfer_len <= SVC_I3C_FIFO_SIZE);
> + if (ret < 0)
> + goto emit_stop;
> + xfer_len -= len;
> + out += len;
> + }
> +
> ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg,
> SVC_I3C_MSTATUS_MCTRLDONE(reg), 0, 1000);
> if (ret)
> @@ -1306,7 +1319,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
> if (rnw)
> ret = svc_i3c_master_read(master, in, xfer_len);
> else
> - ret = svc_i3c_master_write(master, out, xfer_len);
> + ret = svc_i3c_master_write(master, out, xfer_len, true);
> if (ret < 0)
> goto emit_stop;
>
> @@ -1333,6 +1346,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;
> }
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-02-20 17:56 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-20 6:11 [PATCH RESEND v2 0/4] Add support for Nuvoton npcm845 i3c controller Stanley Chu
2025-02-20 6:11 ` [PATCH RESEND v2 1/4] dt-bindings: i3c: silvaco: Add npcm845 compatible string Stanley Chu
2025-02-20 8:19 ` Krzysztof Kozlowski
2025-02-20 6:11 ` [PATCH RESEND v2 2/4] i3c: master: svc: Add support for Nuvoton npcm845 i3c Stanley Chu
2025-02-20 17:40 ` Frank Li
2025-02-20 6:11 ` [PATCH RESEND v2 3/4] i3c: master: svc: Fix npcm845 FIFO empty issue Stanley Chu
2025-02-20 17:56 ` Frank Li
2025-02-20 6:11 ` [PATCH RESEND v2 4/4] i3c: master: svc: Fix npcm845 invalid slvstart event Stanley Chu
2025-02-20 17:43 ` Frank Li
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).