2022-06-27 19:43:11

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 00/16] Canaan devicetree fixes

From: Conor Dooley <[email protected]>

Hey all,
This series should rid us of dtbs_check errors for the RISC-V Canaan k210
based boards. To make keeping it that way a little easier, I changed the
Canaan devicetree Makefile so that it would build all of the devicetrees
in the directory if SOC_CANAAN.

I *DO NOT* have any Canaan hardware so I have not tested any of this in
action. Since I sent v1, I tried to buy some since it's cheap - but could
out of the limited stockists none seemed to want to deliver to Ireland :(
I based the series on next-20220617.

For the bindings, I am never sure about which of {unevaluated,additional}
Properties is correct to use, but the if statements in the binding didn't
work with additional so I used unevaluated...

@Mark, for your ASoC binding I was not sure about the properties that I
made depend on the compatible, but I looked in tree and was not able to
find other users to contradict what's in the Canaan devicetrees nor did
I get that much help from their docs.

@Serge, I dropped your R-b since I changed the enum.

@Rob, <N days ago>'s removal of ilitek,ili9341.txt is moved to ths series
since I was editing the dt-schema binding anyway.

Thanks,
Conor.

Changes since v1:
- I added a new dt node & compatible for the SRAM memory controller due
Damien's wish to preserve the inter-op with U-Boot.
- The dw-apb-ssi binding now uses the default rx/tx widths
- A new patch fixes bus {ranges,reg} warnings
- Rearranged the patches in a slightly more logical order

Conor Dooley (16):
dt-bindings: display: convert ilitek,ili9341.txt to dt-schema
dt-bindings: display: panel: allow ilitek,ili9341 in isolation
ASoC: dt-bindings: convert designware-i2s to dt-schema
spi: dt-bindings: dw-apb-ssi: update spi-{r,t}x-bus-width
dt-bindings: dma: add Canaan k210 to Synopsys DesignWare DMA
dt-bindings: timer: add Canaan k210 to Synopsys DesignWare timer
dt-bindings: memory-controllers: add canaan k210 sram controller
riscv: dts: canaan: fix the k210's memory node.
riscv: dts: canaan: add a specific compatible for k210's dma
riscv: dts: canaan: add a specific compatible for k210's timers
riscv: dts: canaan: fix mmc node names
riscv: dts: canaan: fix kd233 display spi frequency
riscv: dts: canaan: use custom compatible for k210 i2s
riscv: dts: canaan: remove spi-max-frequency from controllers
riscv: dts: canaan: fix bus {ranges,reg} warnings
riscv: dts: canaan: build all devicetress if SOC_CANAAN

.../bindings/display/ilitek,ili9341.txt | 27 ------
.../display/panel/ilitek,ili9341.yaml | 60 ++++++++----
.../bindings/dma/snps,dw-axi-dmac.yaml | 35 +++++--
.../memory-controllers/canaan,k210-sram.yaml | 53 +++++++++++
.../bindings/sound/designware-i2s.txt | 35 -------
.../bindings/sound/snps,designware-i2s.yaml | 93 +++++++++++++++++++
.../bindings/spi/snps,dw-apb-ssi.yaml | 6 --
.../bindings/timer/snps,dw-apb-timer.yaml | 28 ++++--
arch/riscv/boot/dts/canaan/Makefile | 10 +-
arch/riscv/boot/dts/canaan/canaan_kd233.dts | 4 +-
arch/riscv/boot/dts/canaan/k210.dtsi | 38 ++++----
.../riscv/boot/dts/canaan/sipeed_maix_bit.dts | 2 +-
.../boot/dts/canaan/sipeed_maix_dock.dts | 2 +-
arch/riscv/boot/dts/canaan/sipeed_maix_go.dts | 2 +-
.../boot/dts/canaan/sipeed_maixduino.dts | 2 +-
15 files changed, 269 insertions(+), 128 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/display/ilitek,ili9341.txt
create mode 100644 Documentation/devicetree/bindings/memory-controllers/canaan,k210-sram.yaml
delete mode 100644 Documentation/devicetree/bindings/sound/designware-i2s.txt
create mode 100644 Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml

--
2.36.1


2022-06-27 19:43:36

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 03/16] ASoC: dt-bindings: convert designware-i2s to dt-schema

From: Conor Dooley <[email protected]>

Convert the Synopsys DesignWare I2S controller binding to dt-schema.
There was no listed maintainer but Jose Abreu was the last editor of the
txt binding so add him as maintainer.

Signed-off-by: Conor Dooley <[email protected]>
---
.../bindings/sound/designware-i2s.txt | 35 -------
.../bindings/sound/snps,designware-i2s.yaml | 93 +++++++++++++++++++
2 files changed, 93 insertions(+), 35 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/sound/designware-i2s.txt
create mode 100644 Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml

diff --git a/Documentation/devicetree/bindings/sound/designware-i2s.txt b/Documentation/devicetree/bindings/sound/designware-i2s.txt
deleted file mode 100644
index 6a536d570e29..000000000000
--- a/Documentation/devicetree/bindings/sound/designware-i2s.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-DesignWare I2S controller
-
-Required properties:
- - compatible : Must be "snps,designware-i2s"
- - reg : Must contain the I2S core's registers location and length
- - clocks : Pairs of phandle and specifier referencing the controller's
- clocks. The controller expects one clock: the clock used as the sampling
- rate reference clock sample.
- - clock-names : "i2sclk" for the sample rate reference clock.
- - dmas: Pairs of phandle and specifier for the DMA channels that are used by
- the core. The core expects one or two dma channels: one for transmit and
- one for receive.
- - dma-names : "tx" for the transmit channel, "rx" for the receive channel.
-
-Optional properties:
- - interrupts: The interrupt line number for the I2S controller. Add this
- parameter if the I2S controller that you are using does not support DMA.
-
-For more details on the 'dma', 'dma-names', 'clock' and 'clock-names'
-properties please check:
- * resource-names.txt
- * clock/clock-bindings.txt
- * dma/dma.txt
-
-Example:
-
- soc_i2s: i2s@7ff90000 {
- compatible = "snps,designware-i2s";
- reg = <0x0 0x7ff90000 0x0 0x1000>;
- clocks = <&scpi_i2sclk 0>;
- clock-names = "i2sclk";
- #sound-dai-cells = <0>;
- dmas = <&dma0 5>;
- dma-names = "tx";
- };
diff --git a/Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml b/Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml
new file mode 100644
index 000000000000..5ac9c00157bf
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml
@@ -0,0 +1,93 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/snps,designware-i2s.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: DesignWare I2S controller
+
+maintainers:
+ - Jose Abreu <[email protected]>
+
+properties:
+ compatible:
+ oneOf:
+ - items:
+ - const: canaan,k210-i2s
+ - const: snps,designware-i2s
+ - enum:
+ - snps,designware-i2s
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ description: |
+ The interrupt line number for the I2S controller. Add this
+ parameter if the I2S controller that you are using does not
+ support DMA.
+ maxItems: 1
+
+ clocks:
+ description: Sampling rate reference clock
+
+ clock-names:
+ const: i2sclk
+
+ resets:
+ maxItems: 1
+
+ dmas:
+ items:
+ - description: TX DMA Channel
+ - description: RX DMA Channel
+ minItems: 1
+
+ dma-names:
+ items:
+ - const: tx
+ - const: rx
+ minItems: 1
+
+if:
+ properties:
+ compatible:
+ contains:
+ const: canaan,k210-i2s
+
+then:
+ properties:
+ "#sound-dai-cells":
+ const: 1
+
+else:
+ properties:
+ "#sound-dai-cells":
+ const: 0
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+
+oneOf:
+ - required:
+ - dmas
+ - dma-names
+ - required:
+ - interrupts
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ soc_i2s: i2s@7ff90000 {
+ compatible = "snps,designware-i2s";
+ reg = <0x7ff90000 0x1000>;
+ clocks = <&scpi_i2sclk 0>;
+ clock-names = "i2sclk";
+ #sound-dai-cells = <0>;
+ dmas = <&dma0 5>;
+ dma-names = "tx";
+ };
--
2.36.1

