From: Serge Semin <fancer.lancer@gmail.com>
To: Sudip Mukherjee <sudip.mukherjee@sifive.com>
Cc: Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
jude.onyenegecha@sifive.com, ben.dooks@sifive.com,
jeegar.lakhani@sifive.com, linux-spi@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 04/15] spi: dw: add check for support of enhanced spi
Date: Mon, 9 Jan 2023 20:34:16 +0300 [thread overview]
Message-ID: <20230109173416.zzphzen7vnzsttsu@mobilestation> (raw)
In-Reply-To: <20221212180732.79167-5-sudip.mukherjee@sifive.com>
On Mon, Dec 12, 2022 at 06:07:21PM +0000, Sudip Mukherjee wrote:
> Before doing the mem op, spi controller will be queried about the
> buswidths it supports. Add the dual/quad/octal if the controller
> has the DW_SPI_CAP_EMODE capability.
> The DW_SPI_CAP_EMODE capability will be enabled in a later patch.
>
> Signed-off-by: Sudip Mukherjee <sudip.mukherjee@sifive.com>
> ---
> drivers/spi/spi-dw-core.c | 25 ++++++++++++++++++++++++-
> drivers/spi/spi-dw.h | 1 +
> 2 files changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c
> index d59401f16c47a..49fad58ceb94a 100644
> --- a/drivers/spi/spi-dw-core.c
> +++ b/drivers/spi/spi-dw-core.c
> @@ -510,6 +510,26 @@ static int dw_spi_adjust_mem_op_size(struct spi_mem *mem, struct spi_mem_op *op)
> return 0;
> }
>
> +static bool dw_spi_supports_enh_mem_op(struct spi_mem *mem,
> + const struct spi_mem_op *op)
> +{
> + if (op->addr.nbytes != 0 && op->addr.buswidth != 1 &&
> + op->addr.buswidth != op->data.buswidth)
> + return false;
> +
> + if (op->cmd.buswidth != 1 && op->cmd.buswidth != op->addr.buswidth &&
> + op->cmd.buswidth != op->data.buswidth)
> + return false;
> +
> + if (op->dummy.nbytes != 0 && op->data.dir == SPI_MEM_DATA_OUT)
> + return false;
> +
> + if (op->dummy.nbytes != 0 && op->dummy.nbytes / op->dummy.buswidth > 4)
> + return false;
> +
> + return spi_mem_default_supports_op(mem, op);
> +}
> +
> static bool dw_spi_supports_mem_op(struct spi_mem *mem,
> const struct spi_mem_op *op)
> {
> @@ -792,7 +812,10 @@ static void dw_spi_init_mem_ops(struct dw_spi *dws)
> if (!dws->mem_ops.exec_op && !(dws->caps & DW_SPI_CAP_CS_OVERRIDE) &&
> !dws->set_cs) {
> dws->mem_ops.adjust_op_size = dw_spi_adjust_mem_op_size;
> - dws->mem_ops.supports_op = dw_spi_supports_mem_op;
Please see my comment to the cover letter. In order to have a more
readable method I'd suggest to convert it to something like this:
< dw_spi_init_mem_ops() {
< if (dws->mem_ops.exec_op || dws->caps & DW_SPI_CAP_CS_OVERRIDE ||
< dws->set_cs)
< return;
<
< if (dws->caps & DW_SPI_CAP_ENH_CLK_STR) {
< dws->mem_ops.adjust_op_size = dw_spi_enh_adjust_mem_op;
< dws->mem_ops.supports_op = dw_spi_enh_supports_mem_op;
< dws->mem_ops.exec_op = dw_spi_enh_exec_mem_op;
<
< return;
< }
<
< dws->mem_ops.adjust_op_size = dw_spi_adjust_mem_op_size;
< dws->mem_ops.supports_op = dw_spi_supports_mem_op;
< dws->mem_ops.exec_op = dw_spi_exec_mem_op;
<
< return;
< }
> + if (dws->caps & DW_SPI_CAP_EMODE)
Your implementation is working only if the clock-stretching feature is
available.
> + dws->mem_ops.supports_op = dw_spi_supports_enh_mem_op;
> + else
> + dws->mem_ops.supports_op = dw_spi_supports_mem_op;
> dws->mem_ops.exec_op = dw_spi_exec_mem_op;
> if (!dws->max_mem_freq)
> dws->max_mem_freq = dws->max_freq;
> diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
> index f29d89d05f34b..327d037bdb10e 100644
> --- a/drivers/spi/spi-dw.h
> +++ b/drivers/spi/spi-dw.h
> @@ -34,6 +34,7 @@
> /* DW SPI controller capabilities */
> #define DW_SPI_CAP_CS_OVERRIDE BIT(0)
> #define DW_SPI_CAP_DFS32 BIT(1)
> +#define DW_SPI_CAP_EMODE BIT(2)
As I suggested in the cover letter let's make it DW_SPI_CAP_ENH (any
better suggestion?). Then the clock-stretching capability flag will be
DW_SPI_CAP_ENH_CLK_STR.
-Serge(y)
>
> /* Register offsets (Generic for both DWC APB SSI and DWC SSI IP-cores) */
> #define DW_SPI_CTRLR0 0x00
> --
> 2.30.2
>
next prev parent reply other threads:[~2023-01-09 17:35 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-12 18:07 [PATCH v2 00/15] Add support for enhanced SPI for Designware SPI controllers Sudip Mukherjee
2022-12-12 18:07 ` [PATCH v2 01/15] spi: dw: Introduce spi_frf and STD_SPI Sudip Mukherjee
2023-01-09 16:43 ` Serge Semin
2022-12-12 18:07 ` [PATCH v2 02/15] spi: dw: update NDF while using enhanced spi mode Sudip Mukherjee
2023-01-09 16:52 ` Serge Semin
2022-12-12 18:07 ` [PATCH v2 03/15] spi: dw: update SPI_CTRLR0 register Sudip Mukherjee
2023-01-09 17:06 ` Serge Semin
2022-12-12 18:07 ` [PATCH v2 04/15] spi: dw: add check for support of enhanced spi Sudip Mukherjee
2023-01-09 17:34 ` Serge Semin [this message]
2022-12-12 18:07 ` [PATCH v2 05/15] spi: dw: Introduce enhanced mem_op Sudip Mukherjee
2023-01-10 11:10 ` Serge Semin
2022-12-12 18:07 ` [PATCH v2 06/15] spi: dw: Introduce dual/quad/octal spi Sudip Mukherjee
2023-01-10 11:40 ` Serge Semin
2022-12-12 18:07 ` [PATCH v2 07/15] spi: dw: send cmd and addr to start the spi transfer Sudip Mukherjee
2023-01-10 11:42 ` Serge Semin
2022-12-12 18:07 ` [PATCH v2 08/15] spi: dw: update irq setup to use multiple handler Sudip Mukherjee
2023-01-10 11:46 ` Serge Semin
2022-12-12 18:07 ` [PATCH v2 09/15] spi: dw: use irq handler for enhanced spi Sudip Mukherjee
2023-01-10 12:08 ` Serge Semin
2022-12-12 18:07 ` [PATCH v2 10/15] spi: dw: Calculate Receive FIFO Threshold Level Sudip Mukherjee
2022-12-12 18:07 ` [PATCH v2 11/15] spi: dw: adjust size of mem_op Sudip Mukherjee
2022-12-12 18:07 ` [PATCH v2 12/15] spi: dw: Add retry for enhanced spi mode Sudip Mukherjee
2023-01-10 12:10 ` Serge Semin
2022-12-12 18:07 ` [PATCH v2 13/15] spi: dw: detect " Sudip Mukherjee
2023-01-10 12:20 ` Serge Semin
2022-12-12 18:07 ` [PATCH v2 14/15] spi: dt-bindings: snps,dw-ahb-ssi: Add generic dw-ahb-ssi version Sudip Mukherjee
2022-12-13 16:32 ` Rob Herring
2022-12-13 16:59 ` Mark Brown
2022-12-13 17:47 ` Sudip Mukherjee
2022-12-13 18:29 ` Serge Semin
2022-12-12 18:07 ` [PATCH v2 15/15] spi: dw: initialize dwc-ssi controller Sudip Mukherjee
2022-12-18 17:45 ` [PATCH v2 00/15] Add support for enhanced SPI for Designware SPI controllers Serge Semin
2023-01-04 22:20 ` Serge Semin
2023-01-09 16:25 ` Serge Semin
2023-01-19 16:26 ` Sudip Mukherjee
2023-01-19 16:37 ` Serge Semin
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=20230109173416.zzphzen7vnzsttsu@mobilestation \
--to=fancer.lancer@gmail.com \
--cc=ben.dooks@sifive.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jeegar.lakhani@sifive.com \
--cc=jude.onyenegecha@sifive.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=sudip.mukherjee@sifive.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