All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: lkml <linux-kernel@vger.kernel.org>
Cc: Youlin Wang <wwx575822@notesmail.huawei.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Vinod Koul <vkoul@kernel.org>,
	Zhuangluan Su <suzhuangluan@hisilicon.com>,
	Ryan Grachek <ryan@edited.us>,
	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
	dmaengine@vger.kernel.org, Tanglei Han <hantanglei@huawei.com>,
	John Stultz <john.stultz@linaro.org>
Subject: [3/8,v4] dma: k3dma: Upgrade k3dma driver to support hisi_asp_dma hardware
Date: Wed, 16 Jan 2019 09:10:24 -0800	[thread overview]
Message-ID: <1547658629-25378-4-git-send-email-john.stultz@linaro.org> (raw)

From: Youlin Wang <wwx575822@notesmail.huawei.com>

On the hi3660 hardware there are two (at least) DMA controllers,
the DMA-P (Peripherial DMA) and the DMA-A (Audio DMA). The
two blocks are similar, but have some slight differences. This
resulted in the vendor implementing two separate drivers, which
after review, they have been able to condense and re-use the
existing k3dma driver.

Thus, this patch adds support for the new "hisi-pcm-asp-dma-1.0"
compatible string in the binding.

One difference with the DMA-A controller, is that it does not
need to initialize a clock. So we skip this by adding and using
soc data flags.

After above this driver will support both k3 and hisi_asp dma
hardware.

Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Vinod Koul <vkoul@kernel.org>
Cc: Zhuangluan Su <suzhuangluan@hisilicon.com>
Cc: Ryan Grachek <ryan@edited.us>
Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: dmaengine@vger.kernel.org
Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Youlin Wang <wwx575822@notesmail.huawei.com>
Signed-off-by: Tanglei Han <hantanglei@huawei.com>
[jstultz: Reworked to use of_match_data, commit msg improvements]
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
v2:
* Reworked to use of_match_data
v3:
* Further rework of the commit message
---
 drivers/dma/k3dma.c | 37 ++++++++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c
index fdec2b6..df61406 100644
--- a/drivers/dma/k3dma.c
+++ b/drivers/dma/k3dma.c
@@ -116,6 +116,13 @@ struct k3_dma_dev {
 	unsigned int		irq;
 };
 
+
+#define K3_FLAG_NOCLK  (1<<0)
+struct k3dma_soc_data {
+	unsigned long flags;
+};
+
+
 #define to_k3_dma(dmadev) container_of(dmadev, struct k3_dma_dev, slave)
 
 static int k3_dma_config_write(struct dma_chan *chan,
@@ -790,8 +797,21 @@ static int k3_dma_transfer_resume(struct dma_chan *chan)
 	return 0;
 }
 
+static const struct k3dma_soc_data k3_v1_dma_data = {
+	.flags = 0,
+};
+
+static const struct k3dma_soc_data asp_v1_dma_data = {
+	.flags = K3_FLAG_NOCLK,
+};
+
 static const struct of_device_id k3_pdma_dt_ids[] = {
-	{ .compatible = "hisilicon,k3-dma-1.0", },
+	{ .compatible = "hisilicon,k3-dma-1.0",
+	  .data = &k3_v1_dma_data
+	},
+	{ .compatible = "hisilicon,hisi-pcm-asp-dma-1.0",
+	  .data = &asp_v1_dma_data
+	},
 	{}
 };
 MODULE_DEVICE_TABLE(of, k3_pdma_dt_ids);
@@ -810,6 +830,7 @@ static struct dma_chan *k3_of_dma_simple_xlate(struct of_phandle_args *dma_spec,
 
 static int k3_dma_probe(struct platform_device *op)
 {
+	const struct k3dma_soc_data *soc_data;
 	struct k3_dma_dev *d;
 	const struct of_device_id *of_id;
 	struct resource *iores;
@@ -823,6 +844,10 @@ static int k3_dma_probe(struct platform_device *op)
 	if (!d)
 		return -ENOMEM;
 
+	soc_data = device_get_match_data(&op->dev);
+	if (!soc_data)
+		return -EINVAL;
+
 	d->base = devm_ioremap_resource(&op->dev, iores);
 	if (IS_ERR(d->base))
 		return PTR_ERR(d->base);
@@ -835,10 +860,12 @@ static int k3_dma_probe(struct platform_device *op)
 				"dma-requests", &d->dma_requests);
 	}
 
