mbox series

[0/6] Renesas RZ/G2L CANFD support

Message ID 20210715182123.23372-1-prabhakar.mahadev-lad.rj@bp.renesas.com
Headers show
Series Renesas RZ/G2L CANFD support | expand

Message

Prabhakar Mahadev Lad July 15, 2021, 6:21 p.m. UTC
Hi All,

This patch series adds CANFD support to Renesas RZ/G2L family.

CANFD block on RZ/G2L SoC is almost identical to one found on
R-Car Gen3 SoC's. On RZ/G2L SoC interrupt sources for each channel
are split into individual sources.

Patches are based on top of [1] (master branch) + patch [2].

Cheers,
Prabhakar

[1] https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git/log/
[2] https://patchwork.kernel.org/project/linux-renesas-soc/patch/
20210712194422.12405-4-prabhakar.mahadev-lad.rj@bp.renesas.com/

Lad Prabhakar (6):
  dt-bindings: net: can: renesas,rcar-canfd: Document RZ/G2L SoC
  can: rcar_canfd: Add support for RZ/G2L family
  dt-bindings: clk: r9a07g044-cpg: Add entry for P0_DIV2 core clock
  clk: renesas: r9a07g044-cpg: Add entry for fixed clock P0_DIV2
  clk: renesas: r9a07g044-cpg: Add clock and reset entries for CANFD
  arm64: dts: renesas: r9a07g044: Add CANFD node

 .../bindings/net/can/renesas,rcar-canfd.yaml  |  45 ++-
 arch/arm64/boot/dts/renesas/r9a07g044.dtsi    |  37 +++
 drivers/clk/renesas/r9a07g044-cpg.c           |   7 +-
 drivers/net/can/rcar/rcar_canfd.c             | 275 ++++++++++++++++--
 include/dt-bindings/clock/r9a07g044-cpg.h     |   2 +
 5 files changed, 328 insertions(+), 38 deletions(-)


base-commit: b37235d5fdf50e5f1c23f868ab70bbe640081b21
prerequisite-patch-id: 7436c0d801737268ef470fcb50e620428286e085

Comments

Geert Uytterhoeven July 16, 2021, 7:38 a.m. UTC | #1
Hi Prabhakar,

On Thu, Jul 15, 2021 at 8:21 PM Lad Prabhakar
<prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:
> Add CANFD binding documentation for Renesas RZ/G2L SoC.

>

> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>


Thanks for your patch!

> --- a/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml

> +++ b/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml


> @@ -78,6 +79,38 @@ patternProperties:

>        node.  Each child node supports the "status" property only, which

>        is used to enable/disable the respective channel.

>

> +if:

> +  properties:

> +    compatible:

> +      contains:

> +        enum:

> +          - renesas,rzg2l-canfd

> +then:

> +  properties:

> +    interrupts:

> +      items:

> +        - description: CAN global error interrupt

> +        - description: CAN receive FIFO interrupt

> +        - description: CAN0 error interrupt

> +        - description: CAN0 transmit interrupt

> +        - description: CAN0 transmit/receive FIFO receive completion interrupt

> +        - description: CAN1 error interrupt

> +        - description: CAN1 transmit interrupt

> +        - description: CAN1 transmit/receive FIFO receive completion interrupt


Does it make sense to add interrupt-names?

> +

> +    resets:

> +      maxItems: 2


Same here, for reset-names?
Or a list of descriptions, so we know which reset serves what purpose.

> +

> +else:

> +  properties:

> +    interrupts:

> +      items:

> +        - description: Channel interrupt

> +        - description: Global interrupt

> +

> +    resets:

> +      maxItems: 1

> +

>  required:

>    - compatible

>    - reg


The rest looks good to me.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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 Torvalds
Geert Uytterhoeven July 16, 2021, 8:07 a.m. UTC | #2
Hi Prabhakar,

Thanks for your patch!

On Thu, Jul 15, 2021 at 8:21 PM Lad Prabhakar
<prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:
> Add P0_DIV2 core clock required for CANFD module. CANFD core clock is

> sourced from P0_DIV2 referenced from HW manual Rev.0.50.


OK.

> Also add R9A07G044_LAST_CORE_CLK entry to avoid changes in

> r9a07g044-cpg.c file.


I'm not so fond of adding this.  Unlike the other definitions, it is
not really part of the bindings, but merely a convenience definition
for the driver.  Furthermore it has to change when a new definition
is ever added.

> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>

> ---

>  include/dt-bindings/clock/r9a07g044-cpg.h | 2 ++

>  1 file changed, 2 insertions(+)

>

> diff --git a/include/dt-bindings/clock/r9a07g044-cpg.h b/include/dt-bindings/clock/r9a07g044-cpg.h

> index 0728ad07ff7a..2fd20db0b2f4 100644