2022-06-27 19:43:37

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 06/16] dt-bindings: timer: add Canaan k210 to Synopsys DesignWare timer

From: Conor Dooley <[email protected]>

The Canaan k210 apparently has a Sysnopsys Designware timer but
according to the documentation & devicetree it has 2 interrupts rather
than the standard one. Add a custom compatible that supports the 2
interrupt configuration and 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 <[email protected]>
---
.../bindings/timer/snps,dw-apb-timer.yaml | 28 +++++++++++++++----
1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/timer/snps,dw-apb-timer.yaml b/Documentation/devicetree/bindings/timer/snps,dw-apb-timer.yaml
index d33c9205a909..9a76acc7a66f 100644
--- a/Documentation/devicetree/bindings/timer/snps,dw-apb-timer.yaml
+++ b/Documentation/devicetree/bindings/timer/snps,dw-apb-timer.yaml
@@ -12,6 +12,9 @@ maintainers:
properties:
compatible:
oneOf:
+ - items:
+ - const: canaan,k210-apb-timer
+ - const: snps,dw-apb-timer
- const: snps,dw-apb-timer
- enum:
- snps,dw-apb-timer-sp
@@ -21,9 +24,6 @@ properties:
reg:
maxItems: 1

- interrupts:
- maxItems: 1
-
resets:
maxItems: 1

@@ -41,7 +41,23 @@ properties:

clock-frequency: true

-additionalProperties: false
+unevaluatedProperties: false
+
+if:
+ properties:
+ compatible:
+ contains:
+ const: canaan,k210-apb-timer
+
+then:
+ properties:
+ interrupts:
+ maxItems: 2
+
+else:
+ properties:
+ interrupts:
+ maxItems: 1

required:
- compatible
@@ -60,8 +76,8 @@ oneOf:
examples:
- |
timer@ffe00000 {
- compatible = "snps,dw-apb-timer";
- interrupts = <0 170 4>;
+ compatible = "canaan,k210-apb-timer", "snps,dw-apb-timer";
+ interrupts = <0 170 4>, <0 170 4>;
reg = <0xffe00000 0x1000>;
clocks = <&timer_clk>, <&timer_pclk>;
clock-names = "timer", "pclk";
--
2.36.1

2022-06-27 19:43:37

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 04/16] spi: dt-bindings: dw-apb-ssi: update spi-{r,t}x-bus-width

From: Conor Dooley <[email protected]>

Most users of dw-apb-ssi use spi-{r,t}x-bus-width of 1, however the
Canaan k210 is wired up for a width of 4.
Quoting Serge:
The modern DW APB SSI controllers of v.4.* and newer also support the
enhanced SPI Modes too (Dual, Quad and Octal). Since the IP-core
version is auto-detected at run-time there is no way to create a
DT-schema correctly constraining the Rx/Tx SPI bus widths.
/endquote

As such, drop the restriction on only supporting a bus width of 1.

Link: https://lore.kernel.org/all/20220620205654.g7fyipwytbww5757@mobilestation/
Signed-off-by: Conor Dooley <[email protected]>
---
Serge, I dropped your R-b when I swapped to the default
property since it changed the enum.
---
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml | 6 ------
1 file changed, 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
index e25d44c218f2..0a43d6e0ef91 100644
--- a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
+++ b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
@@ -143,12 +143,6 @@ patternProperties:
minimum: 0
maximum: 3

- spi-rx-bus-width:
- const: 1
-
- spi-tx-bus-width:
- const: 1
-
unevaluatedProperties: false

required:
--
2.36.1

2022-06-27 19:43:37

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 09/16] riscv: dts: canaan: add a specific compatible for k210's dma

From: Conor Dooley <[email protected]>

The DMAC on the k210 has a non standard interrupt configuration, which
leads to dtbs_check warnings:

k210_generic.dtb: dma-controller@50000000: interrupts: [[27], [28], [29], [30], [31], [32]] is too long
From schema: Documentation/devicetree/bindings/dma/snps,dw-axi-dmac.yaml

Update the binding to use a custom compatible to avoid the warning.

Signed-off-by: Conor Dooley <[email protected]>
---
arch/riscv/boot/dts/canaan/k210.dtsi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/boot/dts/canaan/k210.dtsi b/arch/riscv/boot/dts/canaan/k210.dtsi
index cd4eae82d8b2..45ccab36618a 100644
--- a/arch/riscv/boot/dts/canaan/k210.dtsi
+++ b/arch/riscv/boot/dts/canaan/k210.dtsi
@@ -143,7 +143,7 @@ gpio0: gpio-controller@38001000 {
};

dmac0: dma-controller@50000000 {
- compatible = "snps,axi-dma-1.01a";
+ compatible = "canaan,k210-axi-dma", "snps,axi-dma-1.01a";
reg = <0x50000000 0x1000>;
interrupts = <27>, <28>, <29>, <30>, <31>, <32>;
#dma-cells = <1>;
--
2.36.1

2022-06-27 19:43:37

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 02/16] dt-bindings: display: panel: allow ilitek,ili9341 in isolation

From: Conor Dooley <[email protected]>

The dt-binding for the ilitek,ili9341 does not allow it to be used as a
compatible in isolation. This generates a warning for the Canaan kd233
devicetree:
arch/riscv/boot/dts/canaan/canaan_kd233.dtb: panel@0: compatible:0: 'ilitek,ili9341' is not one of ['st,sf-tc240t-9370-t']
From schema: Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml
arch/riscv/boot/dts/canaan/canaan_kd233.dtb: panel@0: compatible: ['ilitek,ili9341'] is too short
From schema: Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml
Allow ilitek,ili9341 to be selected in isolation.

Signed-off-by: Conor Dooley <[email protected]>
---
.../bindings/display/panel/ilitek,ili9341.yaml | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml b/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml
index 94ca92878434..c402bedaa37a 100644
--- a/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml
+++ b/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml
@@ -19,12 +19,14 @@ allOf:

properties:
compatible:
- items:
- - enum:
- # ili9341 240*320 Color on stm32f429-disco board
- - st,sf-tc240t-9370-t
- - adafruit,yx240qv29
- - const: ilitek,ili9341
+ oneOf:
+ - items:
+ - const: ilitek,ili9341
+ - items:
+ - enum:
+ - st,sf-tc240t-9370-t
+ - adafruit,yx240qv29
+ - const: ilitek,ili9341

reg: true

--
2.36.1

2022-06-27 19:44:30

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 10/16] riscv: dts: canaan: add a specific compatible for k210's timers

From: Conor Dooley <[email protected]>

The timers on the k210 have non standard interrupt configurations,
which leads to dtbs_check warnings:

k210_generic.dtb: timer@502d0000: interrupts: [[14], [15]] is too long
From schema: Documentation/devicetree/bindings/timer/snps,dw-apb-timer.yaml

Change to using the newly added canaan k210 specific binding to avoid
the warning.

