linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Hans-Christian Egtvedt <egtvedt@samfundet.no>,
	Haavard Skinnemoen <hskinnemoen@gmail.com>,
	Vinod Koul <vinod.koul@intel.com>,
	Mark Brown <broonie@kernel.org>,
	Hein Tibosch <hein_tibosch@yahoo.es>,
	Russell King <linux@arm.linux.org.uk>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Takashi Iwai <tiwai@suse.de>,
	Kweh Hock Leong <hock.leong.kweh@intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Alan Cox <alan@linux.intel.com>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 11/12] serial: 8250: don't use slave_id of dma_slave_config
Date: Tue, 19 Aug 2014 20:29:22 +0300	[thread overview]
Message-ID: <1408469363-15901-12-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <1408469363-15901-1-git-send-email-andriy.shevchenko@linux.intel.com>

That field has been deprecated in favour of getting the necessary information
from ACPI or DT.

However, we still need to deal systems that are PCI only (no ACPI to back up)
like Intel Bay Trail. In order to support such systems, we explicitly bind
setup() to the appropriate DMA filter function and its corresponding parameter.
Then when serial8250_request_dma() doesn't find the channel via ACPI or DT, it
falls back to use the given filter function.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/8250/8250.h     |  6 ++---
 drivers/tty/serial/8250/8250_dw.c  |  7 +-----
 drivers/tty/serial/8250/8250_pci.c | 51 ++++++++++++++++++++++++++++++--------
 3 files changed, 44 insertions(+), 20 deletions(-)

diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index 1b08c91..c3c7091 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -16,13 +16,13 @@
 #include <linux/dmaengine.h>
 
 struct uart_8250_dma {
+	/* Filter function */
 	dma_filter_fn		fn;
+
+	/* Parameter to the filter function */
 	void			*rx_param;
 	void			*tx_param;
 
-	int			rx_chan_id;
-	int			tx_chan_id;
-
 	struct dma_slave_config	rxconf;
 	struct dma_slave_config	txconf;
 
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 4db7987..6664de2 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -216,10 +216,7 @@ out:
 
 static bool dw8250_dma_filter(struct dma_chan *chan, void *param)
 {
-	struct dw8250_data *data = param;
-
-	return chan->chan_id == data->dma.tx_chan_id ||
-	       chan->chan_id == data->dma.rx_chan_id;
+	return false;
 }
 
 static void dw8250_setup_port(struct uart_8250_port *up)
@@ -399,8 +396,6 @@ static int dw8250_probe(struct platform_device *pdev)
 	if (!IS_ERR(data->rst))
 		reset_control_deassert(data->rst);
 
-	data->dma.rx_chan_id = -1;
-	data->dma.tx_chan_id = -1;
 	data->dma.rx_param = data;
 	data->dma.tx_param = data;
 	data->dma.fn = dw8250_dma_filter;
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 61830b1..a00c9de 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -25,6 +25,9 @@
 #include <asm/byteorder.h>
 #include <asm/io.h>
 
+#include <linux/dmaengine.h>
+#include <linux/platform_data/dma-dw.h>
+
 #include "8250.h"
 
 /*
@@ -1427,7 +1430,13 @@ byt_set_termios(struct uart_port *p, struct ktermios *termios,
 
 static bool byt_dma_filter(struct dma_chan *chan, void *param)
 {
-	return chan->chan_id == *(int *)param;
+	struct dw_dma_slave *dws = param;
+
+	if (dws->dma_dev != chan->device->dev)
+		return false;
+
+	chan->private = dws;
+	return true;
 }
 
 static int
@@ -1435,35 +1444,55 @@ byt_serial_setup(struct serial_private *priv,
 		 const struct pciserial_board *board,
 		 struct uart_8250_port *port, int idx)
 {
+	struct pci_dev *pdev = priv->dev;
+	struct device *dev = port->port.dev;
 	struct uart_8250_dma *dma;
+	struct dw_dma_slave *tx_param, *rx_param;
+	struct pci_dev *dma_dev;
 	int ret;
 
-	dma = devm_kzalloc(port->port.dev, sizeof(*dma), GFP_KERNEL);
+	dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);
 	if (!dma)
 		return -ENOMEM;
 
-	switch (priv->dev->device) {
+	tx_param = devm_kzalloc(dev, sizeof(*tx_param), GFP_KERNEL);
+	if (!tx_param)
+		return -ENOMEM;
+
+	rx_param = devm_kzalloc(dev, sizeof(*rx_param), GFP_KERNEL);
+	if (!rx_param)
+		return -ENOMEM;
+
+	switch (pdev->device) {
 	case PCI_DEVICE_ID_INTEL_BYT_UART1:
-		dma->rx_chan_id = 3;
-		dma->tx_chan_id = 2;
+		rx_param->src_id = 3;
+		tx_param->dst_id = 2;
 		break;
 	case PCI_DEVICE_ID_INTEL_BYT_UART2:
-		dma->rx_chan_id = 5;
-		dma->tx_chan_id = 4;
+		rx_param->src_id = 5;
+		tx_param->dst_id = 4;
 		break;
 	default:
 		return -EINVAL;
 	}
 
-	dma->rxconf.slave_id = dma->rx_chan_id;
+	rx_param->src_master = 1;
+	rx_param->dst_master = 0;
+
 	dma->rxconf.src_maxburst = 16;
 
-	dma->txconf.slave_id = dma->tx_chan_id;
+	tx_param->src_master = 1;
+	tx_param->dst_master = 0;
+
 	dma->txconf.dst_maxburst = 16;
 
+	dma_dev = pci_get_slot(pdev->bus, PCI_DEVFN(PCI_SLOT(pdev->devfn), 0));
+	rx_param->dma_dev = &dma_dev->dev;
+	tx_param->dma_dev = &dma_dev->dev;
+
 	dma->fn = byt_dma_filter;
-	dma->rx_param = &dma->rx_chan_id;
-	dma->tx_param = &dma->tx_chan_id;
+	dma->rx_param = rx_param;
+	dma->tx_param = tx_param;
 
 	ret = pci_default_setup(priv, board, port, idx);
 	port->port.iotype = UPIO_MEM;
-- 
2.1.0


  parent reply	other threads:[~2014-08-19 17:31 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-19 17:29 [PATCH v1 00/12] dmaengine: dw: remove slave_id, add PCI support Andy Shevchenko
2014-08-19 17:29 ` [PATCH v1 01/12] dmaengine: dw: move dw_dmac.h to where it belongs to Andy Shevchenko
2014-08-20  6:01   ` Hans-Christian Egtvedt
2014-08-20  8:55   ` Viresh Kumar
2014-08-20  8:56     ` Viresh Kumar
2014-08-20  9:28     ` Andy Shevchenko
2014-08-19 17:29 ` [PATCH v1 02/12] avr32: at32ap700x: don't rely on default DMA masters Andy Shevchenko
2014-08-20  6:03   ` Hans-Christian Egtvedt
2014-08-19 17:29 ` [PATCH v1 03/12] dmaengine: dw: convert dw_dma_slave to use explicit HS interfaces Andy Shevchenko
2014-08-20  6:15   ` Hans-Christian Egtvedt
2014-08-19 17:29 ` [PATCH v1 04/12] dmaengine: dw: apply both HS interfaces and remove slave_id usage Andy Shevchenko
2014-08-19 17:29 ` [PATCH v1 05/12] dmaengine: dw: introduce generic filter function Andy Shevchenko
2014-08-19 17:29 ` [PATCH v1 06/12] dmaengine: dw: move clock operations to platform.c Andy Shevchenko
2014-08-19 17:29 ` [PATCH v1 07/12] dmaengine: dw: add PCI IDs for Braswell DMAs Andy Shevchenko
2014-08-19 17:29 ` [PATCH v1 08/12] spi/pxa2xx: Don't use slave_id of dma_slave_config Andy Shevchenko
2014-08-19 21:13   ` Mark Brown
2014-09-11  6:20   ` Vinod Koul
2014-08-19 17:29 ` [PATCH v1 09/12] spi/pxa2xx-pci: remove unnecessary assignment Andy Shevchenko
2014-08-19 21:12   ` Mark Brown
2014-08-19 17:29 ` [PATCH v1 10/12] spi/pxa2xx-pci: Add support for Intel Braswell Andy Shevchenko
2014-08-19 21:14   ` Mark Brown
2014-08-19 17:29 ` Andy Shevchenko [this message]
2014-08-26 22:38   ` [PATCH v1 11/12] serial: 8250: don't use slave_id of dma_slave_config Greg Kroah-Hartman
2014-08-19 17:29 ` [PATCH v1 12/12] serial: 8250_pci: Add PCI IDs for Intel Braswell Andy Shevchenko
2014-08-26 22:38   ` Greg Kroah-Hartman
2014-08-20  6:17 ` [PATCH v1 00/12] dmaengine: dw: remove slave_id, add PCI support Hans-Christian Egtvedt
2014-08-27  6:33   ` Andy Shevchenko
2014-08-26 15:27 ` Andy Shevchenko
2014-08-26 22:39   ` Greg Kroah-Hartman
2014-08-27  6:32     ` Andy Shevchenko
2014-08-29 10:00 ` Andy Shevchenko
2014-09-11  6:42 ` Vinod Koul
2014-09-11  7:53   ` Shevchenko, Andriy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1408469363-15901-12-git-send-email-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=alan@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=egtvedt@samfundet.no \
    --cc=gregkh@linuxfoundation.org \
    --cc=hein_tibosch@yahoo.es \
    --cc=hock.leong.kweh@intel.com \
    --cc=hskinnemoen@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mika.westerberg@linux.intel.com \
    --cc=tiwai@suse.de \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).