2013-06-13 08:40:14

by Ludovic Desroches

[permalink] [raw]
Subject: [PATCH v3 0/2] dmaengine: at_hdmac: dt dma bindings update

From: Ludovic Desroches <[email protected]>

Vinod,

This version removes the extra tab in patch 2/2 and add Arnd's ack.


Thanks

Regards

Ludovic


This set of patches update the dt dma binding for at_hdmac since we need one
more parameter. In order to keep backward compatibility, an existing cell will
be used to add this parameter. Since the content of that cell will become a
magic value due to the concatenation of the two parameters, it is time to
use macros.

v3:
- remove extra tab in patch 2/2
v2:
- rebased on slave-dma/next


Ludovic Desroches (2):
ARM: at91: dt: add header to define at_hdmac configuration
at_hdmac: add FIFO configuration parameter to DMA DT binding

.../devicetree/bindings/dma/atmel-dma.txt | 7 ++++--
drivers/dma/at_hdmac.c | 25 ++++++++++++++++----
include/dt-bindings/dma/at91.h | 27 ++++++++++++++++++++++
3 files changed, 53 insertions(+), 6 deletions(-)
create mode 100644 include/dt-bindings/dma/at91.h

--
1.7.11.3


2013-06-13 08:40:51

by Ludovic Desroches

[permalink] [raw]
Subject: [PATCH v3 1/2] ARM: at91: dt: add header to define at_hdmac configuration

From: Ludovic Desroches <[email protected]>

DMA-cell content is a concatenation of several values. In order to keep this
stuff human readable, macros are introduced.

The values for the FIFO configuration are not the same as the ones used in the
configuration register in order to keep backward compatibility. Most devices
use the half FIFO configuration but USART ones have to use the ASAP
configuration. This parameter was not initially planed to be into the at91 dma
dt binding. The third cell will be used to store this parameter, it will
become a concatenation of the FIFO configuration and of the peripheral ID. In
order to keep backward compatibility i.e. FIFO configuration is equal to 0, we
have to perform a translation since the value to put in the register to set
half FIFO is 1.

Acked-by: Arnd Bergmann <[email protected]>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by: Ludovic Desroches <[email protected]>
---
include/dt-bindings/dma/at91.h | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 include/dt-bindings/dma/at91.h

diff --git a/include/dt-bindings/dma/at91.h b/include/dt-bindings/dma/at91.h
new file mode 100644
index 0000000..e835037
--- /dev/null
+++ b/include/dt-bindings/dma/at91.h
@@ -0,0 +1,27 @@
+/*
+ * This header provides macros for at91 dma bindings.
+ *
+ * Copyright (C) 2013 Ludovic Desroches <[email protected]>
+ *
+ * GPLv2 only
+ */
+
+#ifndef __DT_BINDINGS_AT91_DMA_H__
+#define __DT_BINDINGS_AT91_DMA_H__
+
+/*
+ * Source and/or destination peripheral ID
+ */
+#define AT91_DMA_CFG_PER_ID_MASK (0xff)
+#define AT91_DMA_CFG_PER_ID(id) (id & AT91_DMA_CFG_PER_ID_MASK)
+
+/*
+ * FIFO configuration: it defines when a request is serviced.
+ */
+#define AT91_DMA_CFG_FIFOCFG_OFFSET (8)
+#define AT91_DMA_CFG_FIFOCFG_MASK (0xf << AT91_DMA_CFG_FIFOCFG_OFFSET)
+#define AT91_DMA_CFG_FIFOCFG_HALF (0x0 << AT91_DMA_CFG_FIFOCFG_OFFSET) /* half FIFO (default behavior) */
+#define AT91_DMA_CFG_FIFOCFG_ALAP (0x1 << AT91_DMA_CFG_FIFOCFG_OFFSET) /* largest defined AHB burst */
+#define AT91_DMA_CFG_FIFOCFG_ASAP (0x2 << AT91_DMA_CFG_FIFOCFG_OFFSET) /* single AHB access */
+
+#endif /* __DT_BINDINGS_AT91_DMA_H__ */
--
1.7.11.3

2013-06-13 08:41:11

by Ludovic Desroches

[permalink] [raw]
Subject: [PATCH v3 2/2] at_hdmac: add FIFO configuration parameter to DMA DT binding

From: Ludovic Desroches <[email protected]>

For most devices the FIFO configuration is the same i.e. when half FIFO size is
available/filled, a source/destination request is serviced. But USART devices
have to do it when there is enough space/data available to perform a single
AHB access so the ASAP configuration.

Acked-by: Nicolas Ferre <[email protected]>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by: Ludovic Desroches <[email protected]>
---
.../devicetree/bindings/dma/atmel-dma.txt | 7 ++++--
drivers/dma/at_hdmac.c | 25 ++++++++++++++++++----
2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/dma/atmel-dma.txt b/Documentation/devicetree/bindings/dma/atmel-dma.txt
index c80e8a3..c280a0e 100644
--- a/Documentation/devicetree/bindings/dma/atmel-dma.txt
+++ b/Documentation/devicetree/bindings/dma/atmel-dma.txt
@@ -24,8 +24,11 @@ The three cells in order are:
1. A phandle pointing to the DMA controller.
2. The memory interface (16 most significant bits), the peripheral interface
(16 less significant bits).
-3. The peripheral identifier for the hardware handshaking interface. The
-identifier can be different for tx and rx.
+3. Parameters for the at91 DMA configuration register which are device
+dependant:
+ - bit 7-0: peripheral identifier for the hardware handshaking interface. The
+ identifier can be different for tx and rx.
+ - bit 11-8: FIFO configuration. 0 for half FIFO, 1 for ALAP, 1 for ASAP.

