From: Jia Jie Ho <jiajie.ho@starfivetech.com>
To: Herbert Xu <herbert@gondor.apana.org.au>,
"David S . Miller" <davem@davemloft.net>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>,
Vinod Koul <vkoul@kernel.org>,
linux-crypto@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org
Subject: [PATCH v3 4/6] dmaengine: dw-axi-dmac: Support hardware quirks
Date: Wed, 28 Feb 2024 00:37:56 +0800 [thread overview]
Message-ID: <20240227163758.198133-5-jiajie.ho@starfivetech.com> (raw)
In-Reply-To: <20240227163758.198133-1-jiajie.ho@starfivetech.com>
Adds separate dma hardware descriptor setup for JH8100 hardware quirks.
JH8100 engine uses AXI1 master for data transfer but current dma driver
is hardcoded to use AXI0 only. The FIFO offset needs to be incremented due
to hardware limitations.
Signed-off-by: Jia Jie Ho <jiajie.ho@starfivetech.com>
---
.../dma/dw-axi-dmac/dw-axi-dmac-platform.c | 32 ++++++++++++++++---
drivers/dma/dw-axi-dmac/dw-axi-dmac.h | 2 ++
include/linux/dma/dw_axi.h | 11 +++++++
3 files changed, 40 insertions(+), 5 deletions(-)
create mode 100644 include/linux/dma/dw_axi.h
diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index 2a4747917a3e..056b6ee1963b 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -647,6 +647,7 @@ static void set_desc_dest_master(struct axi_dma_hw_desc *hw_desc,
static int dw_axi_dma_set_hw_desc(struct axi_dma_chan *chan,
struct axi_dma_hw_desc *hw_desc,
+ struct axi_dma_desc *desc,
dma_addr_t mem_addr, size_t len)
{
unsigned int data_width = BIT(chan->chip->dw->hdata->m_data_width);
@@ -655,6 +656,8 @@ static int dw_axi_dma_set_hw_desc(struct axi_dma_chan *chan,
dma_addr_t device_addr;
size_t axi_block_ts;
size_t block_ts;
+ bool hw_quirks = chan->quirks & DWAXIDMAC_STARFIVE_SM_ALGO;
+ u32 val;
u32 ctllo, ctlhi;
u32 burst_len, src_burst_trans_len, dst_burst_trans_len;
@@ -675,7 +678,8 @@ static int dw_axi_dma_set_hw_desc(struct axi_dma_chan *chan,
device_addr = chan->config.dst_addr;
ctllo = reg_width << CH_CTL_L_DST_WIDTH_POS |
mem_width << CH_CTL_L_SRC_WIDTH_POS |
- DWAXIDMAC_CH_CTL_L_NOINC << CH_CTL_L_DST_INC_POS |
+ (hw_quirks ? DWAXIDMAC_CH_CTL_L_INC << CH_CTL_L_DST_INC_POS :
+ DWAXIDMAC_CH_CTL_L_NOINC << CH_CTL_L_DST_INC_POS) |
DWAXIDMAC_CH_CTL_L_INC << CH_CTL_L_SRC_INC_POS;
block_ts = len >> mem_width;
break;
@@ -685,7 +689,8 @@ static int dw_axi_dma_set_hw_desc(struct axi_dma_chan *chan,
ctllo = reg_width << CH_CTL_L_SRC_WIDTH_POS |
mem_width << CH_CTL_L_DST_WIDTH_POS |
DWAXIDMAC_CH_CTL_L_INC << CH_CTL_L_DST_INC_POS |
- DWAXIDMAC_CH_CTL_L_NOINC << CH_CTL_L_SRC_INC_POS;
+ (hw_quirks ? DWAXIDMAC_CH_CTL_L_INC << CH_CTL_L_SRC_INC_POS :
+ DWAXIDMAC_CH_CTL_L_NOINC << CH_CTL_L_SRC_INC_POS);
block_ts = len >> reg_width;
break;
default:
@@ -738,6 +743,17 @@ static int dw_axi_dma_set_hw_desc(struct axi_dma_chan *chan,
set_desc_src_master(hw_desc);
+ if (hw_quirks) {
+ if (chan->direction == DMA_MEM_TO_DEV) {
+ set_desc_dest_master(hw_desc, desc);
+ } else {
+ /* Select AXI1 for src master */
+ val = le32_to_cpu(hw_desc->lli->ctl_lo);
+ val |= CH_CTL_L_SRC_MAST;
+ hw_desc->lli->ctl_lo = cpu_to_le32(val);
+ }
+ }
+
hw_desc->len = len;
return 0;
}
@@ -814,8 +830,8 @@ dw_axi_dma_chan_prep_cyclic(struct dma_chan *dchan, dma_addr_t dma_addr,
for (i = 0; i < total_segments; i++) {
hw_desc = &desc->hw_desc[i];
- status = dw_axi_dma_set_hw_desc(chan, hw_desc, src_addr,
- segment_len);
+ status = dw_axi_dma_set_hw_desc(chan, hw_desc, NULL,
+ src_addr, segment_len);
if (status < 0)
goto err_desc_get;
@@ -897,7 +913,8 @@ dw_axi_dma_chan_prep_slave_sg(struct dma_chan *dchan, struct scatterlist *sgl,
do {
hw_desc = &desc->hw_desc[loop++];
- status = dw_axi_dma_set_hw_desc(chan, hw_desc, mem, segment_len);
+ status = dw_axi_dma_set_hw_desc(chan, hw_desc, desc,
+ mem, segment_len);
if (status < 0)
goto err_desc_get;
@@ -1035,8 +1052,13 @@ static int dw_axi_dma_chan_slave_config(struct dma_chan *dchan,
struct dma_slave_config *config)
{
struct axi_dma_chan *chan = dchan_to_axi_dma_chan(dchan);
+ struct dw_axi_peripheral_config *periph = config->peripheral_config;
memcpy(&chan->config, config, sizeof(*config));
+ if (config->peripheral_size == sizeof(*periph))
+ chan->quirks = periph->quirks;
+ else
+ chan->quirks = 0;
return 0;
}
diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
index 652e983409ba..f0ab5b692b21 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
@@ -14,6 +14,7 @@
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/dmaengine.h>
+#include <linux/dma/dw_axi.h>
#include <linux/types.h>
#include "../virt-dma.h"
@@ -50,6 +51,7 @@ struct axi_dma_chan {
struct dma_slave_config config;
enum dma_transfer_direction direction;
bool cyclic;
+ u32 quirks;
/* these other elements are all protected by vc.lock */
bool is_paused;
};
diff --git a/include/linux/dma/dw_axi.h b/include/linux/dma/dw_axi.h
new file mode 100644
index 000000000000..fd49152869a4
--- /dev/null
+++ b/include/linux/dma/dw_axi.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __LINUX_DMA_DW_AXI_H
+#define __LINUX_DMA_DW_AXI_H
+
+#include <linux/types.h>
+
+struct dw_axi_peripheral_config {
+#define DWAXIDMAC_STARFIVE_SM_ALGO BIT(0)
+ u32 quirks;
+};
+#endif /* __LINUX_DMA_DW_AXI_H */
--
2.34.1
next prev parent reply other threads:[~2024-02-27 16:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 16:37 [PATCH v3 0/6] crypto: starfive: Add support for JH8100 Jia Jie Ho
2024-02-27 16:37 ` [PATCH v3 1/6] dt-bindings: crypto: starfive: Add jh8100 support Jia Jie Ho
2024-02-28 11:19 ` Conor Dooley
2024-02-28 15:51 ` Rob Herring
2024-02-29 2:17 ` JiaJie Ho
2024-02-27 16:37 ` [PATCH v3 2/6] crypto: starfive: Update hash dma usage Jia Jie Ho
2024-02-27 16:37 ` [PATCH v3 3/6] crypto: starfive: Use dma for aes requests Jia Jie Ho
2024-02-27 16:37 ` Jia Jie Ho [this message]
2024-02-27 16:37 ` [PATCH v3 5/6] crypto: starfive: Add sm3 support for JH8100 Jia Jie Ho
2024-02-27 16:37 ` [PATCH v3 6/6] crypto: starfive: Add sm4 " Jia Jie Ho
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=20240227163758.198133-5-jiajie.ho@starfivetech.com \
--to=jiajie.ho@starfivetech.com \
--cc=Eugeniy.Paltsev@synopsys.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=vkoul@kernel.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
all inboxes | Powered by JetHome®