add FlexCAN support for S32G2/S32G3 SoCs
Subsystems (3)
v4 cover add FlexCAN support for S32G2/S32G3 SoCs
From: Ciprian Marian Costea <[email protected]>
S32G2 and S32G3 SoCs share the FlexCAN module with i.MX SoCs, with some hardware integration particularities.
Main difference covered by this patchset relates to interrupt management. On S32G2/S32G3 SoC, there are separate interrupts for state change, bus errors, MBs 0-7 and MBs 8-127 respectively.
Changes in V4:
- Updated irq description in bindings documentation
- Fixed some small issues with the proposed changes in the flexcan binding documentation
Changes in V3:
- Added Vincent Mailhol's Reviewed-by tag on the second patch
- Changed to 'platform_get_irq_byname' for second range of mailboxes
- Made several rephasing in bindings doc
- Removed Frank Li's Reviewed-by tags since changes were made afterwards.
Changes in V2:
- Separated 'FLEXCAN_QUIRK_NR_IRQ_3' quirk addition from S32G SoC Flexcan support.
- Provided more information in dt-bindings documentation with respect to FlexCAN module integration on S32G SoCs.
- Fixed and irq resource freeing management issue.
Ciprian Marian Costea (3):
dt-bindings: can: fsl,flexcan: add S32G2/S32G3 SoC support
can: flexcan: Add quirk to handle separate interrupt lines for
mailboxes
can: flexcan: add NXP S32G2/S32G3 SoC support
.../bindings/net/can/fsl,flexcan.yaml | 44 +++++++++++++++++-- drivers/net/can/flexcan/flexcan-core.c | 35 ++++++++++++++- drivers/net/can/flexcan/flexcan.h | 5 +++ 3 files changed, 79 insertions(+), 5 deletions(-)
Signature · 1 line
2.45.2
PATCH RESEND v4 1/3 dt-bindings: can: fsl,flexcan: add S32G2/S32G3 SoC support
From: Ciprian Marian Costea <[email protected]>
Add S32G2/S32G3 SoCs compatible strings.
A particularity for these SoCs is the presence of separate interrupts for state change, bus errors, MBs 0-7 and MBs 8-127 respectively.
Increase maxItems of 'interrupts' to 4 for S32G based SoCs and keep the same restriction for other SoCs.
Also, as part of this commit, move the 'allOf' after the required properties to make the documentation easier to read.
--- .../bindings/net/can/fsl,flexcan.yaml | 44 +++++++++++++++++-- 1 file changed, 40 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml +40 -4
@@ -10,9 +10,6 @@ title: maintainers: - Marc Kleine-Budde <[email protected]> -allOf: - - $ref: can-controller.yaml# - properties: compatible: oneOf:
@@ -28,6 +25,7 @@ properties: - fsl,vf610-flexcan - fsl,ls1021ar2-flexcan - fsl,lx2160ar1-flexcan + - nxp,s32g2-flexcan - items: - enum: - fsl,imx53-flexcan
@@ -43,12 +41,21 @@ properties: - enum: - fsl,ls1028ar1-flexcan - const: fsl,lx2160ar1-flexcan + - items: + - enum: + - nxp,s32g3-flexcan + - const: nxp,s32g2-flexcan reg: maxItems: 1 interrupts: - maxItems: 1 + minItems: 1 + maxItems: 4 + + interrupt-names: + minItems: 1 + maxItems: 4 clocks: maxItems: 2
@@ -136,6 +143,35 @@ required: - reg - interrupts +allOf: + - $ref: can-controller.yaml# + - if: + properties: + compatible: + contains: + const: nxp,s32g2-flexcan + then: + properties: + interrupts: + items: + - description: Message Buffer interrupt for mailboxes 0-7 and Enhanced RX FIFO + - description: Device state change + - description: Bus Error detection + - description: Message Buffer interrupt for mailboxes 8-127 + interrupt-names: + items: + - const: mb-0 + - const: state + - const: berr + - const: mb-1 + required: + - interrupt-names + else: + properties: + interrupts: + maxItems: 1 + interrupt-names: false + additionalProperties: false examples:
Signature · 1 line
2.45.2
Re: [PATCH v4 1/3 RESEND] dt-bindings: can: fsl,flexcan: add S32G2/S32G3 SoC support
Quoted 10 lines · Ciprian Costea
From: Ciprian Marian Costea <[email protected]>
Add S32G2/S32G3 SoCs compatible strings.
A particularity for these SoCs is the presence of separate interrupts for state change, bus errors, MBs 0-7 and MBs 8-127 respectively.
Increase maxItems of 'interrupts' to 4 for S32G based SoCs and keep the same restriction for other SoCs.
Quoted 8 lines
Also, as part of this commit, move the 'allOf' after the required properties to make the documentation easier to read.
Signed-off-by Ciprian Marian Costea <[email protected]>--- .../bindings/net/can/fsl,flexcan.yaml | 44 +++++++++++++++++-- 1 file changed, 40 insertions(+), 4 deletions(-)
Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.
If a tag was not added on purpose, please state why and what changed.
Missing tags:
Re: [PATCH v4 1/3 RESEND] dt-bindings: can: fsl,flexcan: add S32G2/S32G3 SoC support
Quoted 26 lines · Rob Herring (Arm)
Quoted 10 lines · Ciprian Costea
From: Ciprian Marian Costea <[email protected]>
Add S32G2/S32G3 SoCs compatible strings.
A particularity for these SoCs is the presence of separate interrupts for state change, bus errors, MBs 0-7 and MBs 8-127 respectively.
Increase maxItems of 'interrupts' to 4 for S32G based SoCs and keep the same restriction for other SoCs.
Quoted 8 lines
Also, as part of this commit, move the 'allOf' after the required properties to make the documentation easier to read.
Signed-off-by Ciprian Marian Costea <[email protected]>--- .../bindings/net/can/fsl,flexcan.yaml | 44 +++++++++++++++++-- 1 file changed, 40 insertions(+), 4 deletions(-)Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.
Quoted 8 lines
If a tag was not added on purpose, please state why and what changed.
Missing tags:
Acked-by Conor Dooley <[email protected]>
Hello Rob,
I just wanted to add the RESEND word to these patch series because no update was made with respect to its acceptance. Following [1] kernel documentation for submitting patches I was not sure if by adding the received 'Acked-by' to a commit it will still be correct to add the RESEND word or I should send a new patch version on this series.
On short, my lack of addition for the 'Acked-by' was not on purpose.
[1] https://docs.kernel.org/process/submitting-patches.html
Best Regards,
Ciprian
PATCH RESEND v4 2/3 can: flexcan: Add quirk to handle separate interrupt lines for mailboxes
In reply to Ciprian CosteaFrom: Ciprian Marian Costea <[email protected]>
Introduce 'FLEXCAN_QUIRK_SECONDARY_MB_IRQ' quirk to handle a FlexCAN hardware module integration particularity where two ranges of mailboxes are controlled by separate hardware interrupt lines.
The same 'flexcan_irq' handler is used for both separate mailbox interrupt lines, with no other changes.
--- drivers/net/can/flexcan/flexcan-core.c | 24 +++++++++++++++++++++++- drivers/net/can/flexcan/flexcan.h | 5 +++++ 2 files changed, 28 insertions(+), 1 deletion(-)
drivers/net/can/flexcan/flexcan-core.c +23 -1
@@ -1762,14 +1762,25 @@ static int flexcan_open(struct net_device *dev) goto out_free_irq_boff; } +if (priv->devtype_data.quirks &FLEXCAN_QUIRK_SECONDARY_MB_IRQ ) { + err =request_irq (priv->irq_secondary_mb, + flexcan_irq,IRQF_SHARED , dev->name, dev); +if (err) + goto out_free_irq_err; + } +flexcan_chip_interrupts_enable (dev);netif_start_queue (dev);return 0 ; + out_free_irq_err: +if (priv->devtype_data.quirks &FLEXCAN_QUIRK_NR_IRQ_3 ) +free_irq (priv->irq_err, dev); out_free_irq_boff: -free_irq (priv->irq_boff, dev); +if (priv->devtype_data.quirks &FLEXCAN_QUIRK_NR_IRQ_3 ) +free_irq (priv->irq_boff, dev); out_free_irq:free_irq (dev->irq, dev); out_can_rx_offload_disable:
@@ -1799,6 +1810,9 @@ static int flexcan_close(struct net_device *dev)free_irq (priv->irq_boff, dev); } +if (priv->devtype_data.quirks &FLEXCAN_QUIRK_SECONDARY_MB_IRQ ) +free_irq (priv->irq_secondary_mb, dev); +free_irq (dev->irq, dev);can_rx_offload_disable (&priv->offload);flexcan_chip_stop_disable_on_error (dev);
@@ -2187,6 +2201,14 @@ static int flexcan_probe(struct platform_device *pdev) } } +if (priv->devtype_data.quirks &FLEXCAN_QUIRK_SECONDARY_MB_IRQ ) { + priv->irq_secondary_mb =platform_get_irq_byname (pdev,"mb-1" ); +if (priv->irq_secondary_mb <0 ) { + err = priv->irq_secondary_mb; + goto failed_platform_get_irq; + } + } +if (priv->devtype_data.quirks &FLEXCAN_QUIRK_SUPPORT_FD ) { priv->can.ctrlmode_supported |=CAN_CTRLMODE_FD |CAN_CTRLMODE_FD_NON_ISO ;
drivers/net/can/flexcan/flexcan.h +5 -0
@@ -70,6 +70,10 @@#define FLEXCAN_QUIRK_SUPPORT_RX_FIFO BIT(16)/* Setup stop mode with ATF SCMI protocol to support wakeup */ #define FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI BIT(17) +/* Device has two separate interrupt lines for two mailbox ranges, which +* both need to have an interrupt handler registered. +*/ +#define FLEXCAN_QUIRK_SECONDARY_MB_IRQ BIT(18)struct flexcan_devtype_data {u32 quirks;/* quirks needed for different IP cores */
@@ -107,6 +111,7 @@ struct flexcan_priv {int irq_boff;int irq_err; +int irq_secondary_mb;/* IPC handle when setup stop mode by System Controller firmware(scfw) */ struct imx_sc_ipc *sc_ipc_handle;
Signature · 1 line
2.45.2
Marc Kleine-Budde
maintainerRe: [PATCH v4 2/3 RESEND] can: flexcan: Add quirk to handle separate interrupt lines for mailboxes
Quoted 47 lines · Ciprian Costea
From: Ciprian Marian Costea <[email protected]>
Introduce '
FLEXCAN_QUIRK_SECONDARY_MB_IRQ' quirk to handle a FlexCAN hardware module integration particularity where two ranges of mailboxes are controlled by separate hardware interrupt lines.
The same 'flexcan_irq' handler is used for both separate mailbox interrupt lines, with no other changes.Signed-off-by Ciprian Marian Costea <[email protected]>Reviewed-by Vincent Mailhol <[email protected]>--- drivers/net/can/flexcan/flexcan-core.c | 24 +++++++++++++++++++++++- drivers/net/can/flexcan/flexcan.h | 5 +++++ 2 files changed, 28 insertions(+), 1 deletion(-)drivers/net/can/flexcan/flexcan-core.c +12
-1@@ -1762,14 +1762,25 @@ static int flexcan_open(struct net_device *dev) goto out_free_irq_boff; } +if (priv->devtype_data.quirks &FLEXCAN_QUIRK_SECONDARY_MB_IRQ ) { + err =request_irq (priv->irq_secondary_mb, + flexcan_irq,IRQF_SHARED , dev->name, dev); +if (err) + goto out_free_irq_err; + } +flexcan_chip_interrupts_enable (dev);netif_start_queue (dev);return 0 ; + out_free_irq_err: +if (priv->devtype_data.quirks &FLEXCAN_QUIRK_NR_IRQ_3 ) +free_irq (priv->irq_err, dev); out_free_irq_boff: -free_irq (priv->irq_boff, dev); +if (priv->devtype_data.quirks &FLEXCAN_QUIRK_NR_IRQ_3 ) +free_irq (priv->irq_boff, dev); out_free_irq:free_irq (dev->irq, dev); out_can_rx_offload_disable:
drivers/net/can/flexcan/flexcan-core.c static int flexcan_close(struct net_device *dev) · line 1815
Quoted 6 lines
drivers/net/can/flexcan/flexcan-core.c +3
-0@@ -1799,6 +1810,9 @@ static int flexcan_close(struct net_device *dev)free_irq (priv->irq_boff, dev); } +if (priv->devtype_data.quirks &FLEXCAN_QUIRK_SECONDARY_MB_IRQ ) +free_irq (priv->irq_secondary_mb, dev); +
While applying, I've changed the order to free the secondary IRQ first, to be symmetrical to flexcan_open().
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
PATCH RESEND v4 3/3 can: flexcan: add NXP S32G2/S32G3 SoC support
In reply to Ciprian CosteaFrom: Ciprian Marian Costea <[email protected]>
Add device type data for S32G2/S32G3 SoC.
FlexCAN module from S32G2/S32G3 is similar with i.MX SoCs, but interrupt management is different.
On S32G2/S32G3 SoC, there are separate interrupts for state change, bus errors, Mailboxes 0-7 and Mailboxes 8-127 respectively.
In order to handle this FlexCAN hardware particularity, first reuse the 'FLEXCAN_QUIRK_NR_IRQ_3' quirk provided by mcf5441x's irq handling support. Secondly, use the newly introduced 'FLEXCAN_QUIRK_SECONDARY_MB_IRQ' quirk which handles the case where two separate mailbox ranges are controlled by independent hardware interrupt lines.
--- drivers/net/can/flexcan/flexcan-core.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/can/flexcan/flexcan-core.c +11 -0
@@ -386,6 +386,16 @@ static const struct flexcan_devtype_data fsl_lx2160a_r1_devtype_data = { FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR, }; +static const struct flexcan_devtype_data nxp_s32g2_devtype_data = { + .quirks =FLEXCAN_QUIRK_DISABLE_RXFG |FLEXCAN_QUIRK_ENABLE_EACEN_RRS | +FLEXCAN_QUIRK_DISABLE_MECR |FLEXCAN_QUIRK_BROKEN_PERR_STATE | +FLEXCAN_QUIRK_USE_RX_MAILBOX |FLEXCAN_QUIRK_SUPPORT_FD | +FLEXCAN_QUIRK_SUPPORT_ECC |FLEXCAN_QUIRK_NR_IRQ_3 | +FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX | +FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR | +FLEXCAN_QUIRK_SECONDARY_MB_IRQ , +}; +static const struct can_bittiming_const flexcan_bittiming_const = { .name =DRV_NAME , .tseg1_min =4 ,
@@ -2055,6 +2065,7 @@ static const struct of_device_id flexcan_of_match[] = { { .compatible = "fsl,vf610-flexcan", .data = &fsl_vf610_devtype_data, }, { .compatible = "fsl,ls1021ar2-flexcan", .data = &fsl_ls1021a_r2_devtype_data, }, { .compatible = "fsl,lx2160ar1-flexcan", .data = &fsl_lx2160a_r1_devtype_data, }, + { .compatible = "nxp,s32g2-flexcan", .data = &nxp_s32g2_devtype_data, }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, flexcan_of_match);
Signature · 1 line
2.45.2