devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 18/18] [RFC] spi: rspi: Add DT support to DMA setup
       [not found] ` <1401716301-29612-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
@ 2014-06-02 13:38   ` Geert Uytterhoeven
  2014-06-02 14:54     ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2014-06-02 13:38 UTC (permalink / raw)
  To: Mark Brown
  Cc: Yoshihiro Shimoda, Magnus Damm, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-sh-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
The format of the DMA specifiers depends on the DT bindings for SHDMA,
which are still under development.
---
 Documentation/devicetree/bindings/spi/spi-rspi.txt |  6 ++++
 drivers/spi/spi-rspi.c                             | 37 ++++++++++++++--------
 2 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/spi-rspi.txt b/Documentation/devicetree/bindings/spi/spi-rspi.txt
index d57d82a74054..a274073bd41d 100644
--- a/Documentation/devicetree/bindings/spi/spi-rspi.txt
+++ b/Documentation/devicetree/bindings/spi/spi-rspi.txt
@@ -30,6 +30,9 @@ Required properties:
 
 Optional properties:
 - clocks           : Must contain a reference to the functional clock.
+- dmas             : Must contain a list of two references to DMA specifiers,
+		     one for transmission, and one for reception.
+- dma-names        : Must contain a list of two DMA names, "tx" and "rx".
 
 Pinctrl properties might be needed, too.  See
 Documentation/devicetree/bindings/pinctrl/renesas,*.
@@ -58,4 +61,7 @@ Examples:
 		num-cs = <1>;
 		#address-cells = <1>;
 		#size-cells = <0>;
+		dmas = <&dma0 R8A7791_DMA_QSPI_TX CHCR_TX_8BIT>,
+		       <&dma0 R8A7791_DMA_QSPI_RX CHCR_RX_8BIT>;
+		dma-names = "tx", "rx";
 	};
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 10112745bb17..16de9ad60d74 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -874,10 +874,11 @@ static struct dma_chan *rspi_request_dma_chan(struct device *dev,
 	dma_cap_zero(mask);
 	dma_cap_set(DMA_SLAVE, mask);
 
-	chan = dma_request_channel(mask, shdma_chan_filter,
-				   (void *)(unsigned long)id);
+	chan = dma_request_slave_channel_compat(mask, shdma_chan_filter,
+				(void *)(unsigned long)id, dev,
+				dir == DMA_MEM_TO_DEV ? "tx" : "rx");
 	if (!chan) {
-		dev_warn(dev, "dma_request_channel failed\n");
+		dev_warn(dev, "dma_request_slave_channel_compat failed\n");
 		return NULL;
 	}
 
@@ -903,22 +904,30 @@ static int rspi_request_dma(struct device *dev, struct spi_master *master,
 			    const struct resource *res)
 {
 	const struct rspi_plat_data *rspi_pd = dev_get_platdata(dev);
+	unsigned int dma_tx_id, dma_rx_id;
+
+	if (dev->of_node) {
+		/* In the OF case we will get the slave IDs from the DT */
+		dma_tx_id = 0;
+		dma_rx_id = 0;
+	} else if (rspi_pd && rspi_pd->dma_tx_id && rspi_pd->dma_rx_id) {
+		dma_tx_id = rspi_pd->dma_tx_id;
+		dma_rx_id = rspi_pd->dma_rx_id;
+	} else {
+		/* The driver assumes no error. */
+		return 0;
+	}
 
-	if (!rspi_pd || !rspi_pd->dma_rx_id || !rspi_pd->dma_tx_id)
-		return 0;	/* The driver assumes no error. */
-
-	master->dma_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM,
-					       rspi_pd->dma_rx_id,
+	master->dma_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV, dma_tx_id,
 					       res->start + RSPI_SPDR);
-	if (!master->dma_rx)
+	if (!master->dma_tx)
 		return -ENODEV;
 
-	master->dma_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV,
-					       rspi_pd->dma_tx_id,
+	master->dma_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM, dma_rx_id,
 					       res->start + RSPI_SPDR);
-	if (!master->dma_tx) {
-		dma_release_channel(master->dma_rx);
-		master->dma_rx = NULL;
+	if (!master->dma_rx) {
+		dma_release_channel(master->dma_tx);
+		master->dma_tx = NULL;
 		return -ENODEV;
 	}
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 18/18] [RFC] spi: rspi: Add DT support to DMA setup
  2014-06-02 13:38   ` [PATCH 18/18] [RFC] spi: rspi: Add DT support to DMA setup Geert Uytterhoeven
@ 2014-06-02 14:54     ` Mark Brown
       [not found]       ` <20140602145447.GJ31751-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2014-06-02 14:54 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Yoshihiro Shimoda, Magnus Damm, linux-spi, linux-sh, devicetree

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

On Mon, Jun 02, 2014 at 03:38:20PM +0200, Geert Uytterhoeven wrote:
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: devicetree@vger.kernel.org
> ---
> The format of the DMA specifiers depends on the DT bindings for SHDMA,
> which are still under development.

This looks fine to me, can you resend when the DMA specifiers for the
controller are resolved?  I've applied everything up to here, it all
looks good especially the performance improvement.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 18/18] [RFC] spi: rspi: Add DT support to DMA setup
       [not found]       ` <20140602145447.GJ31751-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2014-06-02 14:57         ` Geert Uytterhoeven
  0 siblings, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2014-06-02 14:57 UTC (permalink / raw)
  To: Mark Brown
  Cc: Geert Uytterhoeven, Yoshihiro Shimoda, Magnus Damm, linux-spi,
	Linux-sh list, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

Hi Mark,

On Mon, Jun 2, 2014 at 4:54 PM, Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
> On Mon, Jun 02, 2014 at 03:38:20PM +0200, Geert Uytterhoeven wrote:
>> Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
>> Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> ---
>> The format of the DMA specifiers depends on the DT bindings for SHDMA,
>> which are still under development.
>
> This looks fine to me, can you resend when the DMA specifiers for the
> controller are resolved?  I've applied everything up to here, it all

Sure.

> looks good especially the performance improvement.

That was quick, thanks a lot!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-02 14:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1401716301-29612-1-git-send-email-geert+renesas@glider.be>
     [not found] ` <1401716301-29612-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2014-06-02 13:38   ` [PATCH 18/18] [RFC] spi: rspi: Add DT support to DMA setup Geert Uytterhoeven
2014-06-02 14:54     ` Mark Brown
     [not found]       ` <20140602145447.GJ31751-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-06-02 14:57         ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).