linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] Support for QCOM BAM DMA command descriptor
@ 2017-08-01 14:11 Abhishek Sahu
  2017-08-01 14:11 ` [PATCH v3 1/3] dmaengine: add DMA_PREP_CMD for non-Data descriptors Abhishek Sahu
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Abhishek Sahu @ 2017-08-01 14:11 UTC (permalink / raw)
  To: vinod.koul, corbet, dan.j.williams
  Cc: andy.gross, david.brown, linux-arm-msm, linux-soc, dmaengine,
	linux-kernel, linux-doc, Abhishek Sahu

v3:

1. Added Documentation for new flag
2. Changed the flag description

v2:

1. Added DMA_PREP_CMD flag and used the same for BAM DMA
   command descriptor
2. Removed custom mapping API patches

v1:

https://www.spinics.net/lists/dmaengine/msg12009.html

These patches mainly add the support for QCOM BAM command
descriptor implementing BAM DMA support for some QCOM
peripherals like QPIC NAND/LCD.

Currently there is no flag in DMA API which tells the DMA
controller that the passed data is in command descriptor
format so added the flag in DMA API for this.

Abhishek Sahu (3):
  dmaengine: add DMA_PREP_CMD for non-Data descriptors.
  dmaengine: qcom: bam_dma: wrapper functions for command descriptor
  dmaengine: qcom: bam_dma: add command descriptor flag

 Documentation/dmaengine/provider.txt |  7 ++++
 drivers/dma/qcom/bam_dma.c           |  6 ++-
 include/linux/dma/qcom_bam_dma.h     | 79 ++++++++++++++++++++++++++++++++++++
 include/linux/dmaengine.h            |  4 ++
 4 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 include/linux/dma/qcom_bam_dma.h

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

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

* [PATCH v3 1/3] dmaengine: add DMA_PREP_CMD for non-Data descriptors.
  2017-08-01 14:11 [PATCH v3 0/3] Support for QCOM BAM DMA command descriptor Abhishek Sahu
@ 2017-08-01 14:11 ` Abhishek Sahu
  2017-08-01 14:11 ` [PATCH v3 2/3] dmaengine: qcom: bam_dma: wrapper functions for command descriptor Abhishek Sahu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Abhishek Sahu @ 2017-08-01 14:11 UTC (permalink / raw)
  To: vinod.koul, corbet, dan.j.williams
  Cc: andy.gross, david.brown, linux-arm-msm, linux-soc, dmaengine,
	linux-kernel, linux-doc, Abhishek Sahu

Some of the DMA controllers are capable of issuing the commands
to peripheral by the DMA. These commands can be list of register
reads/writes and its different from normal data reads/writes.
This patch adds new flag DMA_PREP_CMD in DMA API which tells
the driver that the data passed to DMA API is command data
and DMA controller driver will form descriptor in the required
format.

This flag can be used by any DMA controller driver which requires
the descriptor in different format for non-Data descriptors.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
---
 Documentation/dmaengine/provider.txt | 7 +++++++
 include/linux/dmaengine.h            | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/Documentation/dmaengine/provider.txt b/Documentation/dmaengine/provider.txt
index e33bc1c..bfadbfd 100644
--- a/Documentation/dmaengine/provider.txt
+++ b/Documentation/dmaengine/provider.txt
@@ -395,6 +395,13 @@ where to put them)
 	  when DMA_CTRL_REUSE is already set
 	- Terminating the channel
 
+  * DMA_PREP_CMD
+    - If set, the client driver tells DMA controller that passed data in DMA
+      API is command data.
+    - Interpretation of command data is DMA controller specific. It can be
+      used for issuing commands to other peripherals/register reads/register
+      writes for which the descriptor should be in different format from
+      normal data descriptors.
 
 General Design Notes
 --------------------
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 5336808..45fc833 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -186,6 +186,9 @@ struct dma_interleaved_template {
  *  on the result of this operation
  * @DMA_CTRL_REUSE: client can reuse the descriptor and submit again till
  *  cleared or freed
+ * @DMA_PREP_CMD: tell the driver that the data passed to DMA API is command
+ *  data and the descriptor should be in different format from normal
+ *  data descriptors.
  */
 enum dma_ctrl_flags {
 	DMA_PREP_INTERRUPT = (1 << 0),
@@ -195,6 +198,7 @@ enum dma_ctrl_flags {
 	DMA_PREP_CONTINUE = (1 << 4),
 	DMA_PREP_FENCE = (1 << 5),
 	DMA_CTRL_REUSE = (1 << 6),
+	DMA_PREP_CMD = (1 << 7),
 };
 
 /**
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

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

* [PATCH v3 2/3] dmaengine: qcom: bam_dma: wrapper functions for command descriptor
  2017-08-01 14:11 [PATCH v3 0/3] Support for QCOM BAM DMA command descriptor Abhishek Sahu
  2017-08-01 14:11 ` [PATCH v3 1/3] dmaengine: add DMA_PREP_CMD for non-Data descriptors Abhishek Sahu