Signed-off-by: Conor Dooley <[email protected]>
---
arch/riscv/boot/dts/canaan/k210.dtsi | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/boot/dts/canaan/k210.dtsi b/arch/riscv/boot/dts/canaan/k210.dtsi
index 45ccab36618a..be42c56e770c 100644
--- a/arch/riscv/boot/dts/canaan/k210.dtsi
+++ b/arch/riscv/boot/dts/canaan/k210.dtsi
@@ -318,7 +318,7 @@ fpioa: pinmux@502b0000 {
};

timer0: timer@502d0000 {
- compatible = "snps,dw-apb-timer";
+ compatible = "canaan,k210-apb-timer", "snps,dw-apb-timer";
reg = <0x502D0000 0x100>;
interrupts = <14>, <15>;
clocks = <&sysclk K210_CLK_TIMER0>,
@@ -328,7 +328,7 @@ timer0: timer@502d0000 {
};

timer1: timer@502e0000 {
- compatible = "snps,dw-apb-timer";
+ compatible = "canaan,k210-apb-timer", "snps,dw-apb-timer";
reg = <0x502E0000 0x100>;
interrupts = <16>, <17>;
clocks = <&sysclk K210_CLK_TIMER1>,
@@ -338,7 +338,7 @@ timer1: timer@502e0000 {
};

timer2: timer@502f0000 {
- compatible = "snps,dw-apb-timer";
+ compatible = "canaan,k210-apb-timer", "snps,dw-apb-timer";
reg = <0x502F0000 0x100>;
interrupts = <18>, <19>;
clocks = <&sysclk K210_CLK_TIMER2>,
--
2.36.1

2022-06-27 19:44:46

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 08/16] riscv: dts: canaan: fix the k210's memory node.

From: Conor Dooley <[email protected]>

The k210 U-Boot port has been using the clocks defined in the
devicetree to bring up the board's SRAM, but this violates the
dt-schema. As such, move the clocks to a dedicated node with
the same compatible string. The regs property does not fit in
either node, so is replaced by comments.

Signed-off-by: Conor Dooley <[email protected]>
---
The corresponding U-Boot code seems to be:
static int sram_init(void)
{
int ret, i;
const char * const banks[] = { "sram0", "sram1", "aisram" };
ofnode memory;
struct clk clk;

/* Enable RAM clocks */
memory = ofnode_by_compatible(ofnode_null(), "canaan,k210-sram");
if (ofnode_equal(memory, ofnode_null()))
return -ENOENT;

for (i = 0; i < ARRAY_SIZE(banks); i++) {
ret = clk_get_by_name_nodev(memory, banks[i], &clk);
if (ret)
continue;

ret = clk_enable(&clk);
clk_free(&clk);
if (ret)
return ret;
}

return 0;
}

Which, without having the hardware etc, I suspect is likely to keep
working after the move.
---
arch/riscv/boot/dts/canaan/k210.dtsi | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/riscv/boot/dts/canaan/k210.dtsi b/arch/riscv/boot/dts/canaan/k210.dtsi
index 44d338514761..cd4eae82d8b2 100644
--- a/arch/riscv/boot/dts/canaan/k210.dtsi
+++ b/arch/riscv/boot/dts/canaan/k210.dtsi
@@ -69,11 +69,13 @@ cpu1_intc: interrupt-controller {

sram: memory@80000000 {
device_type = "memory";
+ reg = <0x80000000 0x400000>, /* sram0 4 MiB */
+ <0x80400000 0x200000>, /* sram1 2 MiB */
+ <0x80600000 0x200000>; /* aisram 2 MiB */
+ };
+
+ sram_controller: memory-controller {
compatible = "canaan,k210-sram";
- reg = <0x80000000 0x400000>,
- <0x80400000 0x200000>,
- <0x80600000 0x200000>;
- reg-names = "sram0", "sram1", "aisram";
clocks = <&sysclk K210_CLK_SRAM0>,
<&sysclk K210_CLK_SRAM1>,
<&sysclk K210_CLK_AI>;
--
2.36.1

2022-06-27 19:45:17

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 14/16] riscv: dts: canaan: remove spi-max-frequency from controllers

From: Conor Dooley <[email protected]>

spi-max-frequency is a device, not a controller property and should be
removed.

Link: https://lore.kernel.org/lkml/[email protected]/
Signed-off-by: Conor Dooley <[email protected]>
---
arch/riscv/boot/dts/canaan/k210.dtsi | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/riscv/boot/dts/canaan/k210.dtsi b/arch/riscv/boot/dts/canaan/k210.dtsi
index 10c2a1417deb..84a7ab363d72 100644
--- a/arch/riscv/boot/dts/canaan/k210.dtsi
+++ b/arch/riscv/boot/dts/canaan/k210.dtsi
@@ -421,7 +421,6 @@ spi0: spi@52000000 {
clock-names = "ssi_clk", "pclk";
resets = <&sysrst K210_RST_SPI0>;
reset-names = "spi";
- spi-max-frequency = <25000000>;
num-cs = <4>;
reg-io-width = <4>;
};
@@ -437,7 +436,6 @@ spi1: spi@53000000 {
clock-names = "ssi_clk", "pclk";
resets = <&sysrst K210_RST_SPI1>;
reset-names = "spi";
- spi-max-frequency = <25000000>;
num-cs = <4>;
reg-io-width = <4>;
};
@@ -453,8 +451,7 @@ spi3: spi@54000000 {
clock-names = "ssi_clk", "pclk";
resets = <&sysrst K210_RST_SPI3>;
reset-names = "spi";
- /* Could possibly go up to 200 MHz */
- spi-max-frequency = <100000000>;
+
num-cs = <4>;
reg-io-width = <4>;
};
--
2.36.1

2022-06-27 19:55:16

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 05/16] dt-bindings: dma: add Canaan k210 to Synopsys DesignWare DMA

From: Conor Dooley <[email protected]>

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 <[email protected]>
---
.../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
+ - 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>;
--
2.36.1

2022-06-27 19:55:37

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 12/16] riscv: dts: canaan: fix kd233 display spi frequency

From: Conor Dooley <[email protected]>

The binding for the ili9341 specifies a const spi-max-frequency of 10
MHz but the kd233 devicetree entry has it listed at 15 Mhz.
Align the devicetree with the value in the binding.

Signed-off-by: Conor Dooley <[email protected]>
---
arch/riscv/boot/dts/canaan/canaan_kd233.dts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/boot/dts/canaan/canaan_kd233.dts b/arch/riscv/boot/dts/canaan/canaan_kd233.dts
index 40992d495aa8..4a540158f287 100644
--- a/arch/riscv/boot/dts/canaan/canaan_kd233.dts
+++ b/arch/riscv/boot/dts/canaan/canaan_kd233.dts
@@ -130,7 +130,7 @@ panel@0 {
compatible = "ilitek,ili9341";
reg = <0>;
dc-gpios = <&gpio0 21 GPIO_ACTIVE_HIGH>;
- spi-max-frequency = <15000000>;
+ spi-max-frequency = <10000000>;
status = "disabled";
};
};
--
2.36.1

2022-06-27 19:55:48

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 13/16] riscv: dts: canaan: use custom compatible for k210 i2s

From: Conor Dooley <[email protected]>

The devicetrees using the Canaan k210 all have a sound-dai-cells value
of 1, whereas the standard binding example for the DesignWare i2s and
other use cases suggest 0. Use a k210 specific compatible which
supports this difference.

Signed-off-by: Conor Dooley <[email protected]>
---
arch/riscv/boot/dts/canaan/k210.dtsi | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/boot/dts/canaan/k210.dtsi b/arch/riscv/boot/dts/canaan/k210.dtsi
index be42c56e770c..10c2a1417deb 100644
--- a/arch/riscv/boot/dts/canaan/k210.dtsi
+++ b/arch/riscv/boot/dts/canaan/k210.dtsi
@@ -251,7 +251,7 @@ spi2: spi@50240000 {
};

