All of lore.kernel.org
 help / color / mirror / Atom feed
From: "R, Vignesh" <vigneshr@ti.com>
To: Marek Vasut <marex@denx.de>, <linux-mtd@lists.infradead.org>
Cc: Graham Moore <grmoore@opensource.altera.com>,
	Alan Tull <atull@opensource.altera.com>,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Dinh Nguyen <dinguyen@opensource.altera.com>,
	Yves Vandervennet <yvanderv@opensource.altera.com>,
	<devicetree@vger.kernel.org>
Subject: Re: [PATCH V10 2/2] mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller.
Date: Wed, 6 Apr 2016 22:25:29 +0530	[thread overview]
Message-ID: <57053F81.70204@ti.com> (raw)
In-Reply-To: <1452486886-8049-2-git-send-email-marex@denx.de>

Hi Marek,

I encountered a issue with this driver while testing.

On 1/11/2016 10:04 AM, Marek Vasut wrote:
> From: Graham Moore <grmoore@opensource.altera.com>
> 
> Add support for the Cadence QSPI controller. This controller is
> present in the Altera SoCFPGA SoCs and this driver has been tested
> on the Cyclone V SoC.


> +static void cqspi_switch_cs(struct spi_nor *nor)
> +{
> +	struct cqspi_flash_pdata *f_pdata = nor->priv;
> +	struct cqspi_st *cqspi = f_pdata->cqspi;
> +	void __iomem *iobase = cqspi->iobase;
> +	unsigned int reg;
> +
> +	cqspi_controller_enable(cqspi, 0);
> +
> +	/* configure page size and block size. */
> +	reg = readl(iobase + CQSPI_REG_SIZE);
> +	reg &= ~(CQSPI_REG_SIZE_PAGE_MASK << CQSPI_REG_SIZE_PAGE_LSB);
> +	reg &= ~(CQSPI_REG_SIZE_BLOCK_MASK << CQSPI_REG_SIZE_BLOCK_LSB);
> +	reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK;
> +	reg |= (nor->page_size << CQSPI_REG_SIZE_PAGE_LSB);
> +	reg |= (ilog2(nor->mtd.erasesize) << CQSPI_REG_SIZE_BLOCK_LSB);
> +	reg |= (nor->addr_width - 1);
> +	writel(reg, iobase + CQSPI_REG_SIZE);
> +

Page size and block size are configured here...

> +	/* configure the chip select */
> +	cqspi_chipselect(nor);
> +
> +	cqspi_controller_enable(cqspi, 1);
> +}
> +
> +static int cqspi_prep(struct spi_nor *nor, enum spi_nor_ops ops)
> +{
> +	struct cqspi_flash_pdata *f_pdata = nor->priv;
> +	struct cqspi_st *cqspi = f_pdata->cqspi;
> +	const unsigned int sclk = f_pdata->clk_rate;
> +
> +	/* Switch chip select. */
> +	if (cqspi->current_cs != f_pdata->cs) {
> +		cqspi->current_cs = f_pdata->cs;
> +		cqspi_switch_cs(nor);

cqspi_switch_cs(nor) is called from cqspi_prep(). And is called only
once for a given slave (assuming only one slave on the QSPI bus)

> +	}
> +
> +	/* Setup baudrate divisor and delays */
> +	if (cqspi->sclk != sclk) {
> +		cqspi->sclk = sclk;
> +		cqspi_controller_enable(cqspi, 0);
> +		cqspi_config_baudrate_div(cqspi, sclk);
> +		cqspi_delay(nor, sclk);
> +		cqspi_readdata_capture(cqspi, 1, f_pdata->read_delay);
> +		cqspi_controller_enable(cqspi, 1);
> +	}
> +
> +	return 0;
> +}
> +
> +static int cqspi_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len)
> +{
> +	int ret;
> +
> +	ret = cqspi_set_protocol(nor, nor->reg_proto);
> +	if (ret)
> +		return ret;
> +
> +	cqspi_prep(nor, SPI_NOR_OPS_READ);

cqspi_read_reg() is first called to read JEDEC ID, this calls
cqspi_prep() for first time. But nor->page_size, nor->mtd.erasesize are
not yet populated. Therefore cqspi_switch_cs() will not populate
CQSPI_REG_SIZE with correct values.
I think its better to configure this register each time during
read/write ops.

Regards
Vignesh

WARNING: multiple messages have this Message-ID (diff)
From: "R, Vignesh" <vigneshr-l0cyMroinI0@public.gmane.org>
To: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: Graham Moore
	<grmoore-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>,
	Alan Tull
	<atull-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>,
	Brian Norris
	<computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	Dinh Nguyen
	<dinguyen-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>,
	Yves Vandervennet
	<yvanderv-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH V10 2/2] mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller.