@ 2017-08-01 14:11 ` Abhishek Sahu
  2017-08-01 14:11 ` [PATCH v3 3/3] dmaengine: qcom: bam_dma: add command descriptor flag Abhishek Sahu
  2017-08-28 11:10 ` [PATCH v3 0/3] Support for QCOM BAM DMA command descriptor Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Abhishek Sahu @ 2017-08-01 14:11 UTC (permalink / raw)
  To: vinod.koul, corbet, dan.j.williams
  Cc: andy.gross, david.brown, linux-arm-msm, linux-soc, dmaengine,
	linux-kernel, linux-doc, Abhishek Sahu

QCOM BAM also supports command descriptor which allows the SW to
create descriptors of type command which does not generate any
data transmissions but configures registers in the peripheral.
In command descriptor the 32bit address point to the start of
the command block which holds the command elements and the
16bit size define the size of the command block.

Each Command Element is structured by 4 words:
    Write command: address + cmd
                   register data
                   register mask
                   reserved

    Read command: address + cmd
                  read data result address,
                  reserved
                  reserved

This patch creates a new header file for BAM driver which contains the
structures and wrapper functions for command descriptor. This file will
be used by different QCOM peripheral drivers for forming the command
descriptor

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
---
 include/linux/dma/qcom_bam_dma.h | 79 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 include/linux/dma/qcom_bam_dma.h

diff --git a/include/linux/dma/qcom_bam_dma.h b/include/linux/dma/qcom_bam_dma.h
new file mode 100644
index 0000000..077d43a
--- /dev/null
+++ b/include/linux/dma/qcom_bam_dma.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _QCOM_BAM_DMA_H
+#define _QCOM_BAM_DMA_H
+
+#include <asm/byteorder.h>
+
+/*
+ * This data type corresponds to the native Command Element
+ * supported by BAM DMA Engine.
+ *
+ * @cmd_and_addr - upper 8 bits command and lower 24 bits register address.
+ * @data - for write command: content to be written into peripheral register.
+ *	   for read command: dest addr to write peripheral register value.
+ * @mask - register mask.
+ * @reserved - for future usage.
+ *
+ */
+struct bam_cmd_element {
+	__le32 cmd_and_addr;
+	__le32 data;
+	__le32 mask;
+	__le32 reserved;
+};
+
+/*
+ * This enum indicates the command type in a command element
+ */
+enum bam_command_type {
+	BAM_WRITE_COMMAND = 0,
+	BAM_READ_COMMAND,
+};
+
+/*
+ * prep_bam_ce_le32 - Wrapper function to prepare a single BAM command
+ * element with the data already in le32 format.
+ *
+ * @bam_ce: bam command element
+ * @addr: target address
+ * @cmd: BAM command
+ * @data: actual data for write and dest addr for read in le32
+ */
+static inline void
+bam_prep_ce_le32(struct bam_cmd_element *bam_ce, u32 addr,
+		 enum bam_command_type cmd, __le32 data)
+{
+	bam_ce->cmd_and_addr =
+		cpu_to_le32((addr & 0xffffff) | ((cmd & 0xff) << 24));
+	bam_ce->data = data;
+	bam_ce->mask = cpu_to_le32(0xffffffff);
+}
+
+/*
+ * bam_prep_ce - Wrapper function to prepare a single BAM command element
+ * with the data.
+ *
+ * @bam_ce: BAM command element
+ * @addr: target address
+ * @cmd: BAM command
+ * @data: actual data for write and dest addr for read
+ */
+static inline void
+bam_prep_ce(struct bam_cmd_element *bam_ce, u32 addr,
+	    enum bam_command_type cmd, u32 data)
+{
+	bam_prep_ce_le32(bam_ce, addr, cmd, cpu_to_le32(data));
+}
+#endif
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

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

* [PATCH v3 3/3] dmaengine: qcom: bam_dma: add command descriptor flag
  2017-08-01 14:11 [PATCH v3 0/3] Support for QCOM BAM DMA command descriptor Abhishek Sahu
  2017-08-01 14:11 ` [PATCH v3 1/3] dmaengine: add DMA_PREP_CMD for non-Data descriptors Abhishek Sahu
  2017-08-01 14:11 ` [PATCH v3 2/3] dmaengine: qcom: bam_dma: wrapper functions for command descriptor Abhishek Sahu
@ 2017-08-01 14:11 ` Abhishek Sahu
  2017-08-28 11:10 ` [PATCH v3 0/3] Support for QCOM BAM DMA command descriptor Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Abhishek Sahu @ 2017-08-01 14:11 UTC (permalink / raw)
  To: vinod.koul, corbet, dan.j.williams
  Cc: andy.gross, david.brown, linux-arm-msm, linux-soc, dmaengine,
	linux-kernel, linux-doc, Abhishek Sahu

If DMA_PREP_CMD flag is passed in prep_slave_sg then peripheral
driver has passed the data is in BAM command descriptor format
and BAM driver should set CMD bit for each of the HW descriptors.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
---
 drivers/dma/qcom/bam_dma.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
index 03c4eb3..6d89fb6 100644
--- a/drivers/dma/qcom/bam_dma.c
+++ b/drivers/dma/qcom/bam_dma.c
@@ -65,6 +65,7 @@ struct bam_desc_hw {
 #define DESC_FLAG_EOT BIT(14)
 #define DESC_FLAG_EOB BIT(13)
 #define DESC_FLAG_NWD BIT(12)
+#define DESC_FLAG_CMD BIT(11)
 
 struct bam_async_desc {
 	struct virt_dma_desc vd;
@@ -645,6 +646,9 @@ static struct dma_async_tx_descriptor *bam_prep_slave_sg(struct dma_chan *chan,
 		unsigned int curr_offset = 0;
 
 		do {
+			if (flags & DMA_PREP_CMD)
+				desc->flags |= cpu_to_le16(DESC_FLAG_CMD);
+
 			desc->addr = cpu_to_le32(sg_dma_address(sg) +
 						 curr_offset);
 
@@ -960,7 +964,7 @@ static void bam_start_dma(struct bam_chan *bchan)
 
 	/* set any special flags on the last descriptor */
 	if (async_desc->num_desc == async_desc->xfer_len)
-		desc[async_desc->xfer_len - 1].flags =
+		desc[async_desc->xfer_len - 1].flags |=
 					cpu_to_le16(async_desc->flags);
 	else
 		desc[async_desc->xfer_len - 1].flags |=
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

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

* Re: [PATCH v3 0/3] Support for QCOM BAM DMA command descriptor
  2017-08-01 14:11 [PATCH v3 0/3] Support for QCOM BAM DMA command descriptor Abhishek Sahu
                   ` (2 preceding siblings ...)
  2017-08-01 14:11 ` [PATCH v3 3/3] dmaengine: qcom: bam_dma: add command descriptor flag Abhishek Sahu
@ 2017-08-28 11:10 ` Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2017-08-28 11:10 UTC (permalink / raw)
  To: Abhishek Sahu
  Cc: corbet, dan.j.williams, andy.gross, david.brown, linux-arm-msm,
	linux-soc, dmaengine, linux-kernel, linux-doc

