diff mbox series

[04/14] dt-bindings: dma: add Canaan k210 to Synopsys DesignWare DMA

Message ID 20220618123035.563070-5-mail@conchuod.ie
State New
Headers show
Series Canaan devicetree fixes | expand

Commit Message

Conor Dooley June 18, 2022, 12:30 p.m. UTC
From: Conor Dooley <conor.dooley@microchip.com>

The Canaan k210 apparently has a Sysnopsys Designware AXI DMA
controller, but according to the documentation & devicetree it has 6
interrupts rather than the standard one. Add a custom compatible that
supports the 6 interrupt configuration which falls back to the standard
binding which is currently the one in use in the devicetree entry.

Link: https://canaan-creative.com/wp-content/uploads/2020/03/kendryte_standalone_programming_guide_20190311144158_en.pdf #Page 58
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
---
 .../bindings/dma/snps,dw-axi-dmac.yaml        | 35 ++++++++++++++-----
 1 file changed, 26 insertions(+), 9 deletions(-)

Comments

Conor Dooley June 28, 2022, 6:30 a.m. UTC | #1
On 28/06/2022 00:29, Rob Herring wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On Sat, Jun 18, 2022 at 01:30:26PM +0100, Conor Dooley wrote:
>> From: Conor Dooley <conor.dooley@microchip.com>
>>
>> The Canaan k210 apparently has a Sysnopsys Designware AXI DMA
>> controller, but according to the documentation & devicetree it has 6
>> interrupts rather than the standard one. Add a custom compatible that
>> supports the 6 interrupt configuration which falls back to the standard
>> binding which is currently the one in use in the devicetree entry.
> 
> But it works with only 1 interrupt?

Seemingly...

> 
>>
>> Link: https://canaan-creative.com/wp-content/uploads/2020/03/kendryte_standalone_programming_guide_20190311144158_en.pdf #Page 58
>> Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
>> ---
>>   .../bindings/dma/snps,dw-axi-dmac.yaml        | 35 ++++++++++++++-----
>>   1 file changed, 26 insertions(+), 9 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/dma/snps,dw-axi-dmac.yaml b/Documentation/devicetree/bindings/dma/snps,dw-axi-dmac.yaml
>> index 4324a94b26b2..bc85598151ef 100644
>> --- a/Documentation/devicetree/bindings/dma/snps,dw-axi-dmac.yaml
>> +++ b/Documentation/devicetree/bindings/dma/snps,dw-axi-dmac.yaml
>> @@ -18,9 +18,13 @@ allOf:
>>
>>   properties:
>>     compatible:
>> -    enum:
>> -      - snps,axi-dma-1.01a
>> -      - intel,kmb-axi-dma
>> +    oneOf:
>> +      - items:
>> +          - const: canaan,k210-axi-dma
>> +          - const: snps,axi-dma-1.01a
> 
> I would drop this depending on your need for compatibility. Are you sure
> on the IP version? It's not really compatible if the number of
> interrupts is different.

That's what it has been using until now. Am I sure? No.
Do I have docs to go check against? Unfortunately, also no.
Does it not qualify as a fallback compatible if it supports
a subset of what the hardware does?

