i3c: renesas: add R-Car Gen5 support
Subsystems (3)
Wolfram Sang
maintainercover i3c: renesas: add R-Car Gen5 support
Here are the driver changes to make I3C work on R-Car Gen5 based SoCs. Details can be found in the patch descriptions. A complete branch for testing on the Ironhide board is here:
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/x5h/i3c-experimental
Looking forward to comments!
Happy hacking.
Wolfram Sang (2):
dt-bindings: i3c: renesas,i3c: add R-Car Gen 5 support
i3c: renesas: add R-Car Gen5 support
.../devicetree/bindings/i3c/renesas,i3c.yaml | 108 ++++++++++++------ drivers/i3c/master/renesas-i3c.c | 84 ++++++++++++-- 2 files changed, 147 insertions(+), 45 deletions(-)
Signature · 1 line
2.53.0
Wolfram Sang
maintainerPATCH 1/2 dt-bindings: i3c: renesas,i3c: add R-Car Gen5 support
X5H is the first member of the R-Car Gen5 family. The biggest change is that only one interrupt is used instead of many. Also, only one reset is needed.
---
Passed 'dt_binding_check' and 'dtbs_check' for all users of this I3C controller here.
.../devicetree/bindings/i3c/renesas,i3c.yaml | 108 ++++++++++++------ 1 file changed, 70 insertions(+), 38 deletions(-)
Documentation/devicetree/bindings/i3c/renesas,i3c.yaml +70 -38
@@ -22,51 +22,59 @@ properties: - renesas,r9a09g056-i3c # RZ/V2N - renesas,r9a09g057-i3c # RZ/V2H(P) - const: renesas,r9a09g047-i3c + - items: + - enum: + - renesas,r8a78000-i3c # R-Car X5H + - const: renesas,rcar-gen5-i3c reg: maxItems: 1 interrupts: - items: - - description: Non-recoverable internal error interrupt - - description: Normal transfer error interrupt - - description: Normal transfer abort interrupt - - description: Normal response status buffer full interrupt - - description: Normal command buffer empty interrupt - - description: Normal IBI status buffer full interrupt - - description: Normal Rx data buffer full interrupt - - description: Normal Tx data buffer empty interrupt - - description: Normal receive status buffer full interrupt - - description: START condition detection interrupt - - description: STOP condition detection interrupt - - description: Transmit end interrupt - - description: NACK detection interrupt - - description: Arbitration lost interrupt - - description: Timeout detection interrupt - - description: Wake-up condition detection interrupt - - description: HDR Exit Pattern detection interrupt - minItems: 16 + oneOf: + - items: + - description: Non-recoverable internal error interrupt + - description: Normal transfer error interrupt + - description: Normal transfer abort interrupt + - description: Normal response status buffer full interrupt + - description: Normal command buffer empty interrupt + - description: Normal IBI status buffer full interrupt + - description: Normal Rx data buffer full interrupt + - description: Normal Tx data buffer empty interrupt + - description: Normal receive status buffer full interrupt + - description: START condition detection interrupt + - description: STOP condition detection interrupt + - description: Transmit end interrupt + - description: NACK detection interrupt + - description: Arbitration lost interrupt + - description: Timeout detection interrupt + - description: Wake-up condition detection interrupt + - description: HDR Exit Pattern detection interrupt + - items: + - description: Main interrupt interrupt-names: - items: - - const: ierr - - const: terr - - const: abort - - const: resp - - const: cmd - - const: ibi - - const: rx - - const: tx - - const: rcv - - const: st - - const: sp - - const: tend - - const: nack - - const: al - - const: tmo - - const: wu - - const: exit - minItems: 16 + oneOf: + - items: + - const: ierr + - const: terr + - const: abort + - const: resp + - const: cmd + - const: ibi + - const: rx + - const: tx + - const: rcv + - const: st + - const: sp + - const: tend + - const: nack + - const: al + - const: tmo + - const: wu + - const: exit + - items: + - const: main clocks: items:
@@ -89,11 +97,13 @@ properties: items: - description: Reset signal - description: APB interface reset signal/SCAN reset signal + minItems: 1 reset-names: items: - const: presetn - const: tresetn + minItems: 1 required: - compatible
@@ -137,10 +147,32 @@ allOf: clock-names: minItems: 3 interrupts: + minItems: 16 maxItems: 16 interrupt-names: + minItems: 16 maxItems: 16 + - if: + properties: + compatible: + contains: + const: renesas,rcar-gen5-i3c + then: + properties: + clocks: + maxItems: 2 + clock-names: + maxItems: 2 + resets: + maxItems: 1 + reset-names: + maxItems: 1 + interrupts: + maxItems: 1 + interrupt-names: + maxItems: 1 + unevaluatedProperties: false examples:
Signature · 1 line
2.53.0
Re: [PATCH 1/2] dt-bindings: i3c: renesas,i3c: add R-Car Gen5 support
Quoted 18 lines · Wolfram Sang
X5H is the first member of the R-Car Gen5 family. The biggest change is that only one interrupt is used instead of many. Also, only one reset is needed.
Signed-off-by Wolfram Sang <[email protected]>---
Passed '
dt_binding_check' and 'dtbs_check' for all users of this I3C controller here..../devicetree/bindings/i3c/renesas,i3c.yaml | 108 ++++++++++++------ 1 file changed, 70 insertions(+), 38 deletions(-)Documentation/devicetree/bindings/i3c/renesas,i3c.yaml +0
-0
Documentation/devicetree/bindings/i3c/renesas,i3c.yaml properties: · line 28
Quoted 7 lines
Documentation/devicetree/bindings/i3c/renesas,i3c.yaml +4
-0@@ -22,51 +22,59 @@ properties: - renesas,r9a09g056-i3c # RZ/V2N - renesas,r9a09g057-i3c # RZ/V2H(P) - const: renesas,r9a09g047-i3c + - items: + - enum: + - renesas,r8a78000-i3c # R-Car X5H + - const: renesas,rcar-gen5-i3c
not sure why need this fallback? if new soc coming, should fallback to renesas,r8a78000-i3c
Frank
Quoted 140 lines
Documentation/devicetree/bindings/i3c/renesas,i3c.yaml +66
-39reg: maxItems: 1 interrupts: - items: - - description: Non-recoverable internal error interrupt - - description: Normal transfer error interrupt - - description: Normal transfer abort interrupt - - description: Normal response status buffer full interrupt - - description: Normal command buffer empty interrupt - - description: Normal IBI status buffer full interrupt - - description: Normal Rx data buffer full interrupt - - description: Normal Tx data buffer empty interrupt - - description: Normal receive status buffer full interrupt - - description: START condition detection interrupt - - description: STOP condition detection interrupt - - description: Transmit end interrupt - - description: NACK detection interrupt - - description: Arbitration lost interrupt - - description: Timeout detection interrupt - - description: Wake-up condition detection interrupt - - description: HDR Exit Pattern detection interrupt - minItems: 16 + oneOf: + - items: + - description: Non-recoverable internal error interrupt + - description: Normal transfer error interrupt + - description: Normal transfer abort interrupt + - description: Normal response status buffer full interrupt + - description: Normal command buffer empty interrupt + - description: Normal IBI status buffer full interrupt + - description: Normal Rx data buffer full interrupt + - description: Normal Tx data buffer empty interrupt + - description: Normal receive status buffer full interrupt + - description: START condition detection interrupt + - description: STOP condition detection interrupt + - description: Transmit end interrupt + - description: NACK detection interrupt + - description: Arbitration lost interrupt + - description: Timeout detection interrupt + - description: Wake-up condition detection interrupt + - description: HDR Exit Pattern detection interrupt + - items: + - description: Main interrupt interrupt-names: - items: - - const: ierr - - const: terr - - const: abort - - const: resp - - const: cmd - - const: ibi - - const: rx - - const: tx - - const: rcv - - const: st - - const: sp - - const: tend - - const: nack - - const: al - - const: tmo - - const: wu - - const: exit - minItems: 16 + oneOf: + - items: + - const: ierr + - const: terr + - const: abort + - const: resp + - const: cmd + - const: ibi + - const: rx + - const: tx + - const: rcv + - const: st + - const: sp + - const: tend + - const: nack + - const: al + - const: tmo + - const: wu + - const: exit + - items: + - const: main clocks: items:@@ -89,11 +97,13 @@ properties: items: - description: Reset signal - description: APB interface reset signal/SCAN reset signal + minItems: 1 reset-names: items: - const: presetn - const: tresetn + minItems: 1 required: - compatible@@ -137,10 +147,32 @@ allOf: clock-names: minItems: 3 interrupts: + minItems: 16 maxItems: 16 interrupt-names: + minItems: 16 maxItems: 16 + - if: + properties: + compatible: + contains: + const: renesas,rcar-gen5-i3c + then: + properties: + clocks: + maxItems: 2 + clock-names: + maxItems: 2 + resets: + maxItems: 1 + reset-names: + maxItems: 1 + interrupts: + maxItems: 1 + interrupt-names: + maxItems: 1 + unevaluatedProperties: false examples: --2.53.0
Wolfram Sang
maintainerRe: [PATCH 1/2] dt-bindings: i3c: renesas,i3c: add R-Car Gen5 support
Quoted 8 lines
Documentation/devicetree/bindings/i3c/renesas,i3c.yaml properties: · line 28
Quoted 5 lines
Documentation/devicetree/bindings/i3c/renesas,i3c.yaml +4
-0+ - items: + - enum: + - renesas,r8a78000-i3c # R-Car X5H + - const: renesas,rcar-gen5-i3cnot sure why need this fallback? if new soc coming, should fallback to renesas,r8a78000-i3c
We tried this ages ago and concluded that family-compatibles match our chips best. See, e.g.:
Documentation/devicetree/bindings/i2c/renesas,rcar-i2c.yaml Documentation/devicetree/bindings/mmc/renesas,sdhi.yaml Documentation/devicetree/bindings/spi/renesas,sh-msiof.yaml
I could list many more...
Re: [PATCH 1/2] dt-bindings: i3c: renesas,i3c: add R-Car Gen5 support
Quoted 9 lines · Wolfram Sang
Quoted 8 lines
Documentation/devicetree/bindings/i3c/renesas,i3c.yaml properties: · line 28
Quoted 5 lines
Documentation/devicetree/bindings/i3c/renesas,i3c.yaml +4
-0+ - items: + - enum: + - renesas,r8a78000-i3c # R-Car X5H + - const: renesas,rcar-gen5-i3cnot sure why need this fallback? if new soc coming, should fallback to renesas,r8a78000-i3c
Quoted 6 lines
We tried this ages ago and concluded that family-compatibles match our chips best. See, e.g.:
Documentation/devicetree/bindings/i2c/renesas,rcar-i2c.yamlDocumentation/devicetree/bindings/mmc/renesas,sdhi.yamlDocumentation/devicetree/bindings/spi/renesas,sh-msiof.yaml
Okay, most likely dt team doesn't like such generic name even though it exist in tree. We were already rejected many times.
Anyway, I am fine if device tree maintainers think it is okay.
Frank
Quoted 3 lines
I could list many more...
Wolfram Sang
maintainerPATCH 2/2 i3c: renesas: add R-Car Gen5 support
In reply to Wolfram SangR-Car Gen5 uses only a single interrupt. So, add a central interrupt handler which calls into the existing ones depending on interrupt status registers (one is new). In probe(), the proper handling is based on the number of interrupts provided. It may look inconsistent that 'ntst' is using a set of if-blocks, whereas 'bst' uses if/else-blocks. But this actually matches the state machine of the driver to the best of our knowledge.
---
Tested with an Ironhide board (R-Car X5H) and the attached temp sensor on bus I3C0. Also no regressions seen with a RZ/G3S based board.
drivers/i3c/master/renesas-i3c.c | 84 +++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 7 deletions(-)
drivers/i3c/master/renesas-i3c.c +77 -7
@@ -21,6 +21,7 @@#include <linux/list.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_irq.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/reset.h>
@@ -197,6 +198,19 @@#define NDBSTLV0 0x398#define NDBSTLV0_RDBLV (x) FIELD_GET(GENMASK(15, 8), x) +#define INTCLR 0x400 +#define INTCLR_INTRESP BIT(0) +#define INTCLR_INTCMD BIT(1) +#define INTCLR_INTIBI BIT(2) +#define INTCLR_INTRX0 BIT(3) +#define INTCLR_INTTX0 BIT(4) +#define INTCLR_INTRCV BIT(5) +#define INTCLR_INTHRESP BIT(6) +#define INTCLR_INTHCMD BIT(7) +#define INTCLR_INTHRX BIT(8) +#define INTCLR_INTHTX BIT(9) +#define INTCLR_ALL GENMASK(9, 0) +#define RENESAS_I3C_MAX_DEVS 8#define I2C_INIT_MSG -1
@@ -1427,6 +1441,52 @@ static irqreturn_t renesas_i3c_start_isr(int irq, void *data)return IRQ_HANDLED ; } +static irqreturn_t renesas_i3c_main_isr (int irq,void *data) +{ +struct renesas_i3c *i3c = data; + +u32 ntst, bst, ntst_filterd, bst_filterd; +irqreturn_t ret =IRQ_NONE ; + + ntst =renesas_readl (i3c->regs,NTST ); + ntst_filterd = ntst &renesas_readl (i3c->regs,NTIE ); + bst =renesas_readl (i3c->regs,BST ); + bst_filterd = bst &renesas_readl (i3c->regs,BIE ); + +if (ntst_filterd &NTST_TDBEF0 ) { + ret |=renesas_i3c_tx_isr (irq, data); +renesas_set_bit (i3c->regs,INTCLR ,INTCLR_INTTX0 ); + } + +if (ntst_filterd &NTST_RDBFF0 ) { + ret |=renesas_i3c_rx_isr (irq, data); +renesas_set_bit (i3c->regs,INTCLR ,INTCLR_INTRX0 ); + } + +if (ntst_filterd &NTST_RSPQFF ) { + ret |=renesas_i3c_resp_isr (irq, data); +renesas_set_bit (i3c->regs,INTCLR ,INTCLR_INTRESP ); + } + +if (ntst_filterd & ~(NTST_RSPQFF |NTST_RDBFF0 |NTST_TDBEF0 )) { +renesas_writel (i3c->regs,INTCLR ,INTCLR_ALL ); + ret |=IRQ_HANDLED ; + } + +if (bst_filterd &BST_STCNDDF ) { + ret |=renesas_i3c_start_isr (irq, data); + }else if (bst_filterd &BST_SPCNDDF ) { + ret |=renesas_i3c_stop_isr (irq, data); + }else if (bst_filterd &BST_TENDF || bst_filterd &BST_NACKDF ) { + ret |=renesas_i3c_tend_isr (irq, data); + }else { +renesas_clear_bit (i3c->regs,BST , bst); + ret |=IRQ_HANDLED ; + } + +return ret; +} +static const struct i3c_master_controller_ops renesas_i3c_ops = { .bus_init = renesas_i3c_bus_init, .bus_cleanup = renesas_i3c_bus_cleanup,
@@ -1442,7 +1502,7 @@ static const struct i3c_master_controller_ops renesas_i3c_ops = { .i2c_xfers = renesas_i3c_i2c_xfers, }; -static const struct renesas_i3c_irq_desc renesas_i3c_irqs[] = { +static const struct renesas_i3c_irq_desc renesas_i3c_multiple_irqs[] = { { .name ="resp" , .isr = renesas_i3c_resp_isr, .desc ="i3c-resp" }, { .name ="rx" , .isr = renesas_i3c_rx_isr, .desc ="i3c-rx" }, { .name ="tx" , .isr = renesas_i3c_tx_isr, .desc ="i3c-tx" },
@@ -1450,12 +1510,19 @@ static const struct renesas_i3c_irq_desc renesas_i3c_irqs[] = { { .name = "sp", .isr = renesas_i3c_stop_isr, .desc = "i3c-stop" }, { .name = "tend", .isr = renesas_i3c_tend_isr, .desc = "i3c-tend" }, { .name = "nack", .isr = renesas_i3c_tend_isr, .desc = "i3c-nack" }, + {/* sentinel */ } +}; + +static const struct renesas_i3c_irq_desc renesas_i3c_single_irq[] = { + { .name ="main" , .isr = renesas_i3c_main_isr, .desc ="i3c-main" }, + {/* sentinel */ } };static int renesas_i3c_probe (struct platform_device *pdev) { +const struct renesas_i3c_irq_desc *irq_desc;struct renesas_i3c *i3c; -int ret, i; +int ret, i, num_irqs; i3c =devm_kzalloc_obj (&pdev->dev, *i3c);if (!i3c)
@@ -1493,20 +1560,22 @@ static int renesas_i3c_probe(struct platform_device *pdev)if (ret)return ret; -for (i =0 ; i <ARRAY_SIZE (renesas_i3c_irqs); i++) { + num_irqs =of_irq_count (pdev->dev.of_node); + irq_desc = num_irqs ==1 ? renesas_i3c_single_irq : renesas_i3c_multiple_irqs; + +for (i =0 ; irq_desc[i].name; i++) {const char *irqname; - ret =platform_get_irq_byname (pdev, renesas_i3c_irqs[i].name); + ret =platform_get_irq_byname (pdev, irq_desc[i].name);if (ret <0 )return ret; irqname =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"%s:%s" ,dev_name (&pdev->dev), - renesas_i3c_irqs[i].desc); + irq_desc[i].desc);if (!irqname)return -ENOMEM ; - ret =devm_request_irq (&pdev->dev, ret, renesas_i3c_irqs[i].isr, -0 , irqname, i3c); + ret =devm_request_irq (&pdev->dev, ret, irq_desc[i].isr,0 , irqname, i3c);if (ret)return ret; }
@@ -1615,6 +1684,7 @@ static const struct dev_pm_ops renesas_i3c_pm_ops = {static const struct of_device_id renesas_i3c_of_ids[] = { { .compatible ="renesas,r9a08g045-i3c" }, { .compatible ="renesas,r9a09g047-i3c" }, + { .compatible ="renesas,rcar-gen5-i3c" }, {/* sentinel */ }, };MODULE_DEVICE_TABLE (of, renesas_i3c_of_ids);
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] i3c: renesas: unconditional else in renesas_i3c_main_isr() clears BST - [High] i3c: renesas…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [High] i3c: renesas: unconditional else in renesas_i3c_main_isr() clears BST
- [High] i3c: renesas: uncleared INTCLR bits in renesas_i3c_main_isr() cause IRQ storm
--
commit bdbb91ae79ac40e75be22799e9417fb7d14818fc
Author: Wolfram Sang <[email protected]>
i3c: renesas: add R-Car Gen5 support
This commit adds R-Car Gen5 support to the Renesas I3C controller driver by introducing a central interrupt handler for single-IRQ platforms and adding the renesas,rcar-gen5-i3c compatible string.
Quoted 4 lines
drivers/i3c/master/renesas-i3c.c +0
-0
[ ... ]
Quoted 25 lines
drivers/i3c/master/renesas-i3c.c +21
-0@@ -1427,6 +1441,52 @@ static irqreturn_t renesas_i3c_start_isr(int irq, void *data)return IRQ_HANDLED ; } +static irqreturn_t renesas_i3c_main_isr (int irq,void *data) +{ +struct renesas_i3c *i3c = data; + +u32 ntst, bst, ntst_filterd, bst_filterd; +irqreturn_t ret =IRQ_NONE ; + + ntst =renesas_readl (i3c->regs,NTST ); + ntst_filterd = ntst &renesas_readl (i3c->regs,NTIE ); + bst =renesas_readl (i3c->regs,BST ); + bst_filterd = bst &renesas_readl (i3c->regs,BIE ); + +if (ntst_filterd &NTST_TDBEF0 ) { + ret |=renesas_i3c_tx_isr (irq, data); +renesas_set_bit (i3c->regs,INTCLR ,INTCLR_INTTX0 ); + } + +if (ntst_filterd &NTST_RDBFF0 ) { + ret |=renesas_i3c_rx_isr (irq, data); +renesas_set_bit (i3c->regs,INTCLR ,INTCLR_INTRX0 ); + }
drivers/i3c/master/renesas-i3c.c static irqreturn_t renesas_i3c_start_isr(int irq, void *data) · line 1474
Quoted 10 lines
drivers/i3c/master/renesas-i3c.c +10
-0+ +if (ntst_filterd &NTST_RSPQFF ) { + ret |=renesas_i3c_resp_isr (irq, data); +renesas_set_bit (i3c->regs,INTCLR ,INTCLR_INTRESP ); + } + +if (ntst_filterd & ~(NTST_RSPQFF |NTST_RDBFF0 |NTST_TDBEF0 )) { +renesas_writel (i3c->regs,INTCLR ,INTCLR_ALL ); + ret |=IRQ_HANDLED ; + }
[Severity: High]
Can gating the INTCLR writes on ntst_filterd leave an INTCLR bit latched and cause an interrupt storm?
Several paths clear NTIE or NTST without clearing INTCLR. For example, renesas_i3c_irqs_mask_and_clear_locked() (called from renesas_i3c_stop_isr(), on transfer timeouts, and when xferqueue.cur is NULL) writes 0 to NTIE and NTST without touching INTCLR. Similarly, renesas_i3c_resp_isr() clears NTIE_TDBEIE0 or drains the RX FIFO and clears NTIE_RDBFIE0 after renesas_i3c_main_isr() has already snapshotted ntst_filterd, and renesas_i3c_start_isr() clears NTIE_TDBEIE0 on I2C reads without clearing INTCLR_INTTX0.
If an INTCLR bit is latched when its NTIE or NTST bit is cleared, later calls to renesas_i3c_main_isr() see ntst_filterd == 0 and never clear INTCLR, while the unconditional else branch below returns IRQ_HANDLED so the generic IRQ layer cannot disable the stuck interrupt.
drivers/i3c/master/renesas-i3c.c static irqreturn_t renesas_i3c_start_isr(int irq, void *data) · line 1485
Quoted 11 lines
drivers/i3c/master/renesas-i3c.c +11
-0+ +if (bst_filterd &BST_STCNDDF ) { + ret |=renesas_i3c_start_isr (irq, data); + }else if (bst_filterd &BST_SPCNDDF ) { + ret |=renesas_i3c_stop_isr (irq, data); + }else if (bst_filterd &BST_TENDF || bst_filterd &BST_NACKDF ) { + ret |=renesas_i3c_tend_isr (irq, data); + }else { +renesas_clear_bit (i3c->regs,BST , bst); + ret |=IRQ_HANDLED ; + }
[Severity: High]
Should the final else branch check "else if (bst_filterd)"?
As written, whenever bst_filterd is 0 (such as on any NTST-only interrupt or a spurious interrupt), this branch clears raw bst status bits in BST without holding i3c->xferqueue.lock and forces ret |= IRQ_HANDLED. Because renesas_i3c_hw_init() enables BSTE_ALL_FLAG in BSTE, BST latches status bits even while their enable bits in BIE are masked. When renesas_i3c_tx_isr() writes the final I2C byte and enables BIE_TENDIE, returning to renesas_i3c_main_isr() enters this else block and clears bst in BST, which can drop BST_TENDF and stall the I2C transfer until timeout. It also prevents renesas_i3c_main_isr() from ever returning IRQ_NONE.
Signature · 6 lines
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2 -- linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
Quoted 54 lines · Wolfram Sang
R-Car Gen5 uses only a single interrupt. So, add a central interrupt handler which calls into the existing ones depending on interrupt status registers (one is new). In
probe(), the proper handling is based on the number of interrupts provided. It may look inconsistent that 'ntst' is using a set of if-blocks, whereas 'bst' uses if/else-blocks. But this actually matches the state machine of the driver to the best of our knowledge.Signed-off-by Wolfram Sang <[email protected]>---
Tested with an Ironhide board (R-Car X5H) and the attached temp sensor on bus I3C0. Also no regressions seen with a RZ/G3S based board.
drivers/i3c/master/renesas-i3c.c | 84 +++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 7 deletions(-)drivers/i3c/master/renesas-i3c.c +15
-0@@ -21,6 +21,7 @@#include <linux/list.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_irq.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/reset.h> @@ -197,6 +198,19 @@#define NDBSTLV0 0x398#define NDBSTLV0_RDBLV (x) FIELD_GET(GENMASK(15, 8), x) +#define INTCLR 0x400 +#define INTCLR_INTRESP BIT(0) +#define INTCLR_INTCMD BIT(1) +#define INTCLR_INTIBI BIT(2) +#define INTCLR_INTRX0 BIT(3) +#define INTCLR_INTTX0 BIT(4) +#define INTCLR_INTRCV BIT(5) +#define INTCLR_INTHRESP BIT(6) +#define INTCLR_INTHCMD BIT(7) +#define INTCLR_INTHRX BIT(8) +#define INTCLR_INTHTX BIT(9) +#define INTCLR_ALL GENMASK(9, 0) +#define RENESAS_I3C_MAX_DEVS 8#define I2C_INIT_MSG -1@@ -1427,6 +1441,52 @@ static irqreturn_t renesas_i3c_start_isr(int irq, void *data)return IRQ_HANDLED ; } +static irqreturn_t renesas_i3c_main_isr (int irq,void *data)
drivers/i3c/master/renesas-i3c.c static irqreturn_t renesas_i3c_start_isr(int irq, void *data) · line 1454
Quoted 10 lines
drivers/i3c/master/renesas-i3c.c +10
-0+{ +struct renesas_i3c *i3c = data; + +u32 ntst, bst, ntst_filterd, bst_filterd; +irqreturn_t ret =IRQ_NONE ; + + ntst =renesas_readl (i3c->regs,NTST ); + ntst_filterd = ntst &renesas_readl (i3c->regs,NTIE ); + bst =renesas_readl (i3c->regs,BST ); + bst_filterd = bst &renesas_readl (i3c->regs,BIE );
Need clean irqs before call renesas_i3c_tx*(); irq handle mang generate new irq, so irq missed.
Quoted 19 lines
drivers/i3c/master/renesas-i3c.c +19
-0+ +if (ntst_filterd &NTST_TDBEF0 ) { + ret |=renesas_i3c_tx_isr (irq, data); +renesas_set_bit (i3c->regs,INTCLR ,INTCLR_INTTX0 ); + } + +if (ntst_filterd &NTST_RDBFF0 ) { + ret |=renesas_i3c_rx_isr (irq, data); +renesas_set_bit (i3c->regs,INTCLR ,INTCLR_INTRX0 ); + } + +if (ntst_filterd &NTST_RSPQFF ) { + ret |=renesas_i3c_resp_isr (irq, data); +renesas_set_bit (i3c->regs,INTCLR ,INTCLR_INTRESP ); + } + +if (ntst_filterd & ~(NTST_RSPQFF |NTST_RDBFF0 |NTST_TDBEF0 )) { +renesas_writel (i3c->regs,INTCLR ,INTCLR_ALL ); + ret |=IRQ_HANDLED ;
drivers/i3c/master/renesas-i3c.c static irqreturn_t renesas_i3c_start_isr(int irq, void *data) · line 1483
Quoted 10 lines
drivers/i3c/master/renesas-i3c.c +10
-0+ } + +if (bst_filterd &BST_STCNDDF ) { + ret |=renesas_i3c_start_isr (irq, data); + }else if (bst_filterd &BST_SPCNDDF ) { + ret |=renesas_i3c_stop_isr (irq, data); + }else if (bst_filterd &BST_TENDF || bst_filterd &BST_NACKDF ) { + ret |=renesas_i3c_tend_isr (irq, data); + }else { +renesas_clear_bit (i3c->regs,BST , bst);
Most irq status is w1c. are sure clear bit? some hardware may use read clean for irq status.
Frank
Quoted 78 lines
drivers/i3c/master/renesas-i3c.c +23
-8+ ret |=IRQ_HANDLED ; + } + +return ret; +} +static const struct i3c_master_controller_ops renesas_i3c_ops = { .bus_init = renesas_i3c_bus_init, .bus_cleanup = renesas_i3c_bus_cleanup,@@ -1442,7 +1502,7 @@ static const struct i3c_master_controller_ops renesas_i3c_ops = { .i2c_xfers = renesas_i3c_i2c_xfers, }; -static const struct renesas_i3c_irq_desc renesas_i3c_irqs[] = { +static const struct renesas_i3c_irq_desc renesas_i3c_multiple_irqs[] = { { .name ="resp" , .isr = renesas_i3c_resp_isr, .desc ="i3c-resp" }, { .name ="rx" , .isr = renesas_i3c_rx_isr, .desc ="i3c-rx" }, { .name ="tx" , .isr = renesas_i3c_tx_isr, .desc ="i3c-tx" },@@ -1450,12 +1510,19 @@ static const struct renesas_i3c_irq_desc renesas_i3c_irqs[] = { { .name = "sp", .isr = renesas_i3c_stop_isr, .desc = "i3c-stop" }, { .name = "tend", .isr = renesas_i3c_tend_isr, .desc = "i3c-tend" }, { .name = "nack", .isr = renesas_i3c_tend_isr, .desc = "i3c-nack" }, + {/* sentinel */ } +}; + +static const struct renesas_i3c_irq_desc renesas_i3c_single_irq[] = { + { .name ="main" , .isr = renesas_i3c_main_isr, .desc ="i3c-main" }, + {/* sentinel */ } };static int renesas_i3c_probe (struct platform_device *pdev) { +const struct renesas_i3c_irq_desc *irq_desc;struct renesas_i3c *i3c; -int ret, i; +int ret, i, num_irqs; i3c =devm_kzalloc_obj (&pdev->dev, *i3c);if (!i3c)@@ -1493,20 +1560,22 @@ static int renesas_i3c_probe(struct platform_device *pdev)if (ret)return ret; -for (i =0 ; i <ARRAY_SIZE (renesas_i3c_irqs); i++) { + num_irqs =of_irq_count (pdev->dev.of_node); + irq_desc = num_irqs ==1 ? renesas_i3c_single_irq : renesas_i3c_multiple_irqs; + +for (i =0 ; irq_desc[i].name; i++) {const char *irqname; - ret =platform_get_irq_byname (pdev, renesas_i3c_irqs[i].name); + ret =platform_get_irq_byname (pdev, irq_desc[i].name);if (ret <0 )return ret; irqname =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"%s:%s" ,dev_name (&pdev->dev), - renesas_i3c_irqs[i].desc); + irq_desc[i].desc);if (!irqname)return -ENOMEM ; - ret =devm_request_irq (&pdev->dev, ret, renesas_i3c_irqs[i].isr, -0 , irqname, i3c); + ret =devm_request_irq (&pdev->dev, ret, irq_desc[i].isr,0 , irqname, i3c);if (ret)return ret; }@@ -1615,6 +1684,7 @@ static const struct dev_pm_ops renesas_i3c_pm_ops = {static const struct of_device_id renesas_i3c_of_ids[] = { { .compatible ="renesas,r9a08g045-i3c" }, { .compatible ="renesas,r9a09g047-i3c" }, + { .compatible ="renesas,rcar-gen5-i3c" }, {/* sentinel */ }, };MODULE_DEVICE_TABLE (of, renesas_i3c_of_ids); --2.53.0