mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Jules Maselbas <jmaselbas@kalray.eu>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 5/5] mtd: spi-nor: Add Synopsys DesignWare Octal SPI driver
Date: Wed, 26 Jul 2023 13:39:12 +0200	[thread overview]
Message-ID: <20230726113912.GL18491@pengutronix.de> (raw)
In-Reply-To: <20230717165428.27286-5-jmaselbas@kalray.eu>

Hi Jules,

On Mon, Jul 17, 2023 at 06:54:28PM +0200, Jules Maselbas wrote:
> Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
> ---
>  drivers/mtd/spi-nor/Kconfig       |   6 +
>  drivers/mtd/spi-nor/Makefile      |   1 +
>  drivers/mtd/spi-nor/dw-ospi-nor.c | 960 ++++++++++++++++++++++++++++++
>  3 files changed, 967 insertions(+)
>  create mode 100644 drivers/mtd/spi-nor/dw-ospi-nor.c
> 
> diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
> index 2beb26006e..b34c69203e 100644
> --- a/drivers/mtd/spi-nor/Kconfig
> +++ b/drivers/mtd/spi-nor/Kconfig
> @@ -26,4 +26,10 @@ config SPI_CADENCE_QUADSPI
>  	help
>  	  This enables support for the Cadence Quad SPI controller and NOR flash.
>  
> +config SPI_SYNOPSYS_OCTALSPI_NOR
> +	tristate "Synopsys DesignWare Octal SPI controller"
> +	help
> +	  This enables support for the Synopsys DesignWare Octal SPI controller
> +	  and NOR flash.
> +
>  endif
> diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
> index 457a2f0488..61cf789182 100644
> --- a/drivers/mtd/spi-nor/Makefile
> +++ b/drivers/mtd/spi-nor/Makefile
> @@ -1,3 +1,4 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  obj-$(CONFIG_MTD_SPI_NOR)		+= spi-nor.o
>  obj-$(CONFIG_SPI_CADENCE_QUADSPI)	+= cadence-quadspi.o
> +obj-$(CONFIG_SPI_SYNOPSYS_OCTALSPI_NOR) += dw-ospi-nor.o
> diff --git a/drivers/mtd/spi-nor/dw-ospi-nor.c b/drivers/mtd/spi-nor/dw-ospi-nor.c
> new file mode 100644
> index 0000000000..13033f9500
> --- /dev/null
> +static int dw_spi_find_chipselect(struct spi_nor *nor)
> +{
> +	int cs = -1;
> +	struct dw_spi_nor *dw_spi = nor->priv;

Better put a pointer to dw_spi_flash_pdata into nor->priv...
(or use container_of() to get dw_spi_flash_pdata from *nor)

> +
> +	for (cs = 0; cs < dw_spi->supported_cs; cs++)
> +		if (nor == &dw_spi->f_pdata[cs].nor)
> +			break;
> +	return cs;
> +}

...and put cs into struct dw_spi_flash_pdata. This way you don't have to
iterate to get the current chip select.

> +static int dw_spi_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len)
> +{
> +	int i, ret;
> +
> +	dev_dbg(nor->dev, "write_reg opcode 0x%02x: ", opcode);
> +	for (i = 0; i < len; i++)
> +		pr_debug("%02x ", buf[i]);
> +	pr_debug("\n");
> +
> +	if (!IS_ENABLED(CONFIG_MTD_WRITE))
> +		return -ENOTSUPP;

This function looks like it's supposed to write a register. Are you sure
this is not needed when MTD write support is disabled?

> +
> +	ret = dw_spi_prep_std(nor, SPI_TMOD_TO);
> +	if (ret)
> +		return ret;
> +
> +	return dw_spi_write_std(nor, &opcode, 1, buf, len);
> +}

[...]

> +
> +	if (!dev->of_node) {
> +		f_pdata = &dw_spi->f_pdata[0];
> +
> +		ret = dw_spi_setup_flash(dev, f_pdata, np);
> +		if (ret)
> +			goto probe_failed;

Do we need probing without device tree? If not, please remove this case.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2023-07-26 11:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-17 16:54 [PATCH 1/5] mtd: spi-nor: Add SPI_NOR_QUAD_WRITE hwcap Jules Maselbas
2023-07-17 16:54 ` [PATCH 2/5] mtd: spi-nor: enable {dual,quad}-read and quad-write for w25q256 Jules Maselbas
2023-07-17 16:54 ` [PATCH 3/5] mtd: spi-nor: enable quad-write for is25lp01g Jules Maselbas
2023-07-17 16:54 ` [PATCH 4/5] mtd: spi-nor: move SPI_NOR_MAX_ADDR_WIDTH define to spi-nor.h Jules Maselbas
2023-07-17 16:54 ` [PATCH 5/5] mtd: spi-nor: Add Synopsys DesignWare Octal SPI driver Jules Maselbas
2023-07-26 11:39   ` Sascha Hauer [this message]
2023-08-10 15:20     ` Jules Maselbas

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=20230726113912.GL18491@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=jmaselbas@kalray.eu \
    /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