Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1725776 > unrolled thread
| Started by | Stefan Brüns <stefan.bruens@rwth-aachen.de> |
|---|---|
| First post | 2017-09-04 00:50 +0200 |
| Last post | 2017-09-04 02:20 +0200 |
| Articles | 11 — 5 participants |
Back to article view | Back to linux.kernel
[PATCH 00/10] dmaengine: sun6i: Fixes for H3/A83T, enable A64 Stefan Brüns <stefan.bruens@rwth-aachen.de> - 2017-09-04 00:50 +0200
[PATCH 01/10] dmaengine: sun6i: Correct setting of clock autogating register for A83T/H3 Stefan Brüns <stefan.bruens@rwth-aachen.de> - 2017-09-04 00:50 +0200
Re: [PATCH 01/10] dmaengine: sun6i: Correct setting of clock autogating register for A83T/H3 André Przywara <andre.przywara@arm.com> - 2017-09-04 01:30 +0200
Re: [PATCH 01/10] dmaengine: sun6i: Correct setting of clock autogating register for A83T/H3 Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-09-04 09:10 +0200
[PATCH 02/10] dmaengine: sun6i: Correct burst length field offsets for H3 Stefan Brüns <stefan.bruens@rwth-aachen.de> - 2017-09-04 00:50 +0200
Re: [PATCH 02/10] dmaengine: sun6i: Correct burst length field offsets for H3 Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-09-04 10:00 +0200
Re: [PATCH 02/10] dmaengine: sun6i: Correct burst length field offsets for H3 Brüns, Stefan <Stefan.Bruens@rwth-aachen.de> - 2017-09-04 16:50 +0200
[PATCH 09/10] arm64: allwinner: a64: Add device node for DMA controller Stefan Brüns <stefan.bruens@rwth-aachen.de> - 2017-09-04 00:50 +0200
[PATCH 08/10] dmaengine: sun6i: Add support for Allwinner A64 and compatibles Stefan Brüns <stefan.bruens@rwth-aachen.de> - 2017-09-04 00:50 +0200
Re: [PATCH 08/10] dmaengine: sun6i: Add support for Allwinner A64 and compatibles André Przywara <andre.przywara@arm.com> - 2017-09-04 01:50 +0200
Re: [PATCH 08/10] dmaengine: sun6i: Add support for Allwinner A64 and compatibles Stefan Bruens <stefan.bruens@rwth-aachen.de> - 2017-09-04 02:20 +0200
| From | Stefan Brüns <stefan.bruens@rwth-aachen.de> |
|---|---|
| Date | 2017-09-04 00:50 +0200 |
| Subject | [PATCH 00/10] dmaengine: sun6i: Fixes for H3/A83T, enable A64 |
| Message-ID | <ulLSh-5Nr-3@gated-at.bofh.it> |
Commit 3a03ea763a67 ("dmaengine: sun6i: Add support for Allwinner A83T
(sun8i) variant") and commit f008db8c00c1 ("dmaengine: sun6i: Add support for
Allwinner H3 (sun8i) variant") added support for the A83T resp. H3, but missed
some differences between the original A31 and A83T/H3.
The first patch add a variable to group different SoC generations, i.e. A31,
A23+A83T, H3+later, and uses it to for the correct clock autogating setting.
The second and fourth patches reuse this variable to reflect changes in the
channel config register, i.e. different field offsets, new burst widths/lengths.
The third patch restructures some code required for the fourth patch.
Patch 5 restructures the code to decouple some controller details (e.g. channel
count) from the compatible string/the config.
Patches 6, 7 and 8 introduce and use the "dma-chans" property for the A64. Although
register compatible to the H3, the channel count differs and thus it requires a
new compatible. To avoid introduction of new compatibles for each minor variation,
anything but the register model is moved to devicetree properties. There
is at least one SoC (R40) which can then reuse the A64 compatible, the same
would have worked for A83T+V3s.
Patches 9 and 10 add the DMA controller node to the devicetree and add the DMA
controller reference to the SPI nodes.
This patch series could be called v2, but the patches were split and significantly
restructured, thus listing changes individually is not to meaningful.
Stefan Brüns (10):
dmaengine: sun6i: Correct setting of clock autogating register for
A83T/H3
dmaengine: sun6i: Correct burst length field offsets for H3
dmaengine: sun6i: Restructure code to allow extension for new SoCs
dmaengine: sun6i: Enable additional burst lengths/widths on H3
dmaengine: sun6i: Move number of pchans/vchans/request to device
struct
arm64: allwinner: a64: Add devicetree binding for DMA controller
dmaengine: sun6i: Retrieve channel count/max request from devicetree
dmaengine: sun6i: Add support for Allwinner A64 and compatibles
arm64: allwinner: a64: Add device node for DMA controller
arm64: allwinner: a64: add dma controller references to spi nodes
.../devicetree/bindings/dma/sun6i-dma.txt | 26 +++
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 15 ++
drivers/dma/sun6i-dma.c | 207 ++++++++++++++++-----
3 files changed, 197 insertions(+), 51 deletions(-)
--
2.14.1
[toc] | [next] | [standalone]
| From | Stefan Brüns <stefan.bruens@rwth-aachen.de> |
|---|---|
| Date | 2017-09-04 00:50 +0200 |
| Subject | [PATCH 01/10] dmaengine: sun6i: Correct setting of clock autogating register for A83T/H3 |
| Message-ID | <ulLSi-5Nr-15@gated-at.bofh.it> |
| In reply to | #1725776 |
The H83T uses a compatible string different from the A23, but requires
the same clock autogating register setting.
The H3 also requires setting the clock autogating register, but has
the register at a different offset.
Some currently available SoCs not yet supported by the sun6i-dma driver
will require new compatible strings. These SoCs either follow the A23
register model (e.g. V3s) or the H3 register model (A64, R40), so a new
variable is added to the config struct to group SoCs with common register
models.
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
---
drivers/dma/sun6i-dma.c | 34 +++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
index a2358780ab2c..1d9b3be30d22 100644
--- a/drivers/dma/sun6i-dma.c
+++ b/drivers/dma/sun6i-dma.c
@@ -48,6 +48,9 @@
#define SUN8I_DMA_GATE 0x20
#define SUN8I_DMA_GATE_ENABLE 0x4
+#define SUNXI_H3_SECURITE_REG 0x20
+#define SUNXI_H3_DMA_GATE 0x28
+#define SUNXI_H3_DMA_GATE_ENABLE 0x4
/*
* Channels specific registers
*/
@@ -90,6 +93,21 @@
#define NORMAL_WAIT 8
#define DRQ_SDRAM 1
+/*
+ * DMA Controller generations
+ *
+ * Newer SoC generations changed or added some register definitions:
+ * - A23 added a clock gate register
+ * - H3 has a different offset for the clock gating register,
+ * the burst length field has a different offset in the channel
+ * configuration register, also additional burst lengths/widths.
+ */
+enum dmac_variant {
+ DMAC_VARIANT_A31,
+ DMAC_VARIANT_A23,
+ DMAC_VARIANT_H3,
+};
+
/*
* Hardware channels / ports representation
*
@@ -101,6 +119,7 @@ struct sun6i_dma_config {
u32 nr_max_channels;
u32 nr_max_requests;
u32 nr_max_vchans;
+ enum dmac_variant dmac_variant;
};
/*
@@ -998,6 +1017,7 @@ static struct sun6i_dma_config sun6i_a31_dma_cfg = {
.nr_max_channels = 16,
.nr_max_requests = 30,
.nr_max_vchans = 53,
+ .dmac_variant = DMAC_VARIANT_A31,
};
/*
@@ -1009,23 +1029,29 @@ static struct sun6i_dma_config sun8i_a23_dma_cfg = {
.nr_max_channels = 8,
.nr_max_requests = 24,
.nr_max_vchans = 37,
+ .dmac_variant = DMAC_VARIANT_A23,
};
static struct sun6i_dma_config sun8i_a83t_dma_cfg = {
.nr_max_channels = 8,
.nr_max_requests = 28,
.nr_max_vchans = 39,
+ .dmac_variant = DMAC_VARIANT_A23,
};
/*
* The H3 has 12 physical channels, a maximum DRQ port id of 27,
* and a total of 34 usable source and destination endpoints.
+ * It also supports additional burst lengths and bus widths,
+ * and the burst length fields have different offsets.
*/
static struct sun6i_dma_config sun8i_h3_dma_cfg = {
.nr_max_channels = 12,
.nr_max_requests = 27,
.nr_max_vchans = 34,
+ .dmac_variant = DMAC_VARIANT_H3,
+};
};
static const struct of_device_id sun6i_dma_match[] = {
@@ -1177,11 +1203,13 @@ static int sun6i_dma_probe(struct platform_device *pdev)
/*
* sun8i variant requires us to toggle a dma gating register,
* as seen in Allwinner's SDK. This register is not documented
- * in the A23 user manual.
+ * in the A23 user manual, but appears in e.g. the H83T manual.
+ * For the H3, H5 and A64, the register has a different location
*/
- if (of_device_is_compatible(pdev->dev.of_node,
- "allwinner,sun8i-a23-dma"))
+ if (sdc->cfg->dmac_variant == DMAC_VARIANT_A23)
writel(SUN8I_DMA_GATE_ENABLE, sdc->base + SUN8I_DMA_GATE);
+ else if (sdc->cfg->dmac_variant == DMAC_VARIANT_H3)
+ writel(SUNXI_H3_DMA_GATE_ENABLE, sdc->base + SUNXI_H3_DMA_GATE);
return 0;
--
2.14.1
[toc] | [prev] | [next] | [standalone]
| From | André Przywara <andre.przywara@arm.com> |
|---|---|
| Date | 2017-09-04 01:30 +0200 |
| Subject | Re: [PATCH 01/10] dmaengine: sun6i: Correct setting of clock autogating register for A83T/H3 |
| Message-ID | <ulMv0-6gS-3@gated-at.bofh.it> |
| In reply to | #1725777 |
On 03/09/17 23:40, Stefan Brüns wrote:
> The H83T uses a compatible string different from the A23, but requires
A83T
> the same clock autogating register setting.
>
> The H3 also requires setting the clock autogating register, but has
> the register at a different offset.
>
> Some currently available SoCs not yet supported by the sun6i-dma driver
> will require new compatible strings. These SoCs either follow the A23
> register model (e.g. V3s) or the H3 register model (A64, R40), so a new
> variable is added to the config struct to group SoCs with common register
> models.
As mentioned in that other mail, using the actual properties as names
here instead of grouping them to rather arbitrary groups seems more
useful and future-proof to me and should be easier to read.
In this case this should simplify this patch:
sun8i_a23_dma_cfg = {
.nr_max_channels = 8,
.nr_max_requests = 24,
.nr_max_vchans = 37,
+ .auto_clock_gate = 0x20,
...
- if (of_device_is_compatible(pdev->dev.of_node,
- "allwinner,sun8i-a23-dma"))
- writel(SUN8I_DMA_GATE_ENABLE, sdc->base + SUN8I_DMA_GATE);
+ if (sdc->cfg->auto_clock_gate)
+ writel(SUN8I_DMA_GATE_ENABLE,
+ sdc->base + sdc->cfg->auto_clock_gate);
> Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
> ---
> drivers/dma/sun6i-dma.c | 34 +++++++++++++++++++++++++++++++---
> 1 file changed, 31 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
> index a2358780ab2c..1d9b3be30d22 100644
> --- a/drivers/dma/sun6i-dma.c
> +++ b/drivers/dma/sun6i-dma.c
> @@ -48,6 +48,9 @@
> #define SUN8I_DMA_GATE 0x20
> #define SUN8I_DMA_GATE_ENABLE 0x4
>
> +#define SUNXI_H3_SECURITE_REG 0x20
typo? SUNXI_H3_SECURITY_REG ?
Cheers,
Andre.
> +#define SUNXI_H3_DMA_GATE 0x28
> +#define SUNXI_H3_DMA_GATE_ENABLE 0x4
> /*
> * Channels specific registers
> */
> @@ -90,6 +93,21 @@
> #define NORMAL_WAIT 8
> #define DRQ_SDRAM 1
>
> +/*
> + * DMA Controller generations
> + *
> + * Newer SoC generations changed or added some register definitions:
> + * - A23 added a clock gate register
> + * - H3 has a different offset for the clock gating register,
> + * the burst length field has a different offset in the channel
> + * configuration register, also additional burst lengths/widths.
> + */
> +enum dmac_variant {
> + DMAC_VARIANT_A31,
> + DMAC_VARIANT_A23,
> + DMAC_VARIANT_H3,
> +};
> +
> /*
> * Hardware channels / ports representation
> *
> @@ -101,6 +119,7 @@ struct sun6i_dma_config {
> u32 nr_max_channels;
> u32 nr_max_requests;
> u32 nr_max_vchans;
> + enum dmac_variant dmac_variant;
> };
>
> /*
> @@ -998,6 +1017,7 @@ static struct sun6i_dma_config sun6i_a31_dma_cfg = {
> .nr_max_channels = 16,
> .nr_max_requests = 30,
> .nr_max_vchans = 53,
> + .dmac_variant = DMAC_VARIANT_A31,
> };
>
> /*
> @@ -1009,23 +1029,29 @@ static struct sun6i_dma_config sun8i_a23_dma_cfg = {
> .nr_max_channels = 8,
> .nr_max_requests = 24,
> .nr_max_vchans = 37,
> + .dmac_variant = DMAC_VARIANT_A23,
> };
>
> static struct sun6i_dma_config sun8i_a83t_dma_cfg = {
> .nr_max_channels = 8,
> .nr_max_requests = 28,
> .nr_max_vchans = 39,
> + .dmac_variant = DMAC_VARIANT_A23,
> };
>
> /*
> * The H3 has 12 physical channels, a maximum DRQ port id of 27,
> * and a total of 34 usable source and destination endpoints.
> + * It also supports additional burst lengths and bus widths,
> + * and the burst length fields have different offsets.
> */
>
> static struct sun6i_dma_config sun8i_h3_dma_cfg = {
> .nr_max_channels = 12,
> .nr_max_requests = 27,
> .nr_max_vchans = 34,
> + .dmac_variant = DMAC_VARIANT_H3,
> +};
> };
>
> static const struct of_device_id sun6i_dma_match[] = {
> @@ -1177,11 +1203,13 @@ static int sun6i_dma_probe(struct platform_device *pdev)
> /*
> * sun8i variant requires us to toggle a dma gating register,
> * as seen in Allwinner's SDK. This register is not documented
> - * in the A23 user manual.
> + * in the A23 user manual, but appears in e.g. the H83T manual.
> + * For the H3, H5 and A64, the register has a different location
> */
> - if (of_device_is_compatible(pdev->dev.of_node,
> - "allwinner,sun8i-a23-dma"))
> + if (sdc->cfg->dmac_variant == DMAC_VARIANT_A23)
> writel(SUN8I_DMA_GATE_ENABLE, sdc->base + SUN8I_DMA_GATE);
> + else if (sdc->cfg->dmac_variant == DMAC_VARIANT_H3)
> + writel(SUNXI_H3_DMA_GATE_ENABLE, sdc->base + SUNXI_H3_DMA_GATE);
>
> return 0;
>
>
[toc] | [prev] | [next] | [standalone]
| From | Maxime Ripard <maxime.ripard@free-electrons.com> |
|---|---|
| Date | 2017-09-04 09:10 +0200 |
| Subject | Re: [PATCH 01/10] dmaengine: sun6i: Correct setting of clock autogating register for A83T/H3 |
| Message-ID | <ulTG9-2sx-1@gated-at.bofh.it> |
| In reply to | #1725783 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, Sep 04, 2017 at 12:23:09AM +0100, André Przywara wrote:
> On 03/09/17 23:40, Stefan Brüns wrote:
> > The H83T uses a compatible string different from the A23, but requires
>
> A83T
>
> > the same clock autogating register setting.
> >
> > The H3 also requires setting the clock autogating register, but has
> > the register at a different offset.
> >
> > Some currently available SoCs not yet supported by the sun6i-dma driver
> > will require new compatible strings. These SoCs either follow the A23
> > register model (e.g. V3s) or the H3 register model (A64, R40), so a new
> > variable is added to the config struct to group SoCs with common register
> > models.
>
> As mentioned in that other mail, using the actual properties as names
> here instead of grouping them to rather arbitrary groups seems more
> useful and future-proof to me and should be easier to read.
> In this case this should simplify this patch:
> sun8i_a23_dma_cfg = {
> .nr_max_channels = 8,
> .nr_max_requests = 24,
> .nr_max_vchans = 37,
> + .auto_clock_gate = 0x20,
> ...
> - if (of_device_is_compatible(pdev->dev.of_node,
> - "allwinner,sun8i-a23-dma"))
> - writel(SUN8I_DMA_GATE_ENABLE, sdc->base + SUN8I_DMA_GATE);
> + if (sdc->cfg->auto_clock_gate)
> + writel(SUN8I_DMA_GATE_ENABLE,
> + sdc->base + sdc->cfg->auto_clock_gate);
I agree.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
[toc] | [prev] | [next] | [standalone]
| From | Stefan Brüns <stefan.bruens@rwth-aachen.de> |
|---|---|
| Date | 2017-09-04 00:50 +0200 |
| Subject | [PATCH 02/10] dmaengine: sun6i: Correct burst length field offsets for H3 |
| Message-ID | <ulLSi-5Nr-17@gated-at.bofh.it> |
| In reply to | #1725776 |
For the H3, the burst lengths field offsets in the channel configuration
register differs from earlier SoC generations.
Using the A31 register macros actually configured the H3 controller
do to bursts of length 1 always, which although working leads to higher
bus utilisation.
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
---
drivers/dma/sun6i-dma.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
index 1d9b3be30d22..f1a139f0102f 100644
--- a/drivers/dma/sun6i-dma.c
+++ b/drivers/dma/sun6i-dma.c
@@ -68,13 +68,15 @@
#define DMA_CHAN_CFG_SRC_DRQ(x) ((x) & 0x1f)
#define DMA_CHAN_CFG_SRC_IO_MODE BIT(5)
#define DMA_CHAN_CFG_SRC_LINEAR_MODE (0 << 5)
-#define DMA_CHAN_CFG_SRC_BURST(x) (((x) & 0x3) << 7)
+#define DMA_CHAN_CFG_SRC_BURST_A31(x) (((x) & 0x3) << 7)
+#define DMA_CHAN_CFG_SRC_BURST_H3(x) (((x) & 0x3) << 6)
#define DMA_CHAN_CFG_SRC_WIDTH(x) (((x) & 0x3) << 9)
#define DMA_CHAN_CFG_DST_DRQ(x) (DMA_CHAN_CFG_SRC_DRQ(x) << 16)
#define DMA_CHAN_CFG_DST_IO_MODE (DMA_CHAN_CFG_SRC_IO_MODE << 16)
#define DMA_CHAN_CFG_DST_LINEAR_MODE (DMA_CHAN_CFG_SRC_LINEAR_MODE << 16)
-#define DMA_CHAN_CFG_DST_BURST(x) (DMA_CHAN_CFG_SRC_BURST(x) << 16)
+#define DMA_CHAN_CFG_DST_BURST_A31(x) (DMA_CHAN_CFG_SRC_BURST_A31(x) << 16)
+#define DMA_CHAN_CFG_DST_BURST_H3(x) (DMA_CHAN_CFG_SRC_BURST_H3(x) << 16)
#define DMA_CHAN_CFG_DST_WIDTH(x) (DMA_CHAN_CFG_SRC_WIDTH(x) << 16)
#define DMA_CHAN_CUR_SRC 0x10
@@ -554,11 +556,17 @@ static int set_config(struct sun6i_dma_dev *sdev,
if (dst_width < 0)
return dst_width;
- *p_cfg = DMA_CHAN_CFG_SRC_BURST(src_burst) |
- DMA_CHAN_CFG_SRC_WIDTH(src_width) |
- DMA_CHAN_CFG_DST_BURST(dst_burst) |
+ *p_cfg = DMA_CHAN_CFG_SRC_WIDTH(src_width) |
DMA_CHAN_CFG_DST_WIDTH(dst_width);
+ if (sdev->cfg->dmac_variant == DMAC_VARIANT_H3) {
+ *p_cfg |= DMA_CHAN_CFG_SRC_BURST_H3(src_burst) |
+ DMA_CHAN_CFG_DST_BURST_H3(dst_burst);
+ } else {
+ *p_cfg |= DMA_CHAN_CFG_SRC_BURST_A31(src_burst) |
+ DMA_CHAN_CFG_DST_BURST_A31(dst_burst);
+ }
+
return 0;
}
@@ -601,11 +609,17 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_memcpy(
DMA_CHAN_CFG_DST_DRQ(DRQ_SDRAM) |
DMA_CHAN_CFG_DST_LINEAR_MODE |
DMA_CHAN_CFG_SRC_LINEAR_MODE |
- DMA_CHAN_CFG_SRC_BURST(burst) |
DMA_CHAN_CFG_SRC_WIDTH(width) |
- DMA_CHAN_CFG_DST_BURST(burst) |
DMA_CHAN_CFG_DST_WIDTH(width);
+ if (sdev->cfg->dmac_variant == DMAC_VARIANT_H3) {
+ v_lli->cfg |= DMA_CHAN_CFG_SRC_BURST_H3(burst) |
+ DMA_CHAN_CFG_DST_BURST_H3(burst);
+ } else {
+ v_lli->cfg |= DMA_CHAN_CFG_SRC_BURST_A31(burst) |
+ DMA_CHAN_CFG_DST_BURST_A31(burst);
+ }
+
sun6i_dma_lli_add(NULL, v_lli, p_lli, txd);
sun6i_dma_dump_lli(vchan, v_lli);
--
2.14.1
[toc] | [prev] | [next] | [standalone]
| From | Maxime Ripard <maxime.ripard@free-electrons.com> |
|---|---|
| Date | 2017-09-04 10:00 +0200 |
| Subject | Re: [PATCH 02/10] dmaengine: sun6i: Correct burst length field offsets for H3 |
| Message-ID | <ulUsy-2Ip-5@gated-at.bofh.it> |
| In reply to | #1725778 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, Sep 04, 2017 at 12:40:53AM +0200, Stefan Brüns wrote:
> For the H3, the burst lengths field offsets in the channel configuration
> register differs from earlier SoC generations.
>
> Using the A31 register macros actually configured the H3 controller
> do to bursts of length 1 always, which although working leads to higher
> bus utilisation.
>
> Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
> ---
> drivers/dma/sun6i-dma.c | 28 +++++++++++++++++++++-------
> 1 file changed, 21 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
> index 1d9b3be30d22..f1a139f0102f 100644
> --- a/drivers/dma/sun6i-dma.c
> +++ b/drivers/dma/sun6i-dma.c
> @@ -68,13 +68,15 @@
> #define DMA_CHAN_CFG_SRC_DRQ(x) ((x) & 0x1f)
> #define DMA_CHAN_CFG_SRC_IO_MODE BIT(5)
> #define DMA_CHAN_CFG_SRC_LINEAR_MODE (0 << 5)
> -#define DMA_CHAN_CFG_SRC_BURST(x) (((x) & 0x3) << 7)
> +#define DMA_CHAN_CFG_SRC_BURST_A31(x) (((x) & 0x3) << 7)
> +#define DMA_CHAN_CFG_SRC_BURST_H3(x) (((x) & 0x3) << 6)
> #define DMA_CHAN_CFG_SRC_WIDTH(x) (((x) & 0x3) << 9)
>
> #define DMA_CHAN_CFG_DST_DRQ(x) (DMA_CHAN_CFG_SRC_DRQ(x) << 16)
> #define DMA_CHAN_CFG_DST_IO_MODE (DMA_CHAN_CFG_SRC_IO_MODE << 16)
> #define DMA_CHAN_CFG_DST_LINEAR_MODE (DMA_CHAN_CFG_SRC_LINEAR_MODE << 16)
> -#define DMA_CHAN_CFG_DST_BURST(x) (DMA_CHAN_CFG_SRC_BURST(x) << 16)
> +#define DMA_CHAN_CFG_DST_BURST_A31(x) (DMA_CHAN_CFG_SRC_BURST_A31(x) << 16)
> +#define DMA_CHAN_CFG_DST_BURST_H3(x) (DMA_CHAN_CFG_SRC_BURST_H3(x) << 16)
> #define DMA_CHAN_CFG_DST_WIDTH(x) (DMA_CHAN_CFG_SRC_WIDTH(x) << 16)
>
> #define DMA_CHAN_CUR_SRC 0x10
> @@ -554,11 +556,17 @@ static int set_config(struct sun6i_dma_dev *sdev,
> if (dst_width < 0)
> return dst_width;
>
> - *p_cfg = DMA_CHAN_CFG_SRC_BURST(src_burst) |
> - DMA_CHAN_CFG_SRC_WIDTH(src_width) |
> - DMA_CHAN_CFG_DST_BURST(dst_burst) |
> + *p_cfg = DMA_CHAN_CFG_SRC_WIDTH(src_width) |
> DMA_CHAN_CFG_DST_WIDTH(dst_width);
>
> + if (sdev->cfg->dmac_variant == DMAC_VARIANT_H3) {
> + *p_cfg |= DMA_CHAN_CFG_SRC_BURST_H3(src_burst) |
> + DMA_CHAN_CFG_DST_BURST_H3(dst_burst);
> + } else {
> + *p_cfg |= DMA_CHAN_CFG_SRC_BURST_A31(src_burst) |
> + DMA_CHAN_CFG_DST_BURST_A31(dst_burst);
> + }
> +
I guess we have two options to support that properly. We could either
have a different function that would generate that register value
based on the parameters we have, or duplicate the set_config function
entirely, with function pointer stored in the configuration.
I think I prefer the former, as it reduces the code duplication.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
[toc] | [prev] | [next] | [standalone]
| From | Brüns, Stefan <Stefan.Bruens@rwth-aachen.de> |
|---|---|
| Date | 2017-09-04 16:50 +0200 |
| Subject | Re: [PATCH 02/10] dmaengine: sun6i: Correct burst length field offsets for H3 |
| Message-ID | <um0Rk-6HY-5@gated-at.bofh.it> |
| In reply to | #1725900 |
On Montag, 4. September 2017 09:59:24 CEST Maxime Ripard wrote:
> On Mon, Sep 04, 2017 at 12:40:53AM +0200, Stefan Brüns wrote:
> > For the H3, the burst lengths field offsets in the channel configuration
> > register differs from earlier SoC generations.
> >
> > Using the A31 register macros actually configured the H3 controller
> > do to bursts of length 1 always, which although working leads to higher
> > bus utilisation.
> >
> > Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
> > ---
> >
> > drivers/dma/sun6i-dma.c | 28 +++++++++++++++++++++-------
> > 1 file changed, 21 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
> > index 1d9b3be30d22..f1a139f0102f 100644
> > --- a/drivers/dma/sun6i-dma.c
> > +++ b/drivers/dma/sun6i-dma.c
> > @@ -68,13 +68,15 @@
> >
> > #define DMA_CHAN_CFG_SRC_DRQ(x) ((x) & 0x1f)
> > #define DMA_CHAN_CFG_SRC_IO_MODE BIT(5)
> > #define DMA_CHAN_CFG_SRC_LINEAR_MODE (0 << 5)
> >
> > -#define DMA_CHAN_CFG_SRC_BURST(x) (((x) & 0x3) << 7)
> > +#define DMA_CHAN_CFG_SRC_BURST_A31(x) (((x) & 0x3) << 7)
> > +#define DMA_CHAN_CFG_SRC_BURST_H3(x) (((x) & 0x3) << 6)
> >
> > #define DMA_CHAN_CFG_SRC_WIDTH(x) (((x) & 0x3) << 9)
> >
> > #define DMA_CHAN_CFG_DST_DRQ(x) (DMA_CHAN_CFG_SRC_DRQ(x) << 16)
> > #define DMA_CHAN_CFG_DST_IO_MODE (DMA_CHAN_CFG_SRC_IO_MODE << 16)
> > #define DMA_CHAN_CFG_DST_LINEAR_MODE (DMA_CHAN_CFG_SRC_LINEAR_MODE << 16)
> >
> > -#define DMA_CHAN_CFG_DST_BURST(x) (DMA_CHAN_CFG_SRC_BURST(x) << 16)
> > +#define DMA_CHAN_CFG_DST_BURST_A31(x) (DMA_CHAN_CFG_SRC_BURST_A31(x) <<
> > 16) +#define DMA_CHAN_CFG_DST_BURST_H3(x) (DMA_CHAN_CFG_SRC_BURST_H3(x)
> > << 16)>
> > #define DMA_CHAN_CFG_DST_WIDTH(x) (DMA_CHAN_CFG_SRC_WIDTH(x) << 16)
> >
> > #define DMA_CHAN_CUR_SRC 0x10
> >
> > @@ -554,11 +556,17 @@ static int set_config(struct sun6i_dma_dev *sdev,
> >
> > if (dst_width < 0)
> >
> > return dst_width;
> >
> > - *p_cfg = DMA_CHAN_CFG_SRC_BURST(src_burst) |
> > - DMA_CHAN_CFG_SRC_WIDTH(src_width) |
> > - DMA_CHAN_CFG_DST_BURST(dst_burst) |
> > + *p_cfg = DMA_CHAN_CFG_SRC_WIDTH(src_width) |
> >
> > DMA_CHAN_CFG_DST_WIDTH(dst_width);
> >
> > + if (sdev->cfg->dmac_variant == DMAC_VARIANT_H3) {
> > + *p_cfg |= DMA_CHAN_CFG_SRC_BURST_H3(src_burst) |
> > + DMA_CHAN_CFG_DST_BURST_H3(dst_burst);
> > + } else {
> > + *p_cfg |= DMA_CHAN_CFG_SRC_BURST_A31(src_burst) |
> > + DMA_CHAN_CFG_DST_BURST_A31(dst_burst);
> > + }
> > +
>
> I guess we have two options to support that properly. We could either
> have a different function that would generate that register value
> based on the parameters we have, or duplicate the set_config function
> entirely, with function pointer stored in the configuration.
>
> I think I prefer the former, as it reduces the code duplication.
Duplicating "set_config" would also mean duplicating sun6i_dma_prep_dma_memcpy
- there are two hunks which change setting of the burst length register value.
A function pointer in the config would work.
Kind regards,
Stefan
[toc] | [prev] | [next] | [standalone]
| From | Stefan Brüns <stefan.bruens@rwth-aachen.de> |
|---|---|
| Date | 2017-09-04 00:50 +0200 |
| Subject | [PATCH 09/10] arm64: allwinner: a64: Add device node for DMA controller |
| Message-ID | <ulLSi-5Nr-11@gated-at.bofh.it> |
| In reply to | #1725776 |
The A64 SoC has a DMA controller that supports 8 DMA channels
to and from various peripherals. The last used DRQ port is 27.
Add a device node for it.
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
---
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
index 882e2155f0aa..ccec81c4e9d2 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
@@ -136,6 +136,17 @@
reg = <0x01c00000 0x1000>;
};
+ dma: dma-controller@01c02000 {
+ compatible = "allwinner,sun50i-a64-dma";
+ reg = <0x01c02000 0x1000>;
+ interrupts = <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&ccu CLK_BUS_DMA>;
+ dma-channels = <8>;
+ dma-requests = <27>;
+ resets = <&ccu RST_BUS_DMA>;
+ #dma-cells = <1>;
+ };
+
mmc0: mmc@1c0f000 {
compatible = "allwinner,sun50i-a64-mmc";
reg = <0x01c0f000 0x1000>;
--
2.14.1
[toc] | [prev] | [next] | [standalone]
| From | Stefan Brüns <stefan.bruens@rwth-aachen.de> |
|---|---|
| Date | 2017-09-04 00:50 +0200 |
| Subject | [PATCH 08/10] dmaengine: sun6i: Add support for Allwinner A64 and compatibles |
| Message-ID | <ulLSi-5Nr-19@gated-at.bofh.it> |
| In reply to | #1725776 |
The A64 SoC has the same dma engine as the H3 (sun8i), with a
reduced amount of physical channels. To allow future reuse of the
compatible, leave the channel count etc. in the config data blank
and retrieve it from the devicetree.
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
---
drivers/dma/sun6i-dma.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
index bd4c2e4a759b..4fae7ffad549 100644
--- a/drivers/dma/sun6i-dma.c
+++ b/drivers/dma/sun6i-dma.c
@@ -1076,6 +1076,16 @@ static struct sun6i_dma_config sun8i_h3_dma_cfg = {
.nr_max_vchans = 34,
.dmac_variant = DMAC_VARIANT_H3,
};
+
+/*
+ * The A64 binding uses the number of dma channels from the
+ * device tree node.
+ */
+static struct sun6i_dma_config sun50i_a64_dma_cfg = {
+ .nr_max_channels = 0,
+ .nr_max_requests = 0,
+ .nr_max_vchans = 0,
+ .dmac_variant = DMAC_VARIANT_H3,
};
static const struct of_device_id sun6i_dma_match[] = {
@@ -1083,6 +1093,7 @@ static const struct of_device_id sun6i_dma_match[] = {
{ .compatible = "allwinner,sun8i-a23-dma", .data = &sun8i_a23_dma_cfg },
{ .compatible = "allwinner,sun8i-a83t-dma", .data = &sun8i_a83t_dma_cfg },
{ .compatible = "allwinner,sun8i-h3-dma", .data = &sun8i_h3_dma_cfg },
+ { .compatible = "allwinner,sun50i-a64-dma", .data = &sun50i_a64_dma_cfg },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, sun6i_dma_match);
@@ -1090,6 +1101,7 @@ MODULE_DEVICE_TABLE(of, sun6i_dma_match);
static int sun6i_dma_probe(struct platform_device *pdev)
{
const struct of_device_id *device;
+ struct device_node *np = pdev->dev.of_node;
struct sun6i_dma_dev *sdc;
struct resource *res;
int ret, i;
--
2.14.1
[toc] | [prev] | [next] | [standalone]
| From | André Przywara <andre.przywara@arm.com> |
|---|---|
| Date | 2017-09-04 01:50 +0200 |
| Subject | Re: [PATCH 08/10] dmaengine: sun6i: Add support for Allwinner A64 and compatibles |
| Message-ID | <ulMOl-6mU-1@gated-at.bofh.it> |
| In reply to | #1725780 |
Hi,
On 03/09/17 23:40, Stefan Brüns wrote:
> The A64 SoC has the same dma engine as the H3 (sun8i), with a
> reduced amount of physical channels. To allow future reuse of the
> compatible, leave the channel count etc. in the config data blank
> and retrieve it from the devicetree.
>
> Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
> ---
> drivers/dma/sun6i-dma.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
> index bd4c2e4a759b..4fae7ffad549 100644
> --- a/drivers/dma/sun6i-dma.c
> +++ b/drivers/dma/sun6i-dma.c
> @@ -1076,6 +1076,16 @@ static struct sun6i_dma_config sun8i_h3_dma_cfg = {
> .nr_max_vchans = 34,
> .dmac_variant = DMAC_VARIANT_H3,
> };
> +
> +/*
> + * The A64 binding uses the number of dma channels from the
> + * device tree node.
> + */
> +static struct sun6i_dma_config sun50i_a64_dma_cfg = {
> + .nr_max_channels = 0,
> + .nr_max_requests = 0,
But this does not work with the "dma-requests" property being optional
according to the binding spec? Either we put the value for the A64 in
here (and thus force the R40 and others to specify this in the DT) or we
map the "0" from struct config to DMA_CHAN_MAX_DRQ in the probe function.
> + .nr_max_vchans = 0,
> + .dmac_variant = DMAC_VARIANT_H3,
> };
>
> static const struct of_device_id sun6i_dma_match[] = {
> @@ -1083,6 +1093,7 @@ static const struct of_device_id sun6i_dma_match[] = {
> { .compatible = "allwinner,sun8i-a23-dma", .data = &sun8i_a23_dma_cfg },
> { .compatible = "allwinner,sun8i-a83t-dma", .data = &sun8i_a83t_dma_cfg },
> { .compatible = "allwinner,sun8i-h3-dma", .data = &sun8i_h3_dma_cfg },
> + { .compatible = "allwinner,sun50i-a64-dma", .data = &sun50i_a64_dma_cfg },
> { /* sentinel */ }
> };
> MODULE_DEVICE_TABLE(of, sun6i_dma_match);
> @@ -1090,6 +1101,7 @@ MODULE_DEVICE_TABLE(of, sun6i_dma_match);
> static int sun6i_dma_probe(struct platform_device *pdev)
> {
> const struct of_device_id *device;
> + struct device_node *np = pdev->dev.of_node;
Is this some rebase/split artefact?
Cheers,
Andre.
> struct sun6i_dma_dev *sdc;
> struct resource *res;
> int ret, i;
>
[toc] | [prev] | [next] | [standalone]
| From | Stefan Bruens <stefan.bruens@rwth-aachen.de> |
|---|---|
| Date | 2017-09-04 02:20 +0200 |
| Subject | Re: [PATCH 08/10] dmaengine: sun6i: Add support for Allwinner A64 and compatibles |
| Message-ID | <ulNhn-6Ld-3@gated-at.bofh.it> |
| In reply to | #1725785 |
On Montag, 4. September 2017 01:37:58 CEST André Przywara wrote:
> > @@ -1090,6 +1101,7 @@ MODULE_DEVICE_TABLE(of, sun6i_dma_match);
> >
> > static int sun6i_dma_probe(struct platform_device *pdev)
> > {
> >
> > const struct of_device_id *device;
> >
> > + struct device_node *np = pdev->dev.of_node;
>
> Is this some rebase/split artefact?
>
> Cheers,
> Andre.
>
Yes, that one should be in patch 7/10 ...
Kind regards,
Stefan
--
Stefan Brüns / Bergstraße 21 / 52062 Aachen
home: +49 241 53809034 mobile: +49 151 50412019
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web