-	d->clk = devm_clk_get(&op->dev, NULL);
-	if (IS_ERR(d->clk)) {
-		dev_err(&op->dev, "no dma clk\n");
-		return PTR_ERR(d->clk);
+	if (!(soc_data->flags & K3_FLAG_NOCLK)) {
+		d->clk = devm_clk_get(&op->dev, NULL);
+		if (IS_ERR(d->clk)) {
+			dev_err(&op->dev, "no dma clk\n");
+			return PTR_ERR(d->clk);
+		}
 	}
 
 	irq = platform_get_irq(op, 0);

WARNING: multiple messages have this Message-ID (diff)
From: John Stultz <john.stultz@linaro.org>
To: lkml <linux-kernel@vger.kernel.org>
Cc: Youlin Wang <wwx575822@notesmail.huawei.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Vinod Koul <vkoul@kernel.org>,
	Zhuangluan Su <suzhuangluan@hisilicon.com>,
	Ryan Grachek <ryan@edited.us>,
	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
	dmaengine@vger.kernel.org, Tanglei Han <hantanglei@huawei.com>,
	John Stultz <john.stultz@linaro.org>
Subject: [PATCH 3/8 v4] dma: k3dma: Upgrade k3dma driver to support hisi_asp_dma hardware
Date: Wed, 16 Jan 2019 09:10:24 -0800	[thread overview]
Message-ID: <1547658629-25378-4-git-send-email-john.stultz@linaro.org> (raw)
In-Reply-To: <1547658629-25378-1-git-send-email-john.stultz@linaro.org>

From: Youlin Wang <wwx575822@notesmail.huawei.com>

On the hi3660 hardware there are two (at least) DMA controllers,
the DMA-P (Peripherial DMA) and the DMA-A (Audio DMA). The
two blocks are similar, but have some slight differences. This
resulted in the vendor implementing two separate drivers, which
after review, they have been able to condense and re-use the
existing k3dma driver.

Thus, this patch adds support for the new "hisi-pcm-asp-dma-1.0"
compatible string in the binding.

One difference with the DMA-A controller, is that it does not
need to initialize a clock. So we skip this by adding and using
soc data flags.

After above this driver will support both k3 and hisi_asp dma
hardware.

Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Vinod Koul <vkoul@kernel.org>
Cc: Zhuangluan Su <suzhuangluan@hisilicon.com>
Cc: Ryan Grachek <ryan@edited.us>
Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: dmaengine@vger.kernel.org
Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Youlin Wang <wwx575822@notesmail.huawei.com>
Signed-off-by: Tanglei Han <hantanglei@huawei.com>
[jstultz: Reworked to use of_match_data, commit msg improvements]
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
v2:
* Reworked to use of_match_data
v3:
* Further rework of the commit message
---
 drivers/dma/k3dma.c | 37 ++++++++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c
index fdec2b6..df61406 100644
--- a/drivers/dma/k3dma.c
+++ b/drivers/dma/k3dma.c
@@ -116,6 +116,13 @@ struct k3_dma_dev {
 	unsigned int		irq;
 };
 
+
+#define K3_FLAG_NOCLK  (1<<0)
+struct k3dma_soc_data {
+	unsigned long flags;
+};
+
+
 #define to_k3_dma(dmadev) container_of(dmadev, struct k3_dma_dev, slave)
 
 static int k3_dma_config_write(struct dma_chan *chan,
@@ -790,8 +797,21 @@ static int k3_dma_transfer_resume(struct dma_chan *chan)
 	return 0;
 }
 
+static const struct k3dma_soc_data k3_v1_dma_data = {
+	.flags = 0,
+};
+
+static const struct k3dma_soc_data asp_v1_dma_data = {
+	.flags = K3_FLAG_NOCLK,
+};
+
 static const struct of_device_id k3_pdma_dt_ids[] = {
-	{ .compatible = "hisilicon,k3-dma-1.0", },
+	{ .compatible = "hisilicon,k3-dma-1.0",
+	  .data = &k3_v1_dma_data
+	},
+	{ .compatible = "hisilicon,hisi-pcm-asp-dma-1.0",
+	  .data = &asp_v1_dma_data
+	},
 	{}
 };
 MODULE_DEVICE_TABLE(of, k3_pdma_dt_ids);
@@ -810,6 +830,7 @@ static struct dma_chan *k3_of_dma_simple_xlate(struct of_phandle_args *dma_spec,
 
 static int k3_dma_probe(struct platform_device *op)
 {
+	const struct k3dma_soc_data *soc_data;
 	struct k3_dma_dev *d;
 	const struct of_device_id *of_id;
 	struct resource *iores;
@@ -823,6 +844,10 @@ static int k3_dma_probe(struct platform_device *op)
 	if (!d)
 		return -ENOMEM;
 
+	soc_data = device_get_match_data(&op->dev);
+	if (!soc_data)
+		return -EINVAL;
+
 	d->base = devm_ioremap_resource(&op->dev, iores);
 	if (IS_ERR(d->base))
 		return PTR_ERR(d->base);
@@ -835,10 +860,12 @@ static int k3_dma_probe(struct platform_device *op)
 				"dma-requests", &d->dma_requests);
 	}
 
-	d->clk = devm_clk_get(&op->dev, NULL);
-	if (IS_ERR(d->clk)) {
-		dev_err(&op->dev, "no dma clk\n");
-		return PTR_ERR(d->clk);
+	if (!(soc_data->flags & K3_FLAG_NOCLK)) {
+		d->clk = devm_clk_get(&op->dev, NULL);
+		if (IS_ERR(d->clk)) {
+			dev_err(&op->dev, "no dma clk\n");
+			return PTR_ERR(d->clk);
+		}
 	}
 
 	irq = platform_get_irq(op, 0);
-- 
2.7.4


             reply	other threads:[~2019-01-16 17:10 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-16 17:10 John Stultz [this message]
2019-01-16 17:10 ` [PATCH 3/8 v4] dma: k3dma: Upgrade k3dma driver to support hisi_asp_dma hardware John Stultz
  -- strict thread matches above, loose matches on Subject: below --
2019-01-24  4:32 [3/8,v4] " John Stultz
2019-01-24  4:32 ` [PATCH 3/8 v4] " John Stultz
2019-01-23 12:55 [3/8,v4] " Vinod Koul
2019-01-23 12:55 ` [PATCH 3/8 v4] " Vinod Koul
2019-01-23  0:27 [5/8,v4] dma: k3dma: Add support for dma-channel-mask John Stultz
2019-01-23  0:27 ` [PATCH 5/8 v4] " John Stultz
2019-01-22 23:48 [3/8,v4] dma: k3dma: Upgrade k3dma driver to support hisi_asp_dma hardware John Stultz
2019-01-22 23:48 ` [PATCH 3/8 v4] " John Stultz
2019-01-22  1:13 [2/8,v4] Documentation: bindings: dma: Add binding for dma-channel-mask Rob Herring
2019-01-22  1:13 ` [PATCH 2/8 v4] " Rob Herring
2019-01-22  1:13 ` Rob Herring
2019-01-20 11:11 [3/8,v4] dma: k3dma: Upgrade k3dma driver to support hisi_asp_dma hardware Vinod Koul
2019-01-20 11:11 ` [PATCH 3/8 v4] " Vinod Koul
2019-01-20 11:06 [2/8,v4] Documentation: bindings: dma: Add binding for dma-channel-mask Vinod Koul
2019-01-20 11:06 ` [PATCH 2/8 v4] " Vinod Koul
2019-01-20 11:06 ` Vinod Koul
2019-01-17 17:43 [2/8,v4] " John Stultz
2019-01-17 17:43 ` [PATCH 2/8 v4] " John Stultz
2019-01-17 17:43 ` John Stultz
2019-01-17 17:14 [5/8,v4] dma: k3dma: Add support " Manivannan Sadhasivam
2019-01-17 17:14 ` [PATCH 5/8 v4] " Manivannan Sadhasivam
2019-01-17 17:08 [2/8,v4] Documentation: bindings: dma: Add binding " Manivannan Sadhasivam
2019-01-17 17:08 ` [PATCH 2/8 v4] " Manivannan Sadhasivam
2019-01-16 17:10 [5/8,v4] dma: k3dma: Add support " John Stultz
2019-01-16 17:10 ` [PATCH 5/8 v4] " John Stultz
2019-01-16 17:10 [4/8,v4] dma: k3dma: Delete axi_config John Stultz
2019-01-16 17:10 ` [PATCH 4/8 v4] " John Stultz
2019-01-16 17:10 [2/8,v4] Documentation: bindings: dma: Add binding for dma-channel-mask John Stultz
2019-01-16 17:10 ` [PATCH 2/8 v4] " John Stultz
2019-01-16 17:10 [1/8,v4] Documentation: bindings: k3dma: Extend the k3dma driver binding to support hisi-asp John Stultz
2019-01-16 17:10 ` [PATCH 1/8 v4] " John Stultz
2019-01-16 17:10 [PATCH 0/8 v4] k3dma patches to add support for hi3660/HiKey960 John Stultz
2019-01-16 17:10 ` John Stultz
2019-01-16 17:10 ` John Stultz
2019-01-16 17:10 ` [PATCH 6/8 v4] arm64: dts: hi3660: Add dma to uart nodes John Stultz
2019-01-16 17:10   ` John Stultz
2019-01-16 17:10 ` [PATCH 7/8 v4] arm64: dts: hi3660: Add hisi asp dma device John Stultz
2019-01-16 17:10   ` John Stultz
2019-01-16 17:10   ` John Stultz
2019-01-16 17:10 ` [PATCH 8/8 v4] arm64: dts: hi3660: Fixup unofficial dma-min-chan to dma-channel-mask John Stultz
2019-01-16 17:10   ` John Stultz

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=1547658629-25378-4-git-send-email-john.stultz@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=hantanglei@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=ryan@edited.us \
    --cc=suzhuangluan@hisilicon.com \
    --cc=vkoul@kernel.org \
    --cc=wwx575822@notesmail.huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.