Date: Wed, 6 Apr 2016 22:25:29 +0530	[thread overview]
Message-ID: <57053F81.70204@ti.com> (raw)
In-Reply-To: <1452486886-8049-2-git-send-email-marex-ynQEQJNshbs@public.gmane.org>

Hi Marek,

I encountered a issue with this driver while testing.

On 1/11/2016 10:04 AM, Marek Vasut wrote:
> From: Graham Moore <grmoore-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>
> 
> Add support for the Cadence QSPI controller. This controller is
> present in the Altera SoCFPGA SoCs and this driver has been tested
> on the Cyclone V SoC.


> +static void cqspi_switch_cs(struct spi_nor *nor)
> +{
> +	struct cqspi_flash_pdata *f_pdata = nor->priv;
> +	struct cqspi_st *cqspi = f_pdata->cqspi;
> +	void __iomem *iobase = cqspi->iobase;
> +	unsigned int reg;
> +
> +	cqspi_controller_enable(cqspi, 0);
> +
> +	/* configure page size and block size. */
> +	reg = readl(iobase + CQSPI_REG_SIZE);
> +	reg &= ~(CQSPI_REG_SIZE_PAGE_MASK << CQSPI_REG_SIZE_PAGE_LSB);
> +	reg &= ~(CQSPI_REG_SIZE_BLOCK_MASK << CQSPI_REG_SIZE_BLOCK_LSB);
> +	reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK;
> +	reg |= (nor->page_size << CQSPI_REG_SIZE_PAGE_LSB);
> +	reg |= (ilog2(nor->mtd.erasesize) << CQSPI_REG_SIZE_BLOCK_LSB);
> +	reg |= (nor->addr_width - 1);
> +	writel(reg, iobase + CQSPI_REG_SIZE);
> +

Page size and block size are configured here...

> +	/* configure the chip select */
> +	cqspi_chipselect(nor);
> +
> +	cqspi_controller_enable(cqspi, 1);
> +}
> +
> +static int cqspi_prep(struct spi_nor *nor, enum spi_nor_ops ops)
> +{
> +	struct cqspi_flash_pdata *f_pdata = nor->priv;
> +	struct cqspi_st *cqspi = f_pdata->cqspi;
> +	const unsigned int sclk = f_pdata->clk_rate;
> +
> +	/* Switch chip select. */
> +	if (cqspi->current_cs != f_pdata->cs) {
> +		cqspi->current_cs = f_pdata->cs;
> +		cqspi_switch_cs(nor);

cqspi_switch_cs(nor) is called from cqspi_prep(). And is called only
once for a given slave (assuming only one slave on the QSPI bus)

> +	}
> +
> +	/* Setup baudrate divisor and delays */
> +	if (cqspi->sclk != sclk) {
> +		cqspi->sclk = sclk;
> +		cqspi_controller_enable(cqspi, 0);
> +		cqspi_config_baudrate_div(cqspi, sclk);
> +		cqspi_delay(nor, sclk);
> +		cqspi_readdata_capture(cqspi, 1, f_pdata->read_delay);
> +		cqspi_controller_enable(cqspi, 1);
> +	}
> +
> +	return 0;
> +}
> +
> +static int cqspi_read_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len)
> +{
> +	int ret;
> +
> +	ret = cqspi_set_protocol(nor, nor->reg_proto);
> +	if (ret)
> +		return ret;
> +
> +	cqspi_prep(nor, SPI_NOR_OPS_READ);

cqspi_read_reg() is first called to read JEDEC ID, this calls
cqspi_prep() for first time. But nor->page_size, nor->mtd.erasesize are
not yet populated. Therefore cqspi_switch_cs() will not populate
CQSPI_REG_SIZE with correct values.
I think its better to configure this register each time during
read/write ops.

Regards
Vignesh

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-04-06 16:56 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-11  4:34 [PATCH V8 1/2] mtd: spi-nor: Bindings for Cadence Quad SPI Flash Controller driver Marek Vasut
2016-01-11  4:34 ` Marek Vasut
2016-01-11  4:34 ` [PATCH V10 2/2] mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller Marek Vasut
2016-01-11  4:34   ` Marek Vasut
2016-01-11 16:09   ` Dinh Nguyen
2016-01-11 16:09     ` Dinh Nguyen
2016-01-11 16:32     ` Marek Vasut
2016-01-11 16:32       ` Marek Vasut
2016-01-12  4:41     ` Vignesh R
2016-01-12  4:41       ` Vignesh R
2016-01-12 13:49       ` Marek Vasut
2016-01-12 13:49         ` Marek Vasut
2016-04-06 16:55   ` R, Vignesh [this message]
2016-04-06 16:55     ` R, Vignesh
2016-04-06 19:30     ` Marek Vasut
2016-04-06 19:30       ` Marek Vasut
2016-04-07  4:55       ` Vignesh R
2016-04-07  4:55         ` Vignesh R
2016-04-13 10:27         ` Marek Vasut
2016-04-13 10:27           ` Marek Vasut
2016-04-13 15:06         ` Marek Vasut
2016-04-13 15:06           ` Marek Vasut
2016-04-14 16:41           ` R, Vignesh
2016-04-14 16:41             ` R, Vignesh
2016-04-14 17:46             ` Marek Vasut
2016-04-14 17:46               ` Marek Vasut
2016-05-13  0:00   ` Trent Piepho
2016-05-13  0:00     ` Trent Piepho
2016-05-13  0:24     ` Marek Vasut
2016-05-13  0:24       ` Marek Vasut
2016-05-13 20:43       ` Trent Piepho
2016-05-13 20:43         ` Trent Piepho
2016-05-25 23:08         ` Marek Vasut
2016-05-25 23:08           ` Marek Vasut
2016-05-25 23:02     ` Marek Vasut
2016-05-25 23:02       ` Marek Vasut
2016-01-11 16:06 ` [PATCH V8 1/2] mtd: spi-nor: Bindings for Cadence Quad SPI Flash Controller driver Dinh Nguyen
2016-01-11 16:06   ` Dinh Nguyen
2016-01-11 16:32   ` Marek Vasut
2016-01-11 16:32     ` Marek Vasut
2016-01-11 17:03     ` Dinh Nguyen
2016-01-11 17:03       ` Dinh Nguyen
2016-01-11 17:27       ` Marek Vasut
2016-01-11 17:27         ` Marek Vasut
2016-01-13  2:26 ` Rob Herring
2016-01-13  2:26   ` Rob Herring
2016-01-13  2:39   ` Marek Vasut
2016-01-13  2:39     ` Marek Vasut
2016-02-01 21:03     ` Brian Norris
2016-02-01 21:03       ` Brian Norris
2016-02-01 21:13       ` Marek Vasut
2016-02-01 21:13         ` Marek Vasut
2016-02-04  7:38         ` Vignesh R
2016-02-04  7:38           ` Vignesh R
2016-02-04 11:25           ` Marek Vasut
2016-02-04 11:25             ` Marek Vasut
2016-02-04 17:04             ` Dinh Nguyen
2016-02-04 17:04               ` Dinh Nguyen
2016-02-06  7:42               ` Marek Vasut
2016-02-06  7:42                 ` Marek Vasut
2016-02-04 17:30             ` R, Vignesh
2016-02-04 17:30               ` R, Vignesh
2016-02-06  7:42               ` Marek Vasut
2016-02-06  7:42                 ` Marek Vasut
2016-02-08 11:19                 ` Vignesh R
2016-02-08 11:19                   ` Vignesh R
2016-02-08 15:27                   ` Marek Vasut
2016-02-08 15:27                     ` Marek Vasut
2016-02-10 16:10                     ` Graham Moore
2016-02-10 16:10                       ` Graham Moore
2016-02-10 16:17                       ` Marek Vasut
2016-02-10 16:17                         ` Marek Vasut
2016-03-10 20:55                         ` Graham Moore
2016-03-10 20:55                           ` Graham Moore
2016-03-10 21:10                           ` Marek Vasut
2016-03-10 21:10                             ` Marek Vasut
2016-03-14 18:17                             ` Graham Moore
2016-03-14 18:17                               ` Graham Moore
2016-03-14 22:47                               ` Marek Vasut
2016-03-14 22:47                                 ` Marek Vasut

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=57053F81.70204@ti.com \
    --to=vigneshr@ti.com \
    --cc=atull@opensource.altera.com \
    --cc=computersforpeace@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dinguyen@opensource.altera.com \
    --cc=dwmw2@infradead.org \
    --cc=grmoore@opensource.altera.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marex@denx.de \
    --cc=yvanderv@opensource.altera.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.