linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 06/12] i2c: i2c-mxs: move to use generic DMA helper
Date: Tue, 5 Mar 2013 20:23:58 +0800	[thread overview]
Message-ID: <1362486244-24593-7-git-send-email-shawn.guo@linaro.org> (raw)
In-Reply-To: <1362486244-24593-1-git-send-email-shawn.guo@linaro.org>

With the generic DMA device tree helper supported by mxs-dma driver,
client devices only need to call dma_request_slave_channel() for
requesting a DMA channel from dmaengine.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-i2c at vger.kernel.org
---
 Documentation/devicetree/bindings/i2c/i2c-mxs.txt |   12 ++++---
 drivers/i2c/busses/i2c-mxs.c                      |   40 ++-------------------
 2 files changed, 11 insertions(+), 41 deletions(-)

diff --git a/Documentation/devicetree/bindings/i2c/i2c-mxs.txt b/Documentation/devicetree/bindings/i2c/i2c-mxs.txt
index 7a3fe9e..4e1c8ac 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-mxs.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-mxs.txt
@@ -3,10 +3,13 @@
 Required properties:
 - compatible: Should be "fsl,<chip>-i2c"
 - reg: Should contain registers location and length
-- interrupts: Should contain ERROR and DMA interrupts
+- interrupts: Should contain ERROR interrupt number
 - clock-frequency: Desired I2C bus clock frequency in Hz.
                    Only 100000Hz and 400000Hz modes are supported.
-- fsl,i2c-dma-channel: APBX DMA channel for the I2C
+- dmas: DMA specifier, consisting of a phandle to DMA controller node
+  and I2C DMA channel ID.
+  Refer to dma.txt and fsl-mxs-dma.txt for details.
+- dma-names: Must be "rx-tx".
 
 Examples:
 
@@ -15,7 +18,8 @@ i2c0: i2c at 80058000 {
 	#size-cells = <0>;
 	compatible = "fsl,imx28-i2c";
 	reg = <0x80058000 2000>;
-	interrupts = <111 68>;
+	interrupts = <111>;
 	clock-frequency = <100000>;
-	fsl,i2c-dma-channel = <6>;
+	dmas = <&dma_apbx 6>;
+	dma-names = "rx-tx";
 };
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 120f246..d1ba6b4 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -31,7 +31,6 @@
 #include <linux/of_i2c.h>
 #include <linux/dma-mapping.h>
 #include <linux/dmaengine.h>
-#include <linux/fsl/mxs-dma.h>
 
 #define DRIVER_NAME "mxs-i2c"
 