i2s0: i2s@50250000 {
- compatible = "snps,designware-i2s";
+ compatible = "canaan,k210-i2s", "snps,designware-i2s";
reg = <0x50250000 0x200>;
interrupts = <5>;
clocks = <&sysclk K210_CLK_I2S0>;
@@ -260,7 +260,7 @@ i2s0: i2s@50250000 {
};

i2s1: i2s@50260000 {
- compatible = "snps,designware-i2s";
+ compatible = "canaan,k210-i2s", "snps,designware-i2s";
reg = <0x50260000 0x200>;
interrupts = <6>;
clocks = <&sysclk K210_CLK_I2S1>;
@@ -269,7 +269,7 @@ i2s1: i2s@50260000 {
};

i2s2: i2s@50270000 {
- compatible = "snps,designware-i2s";
+ compatible = "canaan,k210-i2s", "snps,designware-i2s";
reg = <0x50270000 0x200>;
interrupts = <7>;
clocks = <&sysclk K210_CLK_I2S2>;
--
2.36.1

2022-06-27 19:57:35

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 01/16] dt-bindings: display: convert ilitek,ili9341.txt to dt-schema

From: Conor Dooley <[email protected]>

A dt-schema binding for the Ilitek ili9341 was created as
panel/ilitek,ili9341.yaml but the txt binding was ignored in the
process. Move the remaining items in the txt binding to the yaml one &
delete it.

The example in the txt binding has a spi-max-frequency which disagrees
with the yaml replacement (and its own documentation) so change that to
conform with the binding. There are no users in tree of the Adafruit
yx240qv29 to check against.

Link: https://cdn-learn.adafruit.com/assets/assets/000/046/879/original/SPEC-YX240QV29-T_Rev.A__1_.pdf
Signed-off-by: Conor Dooley <[email protected]>
---
.../bindings/display/ilitek,ili9341.txt | 27 -----------
.../display/panel/ilitek,ili9341.yaml | 48 +++++++++++++------
2 files changed, 34 insertions(+), 41 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/display/ilitek,ili9341.txt

diff --git a/Documentation/devicetree/bindings/display/ilitek,ili9341.txt b/Documentation/devicetree/bindings/display/ilitek,ili9341.txt
deleted file mode 100644
index 169b32e4ee4e..000000000000
--- a/Documentation/devicetree/bindings/display/ilitek,ili9341.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-Ilitek ILI9341 display panels
-
-This binding is for display panels using an Ilitek ILI9341 controller in SPI
-mode.
-
-Required properties:
-- compatible: "adafruit,yx240qv29", "ilitek,ili9341"
-- dc-gpios: D/C pin
-- reset-gpios: Reset pin
-
-The node for this driver must be a child node of a SPI controller, hence
-all mandatory properties described in ../spi/spi-bus.txt must be specified.
-
-Optional properties:
-- rotation: panel rotation in degrees counter clockwise (0,90,180,270)
-- backlight: phandle of the backlight device attached to the panel
-
-Example:
- display@0{
- compatible = "adafruit,yx240qv29", "ilitek,ili9341";
- reg = <0>;
- spi-max-frequency = <32000000>;
- dc-gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
- reset-gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
- rotation = <270>;
- backlight = <&backlight>;
- };
diff --git a/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml b/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml
index 6058948a9764..94ca92878434 100644
--- a/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml
+++ b/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml
@@ -23,6 +23,7 @@ properties:
- enum:
# ili9341 240*320 Color on stm32f429-disco board
- st,sf-tc240t-9370-t
+ - adafruit,yx240qv29
- const: ilitek,ili9341

reg: true
@@ -47,31 +48,50 @@ properties:
vddi-led-supply:
description: Voltage supply for the LED driver (1.65 .. 3.3 V)

-additionalProperties: false
+unevaluatedProperties: false

required:
- compatible
- reg
- dc-gpios
- - port
+
+if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - st,sf-tc240t-9370-t
+then:
+ required:
+ - port

examples:
- |+
+ #include <dt-bindings/gpio/gpio.h>
spi {
#address-cells = <1>;
#size-cells = <0>;
panel: display@0 {
- compatible = "st,sf-tc240t-9370-t",
- "ilitek,ili9341";
- reg = <0>;
- spi-3wire;
- spi-max-frequency = <10000000>;
- dc-gpios = <&gpiod 13 0>;
- port {
- panel_in: endpoint {
- remote-endpoint = <&display_out>;
- };
- };
- };
+ compatible = "st,sf-tc240t-9370-t",
+ "ilitek,ili9341";
+ reg = <0>;
+ spi-3wire;
+ spi-max-frequency = <10000000>;
+ dc-gpios = <&gpiod 13 0>;
+ port {
+ panel_in: endpoint {
+ remote-endpoint = <&display_out>;
+ };
+ };
+ };
+ display@1{
+ compatible = "adafruit,yx240qv29", "ilitek,ili9341";
+ reg = <1>;
+ spi-max-frequency = <10000000>;
+ dc-gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
+ rotation = <270>;
+ backlight = <&backlight>;
};
+ };
...
--
2.36.1

2022-06-27 20:10:24

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 16/16] riscv: dts: canaan: build all devicetress if SOC_CANAAN

From: Conor Dooley <[email protected]>

Testing & checking the Canaan devicetrees is inconvenient as only the
devicetree corresponding to SOC_CANAAN_K210_DTB_BUILTIN will be built.
Change the Makefile so that all devicetrees are built by default if
SOC_CANAAN but only the one specified by SOC_CANAAN_K210_DTB_BUILTIN
gets built as an object.

Signed-off-by: Conor Dooley <[email protected]>
---
arch/riscv/boot/dts/canaan/Makefile | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/boot/dts/canaan/Makefile b/arch/riscv/boot/dts/canaan/Makefile
index c61b08ac8554..befe4eb7527b 100644
--- a/arch/riscv/boot/dts/canaan/Makefile
+++ b/arch/riscv/boot/dts/canaan/Makefile
@@ -1,3 +1,9 @@
# SPDX-License-Identifier: GPL-2.0
-dtb-$(CONFIG_SOC_CANAAN_K210_DTB_BUILTIN) += $(addsuffix .dtb, $(CONFIG_SOC_CANAAN_K210_DTB_SOURCE))
-obj-$(CONFIG_SOC_CANAAN_K210_DTB_BUILTIN) += $(addsuffix .o, $(dtb-y))
+dtb-$(CONFIG_SOC_CANAAN) += canaan_kd233.dtb
+dtb-$(CONFIG_SOC_CANAAN) += k210_generic.dtb
+dtb-$(CONFIG_SOC_CANAAN) += sipeed_maix_bit.dtb
+dtb-$(CONFIG_SOC_CANAAN) += sipeed_maix_dock.dtb
+dtb-$(CONFIG_SOC_CANAAN) += sipeed_maix_go.dtb
+dtb-$(CONFIG_SOC_CANAAN) += sipeed_maixduino.dtb
+
+obj-$(CONFIG_SOC_CANAAN_K210_DTB_BUILTIN) += $(addsuffix .dtb.o, $(CONFIG_SOC_CANAAN_K210_DTB_SOURCE))
--
2.36.1

2022-06-27 20:10:40

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 07/16] dt-bindings: memory-controllers: add canaan k210 sram controller

From: Conor Dooley <[email protected]>

The k210 U-Boot port has been using the clocks defined in the
devicetree to bring up the board's SRAM, but this violates the
dt-schema. As such, move the clocks to a dedicated node with
the same compatible string & document it.