> --- a/include/dt-bindings/clock/r9a07g044-cpg.h

> +++ b/include/dt-bindings/clock/r9a07g044-cpg.h

> @@ -30,6 +30,8 @@

>  #define R9A07G044_CLK_P2               19

>  #define R9A07G044_CLK_AT               20

>  #define R9A07G044_OSCCLK               21

> +#define R9A07G044_CLK_P0_DIV2          22

> +#define R9A07G044_LAST_CORE_CLK                23


Third issue: off-by-one error, it should be 22 ;-)

>

>  /* R9A07G044 Module Clocks */

>  #define R9A07G044_CA55_SCLK            0


Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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 Torvalds
Geert Uytterhoeven July 16, 2021, 8:09 a.m. UTC | #3
Hi Prabhakar,

On Thu, Jul 15, 2021 at 8:21 PM Lad Prabhakar
<prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:
> Add entry for fixed core clock P0_DIV2 and assign LAST_DT_CORE_CLK

> to R9A07G044_LAST_CORE_CLK.

>

> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>


Thanks for your patch!

> --- a/drivers/clk/renesas/r9a07g044-cpg.c

> +++ b/drivers/clk/renesas/r9a07g044-cpg.c

> @@ -16,7 +16,7 @@

>

>  enum clk_ids {

>         /* Core Clock Outputs exported to DT */

> -       LAST_DT_CORE_CLK = R9A07G044_OSCCLK,

> +       LAST_DT_CORE_CLK = R9A07G044_LAST_CORE_CLK,


Please use R9A07G044_CLK_P0_DIV2 instead.

>

>         /* External Input Clocks */

>         CLK_EXTAL,

> @@ -77,6 +77,7 @@ static const struct cpg_core_clk r9a07g044_core_clks[] __initconst = {

>         DEF_FIXED("I", R9A07G044_CLK_I, CLK_PLL1, 1, 1),

>         DEF_DIV("P0", R9A07G044_CLK_P0, CLK_PLL2_DIV16, DIVPL2A,

>                 dtable_1_32, CLK_DIVIDER_HIWORD_MASK),

> +       DEF_FIXED("P0_DIV2", R9A07G044_CLK_P0_DIV2, R9A07G044_CLK_P0, 1, 2),

>         DEF_FIXED("TSU", R9A07G044_CLK_TSU, CLK_PLL2_DIV20, 1, 1),

>         DEF_DIV("P1", R9A07G044_CLK_P1, CLK_PLL3_DIV2_4,

>                 DIVPL3B, dtable_1_32, CLK_DIVIDER_HIWORD_MASK),


The rest looks good to me.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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 Torvalds
Lad, Prabhakar July 16, 2021, 8:30 a.m. UTC | #4
Hi Geert,

Thank you for the review.

On Fri, Jul 16, 2021 at 8:38 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>

> Hi Prabhakar,

>

> On Thu, Jul 15, 2021 at 8:21 PM Lad Prabhakar

> <prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:

> > Add CANFD binding documentation for Renesas RZ/G2L SoC.

> >

> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

> > Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>

>

> Thanks for your patch!

>

> > --- a/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml

> > +++ b/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml

>

> > @@ -78,6 +79,38 @@ patternProperties:

> >        node.  Each child node supports the "status" property only, which

> >        is used to enable/disable the respective channel.

> >

> > +if:

> > +  properties:

> > +    compatible:

> > +      contains:

> > +        enum:

> > +          - renesas,rzg2l-canfd

> > +then:

> > +  properties:

> > +    interrupts:

> > +      items:

> > +        - description: CAN global error interrupt

> > +        - description: CAN receive FIFO interrupt

> > +        - description: CAN0 error interrupt

> > +        - description: CAN0 transmit interrupt

> > +        - description: CAN0 transmit/receive FIFO receive completion interrupt

> > +        - description: CAN1 error interrupt

> > +        - description: CAN1 transmit interrupt

> > +        - description: CAN1 transmit/receive FIFO receive completion interrupt

>

> Does it make sense to add interrupt-names?

>

Agreed will drop this and add interrupt-names instead. Also I will
update the driver to pick up the interrupts based on names.

> > +

> > +    resets:

> > +      maxItems: 2

>

> Same here, for reset-names?

> Or a list of descriptions, so we know which reset serves what purpose.

>

OK I'll  add the reset-names.

Cheers,
Prabhakar

> > +

> > +else:

> > +  properties:

> > +    interrupts:

> > +      items:

> > +        - description: Channel interrupt

> > +        - description: Global interrupt

> > +

> > +    resets:

> > +      maxItems: 1

> > +

> >  required:

> >    - compatible

> >    - reg

>

> The rest looks good to me.

>

> Gr{oetje,eeting}s,

>

>                         Geert

>

> --

> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

>

> 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 Torvalds
Lad, Prabhakar July 16, 2021, 8:45 a.m. UTC | #5
Hi Geert,

Thank you for the review.

On Fri, Jul 16, 2021 at 9:08 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>

> Hi Prabhakar,

>

> Thanks for your patch!

>

> On Thu, Jul 15, 2021 at 8:21 PM Lad Prabhakar

> <prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:

> > Add P0_DIV2 core clock required for CANFD module. CANFD core clock is

> > sourced from P0_DIV2 referenced from HW manual Rev.0.50.

>

> OK.

>

> > Also add R9A07G044_LAST_CORE_CLK entry to avoid changes in

> > r9a07g044-cpg.c file.

>

> I'm not so fond of adding this.  Unlike the other definitions, it is

> not really part of the bindings, but merely a convenience definition

> for the driver.  Furthermore it has to change when a new definition

> is ever added.

>

Agreed will drop this.

> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

> > Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>

> > ---

> >  include/dt-bindings/clock/r9a07g044-cpg.h | 2 ++

> >  1 file changed, 2 insertions(+)

> >

> > diff --git a/include/dt-bindings/clock/r9a07g044-cpg.h b/include/dt-bindings/clock/r9a07g044-cpg.h

> > index 0728ad07ff7a..2fd20db0b2f4 100644

> > --- a/include/dt-bindings/clock/r9a07g044-cpg.h

> > +++ b/include/dt-bindings/clock/r9a07g044-cpg.h

> > @@ -30,6 +30,8 @@

> >  #define R9A07G044_CLK_P2               19

> >  #define R9A07G044_CLK_AT               20

> >  #define R9A07G044_OSCCLK               21

> > +#define R9A07G044_CLK_P0_DIV2          22

> > +#define R9A07G044_LAST_CORE_CLK                23

>

> Third issue: off-by-one error, it should be 22 ;-)

>

23 was intentionally as these numbers aren't used for core clock count
we use r9a07g044_core_clks[] instead. Said that I'll drop this.

Cheers,
Prabhakar
> >

> >  /* R9A07G044 Module Clocks */

> >  #define R9A07G044_CA55_SCLK            0

>

> Gr{oetje,eeting}s,

>

>                         Geert

>

>

> --

> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

>

> 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 Torvalds
Lad, Prabhakar July 16, 2021, 8:46 a.m. UTC | #6
Hi Geert,

Thank you for the review.

On Fri, Jul 16, 2021 at 9:09 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>

> Hi Prabhakar,

>

> On Thu, Jul 15, 2021 at 8:21 PM Lad Prabhakar

> <prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:

> > Add entry for fixed core clock P0_DIV2 and assign LAST_DT_CORE_CLK

> > to R9A07G044_LAST_CORE_CLK.

> >

> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

> > Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>

>

> Thanks for your patch!

>

> > --- a/drivers/clk/renesas/r9a07g044-cpg.c

> > +++ b/drivers/clk/renesas/r9a07g044-cpg.c

> > @@ -16,7 +16,7 @@

> >

> >  enum clk_ids {

> >         /* Core Clock Outputs exported to DT */

> > -       LAST_DT_CORE_CLK = R9A07G044_OSCCLK,

> > +       LAST_DT_CORE_CLK = R9A07G044_LAST_CORE_CLK,

>

> Please use R9A07G044_CLK_P0_DIV2 instead.

>

Ok, I will update it.

Cheers,
Prabhakar

> >

> >         /* External Input Clocks */

> >         CLK_EXTAL,

> > @@ -77,6 +77,7 @@ static const struct cpg_core_clk r9a07g044_core_clks[] __initconst = {

> >         DEF_FIXED("I", R9A07G044_CLK_I, CLK_PLL1, 1, 1),

> >         DEF_DIV("P0", R9A07G044_CLK_P0, CLK_PLL2_DIV16, DIVPL2A,

> >                 dtable_1_32, CLK_DIVIDER_HIWORD_MASK),

> > +       DEF_FIXED("P0_DIV2", R9A07G044_CLK_P0_DIV2, R9A07G044_CLK_P0, 1, 2),

> >         DEF_FIXED("TSU", R9A07G044_CLK_TSU, CLK_PLL2_DIV20, 1, 1),

> >         DEF_DIV("P1", R9A07G044_CLK_P1, CLK_PLL3_DIV2_4,

> >                 DIVPL3B, dtable_1_32, CLK_DIVIDER_HIWORD_MASK),

>

> The rest looks good to me.

>

> Gr{oetje,eeting}s,

>

>                         Geert

>

> --

> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

>

> 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 Torvalds
Geert Uytterhoeven July 16, 2021, 8:56 a.m. UTC | #7
Hi Prabhakar,

On Fri, Jul 16, 2021 at 10:45 AM Lad, Prabhakar
<prabhakar.csengg@gmail.com> wrote:
> On Fri, Jul 16, 2021 at 9:08 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:

> > On Thu, Jul 15, 2021 at 8:21 PM Lad Prabhakar

> > <prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:

> > > Add P0_DIV2 core clock required for CANFD module. CANFD core clock is

> > > sourced from P0_DIV2 referenced from HW manual Rev.0.50.

> >

> > OK.

> >

> > > Also add R9A07G044_LAST_CORE_CLK entry to avoid changes in

> > > r9a07g044-cpg.c file.

> >

> > I'm not so fond of adding this.  Unlike the other definitions, it is

> > not really part of the bindings, but merely a convenience definition

> > for the driver.  Furthermore it has to change when a new definition

> > is ever added.

> >

> Agreed will drop this.

>

> > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

> > > Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>

> > > ---

> > >  include/dt-bindings/clock/r9a07g044-cpg.h | 2 ++

> > >  1 file changed, 2 insertions(+)

> > >

> > > diff --git a/include/dt-bindings/clock/r9a07g044-cpg.h b/include/dt-bindings/clock/r9a07g044-cpg.h

> > > index 0728ad07ff7a..2fd20db0b2f4 100644

> > > --- a/include/dt-bindings/clock/r9a07g044-cpg.h

> > > +++ b/include/dt-bindings/clock/r9a07g044-cpg.h

> > > @@ -30,6 +30,8 @@

> > >  #define R9A07G044_CLK_P2               19

> > >  #define R9A07G044_CLK_AT               20

> > >  #define R9A07G044_OSCCLK               21

> > > +#define R9A07G044_CLK_P0_DIV2          22

> > > +#define R9A07G044_LAST_CORE_CLK                23

> >

> > Third issue: off-by-one error, it should be 22 ;-)

> >

> 23 was intentionally as these numbers aren't used for core clock count

> we use r9a07g044_core_clks[] instead.


It ends up as an off-by-one bug in the range check in
rzg2l_cpg_clk_src_twocell_get().

> Said that I'll drop this.


OK.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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 Torvalds
Lad, Prabhakar July 16, 2021, 9:02 a.m. UTC | #8
Hi Geert,

On Fri, Jul 16, 2021 at 9:56 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>

> Hi Prabhakar,

>

> On Fri, Jul 16, 2021 at 10:45 AM Lad, Prabhakar

> <prabhakar.csengg@gmail.com> wrote:

> > On Fri, Jul 16, 2021 at 9:08 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:

> > > On Thu, Jul 15, 2021 at 8:21 PM Lad Prabhakar

> > > <prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:

> > > > Add P0_DIV2 core clock required for CANFD module. CANFD core clock is

> > > > sourced from P0_DIV2 referenced from HW manual Rev.0.50.

> > >

> > > OK.

> > >

> > > > Also add R9A07G044_LAST_CORE_CLK entry to avoid changes in

> > > > r9a07g044-cpg.c file.

> > >

> > > I'm not so fond of adding this.  Unlike the other definitions, it is

> > > not really part of the bindings, but merely a convenience definition

> > > for the driver.  Furthermore it has to change when a new definition

> > > is ever added.

> > >

> > Agreed will drop this.

> >

> > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

> > > > Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>

> > > > ---

> > > >  include/dt-bindings/clock/r9a07g044-cpg.h | 2 ++

> > > >  1 file changed, 2 insertions(+)

> > > >

> > > > diff --git a/include/dt-bindings/clock/r9a07g044-cpg.h b/include/dt-bindings/clock/r9a07g044-cpg.h

> > > > index 0728ad07ff7a..2fd20db0b2f4 100644

> > > > --- a/include/dt-bindings/clock/r9a07g044-cpg.h

> > > > +++ b/include/dt-bindings/clock/r9a07g044-cpg.h

> > > > @@ -30,6 +30,8 @@

> > > >  #define R9A07G044_CLK_P2               19

> > > >  #define R9A07G044_CLK_AT               20

> > > >  #define R9A07G044_OSCCLK               21

> > > > +#define R9A07G044_CLK_P0_DIV2          22

> > > > +#define R9A07G044_LAST_CORE_CLK                23

> > >

> > > Third issue: off-by-one error, it should be 22 ;-)

> > >

> > 23 was intentionally as these numbers aren't used for core clock count

> > we use r9a07g044_core_clks[] instead.

>

> It ends up as an off-by-one bug in the range check in

> rzg2l_cpg_clk_src_twocell_get().

>

Ooops missed that!

Cheers,
Prabhakar

> > Said that I'll drop this.

>

> OK.

>

> Gr{oetje,eeting}s,

>

>                         Geert

>

> --

> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

>

> 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 Torvalds