can: rcar_canfd: Add R-Car X5H support
v2 cover can: rcar_canfd: Add R-Car X5H support
From: Geert Uytterhoeven <[email protected]>
Hi all,
This patch series adds support for the CAN-FD interfaces on the Renesas R-Car X5H SoC to the R-Car CAN-FD driver:
1. The first RFC patch documents support for CAN-FD on R-Car X5H,
2. Patches 2-4 add driver support for CAN-FD on R-Car X5H.
Changes compared to v1[1]:
- Drop platform integration patches not intended for the CAN tree,
- Improve RFC question,
- Add Reviewed-by,
- Update new user.
CAN-FD channels 1 to 6 and 12 to 15 have been tested on the Ironhide development board using canfdtest and an oscilloscope.
Thanks for your comments!
[1] "[PATCH 0/9] arm64: renesas: r8a78000: Add PWM support" (yeah, wrong component ^^^, sorry for that)
https://lore.kernel.org/[email protected]
Geert Uytterhoeven (4):
[RFC] dt-bindings: can: renesas,rcar-canfd: Document R-Car X5H support
can: rcar_canfd: Add Runtime PM support
can: rcar_canfd: Make clkp local
can: rcar_canfd: Add support for R-Car Gen5
.../bindings/net/can/renesas,rcar-canfd.yaml | 84 +++++++++++++++++++ drivers/net/can/rcar/rcar_canfd.c | 47 ++++++++--- 2 files changed, 120 insertions(+), 11 deletions(-)
Signature · 12 lines
2.43.0
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus TorvaldsPATCH v2 1/4 dt-bindings: can: renesas,rcar-canfd: Document R-Car X5H support
From: Geert Uytterhoeven <[email protected]>
Document support for the Controller Area Network Flexible Data Rate (CAN-FD) modules as found on R-Car X5H, which is the first member of the R-Car Gen5 family. It is a further evolution of the CAN-FD block found on R-Car Gen4 SoCs, adding Freedom From Interference and Virtual Machine support.
Binding-wise, the major difference is the split of global and per-channel interrupts (like on RZ/G2L), and the addition of Virtual Machine interrupts.
---
Do we need the VM interrupts, or are they meant for the hypervisor? If yes, instead of adding them at the end, should we add a third option for interrupts and interrupt-names, using a different order
- 2 global interrupts,
- 8 VM interrupts,
- 8 (= number of channels) x 3 channel interrupts,
so we can easily restrict the number of interrupts when a variant with less than 8 channels appears?
v2:
- Improve RFC question.
--- .../bindings/net/can/renesas,rcar-canfd.yaml | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+)
Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml +84 -0
@@ -42,6 +42,11 @@ properties: - renesas,r8a779h0-canfd # R-Car V4M - const: renesas,rcar-gen4-canfd # R-Car Gen4 + - items: + - enum: + - renesas,r8a78000-canfd # R-Car X5H + - const: renesas,rcar-gen5-canfd # R-Car Gen5 + - items: - enum: - renesas,r9a07g043-canfd # RZ/G2UL and RZ/Five
@@ -88,6 +93,36 @@ properties: - description: CAN5 error interrupt - description: CAN5 transmit interrupt - description: CAN5 transmit/receive FIFO receive completion interrupt + - description: CAN6 error interrupt + - description: CAN6 transmit interrupt + - description: CAN6 transmit/receive FIFO receive completion interrupt + - description: CAN7 error interrupt + - description: CAN7 transmit interrupt + - description: CAN7 transmit/receive FIFO receive completion interrupt + - description: Virtual Machine 0 transmit interrupt + - description: Virtual Machine 0 receive interrupt + - description: Virtual Machine 0 error interrupt + - description: Virtual Machine 1 transmit interrupt + - description: Virtual Machine 1 receive interrupt + - description: Virtual Machine 1 error interrupt + - description: Virtual Machine 2 transmit interrupt + - description: Virtual Machine 2 receive interrupt + - description: Virtual Machine 2 error interrupt + - description: Virtual Machine 3 transmit interrupt + - description: Virtual Machine 3 receive interrupt + - description: Virtual Machine 3 error interrupt + - description: Virtual Machine 4 transmit interrupt + - description: Virtual Machine 4 receive interrupt + - description: Virtual Machine 4 error interrupt + - description: Virtual Machine 5 transmit interrupt + - description: Virtual Machine 5 receive interrupt + - description: Virtual Machine 5 error interrupt + - description: Virtual Machine 6 transmit interrupt + - description: Virtual Machine 6 receive interrupt + - description: Virtual Machine 6 error interrupt + - description: Virtual Machine 7 transmit interrupt + - description: Virtual Machine 7 receive interrupt + - description: Virtual Machine 7 error interrupt minItems: 8 interrupt-names:
@@ -116,6 +151,36 @@ properties: - const: ch5_err - const: ch5_rec - const: ch5_trx + - const: ch6_err + - const: ch6_rec + - const: ch6_trx + - const: ch7_err + - const: ch7_rec + - const: ch7_trx + - const: vm0_tx + - const: vm0_rx + - const: vm0_err + - const: vm1_tx + - const: vm1_rx + - const: vm1_err + - const: vm2_tx + - const: vm2_rx + - const: vm2_err + - const: vm3_tx + - const: vm3_rx + - const: vm3_err + - const: vm4_tx + - const: vm4_rx + - const: vm4_err + - const: vm5_tx + - const: vm5_rx + - const: vm5_err + - const: vm6_tx + - const: vm6_rx + - const: vm6_err + - const: vm7_tx + - const: vm7_rx + - const: vm7_err minItems: 8 clocks:
@@ -234,6 +299,22 @@ allOf: reset-names: false + - if: + properties: + compatible: + contains: + const: renesas,rcar-gen5-canfd + then: + properties: + interrupts: + minItems: 50 + + interrupt-names: + minItems: 50 + + resets: + maxItems: 1 + - if: properties: compatible:
@@ -243,9 +324,11 @@ allOf: properties: interrupts: minItems: 20 + maxItems: 20 interrupt-names: minItems: 20 + maxItems: 20 resets: minItems: 2
@@ -379,6 +462,7 @@ allOf: enum: - renesas,rcar-gen3-canfd - renesas,rcar-gen4-canfd + - renesas,rcar-gen5-canfd then: required: - resets
Signature · 1 line
2.43.0
PATCH v2 2/4 can: rcar_canfd: Add Runtime PM support
In reply to Geert UytterhoevenFrom: Geert Uytterhoeven <[email protected]>
On R-Car X5H, the CAN-FD module is part of a power domain. This means Runtime PM must be used to make sure the domain is powered when needed. The CAN-FD module is part of a Clock Domain on all supported SoCs. Hence remove explicit management of the functional clock, as this is handled automatically by Runtime PM.
---
v2:
- Add Reviewed-by.
--- drivers/net/can/rcar/rcar_canfd.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/net/can/rcar/rcar_canfd.c +11 -6
@@ -37,6 +37,7 @@#include <linux/of.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/pm_runtime.h> #include <linux/reset.h> #include <linux/types.h>
@@ -2059,9 +2060,9 @@ static int rcar_canfd_global_init(struct rcar_canfd_global *gpriv)int err;/* Enable peripheral clock for register access */ - err =clk_prepare_enable (gpriv->clkp); + err =pm_runtime_resume_and_get (dev);if (err) { -dev_err (dev,"failed to enable peripheral clock: %pe\n" , +dev_err (dev,"pm_runtime_resume_and_get() failed: %pe\n" ,ERR_PTR (err));return err; }
@@ -2071,7 +2072,7 @@ static int rcar_canfd_global_init(struct rcar_canfd_global *gpriv)if (err) {dev_err (dev,"failed to enable RAM clock, error %d\n" , err); - goto fail_clk; + goto fail_rpm; } err =reset_control_reset (gpriv->rstc1);
@@ -2129,8 +2130,8 @@ static int rcar_canfd_global_init(struct rcar_canfd_global *gpriv)reset_control_assert (gpriv->rstc1); fail_ram_clk:clk_disable_unprepare (gpriv->clk_ram); -fail_clk: -clk_disable_unprepare (gpriv->clkp); +fail_rpm: +pm_runtime_put (dev);return err; }
@@ -2148,7 +2149,7 @@ static void rcar_canfd_global_deinit(struct rcar_canfd_global *gpriv, bool full)reset_control_assert (gpriv->rstc2);reset_control_assert (gpriv->rstc1);clk_disable_unprepare (gpriv->clk_ram); -clk_disable_unprepare (gpriv->clkp); +pm_runtime_put (&gpriv->pdev->dev); }static int rcar_canfd_probe (struct platform_device *pdev)
@@ -2319,6 +2320,10 @@ static int rcar_canfd_probe(struct platform_device *pdev) } } + err =devm_pm_runtime_enable (dev); +if (err) + goto fail_dev; + err =rcar_canfd_global_init (gpriv);if (err) goto fail_mode;
Signature · 1 line
2.43.0
PATCH v2 3/4 can: rcar_canfd: Make clkp local
In reply to Geert UytterhoevenFrom: Geert Uytterhoeven <[email protected]>
The peripheral clock is only used in rcar_canfd_probe(), so convert clkp to a local variable.
---
v2:
- Add Reviewed-by,
- Update new user.
--- drivers/net/can/rcar/rcar_canfd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/can/rcar/rcar_canfd.c +5 -5
@@ -469,7 +469,6 @@ struct rcar_canfd_global {void __iomem *base;/* Register base address */ struct rcar_canfd_f_c __iomem *fcbase;struct platform_device *pdev;/* Respective platform device */ -struct clk *clkp;/* Peripheral clock */ struct clk *can_clk;/* fCAN clock */ struct clk *clk_ram;/* Clock RAM */ unsigned long channels_mask;/* Enabled channels mask */
@@ -2166,6 +2165,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)bool fdmode = true;/* CAN FD only mode - default */ char name[9 ] ="channelX" ;u32 ch, fcan_freq; +struct clk *clkp;int i; info =of_device_get_match_data (dev);
@@ -2236,9 +2236,9 @@ static int rcar_canfd_probe(struct platform_device *pdev) "failed to get rstc_n\n");/* Peripheral clock */ - gpriv->clkp =devm_clk_get (dev,"fck" ); -if (IS_ERR (gpriv->clkp)) -return dev_err_probe (dev,PTR_ERR (gpriv->clkp), + clkp =devm_clk_get (dev,"fck" ); +if (IS_ERR (clkp)) +return dev_err_probe (dev,PTR_ERR (clkp),"cannot get peripheral clock\n" );/* fCAN clock: Pick External clock. If not available or its rate is
@@ -2250,7 +2250,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)if (!gpriv->can_clk || (clk_get_rate (gpriv->can_clk) ==0 )) {if (info->fcan_pclk) { - fcan_freq =clk_get_rate (gpriv->clkp); + fcan_freq =clk_get_rate (clkp); gpriv->can_clk =NULL ; }else { gpriv->can_clk =devm_clk_get (dev,"canfd" );
Signature · 1 line
2.43.0
PATCH v2 4/4 can: rcar_canfd: Add support for R-Car Gen5
In reply to Geert UytterhoevenFrom: Geert Uytterhoeven <[email protected]>
The CAN-FD block on R-Car Gen5 is similar to the variant on R-Car Gen4, but uses split global and per-channel interrupts, and has no /2 postdivider for the canfd clock input.
---
v2:
- Correct .postdiv,
- Rebase.
--- drivers/net/can/rcar/rcar_canfd.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/net/can/rcar/rcar_canfd.c +20 -0
@@ -642,6 +642,25 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { .fixed_canfd = 0, }; +static const struct rcar_canfd_hw_info rcar_gen5_hw_info = { + .nom_bittiming = &rcar_canfd_gen4_nom_bittiming_const, + .data_bittiming = &rcar_canfd_gen4_data_bittiming_const, + .tdc_const = &rcar_canfd_gen4_tdc_const, + .regs = &rcar_gen4_regs, + .sh = &rcar_gen4_shift_data, + .rnc_field_width =16 , + .max_aflpn =127 , + .max_cftml =31 , + .max_channels =8 , + .postdiv =1 , + .multi_channel_irqs =1 , + .ch_interface_mode =1 , + .shared_can_regs =1 , + .external_clk =1 , + .fcan_pclk =0 , + .fixed_canfd =0 , +}; +static const struct rcar_canfd_hw_info rzg2l_hw_info = { .nom_bittiming = &rcar_canfd_gen3_nom_bittiming_const, .data_bittiming = &rcar_canfd_gen3_data_bittiming_const,
@@ -2437,6 +2456,7 @@ static const __maybe_unused struct of_device_id rcar_canfd_of_table[] = { { .compatible = "renesas,r9a09g077-canfd", .data = &r9a09g077_hw_info }, { .compatible = "renesas,rcar-gen3-canfd", .data = &rcar_gen3_hw_info }, { .compatible = "renesas,rcar-gen4-canfd", .data = &rcar_gen4_hw_info }, + { .compatible = "renesas,rcar-gen5-canfd", .data = &rcar_gen5_hw_info }, { .compatible = "renesas,rzg2l-canfd", .data = &rzg2l_hw_info }, { } };
Signature · 1 line
2.43.0