> 
>> +      - enum:
>> +          - snps,axi-dma-1.01a
>> +          - intel,kmb-axi-dma
>>
>>     reg:
>>       minItems: 1
>> @@ -33,9 +37,6 @@ properties:
>>         - const: axidma_ctrl_regs
>>         - const: axidma_apb_regs
>>
>> -  interrupts:
>> -    maxItems: 1
>> -
>>     clocks:
>>       items:
>>         - description: Bus Clock
>> @@ -92,6 +93,22 @@ properties:
>>       minimum: 1
>>       maximum: 256
>>
>> +if:
>> +  properties:
>> +    compatible:
>> +      contains:
>> +        const: canaan,k210-axi-dma
>> +
>> +then:
>> +  properties:
>> +    interrupts:
>> +      maxItems: 6
>> +
>> +else:
>> +  properties:
>> +    interrupts:
>> +      maxItems: 1
>> +
>>   required:
>>     - compatible
>>     - reg
>> @@ -105,7 +122,7 @@ required:
>>     - snps,priority
>>     - snps,block-size
>>
>> -additionalProperties: false
>> +unevaluatedProperties: false
>>
>>   examples:
>>     - |
>> @@ -113,12 +130,12 @@ examples:
>>        #include <dt-bindings/interrupt-controller/irq.h>
>>        /* example with snps,dw-axi-dmac */
>>        dmac: dma-controller@80000 {
>> -         compatible = "snps,axi-dma-1.01a";
>> +         compatible = "canaan,k210-axi-dma", "snps,axi-dma-1.01a";
>>            reg = <0x80000 0x400>;
>>            clocks = <&core_clk>, <&cfgr_clk>;
>>            clock-names = "core-clk", "cfgr-clk";
>>            interrupt-parent = <&intc>;
>> -         interrupts = <27>;
>> +         interrupts = <27>, <28>, <29>, <30>, <31>, <32>;
> 
> Does the example really need changing? The old one was correct, right?

:facepalm:, committed my dt_binding_check test
Thanks Rob,
Conor.

> 
>>            #dma-cells = <1>;
>>            dma-channels = <4>;
>>            snps,dma-masters = <2>;
>> --
>> 2.36.1
>>
>>
Geert Uytterhoeven June 28, 2022, 7:08 a.m. UTC | #2
Hi Conor,

On Tue, Jun 28, 2022 at 8:30 AM <Conor.Dooley@microchip.com> wrote:
> On 28/06/2022 00:29, Rob Herring wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> >
> > On Sat, Jun 18, 2022 at 01:30:26PM +0100, Conor Dooley wrote:
> >> From: Conor Dooley <conor.dooley@microchip.com>
> >>
> >> The Canaan k210 apparently has a Sysnopsys Designware AXI DMA
> >> controller, but according to the documentation & devicetree it has 6
> >> interrupts rather than the standard one. Add a custom compatible that
> >> supports the 6 interrupt configuration which falls back to the standard
> >> binding which is currently the one in use in the devicetree entry.
> >
> > But it works with only 1 interrupt?
>
> Seemingly...

The Linux driver uses the only first interrupt.

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
Serge Semin June 28, 2022, 11:04 a.m. UTC | #3
On Tue, Jun 28, 2022 at 09:08:32AM +0200, Geert Uytterhoeven wrote:
> Hi Conor,
> 
> On Tue, Jun 28, 2022 at 8:30 AM <Conor.Dooley@microchip.com> wrote:
> > On 28/06/2022 00:29, Rob Herring wrote:
> > > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> > >
> > > On Sat, Jun 18, 2022 at 01:30:26PM +0100, Conor Dooley wrote:
> > >> From: Conor Dooley <conor.dooley@microchip.com>
> > >>
> > >> The Canaan k210 apparently has a Sysnopsys Designware AXI DMA
> > >> controller, but according to the documentation & devicetree it has 6
> > >> interrupts rather than the standard one. Add a custom compatible that
> > >> supports the 6 interrupt configuration which falls back to the standard
> > >> binding which is currently the one in use in the devicetree entry.
> > >

> > > But it works with only 1 interrupt?
> >
> > Seemingly...
> 
> The Linux driver uses the only first interrupt.

Folks, there v2 of this series. A more suitable and justified solution has
been given there:
Link: https://lore.kernel.org/lkml/20220627213450.ukqai4bsjzcwhnlp@mobilestation/

-Sergey

> 
> 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
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/dma/snps,dw-axi-dmac.yaml b/Documentation/devicetree/bindings/dma/snps,dw-axi-dmac.yaml
index 4324a94b26b2..bc85598151ef 100644
--- a/Documentation/devicetree/bindings/dma/snps,dw-axi-dmac.yaml
+++ b/Documentation/devicetree/bindings/dma/snps,dw-axi-dmac.yaml
@@ -18,9 +18,13 @@  allOf:
 
 properties:
   compatible:
-    enum:
-      - snps,axi-dma-1.01a
-      - intel,kmb-axi-dma
+    oneOf:
+      - items:
+          - const: canaan,k210-axi-dma
+          - const: snps,axi-dma-1.01a
+      - enum:
+          - snps,axi-dma-1.01a
+          - intel,kmb-axi-dma
 
   reg:
     minItems: 1
@@ -33,9 +37,6 @@  properties:
       - const: axidma_ctrl_regs
       - const: axidma_apb_regs
 
-  interrupts:
-    maxItems: 1
-
   clocks:
     items:
       - description: Bus Clock
@@ -92,6 +93,22 @@  properties:
     minimum: 1
     maximum: 256
 
+if:
+  properties:
+    compatible:
+      contains:
+        const: canaan,k210-axi-dma
+
+then:
+  properties:
+    interrupts:
+      maxItems: 6
+
+else:
+  properties:
+    interrupts:
+      maxItems: 1
+
 required:
   - compatible
   - reg
@@ -105,7 +122,7 @@  required:
   - snps,priority
   - snps,block-size
 
-additionalProperties: false
+unevaluatedProperties: false
 
 examples:
   - |
@@ -113,12 +130,12 @@  examples:
      #include <dt-bindings/interrupt-controller/irq.h>
      /* example with snps,dw-axi-dmac */
      dmac: dma-controller@80000 {
-         compatible = "snps,axi-dma-1.01a";
+         compatible = "canaan,k210-axi-dma", "snps,axi-dma-1.01a";
          reg = <0x80000 0x400>;
          clocks = <&core_clk>, <&cfgr_clk>;
          clock-names = "core-clk", "cfgr-clk";
          interrupt-parent = <&intc>;
-         interrupts = <27>;
+         interrupts = <27>, <28>, <29>, <30>, <31>, <32>;
          #dma-cells = <1>;
          dma-channels = <4>;
          snps,dma-masters = <2>;