Signed-off-by: Conor Dooley <[email protected]>
---
I made myself maintainer since I didn't have anywhere else
to point a finger, but I am happy to let someone else take
that on!

The corresponding U-Boot code seems to be:
static int sram_init(void)
{
int ret, i;
const char * const banks[] = { "sram0", "sram1", "aisram" };
ofnode memory;
struct clk clk;

/* Enable RAM clocks */
memory = ofnode_by_compatible(ofnode_null(), "canaan,k210-sram");
if (ofnode_equal(memory, ofnode_null()))
return -ENOENT;

for (i = 0; i < ARRAY_SIZE(banks); i++) {
ret = clk_get_by_name_nodev(memory, banks[i], &clk);
if (ret)
continue;

ret = clk_enable(&clk);
clk_free(&clk);
if (ret)
return ret;
}

return 0;
}

Which, without having the hardware etc, I suspect is likely to keep
working after the move.
---
.../memory-controllers/canaan,k210-sram.yaml | 53 +++++++++++++++++++
1 file changed, 53 insertions(+)
create mode 100644 Documentation/devicetree/bindings/memory-controllers/canaan,k210-sram.yaml

diff --git a/Documentation/devicetree/bindings/memory-controllers/canaan,k210-sram.yaml b/Documentation/devicetree/bindings/memory-controllers/canaan,k210-sram.yaml
new file mode 100644
index 000000000000..837eb65854fc
--- /dev/null
+++ b/Documentation/devicetree/bindings/memory-controllers/canaan,k210-sram.yaml
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/memory-controllers/canaan,k210-sram.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Canaan K210 SRAM memory controller
+
+description: |
+ The Canaan K210 SRAM memory controller is initialised and programmed by
+ firmware, but an OS might want to read its registers for error reporting
+ purposes and to learn about the DRAM topology.
+
+maintainers:
+ - Conor Dooley <[email protected]>
+
+properties:
+ compatible:
+ enum:
+ - canaan,k210-sram
+
+ clocks:
+ minItems: 1
+ items:
+ - description: sram0 clock
+ - description: sram1 clock
+ - description: aisram clock
+
+ clock-names:
+ minItems: 1
+ items:
+ - const: sram0
+ - const: sram1
+ - const: aisram
+
+required:
+ - compatible
+ - clocks
+ - clock-names
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/k210-clk.h>
+ memory-controller {
+ compatible = "canaan,k210-sram";
+ clocks = <&sysclk K210_CLK_SRAM0>,
+ <&sysclk K210_CLK_SRAM1>,
+ <&sysclk K210_CLK_AI>;
+ clock-names = "sram0", "sram1", "aisram";
+ };
+
--
2.36.1

2022-06-27 20:23:05

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 11/16] riscv: dts: canaan: fix mmc node names

From: Conor Dooley <[email protected]>

The newly-converted-to-dt-schema binding expects the mmc node name to be
'^mmc(@.*)?$' so align the devicetree with the schema.

