* Re: [PATCH 00/43] ep93xx device tree conversion
2023-04-24 12:34 [PATCH 00/43] ep93xx device tree conversion Nikita Shubin
@ 2023-04-24 11:31 ` Arnd Bergmann
[not found] ` <20230424152933.48b2ede1@kernel.org>
2023-04-24 12:34 ` [PATCH 20/43] dt-bindings: dma: Add DT bindings ep93xx dma Nikita Shubin
` (5 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Arnd Bergmann @ 2023-04-24 11:31 UTC (permalink / raw)
To: Nikita Shubin
Cc: Arnd Bergmann, Linus Walleij, Alexander Sverdlin,
David S . Miller, Jonathan Neuschäfer, Russell King,
Uwe Kleine-König, Alessandro Zummo, Alexander Gordeev,
Alexandre Belloni, Andy Shevchenko, Bartosz Golaszewski,
Brian Norris, Chuanhong Guo, Conor.Dooley, Damien Le Moal,
Daniel Lezcano, Dmitry Torokhov, Emil Renner Berthing,
Eric Dumazet, Florian Fainelli, Guenter Roeck, Hartley Sweeten,
Heiko Stübner, Hitomi Hasegawa, Jakub Kicinski,
Jaroslav Kysela, Jean Delvare, Joel Stanley, Jonathan Cameron,
Krzysztof Kozlowski, Damien Le Moal, Liam Girdwood, Liang Yang,
Linus Walleij, Lukasz Majewski, Lv Ruyi, Mark Brown,
Masahiro Yamada, Michael Turquette, Miquel Raynal,
Nathan Chancellor, Nick Desaulniers, Nicolas Saenz Julienne,
Olof Johansson, Paolo Abeni, Qin Jian, Richard Weinberger,
Rob Herring, Robert Jarzmik, Russell King, Sebastian Reichel,
Sergey Shtylyov, Stephen Boyd, Sumanth Korikkar, Sven Peter,
Takashi Iwai, Thierry Reding, Thomas Gleixner, Ulf Hansson,
Vasily Gorbik, Vignesh Raghavendra, Vinod Koul, Walker Chen,
Wim Van Sebroeck, Yinbo Zhu, alsa-devel, devicetree, dmaengine,
linux-arm-kernel, linux-clk, open list:GPIO SUBSYSTEM, linux-ide,
linux-input, linux-kernel, linux-mtd, linux-pm, linux-pwm,
linux-rtc, linux-spi, linux-watchdog, Netdev, soc
On Mon, Apr 24, 2023, at 14:34, Nikita Shubin wrote:
> This series aims to convert ep93xx from platform to full device tree support.
>
> Tested on ts7250 64 RAM/128 MiB Nand flash, edb9302.
>
> Thank you Linus and Arnd for your support, review and comments, sorry
> if i missed something -
> these series are quite big for me.
>
> Big thanks to Alexander Sverdlin for his testing, support, review,
> fixes and patches.
Thanks a lot for your continued work. I can't merge any of this at
the moment since the upstream merge window just opened, but I'm
happy to take this all through the soc tree for 6.5, provided we
get the sufficient Acks from the subsystem maintainers. Merging
it through each individual tree would take a lot longer, so I
hope we can avoid that.
Arnd
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 20/43] dt-bindings: dma: Add DT bindings ep93xx dma
2023-04-24 12:34 [PATCH 00/43] ep93xx device tree conversion Nikita Shubin
2023-04-24 11:31 ` Arnd Bergmann
@ 2023-04-24 12:34 ` Nikita Shubin
2023-04-24 16:15 ` Rob Herring
2023-04-24 12:34 ` [PATCH 21/43] dma: cirrus: add DT support for Cirrus EP93xx Nikita Shubin
` (4 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Nikita Shubin @ 2023-04-24 12:34 UTC (permalink / raw)
Cc: Arnd Bergmann, Linus Walleij, Alexander Sverdlin, Vinod Koul,
Rob Herring, Krzysztof Kozlowski, dmaengine, devicetree,
linux-kernel
Add YAML bindings for ep93xx SoC.
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
.../bindings/dma/cirrus,ep93xx-dma-m2m.yaml | 66 ++++++++++++
.../bindings/dma/cirrus,ep93xx-dma-m2p.yaml | 102 ++++++++++++++++++
2 files changed, 168 insertions(+)
create mode 100644 Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2m.yaml
create mode 100644 Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2p.yaml
diff --git a/Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2m.yaml b/Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2m.yaml
new file mode 100644
index 000000000000..9a53ee9052a0
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2m.yaml
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/cirrus,ep93xx-dma-m2m.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cirrus Logick ep93xx SoC DMA controller Device Tree Bindings
+
+maintainers:
+ - Vinod Koul <vkoul@kernel.org>
+
+properties:
+ compatible:
+ items:
+ - const: cirrus,ep9301-dma-m2m
+
+ reg:
+ minItems: 2
+ maxItems: 2
+
+ clocks:
+ items:
+ - description: m2m0 channel gate clock
+ - description: m2m1 channel gate clock
+
+ clock-names:
+ items:
+ - const: m2m0
+ - const: m2m1
+
+ interrupts:
+ minItems: 2
+ maxItems: 2
+
+ dma-channels:
+ minimum: 2
+ maximum: 2
+
+ '#dma-cells': false
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - interrupts
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/cirrus,ep93xx-clock.h>
+ dma1: dma-controller@80000100 {
+ compatible = "cirrus,ep9301-dma-m2m";
+ reg = <0x80000100 0x0040>,
+ <0x80000140 0x0040>;
+ clocks = <&syscon EP93XX_CLK_M2M0>,
+ <&syscon EP93XX_CLK_M2M1>;
+ clock-names = "m2m0", "m2m1";
+ dma-channels = <2>;
+ interrupt-parent = <&vic0>;
+ interrupts = <17>, <18>;
+ };
+
+...
+
diff --git a/Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2p.yaml b/Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2p.yaml
new file mode 100644
index 000000000000..51fd72b4e843
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2p.yaml
@@ -0,0 +1,102 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/cirrus,ep93xx-dma-m2p.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cirrus Logick ep93xx SoC M2P DMA controller Device Tree Bindings
+
+maintainers:
+ - Vinod Koul <vkoul@kernel.org>
+
+properties:
+ compatible:
+ items:
+ - const: cirrus,ep9301-dma-m2p
+
+ reg:
+ minItems: 10
+ maxItems: 10
+
+ clocks:
+ items:
+ - description: m2p0 channel gate clock
+ - description: m2p1 channel gate clock
+ - description: m2p2 channel gate clock
+ - description: m2p3 channel gate clock
+ - description: m2p4 channel gate clock
+ - description: m2p5 channel gate clock
+ - description: m2p6 channel gate clock
+ - description: m2p7 channel gate clock
+ - description: m2p8 channel gate clock
+ - description: m2p9 channel gate clock
+
+ clock-names:
+ items:
+ - const: m2p0
+ - const: m2p1
+ - const: m2p2
+ - const: m2p3
+ - const: m2p4
+ - const: m2p5
+ - const: m2p6
+ - const: m2p7
+ - const: m2p8
+ - const: m2p9
+
+ interrupts:
+ minItems: 10
+ maxItems: 10
+
+ dma-channels:
+ minimum: 10
+ maximum: 10
+
+ '#dma-cells': false
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - interrupts
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/cirrus,ep93xx-clock.h>
+ dma0: dma-controller@80000000 {
+ compatible = "cirrus,ep9301-dma-m2p";
+ reg = <0x80000000 0x0040>,
+ <0x80000040 0x0040>,
+ <0x80000080 0x0040>,
+ <0x800000c0 0x0040>,
+ <0x80000240 0x0040>,
+ <0x80000200 0x0040>,
+ <0x800002c0 0x0040>,
+ <0x80000280 0x0040>,
+ <0x80000340 0x0040>,
+ <0x80000300 0x0040>;
+ clocks = <&syscon EP93XX_CLK_M2P0>,
+ <&syscon EP93XX_CLK_M2P1>,
+ <&syscon EP93XX_CLK_M2P2>,
+ <&syscon EP93XX_CLK_M2P3>,
+ <&syscon EP93XX_CLK_M2P4>,
+ <&syscon EP93XX_CLK_M2P5>,
+ <&syscon EP93XX_CLK_M2P6>,
+ <&syscon EP93XX_CLK_M2P7>,
+ <&syscon EP93XX_CLK_M2P8>,
+ <&syscon EP93XX_CLK_M2P9>;
+ clock-names = "m2p0", "m2p1",
+ "m2p2", "m2p3",
+ "m2p4", "m2p5",
+ "m2p6", "m2p7",
+ "m2p8", "m2p9";
+ dma-channels = <10>;
+ interrupt-parent = <&vic0>;
+ interrupts = <7>, <8>, <9>, <10>, <11>, <12>, <13>, <14>, <15>, <16>;
+ };
+
+...
+
--
2.39.2
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 20/43] dt-bindings: dma: Add DT bindings ep93xx dma
2023-04-24 12:34 ` [PATCH 20/43] dt-bindings: dma: Add DT bindings ep93xx dma Nikita Shubin
@ 2023-04-24 16:15 ` Rob Herring
0 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2023-04-24 16:15 UTC (permalink / raw)
To: Nikita Shubin
Cc: Arnd Bergmann, Linus Walleij, Alexander Sverdlin, Vinod Koul,
Krzysztof Kozlowski, dmaengine, devicetree, linux-kernel
On Mon, Apr 24, 2023 at 03:34:36PM +0300, Nikita Shubin wrote:
> Add YAML bindings for ep93xx SoC.
>
> Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
> ---
> .../bindings/dma/cirrus,ep93xx-dma-m2m.yaml | 66 ++++++++++++
> .../bindings/dma/cirrus,ep93xx-dma-m2p.yaml | 102 ++++++++++++++++++
> 2 files changed, 168 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2m.yaml
> create mode 100644 Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2p.yaml
>
> diff --git a/Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2m.yaml b/Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2m.yaml
> new file mode 100644
> index 000000000000..9a53ee9052a0
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2m.yaml
> @@ -0,0 +1,66 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/dma/cirrus,ep93xx-dma-m2m.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Cirrus Logick ep93xx SoC DMA controller Device Tree Bindings
> +
> +maintainers:
> + - Vinod Koul <vkoul@kernel.org>
Again, wrong person.
> +
> +properties:
> + compatible:
> + items:
> + - const: cirrus,ep9301-dma-m2m
'items' can be dropped.
> +
> + reg:
> + minItems: 2
> + maxItems: 2
Need to define what each entry is.
> +
> + clocks:
> + items:
> + - description: m2m0 channel gate clock
> + - description: m2m1 channel gate clock
> +
> + clock-names:
> + items:
> + - const: m2m0
> + - const: m2m1
> +
> + interrupts:
> + minItems: 2
> + maxItems: 2
Need to define what each entry is.
> +
> + dma-channels:
> + minimum: 2
> + maximum: 2
If the only possible number of channels is 2, why is this property
needed?
> +
> + '#dma-cells': false
> +
> +required:
> + - compatible
> + - reg
> + - clocks
> + - clock-names
> + - interrupts
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/clock/cirrus,ep93xx-clock.h>
> + dma1: dma-controller@80000100 {
> + compatible = "cirrus,ep9301-dma-m2m";
> + reg = <0x80000100 0x0040>,
> + <0x80000140 0x0040>;
> + clocks = <&syscon EP93XX_CLK_M2M0>,
> + <&syscon EP93XX_CLK_M2M1>;
> + clock-names = "m2m0", "m2m1";
> + dma-channels = <2>;
> + interrupt-parent = <&vic0>;
> + interrupts = <17>, <18>;
> + };
> +
> +...
> +
> diff --git a/Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2p.yaml b/Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2p.yaml
> new file mode 100644
> index 000000000000..51fd72b4e843
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/dma/cirrus,ep93xx-dma-m2p.yaml
> @@ -0,0 +1,102 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/dma/cirrus,ep93xx-dma-m2p.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Cirrus Logick ep93xx SoC M2P DMA controller Device Tree Bindings
> +
> +maintainers:
> + - Vinod Koul <vkoul@kernel.org>
> +
> +properties:
> + compatible:
> + items:
> + - const: cirrus,ep9301-dma-m2p
> +
> + reg:
> + minItems: 10
> + maxItems: 10
Define each entry. Looks like it's just N entries for N channels. Just a
description with that is enough.
> +
> + clocks:
> + items:
> + - description: m2p0 channel gate clock
> + - description: m2p1 channel gate clock
> + - description: m2p2 channel gate clock
> + - description: m2p3 channel gate clock
> + - description: m2p4 channel gate clock
> + - description: m2p5 channel gate clock
> + - description: m2p6 channel gate clock
> + - description: m2p7 channel gate clock
> + - description: m2p8 channel gate clock
> + - description: m2p9 channel gate clock
> +
> + clock-names:
> + items:
> + - const: m2p0
> + - const: m2p1
> + - const: m2p2
> + - const: m2p3
> + - const: m2p4
> + - const: m2p5
> + - const: m2p6
> + - const: m2p7
> + - const: m2p8
> + - const: m2p9
> +
> + interrupts:
> + minItems: 10
> + maxItems: 10
> +
> + dma-channels:
> + minimum: 10
> + maximum: 10
> +
> + '#dma-cells': false
> +
> +required:
> + - compatible
> + - reg
> + - clocks
> + - clock-names
> + - interrupts
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/clock/cirrus,ep93xx-clock.h>
> + dma0: dma-controller@80000000 {
> + compatible = "cirrus,ep9301-dma-m2p";
> + reg = <0x80000000 0x0040>,
> + <0x80000040 0x0040>,
> + <0x80000080 0x0040>,
> + <0x800000c0 0x0040>,
> + <0x80000240 0x0040>,
> + <0x80000200 0x0040>,
> + <0x800002c0 0x0040>,
> + <0x80000280 0x0040>,
> + <0x80000340 0x0040>,
> + <0x80000300 0x0040>;
> + clocks = <&syscon EP93XX_CLK_M2P0>,
> + <&syscon EP93XX_CLK_M2P1>,
> + <&syscon EP93XX_CLK_M2P2>,
> + <&syscon EP93XX_CLK_M2P3>,
> + <&syscon EP93XX_CLK_M2P4>,
> + <&syscon EP93XX_CLK_M2P5>,
> + <&syscon EP93XX_CLK_M2P6>,
> + <&syscon EP93XX_CLK_M2P7>,
> + <&syscon EP93XX_CLK_M2P8>,
> + <&syscon EP93XX_CLK_M2P9>;
> + clock-names = "m2p0", "m2p1",
> + "m2p2", "m2p3",
> + "m2p4", "m2p5",
> + "m2p6", "m2p7",
> + "m2p8", "m2p9";
> + dma-channels = <10>;
> + interrupt-parent = <&vic0>;
> + interrupts = <7>, <8>, <9>, <10>, <11>, <12>, <13>, <14>, <15>, <16>;
> + };
> +
> +...
> +
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 21/43] dma: cirrus: add DT support for Cirrus EP93xx
2023-04-24 12:34 [PATCH 00/43] ep93xx device tree conversion Nikita Shubin
2023-04-24 11:31 ` Arnd Bergmann
2023-04-24 12:34 ` [PATCH 20/43] dt-bindings: dma: Add DT bindings ep93xx dma Nikita Shubin
@ 2023-04-24 12:34 ` Nikita Shubin
2023-04-26 20:56 ` [PATCH 00/43] ep93xx device tree conversion Linus Walleij
` (3 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Nikita Shubin @ 2023-04-24 12:34 UTC (permalink / raw)
Cc: Arnd Bergmann, Linus Walleij, Alexander Sverdlin, Vinod Koul,
dmaengine, linux-kernel
- find register range from the device tree
- get clocks, interrupts from device tree
Co-developed-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
Notes:
Arnd Bergmann:
- wildcards ep93xx to something meaningful, i.e. ep9301
- drop wrappers
Changes by Alexander:
- correct dma compatible checks
- fix dma compatible namings
drivers/dma/ep93xx_dma.c | 119 +++++++++++++++++++++--
include/linux/platform_data/dma-ep93xx.h | 3 +
2 files changed, 112 insertions(+), 10 deletions(-)
diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c
index d19ea885c63e..1da1e20a4d77 100644
--- a/drivers/dma/ep93xx_dma.c
+++ b/drivers/dma/ep93xx_dma.c
@@ -20,6 +20,7 @@
#include <linux/dmaengine.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
@@ -104,6 +105,11 @@
#define DMA_MAX_CHAN_BYTES 0xffff
#define DMA_MAX_CHAN_DESCRIPTORS 32
+enum ep93xx_dma_type {
+ M2P_DMA,
+ M2M_DMA,
+};
+
struct ep93xx_dma_engine;
static int ep93xx_dma_slave_config_write(struct dma_chan *chan,
enum dma_transfer_direction dir,
@@ -213,7 +219,7 @@ struct ep93xx_dma_engine {
#define INTERRUPT_NEXT_BUFFER 2
size_t num_channels;
- struct ep93xx_dma_chan channels[];
+ struct ep93xx_dma_chan *channels;
};
static inline struct device *chan2dev(struct ep93xx_dma_chan *edmac)
@@ -875,9 +881,11 @@ static int ep93xx_dma_alloc_chan_resources(struct dma_chan *chan)
if (!edmac->edma->m2m) {
if (!data)
return -EINVAL;
+
if (data->port < EP93XX_DMA_I2S1 ||
data->port > EP93XX_DMA_IRDA)
return -EINVAL;
+
if (data->direction != ep93xx_dma_chan_direction(chan))
return -EINVAL;
} else {
@@ -1315,20 +1323,88 @@ static void ep93xx_dma_issue_pending(struct dma_chan *chan)
ep93xx_dma_advance_work(to_ep93xx_dma_chan(chan));
}
-static int __init ep93xx_dma_probe(struct platform_device *pdev)
+
+#ifdef CONFIG_OF
+static const struct of_device_id ep93xx_dma_of_ids[] = {
+ { .compatible = "cirrus,ep9301-dma-m2p", .data = (const void *)M2P_DMA },
+ { .compatible = "cirrus,ep9301-dma-m2m", .data = (const void *)M2M_DMA },
+ {},
+};
+MODULE_DEVICE_TABLE(of, ep93xx_dma_of_ids);
+
+static int ep93xx_dma_of_probe(struct platform_device *pdev,
+ struct ep93xx_dma_engine *edma)
+{
+ struct device_node *np = pdev->dev.of_node;
+ const struct of_device_id *match = of_match_node(ep93xx_dma_of_ids, pdev->dev.of_node);
+ struct dma_device *dma_dev = &edma->dma_dev;
+ int num_channels;
+ int i, ret;
+
+ ret = of_property_read_u32(np, "dma-channels", &num_channels);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to read dma-channels\n");
+ return ret;
+ }
+
+ edma->channels = devm_kzalloc(&pdev->dev,
+ num_channels * sizeof(struct ep93xx_dma_chan),
+ GFP_KERNEL);
+ if (!edma->channels)
+ return -ENOMEM;
+
+ edma->num_channels = num_channels;
+ edma->m2m = match->data;
+
+ INIT_LIST_HEAD(&dma_dev->channels);
+ for (i = 0; i < num_channels; i++) {
+ struct ep93xx_dma_chan *edmac = &edma->channels[i];
+
+ edmac->chan.device = dma_dev;
+ edmac->regs = devm_platform_ioremap_resource(pdev, i);
+ edmac->irq = platform_get_irq(pdev, i);
+ edmac->edma = edma;
+
+ edmac->clk = of_clk_get(np, i);
+
+ if (IS_ERR(edmac->clk)) {
+ dev_warn(&pdev->dev, "failed to get clock\n");
+ continue;
+ }
+
+ spin_lock_init(&edmac->lock);
+ INIT_LIST_HEAD(&edmac->active);
+ INIT_LIST_HEAD(&edmac->queue);
+ INIT_LIST_HEAD(&edmac->free_list);
+ tasklet_setup(&edmac->tasklet, ep93xx_dma_tasklet);
+
+ list_add_tail(&edmac->chan.device_node,
+ &dma_dev->channels);
+ }
+
+ return 0;
+}
+#else
+static int ep93xx_dma_of_probe(struct platform_device *pdev,
+ struct ep93xx_dma_engine *edma)
+{
+ return -EINVAL;
+}
+#endif
+
+static int ep93xx_init_from_pdata(struct platform_device *pdev,
+ struct ep93xx_dma_engine *edma)
{
struct ep93xx_dma_platform_data *pdata = dev_get_platdata(&pdev->dev);
- struct ep93xx_dma_engine *edma;
- struct dma_device *dma_dev;
- size_t edma_size;
- int ret, i;
+ struct dma_device *dma_dev = &edma->dma_dev;
+ int i;
- edma_size = pdata->num_channels * sizeof(struct ep93xx_dma_chan);
- edma = kzalloc(sizeof(*edma) + edma_size, GFP_KERNEL);
- if (!edma)
+ edma->channels = devm_kzalloc(&pdev->dev,
+ pdata->num_channels * sizeof(struct ep93xx_dma_chan),
+ GFP_KERNEL);
+ if (!edma->channels)
return -ENOMEM;
- dma_dev = &edma->dma_dev;
edma->m2m = platform_get_device_id(pdev)->driver_data;
edma->num_channels = pdata->num_channels;
@@ -1359,6 +1435,27 @@ static int __init ep93xx_dma_probe(struct platform_device *pdev)
&dma_dev->channels);
}
+ return 0;
+}
+
+static int __init ep93xx_dma_probe(struct platform_device *pdev)
+{
+ struct ep93xx_dma_engine *edma;
+ struct dma_device *dma_dev;
+ int ret, i;
+
+ edma = devm_kzalloc(&pdev->dev, sizeof(*edma), GFP_KERNEL);
+
+ if (platform_get_device_id(pdev))
+ ret = ep93xx_init_from_pdata(pdev, edma);
+ else
+ ret = ep93xx_dma_of_probe(pdev, edma);
+
+ if (ret)
+ return ret;
+
+ dma_dev = &edma->dma_dev;
+
dma_cap_zero(dma_dev->cap_mask);
dma_cap_set(DMA_SLAVE, dma_dev->cap_mask);
dma_cap_set(DMA_CYCLIC, dma_dev->cap_mask);
@@ -1415,10 +1512,12 @@ static const struct platform_device_id ep93xx_dma_driver_ids[] = {
{ "ep93xx-dma-m2m", 1 },
{ },
};
+MODULE_DEVICE_TABLE(of, ep93xx_dma_driver_ids);
static struct platform_driver ep93xx_dma_driver = {
.driver = {
.name = "ep93xx-dma",
+ .of_match_table = ep93xx_dma_of_ids,
},
.id_table = ep93xx_dma_driver_ids,
};
diff --git a/include/linux/platform_data/dma-ep93xx.h b/include/linux/platform_data/dma-ep93xx.h
index eb9805bb3fe8..d485e3c21a3a 100644
--- a/include/linux/platform_data/dma-ep93xx.h
+++ b/include/linux/platform_data/dma-ep93xx.h
@@ -70,6 +70,9 @@ struct ep93xx_dma_platform_data {
static inline bool ep93xx_dma_chan_is_m2p(struct dma_chan *chan)
{
+ if (of_device_is_compatible(dev_of_node(chan->device->dev), "cirrus,ep9301-dma-m2p"))
+ return true;
+
return !strcmp(dev_name(chan->device->dev), "ep93xx-dma-m2p");
}
--
2.39.2
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 00/43] ep93xx device tree conversion
2023-04-24 12:34 [PATCH 00/43] ep93xx device tree conversion Nikita Shubin
` (2 preceding siblings ...)
2023-04-24 12:34 ` [PATCH 21/43] dma: cirrus: add DT support for Cirrus EP93xx Nikita Shubin
@ 2023-04-26 20:56 ` Linus Walleij
[not found] ` <b5396ef5-3fed-4e98-8f37-a9cd4473bddc@sirena.org.uk>
2023-05-16 3:47 ` Florian Fainelli
` (2 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Linus Walleij @ 2023-04-26 20:56 UTC (permalink / raw)
To: Nikita Shubin
Cc: Arnd Bergmann, Linus Walleij, Alexander Sverdlin, David S. Miller,
Jonathan Neuschäfer, Russell King (Oracle),
Uwe Kleine-König, Alessandro Zummo, Alexander Gordeev,
Alexandre Belloni, Andy Shevchenko, Arnd Bergmann,
Bartosz Golaszewski, Brian Norris, Chuanhong Guo, Conor Dooley,
Damien Le Moal, Daniel Lezcano, Dmitry Torokhov,
Emil Renner Berthing, Eric Dumazet, Florian Fainelli,
Guenter Roeck, Hartley Sweeten, Heiko Stuebner, Hitomi Hasegawa,
Jakub Kicinski, Jaroslav Kysela, Jean Delvare, Joel Stanley,
Jonathan Cameron, Krzysztof Kozlowski, Le Moal, Liam Girdwood,
Liang Yang, Lukasz Majewski, Lv Ruyi, Mark Brown, Masahiro Yamada,
Michael Turquette, Miquel Raynal, Nathan Chancellor,
Nick Desaulniers, Nicolas Saenz Julienne, Olof Johansson,
Paolo Abeni, Qin Jian, Richard Weinberger, Rob Herring,
Robert Jarzmik, Russell King, Sebastian Reichel, Sergey Shtylyov,
Stephen Boyd, Sumanth Korikkar, Sven Peter, Takashi Iwai,
Thierry Reding, Thomas Gleixner, Ulf Hansson, Vasily Gorbik,
Vignesh Raghavendra, Vinod Koul, Walker Chen, Wim Van Sebroeck,
Yinbo Zhu, alsa-devel, devicetree, dmaengine, linux-arm-kernel,
linux-clk, linux-gpio, linux-ide, linux-input, linux-kernel,
linux-mtd, linux-pm, linux-pwm, linux-rtc, linux-spi,
linux-watchdog, netdev, soc
On Mon, Apr 24, 2023 at 11:35 AM Nikita Shubin
<nikita.shubin@maquefel.me> wrote:
> This series aims to convert ep93xx from platform to full device tree support.
>
> Tested on ts7250 64 RAM/128 MiB Nand flash, edb9302.
Neat, I'd say let's merge this for 6.5 once the final rough edges are
off. The DT bindings should be easy to fix.
This is a big patch set and the improvement to the ARM kernel it
brings is great, so I am a bit worried about over-review stalling the
merged. If there start to be nitpicky comments I would prefer that
we merge it and let minor comments and "nice-to-haves" be
addressed in-tree during the development cycle.
I encourage you to use b4 to manage the patch series if you
have time to learn it, it could help you:
https://people.kernel.org/monsieuricon/sending-a-kernel-patch-with-b4-part-1
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 00/43] ep93xx device tree conversion
2023-04-24 12:34 [PATCH 00/43] ep93xx device tree conversion Nikita Shubin
` (3 preceding siblings ...)
2023-04-26 20:56 ` [PATCH 00/43] ep93xx device tree conversion Linus Walleij
@ 2023-05-16 3:47 ` Florian Fainelli
2023-05-16 10:37 ` Nikita Shubin
2023-06-01 5:45 ` [PATCH v1 21/43] dt-bindings: dma: Add Cirrus EP93xx Nikita Shubin
2023-06-01 5:45 ` [PATCH v1 22/43] dma: cirrus: add DT support for " Nikita Shubin
6 siblings, 1 reply; 14+ messages in thread
From: Florian Fainelli @ 2023-05-16 3:47 UTC (permalink / raw)
To: Nikita Shubin
Cc: Arnd Bergmann, Linus Walleij, Alexander Sverdlin, David S. Miller,
Jonathan Neuschäfer, Russell King (Oracle),
Uwe Kleine-König, Alessandro Zummo, Alexander Gordeev,
Alexandre Belloni, Andy Shevchenko, Arnd Bergmann,
Bartosz Golaszewski, Brian Norris, Chuanhong Guo, Conor Dooley,
Damien Le Moal, Daniel Lezcano, Dmitry Torokhov,
Emil Renner Berthing, Eric Dumazet, Guenter Roeck,
Hartley Sweeten, Heiko Stuebner, Hitomi Hasegawa, Jakub Kicinski,
Jaroslav Kysela, Jean Delvare, Joel Stanley, Jonathan Cameron,
Krzysztof Kozlowski, Le Moal, Liam Girdwood, Liang Yang,
Linus Walleij, Lukasz Majewski, Lv Ruyi, Mark Brown,
Masahiro Yamada, Michael Turquette, Miquel Raynal,
Nathan Chancellor, Nick Desaulniers, Nicolas Saenz Julienne,
Olof Johansson, Paolo Abeni, Qin Jian, Richard Weinberger,
Rob Herring, Robert Jarzmik, Russell King, Sebastian Reichel,
Sergey Shtylyov, Stephen Boyd, Sumanth Korikkar, Sven Peter,
Takashi Iwai, Thierry Reding, Thomas Gleixner, Ulf Hansson,
Vasily Gorbik, Vignesh Raghavendra, Vinod Koul, Walker Chen,
Wim Van Sebroeck, Yinbo Zhu, alsa-devel, devicetree, dmaengine,
linux-arm-kernel, linux-clk, linux-gpio, linux-ide, linux-input,
linux-kernel, linux-mtd, linux-pm, linux-pwm, linux-rtc,
linux-spi, linux-watchdog, netdev, soc
On 4/24/2023 5:34 AM, Nikita Shubin wrote:
> This series aims to convert ep93xx from platform to full device tree support.
>
> Tested on ts7250 64 RAM/128 MiB Nand flash, edb9302.
>
> Thank you Linus and Arnd for your support, review and comments, sorry if i missed something -
> these series are quite big for me.
>
> Big thanks to Alexander Sverdlin for his testing, support, review, fixes and patches.
If anyone is interested I still have a TS-7300 board [1] that is fully
functional and could be sent out to a new home.
https://www.embeddedts.com/products/TS-7300
--
Florian
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 00/43] ep93xx device tree conversion
2023-05-16 3:47 ` Florian Fainelli
@ 2023-05-16 10:37 ` Nikita Shubin
0 siblings, 0 replies; 14+ messages in thread
From: Nikita Shubin @ 2023-05-16 10:37 UTC (permalink / raw)
To: Florian Fainelli
Cc: Arnd Bergmann, Linus Walleij, Alexander Sverdlin, David S. Miller,
Jonathan Neuschäfer, Russell King (Oracle),
Uwe Kleine-König, Alessandro Zummo, Alexander Gordeev,
Alexandre Belloni, Andy Shevchenko, Arnd Bergmann,
Bartosz Golaszewski, Brian Norris, Chuanhong Guo, Conor Dooley,
Damien Le Moal, Daniel Lezcano, Dmitry Torokhov,
Emil Renner Berthing, Eric Dumazet, Guenter Roeck,
Hartley Sweeten, Heiko Stuebner, Hitomi Hasegawa, Jakub Kicinski,
Jaroslav Kysela, Jean Delvare, Joel Stanley, Jonathan Cameron,
Krzysztof Kozlowski, Le Moal, Liam Girdwood, Liang Yang,
Linus Walleij, Lukasz Majewski, Lv Ruyi, Mark Brown,
Masahiro Yamada, Michael Turquette, Miquel Raynal,
Nathan Chancellor, Nick Desaulniers, Nicolas Saenz Julienne,
Olof Johansson, Paolo Abeni, Qin Jian, Richard Weinberger,
Rob Herring, Robert Jarzmik, Russell King, Sebastian Reichel,
Sergey Shtylyov, Stephen Boyd, Sumanth Korikkar, Sven Peter,
Takashi Iwai, Thierry Reding, Thomas Gleixner, Ulf Hansson,
Vasily Gorbik, Vignesh Raghavendra, Vinod Koul, Walker Chen,
Wim Van Sebroeck, Yinbo Zhu, alsa-devel, devicetree, dmaengine,
linux-arm-kernel, linux-clk, linux-gpio, linux-ide, linux-input,
linux-kernel, linux-mtd, linux-pm, linux-pwm, linux-rtc,
linux-spi, linux-watchdog, netdev, soc
Hello Florian!
On Mon, 2023-05-15 at 20:47 -0700, Florian Fainelli wrote:
>
>
> On 4/24/2023 5:34 AM, Nikita Shubin wrote:
> > This series aims to convert ep93xx from platform to full device
> > tree support.
> >
> > Tested on ts7250 64 RAM/128 MiB Nand flash, edb9302.
> >
> > Thank you Linus and Arnd for your support, review and comments,
> > sorry if i missed something -
> > these series are quite big for me.
> >
> > Big thanks to Alexander Sverdlin for his testing, support, review,
> > fixes and patches.
>
> If anyone is interested I still have a TS-7300 board [1] that is
> fully
> functional and could be sent out to a new home.
Thank you kindly, i'll keep this in mind !
>
> https://www.embeddedts.com/products/TS-7300
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v1 21/43] dt-bindings: dma: Add Cirrus EP93xx
2023-04-24 12:34 [PATCH 00/43] ep93xx device tree conversion Nikita Shubin
` (4 preceding siblings ...)
2023-05-16 3:47 ` Florian Fainelli
@ 2023-06-01 5:45 ` Nikita Shubin
2023-06-01 5:45 ` [PATCH v1 22/43] dma: cirrus: add DT support for " Nikita Shubin
6 siblings, 0 replies; 14+ messages in thread
From: Nikita Shubin @ 2023-06-01 5:45 UTC (permalink / raw)
To: Alexander Sverdlin, Arnd Bergmann, Linus Walleij, Vinod Koul,
Rob Herring, Krzysztof Kozlowski, Nikita Shubin
Cc: Michael Peters, Kris Bahnsen, dmaengine, devicetree, linux-kernel
Add YAML bindings for ep93xx SoC DMA.
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
Notes:
v0 -> v1:
Rob Herring:
- replaced maintainers
- defined each entry in reg, interrupts
- dropped dma-channels
Krzysztof Kozlowski:
- fixed title
- renamed files
- use fallback compatible and list all possible compatibles
- dropped label
- fix ident
.../bindings/dma/cirrus,ep9301-dma-m2m.yaml | 72 ++++++++++
.../bindings/dma/cirrus,ep9301-dma-m2p.yaml | 124 ++++++++++++++++++
2 files changed, 196 insertions(+)
create mode 100644 Documentation/devicetree/bindings/dma/cirrus,ep9301-dma-m2m.yaml
create mode 100644 Documentation/devicetree/bindings/dma/cirrus,ep9301-dma-m2p.yaml
diff --git a/Documentation/devicetree/bindings/dma/cirrus,ep9301-dma-m2m.yaml b/Documentation/devicetree/bindings/dma/cirrus,ep9301-dma-m2m.yaml
new file mode 100644
index 000000000000..413492268bd7
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/cirrus,ep9301-dma-m2m.yaml
@@ -0,0 +1,72 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/cirrus,ep9301-dma-m2m.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cirrus Logick ep93xx SoC DMA controller
+
+maintainers:
+ - Alexander Sverdlin <alexander.sverdlin@gmail.com>
+ - Nikita Shubin <nikita.shubin@maquefel.me>
+
+properties:
+ compatible:
+ oneOf:
+ - const: cirrus,ep9301-dma-m2m
+ - items:
+ - enum:
+ - cirrus,ep9302-dma-m2m
+ - cirrus,ep9307-dma-m2m
+ - cirrus,ep9312-dma-m2m
+ - cirrus,ep9315-dma-m2m
+ - const: cirrus,ep9301-dma-m2m
+
+ reg:
+ items:
+ - description: m2m0 channel registers
+ - description: m2m1 channel registers
+
+ clocks:
+ items:
+ - description: m2m0 channel gate clock
+ - description: m2m1 channel gate clock
+
+ clock-names:
+ items:
+ - const: m2m0
+ - const: m2m1
+
+ interrupts:
+ items:
+ - description: m2m0 channel interrupt
+ - description: m2m1 channel interrupt
+
+ '#dma-cells': true
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - interrupts
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/cirrus,ep93xx-clock.h>
+ dma-controller@80000100 {
+ compatible = "cirrus,ep9301-dma-m2m";
+ reg = <0x80000100 0x0040>,
+ <0x80000140 0x0040>;
+ clocks = <&syscon EP93XX_CLK_M2M0>,
+ <&syscon EP93XX_CLK_M2M1>;
+ clock-names = "m2m0", "m2m1";
+ interrupt-parent = <&vic0>;
+ interrupts = <17>, <18>;
+ #dma-cells = <1>;
+ };
+
+...
+
diff --git a/Documentation/devicetree/bindings/dma/cirrus,ep9301-dma-m2p.yaml b/Documentation/devicetree/bindings/dma/cirrus,ep9301-dma-m2p.yaml
new file mode 100644
index 000000000000..79f2d61de6a3
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/cirrus,ep9301-dma-m2p.yaml
@@ -0,0 +1,124 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/cirrus,ep9301-dma-m2p.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cirrus Logick ep93xx SoC M2P DMA controller
+
+maintainers:
+ - Alexander Sverdlin <alexander.sverdlin@gmail.com>
+ - Nikita Shubin <nikita.shubin@maquefel.me>
+
+properties:
+ compatible:
+ oneOf:
+ - const: cirrus,ep9301-dma-m2p
+ - items:
+ - enum:
+ - cirrus,ep9302-dma-m2p
+ - cirrus,ep9307-dma-m2p
+ - cirrus,ep9312-dma-m2p
+ - cirrus,ep9315-dma-m2p
+ - const: cirrus,ep9301-dma-m2p
+
+ reg:
+ items:
+ - description: m2p0 channel registers
+ - description: m2p1 channel registers
+ - description: m2p2 channel registers
+ - description: m2p3 channel registers
+ - description: m2p4 channel registers
+ - description: m2p5 channel registers
+ - description: m2p6 channel registers
+ - description: m2p7 channel registers
+ - description: m2p8 channel registers
+ - description: m2p9 channel registers
+
+ clocks:
+ items:
+ - description: m2p0 channel gate clock
+ - description: m2p1 channel gate clock
+ - description: m2p2 channel gate clock
+ - description: m2p3 channel gate clock
+ - description: m2p4 channel gate clock
+ - description: m2p5 channel gate clock
+ - description: m2p6 channel gate clock
+ - description: m2p7 channel gate clock
+ - description: m2p8 channel gate clock
+ - description: m2p9 channel gate clock
+
+ clock-names:
+ items:
+ - const: m2p0
+ - const: m2p1
+ - const: m2p2
+ - const: m2p3
+ - const: m2p4
+ - const: m2p5
+ - const: m2p6
+ - const: m2p7
+ - const: m2p8
+ - const: m2p9
+
+ interrupts:
+ items:
+ - description: m2p0 channel interrupt
+ - description: m2p1 channel interrupt
+ - description: m2p2 channel interrupt
+ - description: m2p3 channel interrupt
+ - description: m2p4 channel interrupt
+ - description: m2p5 channel interrupt
+ - description: m2p6 channel interrupt
+ - description: m2p7 channel interrupt
+ - description: m2p8 channel interrupt
+ - description: m2p9 channel interrupt
+
+ '#dma-cells': true
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - interrupts
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/cirrus,ep93xx-clock.h>
+ dma-controller@80000000 {
+ compatible = "cirrus,ep9301-dma-m2p";
+ reg = <0x80000000 0x0040>,
+ <0x80000040 0x0040>,
+ <0x80000080 0x0040>,
+ <0x800000c0 0x0040>,
+ <0x80000240 0x0040>,
+ <0x80000200 0x0040>,
+ <0x800002c0 0x0040>,
+ <0x80000280 0x0040>,
+ <0x80000340 0x0040>,
+ <0x80000300 0x0040>;
+ clocks = <&syscon EP93XX_CLK_M2P0>,
+ <&syscon EP93XX_CLK_M2P1>,
+ <&syscon EP93XX_CLK_M2P2>,
+ <&syscon EP93XX_CLK_M2P3>,
+ <&syscon EP93XX_CLK_M2P4>,
+ <&syscon EP93XX_CLK_M2P5>,
+ <&syscon EP93XX_CLK_M2P6>,
+ <&syscon EP93XX_CLK_M2P7>,
+ <&syscon EP93XX_CLK_M2P8>,
+ <&syscon EP93XX_CLK_M2P9>;
+ clock-names = "m2p0", "m2p1",
+ "m2p2", "m2p3",
+ "m2p4", "m2p5",
+ "m2p6", "m2p7",
+ "m2p8", "m2p9";
+ interrupt-parent = <&vic0>;
+ interrupts = <7>, <8>, <9>, <10>, <11>, <12>, <13>, <14>, <15>, <16>;
+ #dma-cells = <1>;
+ };
+
+...
+
--
2.37.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v1 22/43] dma: cirrus: add DT support for Cirrus EP93xx
2023-04-24 12:34 [PATCH 00/43] ep93xx device tree conversion Nikita Shubin
` (5 preceding siblings ...)
2023-06-01 5:45 ` [PATCH v1 21/43] dt-bindings: dma: Add Cirrus EP93xx Nikita Shubin
@ 2023-06-01 5:45 ` Nikita Shubin
2023-06-03 20:39 ` andy.shevchenko
6 siblings, 1 reply; 14+ messages in thread
From: Nikita Shubin @ 2023-06-01 5:45 UTC (permalink / raw)
To: Alexander Sverdlin, Arnd Bergmann, Linus Walleij, Hartley Sweeten,
Russell King, Vinod Koul, Nikita Shubin
Cc: Michael Peters, Kris Bahnsen, linux-arm-kernel, linux-kernel,
dmaengine
- find register range from the device tree
- get clocks, interrupts from device tree
Co-developed-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
arch/arm/mach-ep93xx/dma.c | 1 +
drivers/dma/ep93xx_dma.c | 136 +++++++++++++++++++++--
include/linux/platform_data/dma-ep93xx.h | 3 +
3 files changed, 130 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-ep93xx/dma.c b/arch/arm/mach-ep93xx/dma.c
index 74515acab8ef..273954cbfced 100644
--- a/arch/arm/mach-ep93xx/dma.c
+++ b/arch/arm/mach-ep93xx/dma.c
@@ -19,6 +19,7 @@
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/platform_data/dma-ep93xx.h>
diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c
index 5338a94f1a69..9f71e08ca380 100644
--- a/drivers/dma/ep93xx_dma.c
+++ b/drivers/dma/ep93xx_dma.c
@@ -20,6 +20,7 @@
#include <linux/dmaengine.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
@@ -104,6 +105,11 @@
#define DMA_MAX_CHAN_BYTES 0xffff
#define DMA_MAX_CHAN_DESCRIPTORS 32
+enum ep93xx_dma_type {
+ M2P_DMA,
+ M2M_DMA,
+};
+
struct ep93xx_dma_engine;
static int ep93xx_dma_slave_config_write(struct dma_chan *chan,
enum dma_transfer_direction dir,
@@ -213,7 +219,7 @@ struct ep93xx_dma_engine {
#define INTERRUPT_NEXT_BUFFER 2
size_t num_channels;
- struct ep93xx_dma_chan channels[];
+ struct ep93xx_dma_chan *channels;
};
static inline struct device *chan2dev(struct ep93xx_dma_chan *edmac)
@@ -875,9 +881,11 @@ static int ep93xx_dma_alloc_chan_resources(struct dma_chan *chan)
if (!edmac->edma->m2m) {
if (!data)
return -EINVAL;
+
if (data->port < EP93XX_DMA_I2S1 ||
data->port > EP93XX_DMA_IRDA)
return -EINVAL;
+
if (data->direction != ep93xx_dma_chan_direction(chan))
return -EINVAL;
} else {
@@ -1315,20 +1323,105 @@ static void ep93xx_dma_issue_pending(struct dma_chan *chan)
ep93xx_dma_advance_work(to_ep93xx_dma_chan(chan));
}
-static int __init ep93xx_dma_probe(struct platform_device *pdev)
+
+#ifdef CONFIG_OF
+struct ep93xx_edma_data {
+ u32 id;
+ size_t num_channels;
+};
+
+static const struct ep93xx_edma_data edma_m2p = {
+ .id = M2P_DMA,
+ .num_channels = 10,
+};
+
+static const struct ep93xx_edma_data edma_m2m = {
+ .id = M2M_DMA,
+ .num_channels = 2,
+};
+
+static const struct of_device_id ep93xx_dma_of_ids[] = {
+ { .compatible = "cirrus,ep9301-dma-m2p", .data = &edma_m2p },
+ { .compatible = "cirrus,ep9301-dma-m2m", .data = &edma_m2m },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, ep93xx_dma_of_ids);
+
+static int ep93xx_dma_of_probe(struct platform_device *pdev,
+ struct ep93xx_dma_engine *edma)
+{
+ struct device_node *np = pdev->dev.of_node;
+ const struct of_device_id *match = of_match_node(ep93xx_dma_of_ids, pdev->dev.of_node);
+ const struct ep93xx_edma_data *data = match->data;
+ struct dma_device *dma_dev = &edma->dma_dev;
+ int num_channels;
+ int i;
+
+ match = of_match_device((ep93xx_dma_of_ids), &pdev->dev);
+ if (!match || !match->data) {
+ dev_err(&pdev->dev, "No device match found\n");
+ return -ENODEV;
+ }
+
+ edma->m2m = data->id;
+ num_channels = data->num_channels;
+ edma->channels = devm_kzalloc(&pdev->dev,
+ num_channels * sizeof(struct ep93xx_dma_chan),
+ GFP_KERNEL);
+ if (!edma->channels)
+ return -ENOMEM;
+
+ edma->num_channels = num_channels;
+
+ INIT_LIST_HEAD(&dma_dev->channels);
+ for (i = 0; i < num_channels; i++) {
+ struct ep93xx_dma_chan *edmac = &edma->channels[i];
+
+ edmac->chan.device = dma_dev;
+ edmac->regs = devm_platform_ioremap_resource(pdev, i);
+ edmac->irq = platform_get_irq(pdev, i);
+ edmac->edma = edma;
+
+ edmac->clk = of_clk_get(np, i);
+
+ if (IS_ERR(edmac->clk)) {
+ dev_warn(&pdev->dev, "failed to get clock\n");
+ continue;
+ }
+
+ spin_lock_init(&edmac->lock);
+ INIT_LIST_HEAD(&edmac->active);
+ INIT_LIST_HEAD(&edmac->queue);
+ INIT_LIST_HEAD(&edmac->free_list);
+ tasklet_setup(&edmac->tasklet, ep93xx_dma_tasklet);
+
+ list_add_tail(&edmac->chan.device_node,
+ &dma_dev->channels);
+ }
+
+ return 0;
+}
+#else
+static int ep93xx_dma_of_probe(struct platform_device *pdev,
+ struct ep93xx_dma_engine *edma)
+{
+ return -EINVAL;
+}
+#endif
+
+static int ep93xx_init_from_pdata(struct platform_device *pdev,
+ struct ep93xx_dma_engine *edma)
{
struct ep93xx_dma_platform_data *pdata = dev_get_platdata(&pdev->dev);
- struct ep93xx_dma_engine *edma;
- struct dma_device *dma_dev;
- size_t edma_size;
- int ret, i;
+ struct dma_device *dma_dev = &edma->dma_dev;
+ int i;
- edma_size = pdata->num_channels * sizeof(struct ep93xx_dma_chan);
- edma = kzalloc(sizeof(*edma) + edma_size, GFP_KERNEL);
- if (!edma)
+ edma->channels = devm_kzalloc(&pdev->dev,
+ pdata->num_channels * sizeof(struct ep93xx_dma_chan),
+ GFP_KERNEL);
+ if (!edma->channels)
return -ENOMEM;
- dma_dev = &edma->dma_dev;
edma->m2m = platform_get_device_id(pdev)->driver_data;
edma->num_channels = pdata->num_channels;
@@ -1359,6 +1452,27 @@ static int __init ep93xx_dma_probe(struct platform_device *pdev)
&dma_dev->channels);
}
+ return 0;
+}
+
+static int __init ep93xx_dma_probe(struct platform_device *pdev)
+{
+ struct ep93xx_dma_engine *edma;
+ struct dma_device *dma_dev;
+ int ret, i;
+
+ edma = devm_kzalloc(&pdev->dev, sizeof(*edma), GFP_KERNEL);
+
+ if (platform_get_device_id(pdev))
+ ret = ep93xx_init_from_pdata(pdev, edma);
+ else
+ ret = ep93xx_dma_of_probe(pdev, edma);
+
+ if (ret)
+ return ret;
+
+ dma_dev = &edma->dma_dev;
+
dma_cap_zero(dma_dev->cap_mask);
dma_cap_set(DMA_SLAVE, dma_dev->cap_mask);
dma_cap_set(DMA_CYCLIC, dma_dev->cap_mask);
@@ -1415,10 +1529,12 @@ static const struct platform_device_id ep93xx_dma_driver_ids[] = {
{ "ep93xx-dma-m2m", 1 },
{ },
};
+MODULE_DEVICE_TABLE(of, ep93xx_dma_driver_ids);
static struct platform_driver ep93xx_dma_driver = {
.driver = {
.name = "ep93xx-dma",
+ .of_match_table = ep93xx_dma_of_ids,
},
.id_table = ep93xx_dma_driver_ids,
};
diff --git a/include/linux/platform_data/dma-ep93xx.h b/include/linux/platform_data/dma-ep93xx.h
index eb9805bb3fe8..d485e3c21a3a 100644
--- a/include/linux/platform_data/dma-ep93xx.h
+++ b/include/linux/platform_data/dma-ep93xx.h
@@ -70,6 +70,9 @@ struct ep93xx_dma_platform_data {
static inline bool ep93xx_dma_chan_is_m2p(struct dma_chan *chan)
{
+ if (of_device_is_compatible(dev_of_node(chan->device->dev), "cirrus,ep9301-dma-m2p"))
+ return true;
+
return !strcmp(dev_name(chan->device->dev), "ep93xx-dma-m2p");
}
--
2.37.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v1 22/43] dma: cirrus: add DT support for Cirrus EP93xx
2023-06-01 5:45 ` [PATCH v1 22/43] dma: cirrus: add DT support for " Nikita Shubin
@ 2023-06-03 20:39 ` andy.shevchenko
0 siblings, 0 replies; 14+ messages in thread
From: andy.shevchenko @ 2023-06-03 20:39 UTC (permalink / raw)
To: Nikita Shubin
Cc: Alexander Sverdlin, Arnd Bergmann, Linus Walleij, Hartley Sweeten,
Russell King, Vinod Koul, Michael Peters, Kris Bahnsen,
linux-arm-kernel, linux-kernel, dmaengine
Thu, Jun 01, 2023 at 08:45:27AM +0300, Nikita Shubin kirjoitti:
> - find register range from the device tree
> - get clocks, interrupts from device tree
...
> --- a/arch/arm/mach-ep93xx/dma.c
> +++ b/arch/arm/mach-ep93xx/dma.c
> @@ -19,6 +19,7 @@
> #include <linux/init.h>
> #include <linux/interrupt.h>
> #include <linux/kernel.h>
> +#include <linux/of.h>
> #include <linux/platform_device.h>
>
> #include <linux/platform_data/dma-ep93xx.h>
Stray change.
...
> --- a/drivers/dma/ep93xx_dma.c
> +++ b/drivers/dma/ep93xx_dma.c
> @@ -20,6 +20,7 @@
> #include <linux/dmaengine.h>
> #include <linux/module.h>
> #include <linux/mod_devicetable.h>
> +#include <linux/of_device.h>
> #include <linux/platform_device.h>
> #include <linux/slab.h>
...
> - struct ep93xx_dma_chan channels[];
> + struct ep93xx_dma_chan *channels;
Why? This is helpful to allocate main structure and channels in one go.
...
> @@ -875,9 +881,11 @@ static int ep93xx_dma_alloc_chan_resources(struct dma_chan *chan)
> if (!edmac->edma->m2m) {
> if (!data)
> return -EINVAL;
> +
> if (data->port < EP93XX_DMA_I2S1 ||
> data->port > EP93XX_DMA_IRDA)
> return -EINVAL;
> +
> if (data->direction != ep93xx_dma_chan_direction(chan))
> return -EINVAL;
> } else {
Seems unrelated change.
> ep93xx_dma_advance_work(to_ep93xx_dma_chan(chan));
> }
...
> +static const struct of_device_id ep93xx_dma_of_ids[] = {
> + { .compatible = "cirrus,ep9301-dma-m2p", .data = &edma_m2p },
> + { .compatible = "cirrus,ep9301-dma-m2m", .data = &edma_m2m },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, ep93xx_dma_of_ids);
Move this closer to the real user (see below).
Also this ID table shouldn't be under ifdeffery.
...
> + struct device_node *np = pdev->dev.of_node;
> + const struct of_device_id *match = of_match_node(ep93xx_dma_of_ids, pdev->dev.of_node);
> + const struct ep93xx_edma_data *data = match->data;
No NULL check? Why do you have this duplication, btw?
> + struct dma_device *dma_dev = &edma->dma_dev;
> + int num_channels;
> + int i;
> +
> + match = of_match_device((ep93xx_dma_of_ids), &pdev->dev);
> + if (!match || !match->data) {
> + dev_err(&pdev->dev, "No device match found\n");
> + return -ENODEV;
> + }
Use of_device_get_match_data().
...
> + edma->channels = devm_kzalloc(&pdev->dev,
> + num_channels * sizeof(struct ep93xx_dma_chan),
> + GFP_KERNEL);
> + if (!edma->channels)
> + return -ENOMEM;
Simply no. See below what to do.
...
> + for (i = 0; i < num_channels; i++) {
> + struct ep93xx_dma_chan *edmac = &edma->channels[i];
> +
> + edmac->chan.device = dma_dev;
> + edmac->regs = devm_platform_ioremap_resource(pdev, i);
No error check?
> + edmac->irq = platform_get_irq(pdev, i);
No error check?
> + edmac->edma = edma;
> +
> + edmac->clk = of_clk_get(np, i);
Can this actually use clk_get() or its devm_*() variant?
> +
Redundant blank line.
> + if (IS_ERR(edmac->clk)) {
> + dev_warn(&pdev->dev, "failed to get clock\n");
> + continue;
> + }
> +
> + spin_lock_init(&edmac->lock);
> + INIT_LIST_HEAD(&edmac->active);
> + INIT_LIST_HEAD(&edmac->queue);
> + INIT_LIST_HEAD(&edmac->free_list);
> + tasklet_setup(&edmac->tasklet, ep93xx_dma_tasklet);
> +
> + list_add_tail(&edmac->chan.device_node,
> + &dma_dev->channels);
> + }
...
> - edma_size = pdata->num_channels * sizeof(struct ep93xx_dma_chan);
> - edma = kzalloc(sizeof(*edma) + edma_size, GFP_KERNEL);
> - if (!edma)
> + edma->channels = devm_kzalloc(&pdev->dev,
> + pdata->num_channels * sizeof(struct ep93xx_dma_chan),
> + GFP_KERNEL);
> + if (!edma->channels)
> return -ENOMEM;
No. Just include overflow.h and use struct_size().
...
> + edma = devm_kzalloc(&pdev->dev, sizeof(*edma), GFP_KERNEL);
> +
No error check?!
...
> + if (platform_get_device_id(pdev))
> + ret = ep93xx_init_from_pdata(pdev, edma);
> + else
> + ret = ep93xx_dma_of_probe(pdev, edma);
> +
Redundant blank line.
> + if (ret)
> + return ret;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 14+ messages in thread