Example:

diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 6db5228..b7050a4 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -14,6 +14,7 @@
* found on AT91SAM9263.
*/

+#include <dt-bindings/dma/at91.h>
#include <linux/clk.h>
#include <linux/dmaengine.h>
#include <linux/dma-mapping.h>
@@ -1320,15 +1321,31 @@ static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec,
atslave = devm_kzalloc(&dmac_pdev->dev, sizeof(*atslave), GFP_KERNEL);
if (!atslave)
return NULL;
+
+ atslave->cfg = ATC_DST_H2SEL_HW | ATC_SRC_H2SEL_HW;
/*
* We can fill both SRC_PER and DST_PER, one of these fields will be
* ignored depending on DMA transfer direction.
*/
- per_id = dma_spec->args[1];
- atslave->cfg = ATC_FIFOCFG_HALFFIFO
- | ATC_DST_H2SEL_HW | ATC_SRC_H2SEL_HW
- | ATC_DST_PER_MSB(per_id) | ATC_DST_PER(per_id)
+ per_id = dma_spec->args[1] & AT91_DMA_CFG_PER_ID_MASK;
+ atslave->cfg |= ATC_DST_PER_MSB(per_id) | ATC_DST_PER(per_id)
| ATC_SRC_PER_MSB(per_id) | ATC_SRC_PER(per_id);
+ /*
+ * We have to translate the value we get from the device tree since
+ * the half FIFO configuration value had to be 0 to keep backward
+ * compatibility.
+ */
+ switch (dma_spec->args[1] & AT91_DMA_CFG_FIFOCFG_MASK) {
+ case AT91_DMA_CFG_FIFOCFG_ALAP:
+ atslave->cfg |= ATC_FIFOCFG_LARGESTBURST;
+ break;
+ case AT91_DMA_CFG_FIFOCFG_ASAP:
+ atslave->cfg |= ATC_FIFOCFG_ENOUGHSPACE;
+ break;
+ case AT91_DMA_CFG_FIFOCFG_HALF:
+ default:
+ atslave->cfg |= ATC_FIFOCFG_HALFFIFO;
+ }
atslave->dma_dev = &dmac_pdev->dev;

chan = dma_request_channel(mask, at_dma_filter, atslave);
--
1.7.11.3

2013-06-14 22:12:04

by Nicolas Ferre

[permalink] [raw]
Subject: Re: [PATCH v3 1/2] ARM: at91: dt: add header to define at_hdmac configuration

On 13/06/2013 10:39, [email protected] :
> From: Ludovic Desroches <[email protected]>
>
> DMA-cell content is a concatenation of several values. In order to keep this
> stuff human readable, macros are introduced.
>
> The values for the FIFO configuration are not the same as the ones used in the
> configuration register in order to keep backward compatibility. Most devices
> use the half FIFO configuration but USART ones have to use the ASAP
> configuration. This parameter was not initially planed to be into the at91 dma
> dt binding. The third cell will be used to store this parameter, it will
> become a concatenation of the FIFO configuration and of the peripheral ID. In
> order to keep backward compatibility i.e. FIFO configuration is equal to 0, we
> have to perform a translation since the value to put in the register to set
> half FIFO is 1.
>
> Acked-by: Arnd Bergmann <[email protected]>
> Acked-by: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
> Signed-off-by: Ludovic Desroches <[email protected]>

Of course:
Acked-by: Nicolas Ferre <[email protected]>

In addition to going through slave-dma Vinod's git tree, I also stack it
on the AT91 DT branch so that it can go in arm-soc and prevent a
dependency between the two trees that could lead to a build error...

Best regards,

> ---
> include/dt-bindings/dma/at91.h | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
> create mode 100644 include/dt-bindings/dma/at91.h
>
> diff --git a/include/dt-bindings/dma/at91.h b/include/dt-bindings/dma/at91.h
> new file mode 100644
> index 0000000..e835037
> --- /dev/null
> +++ b/include/dt-bindings/dma/at91.h
> @@ -0,0 +1,27 @@
> +/*
> + * This header provides macros for at91 dma bindings.
> + *
> + * Copyright (C) 2013 Ludovic Desroches <[email protected]>
> + *
> + * GPLv2 only
> + */
> +
> +#ifndef __DT_BINDINGS_AT91_DMA_H__
> +#define __DT_BINDINGS_AT91_DMA_H__
> +
> +/*
> + * Source and/or destination peripheral ID
> + */
> +#define AT91_DMA_CFG_PER_ID_MASK (0xff)
> +#define AT91_DMA_CFG_PER_ID(id) (id & AT91_DMA_CFG_PER_ID_MASK)
> +
> +/*
> + * FIFO configuration: it defines when a request is serviced.
> + */
> +#define AT91_DMA_CFG_FIFOCFG_OFFSET (8)
> +#define AT91_DMA_CFG_FIFOCFG_MASK (0xf << AT91_DMA_CFG_FIFOCFG_OFFSET)
> +#define AT91_DMA_CFG_FIFOCFG_HALF (0x0 << AT91_DMA_CFG_FIFOCFG_OFFSET) /* half FIFO (default behavior) */
> +#define AT91_DMA_CFG_FIFOCFG_ALAP (0x1 << AT91_DMA_CFG_FIFOCFG_OFFSET) /* largest defined AHB burst */
> +#define AT91_DMA_CFG_FIFOCFG_ASAP (0x2 << AT91_DMA_CFG_FIFOCFG_OFFSET) /* single AHB access */
> +
> +#endif /* __DT_BINDINGS_AT91_DMA_H__ */
>


--
Nicolas Ferre