Messages in this thread | | | Date | Wed, 21 Sep 2022 11:14:10 +0100 | Subject | Re: Similar SoCs with different CPUs and interrupt bindings | From | Robin Murphy <> |
| |
On 2022-09-21 10:26, Krzysztof Kozlowski wrote: > On 21/09/2022 11:20, Lad, Prabhakar wrote: >>> >>> What do you mean? Macros support string concatenation and simple >>> arithmetic like adding numbers. I just tested it. >>> >> I did try the below: >> >> diff --git a/arch/arm64/boot/dts/renesas/r9a07g043.dtsi >> b/arch/arm64/boot/dts/renesas/r9a07g043.dtsi >> index 689aa4ba416b..0f923c276cd3 100644 >> --- a/arch/arm64/boot/dts/renesas/r9a07g043.dtsi >> +++ b/arch/arm64/boot/dts/renesas/r9a07g043.dtsi >> @@ -8,6 +8,8 @@ >> #include <dt-bindings/interrupt-controller/arm-gic.h> >> #include <dt-bindings/clock/r9a07g043-cpg.h> >> >> +#define SOC_PERIPHERAL_IRQ(nr, na) GIC_SPI nr na >> + >> / { >> compatible = "renesas,r9a07g043"; >> #address-cells = <2>; >> @@ -128,7 +130,7 @@ ssi1: ssi@1004a000 { >> compatible = "renesas,r9a07g043-ssi", >> "renesas,rz-ssi"; >> reg = <0 0x1004a000 0 0x400>; >> - interrupts = <GIC_SPI 330 IRQ_TYPE_LEVEL_HIGH>, >> + interrupts = <SOC_PERIPHERAL_IRQ(330, IRQ_TYPE_LEVEL_HIGH)>, >> <GIC_SPI 331 IRQ_TYPE_EDGE_RISING>, >> <GIC_SPI 332 IRQ_TYPE_EDGE_RISING>, >> <GIC_SPI 333 IRQ_TYPE_EDGE_RISING>; >> >> This worked as expected, but couldn't get the arithmetic operation >> working. Could you please provide an example? > > diff --git a/arch/arm64/boot/dts/renesas/r9a07g043.dtsi b/arch/arm64/boot/dts/renesas/r9a07g043.dtsi > index ff6aab388eb7..0ecca775fa3f 100644 > --- a/arch/arm64/boot/dts/renesas/r9a07g043.dtsi > +++ b/arch/arm64/boot/dts/renesas/r9a07g043.dtsi > @@ -8,6 +8,8 @@ > #include <dt-bindings/interrupt-controller/arm-gic.h> > #include <dt-bindings/clock/r9a07g043-cpg.h> > > +#define SOC_PERIPHERAL_IRQ_NUMBER(na) (na + 32) > +#define SOC_PERIPHERAL_IRQ(nr, na) GIC_SPI nr SOC_PERIPHERAL_IRQ_NUMBER(na) > / { > compatible = "renesas,r9a07g043"; > #address-cells = <2>; > @@ -128,7 +130,7 @@ ssi1: ssi@1004a000 { > compatible = "renesas,r9a07g043-ssi", > "renesas,rz-ssi"; > reg = <0 0x1004a000 0 0x400>; > - interrupts = <GIC_SPI 330 IRQ_TYPE_LEVEL_HIGH>, > + interrupts = <SOC_PERIPHERAL_IRQ(330, IRQ_TYPE_LEVEL_HIGH)>, > > > > Or any other method like that....
Which will generate the text:
"interrupts = <GIC_SPI 330 (IRQ_TYPE_LEVEL_HIGH + 32)>,"
(give or take some whitespace)
CPP supports constant expressions in #if and #elif directives, but macros are purely literal text replacement. It might technically be achievable with some insane CPP metaprogramming, but for all practical purposes this is a non-starter unless dtc itself grows the ability to process arithmetic expressions.
Thanks, Robin.
| |