On Tue, Aug 01, 2017 at 07:41:41PM +0530, Abhishek Sahu wrote:
> v3:
> 
> 1. Added Documentation for new flag
> 2. Changed the flag description
> 
> v2:
> 
> 1. Added DMA_PREP_CMD flag and used the same for BAM DMA
>    command descriptor
> 2. Removed custom mapping API patches
> 
> v1:
> 
> https://www.spinics.net/lists/dmaengine/msg12009.html
> 
> These patches mainly add the support for QCOM BAM command
> descriptor implementing BAM DMA support for some QCOM
> peripherals like QPIC NAND/LCD.
> 
> Currently there is no flag in DMA API which tells the DMA
> controller that the passed data is in command descriptor
> format so added the flag in DMA API for this.

Applied, thanks

> Abhishek Sahu (3):
>   dmaengine: add DMA_PREP_CMD for non-Data descriptors.
>   dmaengine: qcom: bam_dma: wrapper functions for command descriptor
>   dmaengine: qcom: bam_dma: add command descriptor flag
> 
>  Documentation/dmaengine/provider.txt |  7 ++++
>  drivers/dma/qcom/bam_dma.c           |  6 ++-
>  include/linux/dma/qcom_bam_dma.h     | 79 ++++++++++++++++++++++++++++++++++++
>  include/linux/dmaengine.h            |  4 ++
>  4 files changed, 95 insertions(+), 1 deletion(-)
>  create mode 100644 include/linux/dma/qcom_bam_dma.h
> 
> -- 
> QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
> 
> --
> To unsubscribe from this list: send the line "unsubscribe dmaengine" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
~Vinod

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

end of thread, other threads:[~2017-08-28 11:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-01 14:11 [PATCH v3 0/3] Support for QCOM BAM DMA command descriptor Abhishek Sahu
2017-08-01 14:11 ` [PATCH v3 1/3] dmaengine: add DMA_PREP_CMD for non-Data descriptors Abhishek Sahu
2017-08-01 14:11 ` [PATCH v3 2/3] dmaengine: qcom: bam_dma: wrapper functions for command descriptor Abhishek Sahu
2017-08-01 14:11 ` [PATCH v3 3/3] dmaengine: qcom: bam_dma: add command descriptor flag Abhishek Sahu
2017-08-28 11:10 ` [PATCH v3 0/3] Support for QCOM BAM DMA command descriptor Vinod Koul

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).