@@ -113,9 +112,7 @@ struct mxs_i2c_dev {
 	uint32_t timing1;
 
 	/* DMA support components */
-	int				dma_channel;
 	struct dma_chan         	*dmach;
-	struct mxs_dma_data		dma_data;
 	uint32_t			pio_data[2];
 	uint32_t			addr_data;
 	struct scatterlist		sg_io[2];
@@ -518,21 +515,6 @@ static const struct i2c_algorithm mxs_i2c_algo = {
 	.functionality = mxs_i2c_func,
 };
 
-static bool mxs_i2c_dma_filter(struct dma_chan *chan, void *param)
-{
-	struct mxs_i2c_dev *i2c = param;
-
-	if (!mxs_dma_is_apbx(chan))
-		return false;
-
-	if (chan->chan_id != i2c->dma_channel)
-		return false;
-
-	chan->private = &i2c->dma_data;
-
-	return true;
-}
-
 static void mxs_i2c_derive_timing(struct mxs_i2c_dev *i2c, int speed)
 {
 	/* The I2C block clock run at 24MHz */
@@ -577,17 +559,6 @@ static int mxs_i2c_get_ofdata(struct mxs_i2c_dev *i2c)
 	struct device_node *node = dev->of_node;
 	int ret;
 
-	/*
-	 * TODO: This is a temporary solution and should be changed
-	 * to use generic DMA binding later when the helpers get in.
-	 */
-	ret = of_property_read_u32(node, "fsl,i2c-dma-channel",
-				   &i2c->dma_channel);
-	if (ret) {
-		dev_err(dev, "Failed to get DMA channel!\n");
-		return -ENODEV;
-	}
-
 	ret = of_property_read_u32(node, "clock-frequency", &speed);
 	if (ret) {
 		dev_warn(dev, "No I2C speed selected, using 100kHz\n");
@@ -607,8 +578,7 @@ static int mxs_i2c_probe(struct platform_device *pdev)
 	struct pinctrl *pinctrl;
 	struct resource *res;
 	resource_size_t res_size;
-	int err, irq, dmairq;
-	dma_cap_mask_t mask;
+	int err, irq;
 
 	pinctrl = devm_pinctrl_get_select_default(dev);
 	if (IS_ERR(pinctrl))
@@ -620,9 +590,8 @@ static int mxs_i2c_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	irq = platform_get_irq(pdev, 0);
-	dmairq = platform_get_irq(pdev, 1);
 
-	if (!res || irq < 0 || dmairq < 0)
+	if (!res || irq < 0)
 		return -ENOENT;
 
 	res_size = resource_size(res);
@@ -648,10 +617,7 @@ static int mxs_i2c_probe(struct platform_device *pdev)
 	}
 
 	/* Setup the DMA */
-	dma_cap_zero(mask);
-	dma_cap_set(DMA_SLAVE, mask);
-	i2c->dma_data.chan_irq = dmairq;
-	i2c->dmach = dma_request_channel(mask, mxs_i2c_dma_filter, i2c);
+	i2c->dmach = dma_request_slave_channel(dev, "rx-tx");
 	if (!i2c->dmach) {
 		dev_err(dev, "Failed to request dma\n");
 		return -ENODEV;
-- 
1.7.9.5

  parent reply	other threads:[~2013-03-05 12:23 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-05 12:23 [PATCH v2 00/12] ARM: mxs: move to generic DMA device tree binding Shawn Guo
2013-03-05 12:23 ` [PATCH v2 01/12] ARM: dts: add generic DMA device tree binding for mxs-dma Shawn Guo
2013-03-05 19:38   ` Arnd Bergmann
2013-03-06  5:10     ` Shawn Guo
2013-03-05 12:23 ` [PATCH v2 02/12] dma: mxs-dma: use devm_* managed functions Shawn Guo
2013-03-05 12:23 ` [PATCH v2 03/12] dma: mxs-dma: move to generic device tree binding Shawn Guo
2013-03-05 12:23 ` [PATCH v2 04/12] mmc: mxs-mmc: move to use generic DMA helper Shawn Guo
2013-03-05 12:23 ` [PATCH v2 05/12] spi: mxs-spi: " Shawn Guo
2013-03-05 12:23 ` Shawn Guo [this message]
2013-03-21 11:07   ` [PATCH v2 06/12] i2c: i2c-mxs: " Wolfram Sang
2013-03-05 12:23 ` [PATCH v2 07/12] mtd: gpmi: " Shawn Guo
2013-03-05 12:24 ` [PATCH v2 08/12] serial: mxs-auart: " Shawn Guo
2013-03-06  1:36   ` Greg Kroah-Hartman
2013-03-05 12:24 ` [PATCH v2 09/12] ASoC: dmaengine_pcm: add snd_dmaengine_generic_pcm_open() Shawn Guo
2013-03-05 14:37   ` [PATCH v3 " Shawn Guo
2013-03-05 23:28     ` Marek Vasut
2013-03-06  5:11       ` Shawn Guo
2013-03-06 16:41         ` Marek Vasut
2013-03-06 17:13     ` Russell King - ARM Linux
2013-03-07  2:33       ` Mark Brown
2013-03-07  9:18         ` Russell King - ARM Linux
2013-03-07  9:31           ` Mark Brown
2013-03-07 11:20             ` Russell King - ARM Linux
2013-03-08  7:43               ` Mark Brown
2013-03-05 12:24 ` [PATCH v2 10/12] ASoC: mxs: move to use generic DMA helper Shawn Guo
2013-03-05 12:24 ` [PATCH v2 11/12] dma: mxs-dma: remove code left from generic DMA binding conversion Shawn Guo
2013-03-05 12:24 ` [PATCH v2 12/12] ARM: dts: remove old DMA binding data from client nodes Shawn Guo
2013-03-05 19:39 ` [PATCH v2 00/12] ARM: mxs: move to generic DMA device tree binding Arnd Bergmann

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=1362486244-24593-7-git-send-email-shawn.guo@linaro.org \
    --to=shawn.guo@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).