Signed-off-by: Conor Dooley <[email protected]>
---
arch/riscv/boot/dts/canaan/canaan_kd233.dts | 2 +-
arch/riscv/boot/dts/canaan/sipeed_maix_bit.dts | 2 +-
arch/riscv/boot/dts/canaan/sipeed_maix_dock.dts | 2 +-
arch/riscv/boot/dts/canaan/sipeed_maix_go.dts | 2 +-
arch/riscv/boot/dts/canaan/sipeed_maixduino.dts | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/riscv/boot/dts/canaan/canaan_kd233.dts b/arch/riscv/boot/dts/canaan/canaan_kd233.dts
index 039b92abf046..40992d495aa8 100644
--- a/arch/riscv/boot/dts/canaan/canaan_kd233.dts
+++ b/arch/riscv/boot/dts/canaan/canaan_kd233.dts
@@ -142,7 +142,7 @@ &spi1 {
cs-gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
status = "okay";

- slot@0 {
+ mmc@0 {
compatible = "mmc-spi-slot";
reg = <0>;
voltage-ranges = <3300 3300>;
diff --git a/arch/riscv/boot/dts/canaan/sipeed_maix_bit.dts b/arch/riscv/boot/dts/canaan/sipeed_maix_bit.dts
index b9e30df127fe..5e809d0e11fb 100644
--- a/arch/riscv/boot/dts/canaan/sipeed_maix_bit.dts
+++ b/arch/riscv/boot/dts/canaan/sipeed_maix_bit.dts
@@ -189,7 +189,7 @@ &spi1 {
cs-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
status = "okay";

- slot@0 {
+ mmc@0 {
compatible = "mmc-spi-slot";
reg = <0>;
voltage-ranges = <3300 3300>;
diff --git a/arch/riscv/boot/dts/canaan/sipeed_maix_dock.dts b/arch/riscv/boot/dts/canaan/sipeed_maix_dock.dts
index 8d23401b0bbb..4be5ffac6b4a 100644
--- a/arch/riscv/boot/dts/canaan/sipeed_maix_dock.dts
+++ b/arch/riscv/boot/dts/canaan/sipeed_maix_dock.dts
@@ -191,7 +191,7 @@ &spi1 {
cs-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
status = "okay";

- slot@0 {
+ mmc@0 {
compatible = "mmc-spi-slot";
reg = <0>;
voltage-ranges = <3300 3300>;
diff --git a/arch/riscv/boot/dts/canaan/sipeed_maix_go.dts b/arch/riscv/boot/dts/canaan/sipeed_maix_go.dts
index 24fd83b43d9d..5c63f79b18ec 100644
--- a/arch/riscv/boot/dts/canaan/sipeed_maix_go.dts
+++ b/arch/riscv/boot/dts/canaan/sipeed_maix_go.dts
@@ -199,7 +199,7 @@ &spi1 {
cs-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
status = "okay";

- slot@0 {
+ mmc@0 {
compatible = "mmc-spi-slot";
reg = <0>;
voltage-ranges = <3300 3300>;
diff --git a/arch/riscv/boot/dts/canaan/sipeed_maixduino.dts b/arch/riscv/boot/dts/canaan/sipeed_maixduino.dts
index 25341f38292a..59f7eaf74655 100644
--- a/arch/riscv/boot/dts/canaan/sipeed_maixduino.dts
+++ b/arch/riscv/boot/dts/canaan/sipeed_maixduino.dts
@@ -164,7 +164,7 @@ &spi1 {
cs-gpios = <&gpio1_0 2 GPIO_ACTIVE_LOW>;
status = "okay";

- slot@0 {
+ mmc@0 {
compatible = "mmc-spi-slot";
reg = <0>;
voltage-ranges = <3300 3300>;
--
2.36.1

2022-06-27 20:27:22

by Conor Dooley

[permalink] [raw]
Subject: [PATCH v2 15/16] riscv: dts: canaan: fix bus {ranges,reg} warnings

From: Conor Dooley <[email protected]>

The k210 devicetrees warn about missing/empty reg and/or ranges
properties:
arch/riscv/boot/dts/canaan/k210.dtsi:408.22-460.5: Warning (unit_address_vs_reg): /soc/bus@52000000: node has a unit name, but no reg or ranges property
arch/riscv/boot/dts/canaan/k210.dtsi:352.22-406.5: Warning (simple_bus_reg): /soc/bus@50400000: missing or empty reg/ranges property

Add reg and ranges properties that naively cap the buses after the
allocation of their last devices.

Signed-off-by: Conor Dooley <[email protected]>
---
arch/riscv/boot/dts/canaan/k210.dtsi | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/boot/dts/canaan/k210.dtsi b/arch/riscv/boot/dts/canaan/k210.dtsi
index 84a7ab363d72..337ce2b879e7 100644
--- a/arch/riscv/boot/dts/canaan/k210.dtsi
+++ b/arch/riscv/boot/dts/canaan/k210.dtsi
@@ -163,7 +163,8 @@ apb0: bus@50200000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-pm-bus";
- ranges;
+ regs = <0x50200000 0x200000>;
+ ranges = <0x50200000 0x50200000 0x200000>;
clocks = <&sysclk K210_CLK_APB0>;

gpio1: gpio@50200000 {
@@ -352,7 +353,8 @@ apb1: bus@50400000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-pm-bus";
- ranges;
+ regs = <0x50400000 0x40100>;
+ ranges = <0x50400000 0x50400000 0x40100>;
clocks = <&sysclk K210_CLK_APB1>;

wdt0: watchdog@50400000 {
@@ -407,7 +409,8 @@ apb2: bus@52000000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-pm-bus";
- ranges;
+ regs = <0x52000000 0x2000200>;
+ ranges = <0x52000000 0x52000000 0x2000200>;
clocks = <&sysclk K210_CLK_APB2>;

spi0: spi@52000000 {
--
2.36.1

2022-06-27 20:47:23

by Serge Semin

[permalink] [raw]
Subject: Re: [PATCH v2 04/16] spi: dt-bindings: dw-apb-ssi: update spi-{r,t}x-bus-width

On Mon, Jun 27, 2022 at 08:39:52PM +0100, Conor Dooley wrote:
> From: Conor Dooley <[email protected]>
>
> Most users of dw-apb-ssi use spi-{r,t}x-bus-width of 1, however the
> Canaan k210 is wired up for a width of 4.
> Quoting Serge:
> The modern DW APB SSI controllers of v.4.* and newer also support the
> enhanced SPI Modes too (Dual, Quad and Octal). Since the IP-core
> version is auto-detected at run-time there is no way to create a
> DT-schema correctly constraining the Rx/Tx SPI bus widths.
> /endquote
>
> As such, drop the restriction on only supporting a bus width of 1.
>
> Link: https://lore.kernel.org/all/20220620205654.g7fyipwytbww5757@mobilestation/
> Signed-off-by: Conor Dooley <[email protected]>
> ---
> Serge, I dropped your R-b when I swapped to the default
> property since it changed the enum.
> ---
> Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
> index e25d44c218f2..0a43d6e0ef91 100644
> --- a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
> +++ b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
> @@ -143,12 +143,6 @@ patternProperties:
> minimum: 0
> maximum: 3
>

> - spi-rx-bus-width:
> - const: 1
> -
> - spi-tx-bus-width:
> - const: 1
> -

My comment was:
> > > You can just use a more relaxed constraint "enum: [1 2 4 8]" here
> >
> > 8 too? sure.
Then Rob said:
> Then no constraints needed because the common definition already has
> this presumably.

IMO preserving the device-specific constraints even if they match the
generic ones has some maintainability benefits. What if you get to
discover a new HW which supports Hexal mode? Then you would have
needed to update the common schema constraints. But that would have
caused permitting the unsupported bus-mode for all the schemas, which
isn't correct. So as I see it the explicit bus-width enumeration would
be ok to have here. But I'll leave it for Rob to make a final
decision.

Rob

> unevaluatedProperties: false
>
> required:
> --
> 2.36.1
>

2022-06-27 21:29:35

by Conor Dooley

[permalink] [raw]
Subject: Re: [PATCH v2 06/16] dt-bindings: timer: add Canaan k210 to Synopsys DesignWare timer

On 27/06/2022 22:13, Serge Semin wrote:
> On Mon, Jun 27, 2022 at 08:39:54PM +0100, Conor Dooley wrote:
>> From: Conor Dooley <[email protected]>
>>
>> The Canaan k210 apparently has a Sysnopsys Designware timer but
>> according to the documentation & devicetree it has 2 interrupts rather
>> than the standard one. Add a custom compatible that supports the 2
>> interrupt configuration and 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
>
> Firstly, it's page 51 in the framework of the document pages
> enumeration.

Ah yes, sorry about that.

>
> Judging by the comment in the document above and what the HW reference
> manual says regarding the IRQ signals, what you really have on K210 is
> the DW APB Timer IP-cores each configured with two embedded timers.
> It's done by the IP-core synthesize parameter NUM_TIMERS={1..8}, which
> in your case equals to 2. A similar situation is on our SoC and, for
> instance, here:
>
> arch/arm/boot/dts/berlin2q.dtsi
> arch/arm/boot/dts/berlin2.dtsi
> arch/arm/boot/dts/berlin2cd.dtsi
> (Though the Berlin2 APB Timer have been configured with 8 timers.)
>
> So the correct modification would be:
> 1. Split up the nodes into two ones with one IRQ per each node.
> 2. Make sure I was right by testing the new dts out.
> 3. Update the DT-node only and leave the DT-bindings as is.

Hmm, sounds good. Will give that a whirl tomorrow.
Thanks for the info/suggestions Sergey.

2022-06-27 21:30:24

by Serge Semin

[permalink] [raw]
Subject: Re: [PATCH v2 06/16] dt-bindings: timer: add Canaan k210 to Synopsys DesignWare timer

On Mon, Jun 27, 2022 at 08:39:54PM +0100, Conor Dooley wrote:
> From: Conor Dooley <[email protected]>
>
> The Canaan k210 apparently has a Sysnopsys Designware timer but
> according to the documentation & devicetree it has 2 interrupts rather
> than the standard one. Add a custom compatible that supports the 2
> interrupt configuration and 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

Firstly, it's page 51 in the framework of the document pages
enumeration.

Judging by the comment in the document above and what the HW reference
manual says regarding the IRQ signals, what you really have on K210 is
the DW APB Timer IP-cores each configured with two embedded timers.
It's done by the IP-core synthesize parameter NUM_TIMERS={1..8}, which
in your case equals to 2. A similar situation is on our SoC and, for
instance, here:

arch/arm/boot/dts/berlin2q.dtsi
arch/arm/boot/dts/berlin2.dtsi
arch/arm/boot/dts/berlin2cd.dtsi
(Though the Berlin2 APB Timer have been configured with 8 timers.)

So the correct modification would be:
1. Split up the nodes into two ones with one IRQ per each node.
2. Make sure I was right by testing the new dts out.
3. Update the DT-node only and leave the DT-bindings as is.

-Sergey

> Signed-off-by: Conor Dooley <[email protected]>
> ---
> .../bindings/timer/snps,dw-apb-timer.yaml | 28 +++++++++++++++----
> 1 file changed, 22 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/timer/snps,dw-apb-timer.yaml b/Documentation/devicetree/bindings/timer/snps,dw-apb-timer.yaml
> index d33c9205a909..9a76acc7a66f 100644
> --- a/Documentation/devicetree/bindings/timer/snps,dw-apb-timer.yaml
> +++ b/Documentation/devicetree/bindings/timer/snps,dw-apb-timer.yaml
> @@ -12,6 +12,9 @@ maintainers:
> properties:
> compatible:
> oneOf:
> + - items:
> + - const: canaan,k210-apb-timer
> + - const: snps,dw-apb-timer
> - const: snps,dw-apb-timer
> - enum:
> - snps,dw-apb-timer-sp
> @@ -21,9 +24,6 @@ properties:
> reg:
> maxItems: 1
>
> - interrupts:
> - maxItems: 1
> -
> resets:
> maxItems: 1
>
> @@ -41,7 +41,23 @@ properties:
>
> clock-frequency: true
>
> -additionalProperties: false
> +unevaluatedProperties: false
> +
> +if:
> + properties:
> + compatible:
> + contains:
> + const: canaan,k210-apb-timer
> +
> +then:
> + properties:
> + interrupts:
> + maxItems: 2
> +
> +else:
> + properties:
> + interrupts:
> + maxItems: 1
>
> required:
> - compatible
> @@ -60,8 +76,8 @@ oneOf:
> examples:
> - |
> timer@ffe00000 {
> - compatible = "snps,dw-apb-timer";
> - interrupts = <0 170 4>;
> + compatible = "canaan,k210-apb-timer", "snps,dw-apb-timer";
> + interrupts = <0 170 4>, <0 170 4>;
> reg = <0xffe00000 0x1000>;
> clocks = <&timer_clk>, <&timer_pclk>;
> clock-names = "timer", "pclk";
> --
> 2.36.1
>

2022-06-27 21:44:57

by Serge Semin

[permalink] [raw]
Subject: Re: [PATCH v2 05/16] dt-bindings: dma: add Canaan k210 to Synopsys DesignWare DMA

On Mon, Jun 27, 2022 at 08:39:53PM +0100, Conor Dooley wrote:
> From: Conor Dooley <[email protected]>
>
> 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

I believe what you've got here is the per-channel IRQs, which is
activated for the DW AXI DMAC by setting IP-core synthesize parameter
DMAX_INTR_IO_TYPE=1 (CHANNEL AND COMMONREG). That's why there are six
IRQ signals and six DMA-channels available.

Seeing such setting isn't the Canaan k210 specific, but is the DW AXI
DMA controller common property, what would be right in this case is to
unconditionally extend the number of IRQs in the DT-bindings schema.

Please note the DW AXI DMAC driver currently doesn't support the
per-channel IRQs. So most likely the DMA will only work with using the
channel 0 only.

-Sergey

> Signed-off-by: Conor Dooley <[email protected]>
> ---
> .../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
> + - 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>;
> --
> 2.36.1
>

2022-06-28 15:26:49

by Heiko Stuebner

[permalink] [raw]
Subject: Re: [PATCH v2 01/16] dt-bindings: display: convert ilitek,ili9341.txt to dt-schema

Hi Conor,

Am Montag, 27. Juni 2022, 21:39:49 CEST schrieb Conor Dooley:
> From: Conor Dooley <[email protected]>
>
> A dt-schema binding for the Ilitek ili9341 was created as
> panel/ilitek,ili9341.yaml but the txt binding was ignored in the
> process. Move the remaining items in the txt binding to the yaml one &
> delete it.
>
> The example in the txt binding has a spi-max-frequency which disagrees
> with the yaml replacement (and its own documentation) so change that to
> conform with the binding. There are no users in tree of the Adafruit
> yx240qv29 to check against.
>
> Link: https://cdn-learn.adafruit.com/assets/assets/000/046/879/original/SPEC-YX240QV29-T_Rev.A__1_.pdf
> Signed-off-by: Conor Dooley <[email protected]>

in your v1 you already got a [0]
Reviewed-by: Rob Herring <[email protected]>
for this patch

Looking at the diffstat, which didn't change, you should
include such tags in followup revisions, to prevent
reviewers from double efforts.

Heiko


[0] https://lore.kernel.org/r/[email protected]

> ---
> .../bindings/display/ilitek,ili9341.txt | 27 -----------
> .../display/panel/ilitek,ili9341.yaml | 48 +++++++++++++------
> 2 files changed, 34 insertions(+), 41 deletions(-)
> delete mode 100644 Documentation/devicetree/bindings/display/ilitek,ili9341.txt
>
> diff --git a/Documentation/devicetree/bindings/display/ilitek,ili9341.txt b/Documentation/devicetree/bindings/display/ilitek,ili9341.txt
> deleted file mode 100644
> index 169b32e4ee4e..000000000000
> --- a/Documentation/devicetree/bindings/display/ilitek,ili9341.txt
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -Ilitek ILI9341 display panels
> -
> -This binding is for display panels using an Ilitek ILI9341 controller in SPI
> -mode.
> -
> -Required properties:
> -- compatible: "adafruit,yx240qv29", "ilitek,ili9341"
> -- dc-gpios: D/C pin
> -- reset-gpios: Reset pin
> -
> -The node for this driver must be a child node of a SPI controller, hence
> -all mandatory properties described in ../spi/spi-bus.txt must be specified.
> -
> -Optional properties:
> -- rotation: panel rotation in degrees counter clockwise (0,90,180,270)
> -- backlight: phandle of the backlight device attached to the panel
> -
> -Example:
> - display@0{
> - compatible = "adafruit,yx240qv29", "ilitek,ili9341";
> - reg = <0>;
> - spi-max-frequency = <32000000>;
> - dc-gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
> - reset-gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
> - rotation = <270>;
> - backlight = <&backlight>;
> - };
> diff --git a/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml b/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml
> index 6058948a9764..94ca92878434 100644
> --- a/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml
> +++ b/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml
> @@ -23,6 +23,7 @@ properties:
> - enum:
> # ili9341 240*320 Color on stm32f429-disco board
> - st,sf-tc240t-9370-t
> + - adafruit,yx240qv29
> - const: ilitek,ili9341
>
> reg: true
> @@ -47,31 +48,50 @@ properties:
> vddi-led-supply:
> description: Voltage supply for the LED driver (1.65 .. 3.3 V)
>
> -additionalProperties: false
> +unevaluatedProperties: false
>
> required:
> - compatible
> - reg
> - dc-gpios
> - - port
> +
> +if:
> + properties:
> + compatible:
> + contains:
> + enum:
> + - st,sf-tc240t-9370-t
> +then:
> + required:
> + - port
>
> examples:
> - |+
> + #include <dt-bindings/gpio/gpio.h>
> spi {
> #address-cells = <1>;
> #size-cells = <0>;
> panel: display@0 {
> - compatible = "st,sf-tc240t-9370-t",
> - "ilitek,ili9341";
> - reg = <0>;
> - spi-3wire;
> - spi-max-frequency = <10000000>;
> - dc-gpios = <&gpiod 13 0>;
> - port {
> - panel_in: endpoint {
> - remote-endpoint = <&display_out>;
> - };
> - };
> - };
> + compatible = "st,sf-tc240t-9370-t",
> + "ilitek,ili9341";
> + reg = <0>;
> + spi-3wire;
> + spi-max-frequency = <10000000>;
> + dc-gpios = <&gpiod 13 0>;
> + port {
> + panel_in: endpoint {
> + remote-endpoint = <&display_out>;
> + };
> + };
> + };
> + display@1{
> + compatible = "adafruit,yx240qv29", "ilitek,ili9341";
> + reg = <1>;
> + spi-max-frequency = <10000000>;
> + dc-gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
> + reset-gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
> + rotation = <270>;
> + backlight = <&backlight>;
> };
> + };
> ...
>




2022-06-28 15:44:49

by Heiko Stuebner

[permalink] [raw]
Subject: Re: [PATCH v2 01/16] dt-bindings: display: convert ilitek,ili9341.txt to dt-schema

Am Dienstag, 28. Juni 2022, 17:00:56 CEST schrieb Heiko St?bner:
> Hi Conor,
>
> Am Montag, 27. Juni 2022, 21:39:49 CEST schrieb Conor Dooley:
> > From: Conor Dooley <[email protected]>
> >
> > A dt-schema binding for the Ilitek ili9341 was created as
> > panel/ilitek,ili9341.yaml but the txt binding was ignored in the
> > process. Move the remaining items in the txt binding to the yaml one &
> > delete it.
> >
> > The example in the txt binding has a spi-max-frequency which disagrees
> > with the yaml replacement (and its own documentation) so change that to
> > conform with the binding. There are no users in tree of the Adafruit
> > yx240qv29 to check against.
> >
> > Link: https://cdn-learn.adafruit.com/assets/assets/000/046/879/original/SPEC-YX240QV29-T_Rev.A__1_.pdf
> > Signed-off-by: Conor Dooley <[email protected]>
>
> in your v1 you already got a [0]
> Reviewed-by: Rob Herring <[email protected]>
> for this patch
>
> Looking at the diffstat, which didn't change, you should
> include such tags in followup revisions, to prevent
> reviewers from double efforts.

and now I see that the review actually happened _after_ v2 was send ;-)


> [0] https://lore.kernel.org/r/[email protected]
>
> > ---
> > .../bindings/display/ilitek,ili9341.txt | 27 -----------
> > .../display/panel/ilitek,ili9341.yaml | 48 +++++++++++++------
> > 2 files changed, 34 insertions(+), 41 deletions(-)
> > delete mode 100644 Documentation/devicetree/bindings/display/ilitek,ili9341.txt
> >
> > diff --git a/Documentation/devicetree/bindings/display/ilitek,ili9341.txt b/Documentation/devicetree/bindings/display/ilitek,ili9341.txt
> > deleted file mode 100644
> > index 169b32e4ee4e..000000000000
> > --- a/Documentation/devicetree/bindings/display/ilitek,ili9341.txt
> > +++ /dev/null
> > @@ -1,27 +0,0 @@
> > -Ilitek ILI9341 display panels
> > -
> > -This binding is for display panels using an Ilitek ILI9341 controller in SPI
> > -mode.
> > -
> > -Required properties:
> > -- compatible: "adafruit,yx240qv29", "ilitek,ili9341"
> > -- dc-gpios: D/C pin
> > -- reset-gpios: Reset pin
> > -
> > -The node for this driver must be a child node of a SPI controller, hence
> > -all mandatory properties described in ../spi/spi-bus.txt must be specified.
> > -
> > -Optional properties:
> > -- rotation: panel rotation in degrees counter clockwise (0,90,180,270)
> > -- backlight: phandle of the backlight device attached to the panel
> > -
> > -Example:
> > - display@0{
> > - compatible = "adafruit,yx240qv29", "ilitek,ili9341";
> > - reg = <0>;
> > - spi-max-frequency = <32000000>;
> > - dc-gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
> > - reset-gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
> > - rotation = <270>;
> > - backlight = <&backlight>;
> > - };
> > diff --git a/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml b/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml
> > index 6058948a9764..94ca92878434 100644
> > --- a/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml
> > +++ b/Documentation/devicetree/bindings/display/panel/ilitek,ili9341.yaml
> > @@ -23,6 +23,7 @@ properties:
> > - enum:
> > # ili9341 240*320 Color on stm32f429-disco board
> > - st,sf-tc240t-9370-t
> > + - adafruit,yx240qv29
> > - const: ilitek,ili9341
> >
> > reg: true
> > @@ -47,31 +48,50 @@ properties:
> > vddi-led-supply:
> > description: Voltage supply for the LED driver (1.65 .. 3.3 V)
> >
> > -additionalProperties: false
> > +unevaluatedProperties: false
> >
> > required:
> > - compatible
> > - reg
> > - dc-gpios
> > - - port
> > +
> > +if:
> > + properties:
> > + compatible:
> > + contains:
> > + enum:
> > + - st,sf-tc240t-9370-t
> > +then:
> > + required:
> > + - port
> >
> > examples:
> > - |+
> > + #include <dt-bindings/gpio/gpio.h>
> > spi {
> > #address-cells = <1>;
> > #size-cells = <0>;
> > panel: display@0 {
> > - compatible = "st,sf-tc240t-9370-t",
> > - "ilitek,ili9341";
> > - reg = <0>;
> > - spi-3wire;
> > - spi-max-frequency = <10000000>;
> > - dc-gpios = <&gpiod 13 0>;
> > - port {
> > - panel_in: endpoint {
> > - remote-endpoint = <&display_out>;
> > - };
> > - };
> > - };
> > + compatible = "st,sf-tc240t-9370-t",
> > + "ilitek,ili9341";
> > + reg = <0>;
> > + spi-3wire;
> > + spi-max-frequency = <10000000>;
> > + dc-gpios = <&gpiod 13 0>;
> > + port {
> > + panel_in: endpoint {
> > + remote-endpoint = <&display_out>;
> > + };
> > + };
> > + };
> > + display@1{
> > + compatible = "adafruit,yx240qv29", "ilitek,ili9341";
> > + reg = <1>;
> > + spi-max-frequency = <10000000>;
> > + dc-gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
> > + reset-gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
> > + rotation = <270>;
> > + backlight = <&backlight>;
> > };
> > + };
> > ...
> >
>
>




2022-06-28 16:01:22

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH v2 04/16] spi: dt-bindings: dw-apb-ssi: update spi-{r,t}x-bus-width

On Mon, Jun 27, 2022 at 11:21:49PM +0300, Serge Semin wrote:
> On Mon, Jun 27, 2022 at 08:39:52PM +0100, Conor Dooley wrote:
> > From: Conor Dooley <[email protected]>
> >
> > Most users of dw-apb-ssi use spi-{r,t}x-bus-width of 1, however the
> > Canaan k210 is wired up for a width of 4.
> > Quoting Serge:
> > The modern DW APB SSI controllers of v.4.* and newer also support the
> > enhanced SPI Modes too (Dual, Quad and Octal). Since the IP-core
> > version is auto-detected at run-time there is no way to create a
> > DT-schema correctly constraining the Rx/Tx SPI bus widths.
> > /endquote
> >
> > As such, drop the restriction on only supporting a bus width of 1.
> >
> > Link: https://lore.kernel.org/all/20220620205654.g7fyipwytbww5757@mobilestation/
> > Signed-off-by: Conor Dooley <[email protected]>
> > ---
> > Serge, I dropped your R-b when I swapped to the default
> > property since it changed the enum.
> > ---
> > Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml | 6 ------
> > 1 file changed, 6 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
> > index e25d44c218f2..0a43d6e0ef91 100644
> > --- a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
> > +++ b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
> > @@ -143,12 +143,6 @@ patternProperties:
> > minimum: 0
> > maximum: 3
> >
>
> > - spi-rx-bus-width:
> > - const: 1
> > -
> > - spi-tx-bus-width:
> > - const: 1
> > -
>
> My comment was:
> > > > You can just use a more relaxed constraint "enum: [1 2 4 8]" here
> > >
> > > 8 too? sure.
> Then Rob said:
> > Then no constraints needed because the common definition already has
> > this presumably.
>
> IMO preserving the device-specific constraints even if they match the
> generic ones has some maintainability benefits. What if you get to
> discover a new HW which supports Hexal mode?

x16? Wouldn't we be back to parallel NOR and the problems with parallel
buses?

> Then you would have
> needed to update the common schema constraints. But that would have
> caused permitting the unsupported bus-mode for all the schemas, which
> isn't correct. So as I see it the explicit bus-width enumeration would
> be ok to have here. But I'll leave it for Rob to make a final
> decision.

Assuming a new width does appear, it's just a matter of time before the
DW block has a new rev supporting it too, so there's 2 places to update.
Also, a given platform may pinout less than the block supports, so you
can't ever be 100% sure an out of range value is in a DT.

But either way is okay with me. If you do keep constraints, you only
need 'maximum: 8'.

Acked-by: Rob Herring <[email protected]>

Rob