From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH 10/14] spi: dw: Add DUAL/QUAD/OCTAL caps
Date: Mon, 1 Feb 2021 13:00:00 -0500 [thread overview]
Message-ID: <33154dc8-0c5f-e1cb-a531-d0f2d960faff@gmail.com> (raw)
In-Reply-To: <20210201003436.1180667-11-seanga2@gmail.com>
On 1/31/21 7:34 PM, Sean Anderson wrote:
> These capabilities correspond to SSIC_SPI_MODE of 1, 2, or 3, respectively.
> This doesn't do much yet, but it does add support for detection and for
> disallowing unsupported modes. Unfortunately, we cannot discriminate
> between these modes (only that SSIC_SPI_MODE != 0), so we only assume DUAL
> if something sticks to SPI_FRF.
>
> Signed-off-by: Sean Anderson <seanga2@gmail.com>
> ---
>
> drivers/spi/designware_spi.c | 41 +++++++++++++++++++++++++-----------
> 1 file changed, 29 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
> index 683394a5a4..1dd83e6ca6 100644
> --- a/drivers/spi/designware_spi.c
> +++ b/drivers/spi/designware_spi.c
> @@ -129,6 +129,9 @@ struct dw_spi_priv {
> #define DW_SPI_CAP_KEEMBAY_MST BIT(1) /* Unimplemented */
> #define DW_SPI_CAP_DWC_SSI BIT(2)
> #define DW_SPI_CAP_DFS32 BIT(3)
> +#define DW_SPI_CAP_DUAL BIT(4)
> +#define DW_SPI_CAP_QUAD BIT(5)
> +#define DW_SPI_CAP_OCTAL BIT(5)
Looks like these CAPs both use BIT(5). Will fix in next revision.
Actually, it might be better to just have a CAP_EXTENDED and let the SPI
slave determine the bus width...
--Sean
> unsigned long caps;
> unsigned long bus_clk_rate;
> unsigned int freq; /* Default frequency */
> @@ -141,6 +144,7 @@ struct dw_spi_priv {
> u8 cs; /* chip select pin */
> u8 tmode; /* TR/TO/RO/EEPROM */
> u8 type; /* SPI/SSP/MicroWire */
> + u8 spi_frf; /* BYTE/DUAL/QUAD/OCTAL */
> };
>
> static inline u32 dw_read(struct dw_spi_priv *priv, u32 offset)
> @@ -267,7 +271,6 @@ static void spi_hw_init(struct udevice *bus, struct dw_spi_priv *priv)
> priv->fifo_len = (fifo == 1) ? 0 : fifo;
> dw_write(priv, DW_SPI_TXFTLR, 0);
> }
> - dev_dbg(bus, "fifo_len=%d\n", priv->fifo_len);
> }
>
> /*
> @@ -351,22 +354,21 @@ static int dw_spi_probe(struct udevice *bus)
> if (ret)
> return ret;
>
> - priv->caps = dev_get_driver_data(bus);
> - dw_spi_detect_caps(bus, priv);
> -
> - version = dw_read(priv, DW_SPI_VERSION);
> - dev_dbg(bus, "ssi_version_id=%c.%c%c%c ssi_max_xfer_size=%u\n",
> - version >> 24, version >> 16, version >> 8, version,
> - priv->caps & DW_SPI_CAP_DFS32 ? 32 : 16);
> -
> /* Currently only bits_per_word == 8 supported */
> priv->bits_per_word = 8;
>
> priv->tmode = 0; /* Tx & Rx */
>
> /* Basic HW init */
> + priv->caps = dev_get_driver_data(bus);
> spi_hw_init(bus, priv);
>
> + version = dw_read(priv, DW_SPI_VERSION);
> + dev_dbg(bus,
> + "ssi_version_id=%c.%c%c%c ssi_rx_fifo_depth=%u ssi_max_xfer_size=%u\n",
> + version >> 24, version >> 16, version >> 8, version,
> + priv->fifo_len, priv->caps & DW_SPI_CAP_DFS32 ? 32 : 16);
> +
> return 0;
> }
>
> @@ -748,13 +750,25 @@ static int dw_spi_set_mode(struct udevice *bus, uint mode)
> {
> struct dw_spi_priv *priv = dev_get_priv(bus);
>
> + if (!(priv->caps & DW_SPI_CAP_DUAL) &&
> + (mode & (SPI_RX_DUAL | SPI_TX_DUAL)))
> + return -EINVAL;
> +
> + if (!(priv->caps & DW_SPI_CAP_QUAD) &&
> + (mode & (SPI_RX_QUAD | SPI_TX_QUAD)))
> + return -EINVAL;
> +
> + if (!(priv->caps & DW_SPI_CAP_OCTAL) &&
> + (mode & (SPI_RX_OCTAL | SPI_TX_OCTAL)))
> + return -EINVAL;
> +
> /*
> * Can't set mode yet. Since this depends on if rx, tx, or
> * rx & tx is requested. So we have to defer this to the
> * real transfer function.
> */
> priv->mode = mode;
> - dev_dbg(bus, "mode=%d\n", priv->mode);
> + dev_dbg(bus, "mode=%x\n", mode);
>
> return 0;
> }
> @@ -813,10 +827,13 @@ static const struct udevice_id dw_spi_ids[] = {
> */
> { .compatible = "altr,socfpga-spi" },
> { .compatible = "altr,socfpga-arria10-spi" },
> - { .compatible = "canaan,kendryte-k210-spi" },
> + {
> + .compatible = "canaan,kendryte-k210-spi",
> + .data = DW_SPI_CAP_QUAD | DW_SPI_CAP_OCTAL,
> + },
> {
> .compatible = "canaan,kendryte-k210-ssi",
> - .data = DW_SPI_CAP_DWC_SSI,
> + .data = DW_SPI_CAP_DWC_SSI | DW_SPI_CAP_QUAD,
> },
> { .compatible = "intel,stratix10-spi" },
> { .compatible = "intel,agilex-spi" },
>
next prev parent reply other threads:[~2021-02-01 18:00 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-01 0:34 [PATCH 00/14] spi: dw: Add support for DUAL/QUAD/OCTAL modes Sean Anderson
2021-02-01 0:34 ` [PATCH 01/14] cmd: sf: Display errno on erase failure Sean Anderson
2021-02-01 5:06 ` Bin Meng
2021-02-01 12:51 ` Pratyush Yadav
2021-02-01 0:34 ` [PATCH 02/14] cmd: sf: Print error on test failure Sean Anderson
2021-02-01 5:06 ` Bin Meng
2021-02-01 12:54 ` Pratyush Yadav
2021-02-01 0:34 ` [PATCH 03/14] mtd: spi-nor-core: Fix typo in documentation Sean Anderson
2021-02-01 5:06 ` Bin Meng
2021-02-01 12:23 ` Pratyush Yadav
2021-02-01 0:34 ` [PATCH 04/14] mtd: spi-mem: Export spi_mem_default_supports_op Sean Anderson
2021-02-01 5:06 ` Bin Meng
2021-02-01 12:07 ` Pratyush Yadav
2021-02-01 15:15 ` Sean Anderson
2021-02-01 0:34 ` [PATCH 05/14] spi: spi-mem: Add debug message for spi-mem ops Sean Anderson
2021-02-01 5:06 ` Bin Meng
2021-02-01 12:18 ` Pratyush Yadav
2021-02-01 15:33 ` Sean Anderson
2021-02-01 16:34 ` Pratyush Yadav
2021-02-01 0:34 ` [PATCH 06/14] spi: dw: Log status register on timeout Sean Anderson
2021-02-01 0:34 ` [PATCH 07/14] spi: dw: Mask all possible interrupts Sean Anderson
2021-02-04 4:51 ` Sean Anderson
2021-02-01 0:34 ` [PATCH 08/14] spi: dw: Switch to capabilities Sean Anderson
2021-02-01 0:34 ` [PATCH 09/14] spi: dw: Rewrite poll_transfer logic Sean Anderson
2021-02-01 0:34 ` [PATCH 10/14] spi: dw: Add DUAL/QUAD/OCTAL caps Sean Anderson
2021-02-01 18:00 ` Sean Anderson [this message]
2021-02-01 0:34 ` [PATCH 11/14] spi: dw: Add registers necessary for DUAL/QUAD/OCTAL Sean Anderson
2021-02-01 0:34 ` [PATCH 12/14] spi: dw: Support DUAL/QUAD/OCTAL Sean Anderson
2021-02-01 0:34 ` [PATCH 13/14] spi: dw: Support clock stretching Sean Anderson
2021-02-01 0:34 ` [PATCH 14/14] riscv: k210: Enable QSPI for spi3 Sean Anderson
2021-02-01 5:16 ` Bin Meng
2021-02-04 2:32 ` Leo Liang
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=33154dc8-0c5f-e1cb-a531-d0f2d960faff@gmail.com \
--to=seanga2@gmail.com \
--cc=u-boot@lists.denx.de \
/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