public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Vignesh Raghavendra <vigneshr@ti.com>
To: <Tudor.Ambarus@microchip.com>, <yaliang.wang@windriver.com>,
	<miquel.raynal@bootlin.com>, <richard@nod.at>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH] mtd: spi-nor: Use CLSR command for FL-L chips
Date: Sun, 24 Jan 2021 11:42:40 +0530	[thread overview]
Message-ID: <d2a66253-e755-280f-8f79-d141b3169c56@ti.com> (raw)
In-Reply-To: <f2fe7e4e-a651-491c-f894-8cc264c64744@microchip.com>

 Hi, Yaliang

On 1/23/21 11:15 PM, Tudor.Ambarus@microchip.com wrote:
> Hi, Yaliang,
> 
[...]
>> +static int spi_nor_s25fl_l_sr_ready(struct spi_nor *nor)
>> +{
>> +	u8 *sr = nor->bouncebuf;
>> +	int ret;
>> +
>> +	ret = spi_nor_read_sr(nor, sr);
>> +	if (ret)
>> +		return ret;
>> +
>> +	/**
>> +	 * P_ERR and E_ERR bits are located in the Status Register 2
>> +	 * of Cypress FL-L series chips.
>> +	 */
>> +	ret = spi_nor_s25fl_l_read_sr2(nor, &sr[1]);
>> +	if (ret)
>> +		return ret;
>> +
>> +	if (nor->flags & SNOR_F_USE_CLSR && sr[1] & (SR_E_ERR | SR_P_ERR)) {
> If checking other manufacturer datasheets, would you please check if
> CLSR is used by any other manufacturer?
> 

This is limited to certain subsets of Cypress/Spansion flashes.

>> +		if (sr[1] & SR_E_ERR)
>> +			dev_err(nor->dev, "Erase Error occurred\n");
>> +		else
>> +			dev_err(nor->dev, "Programming Error occurred\n");
>> +
>> +		spi_nor_clear_sr(nor);
>> +
>> +		/*
>> +		 * WEL bit remains set to one when an erase or page program
>> +		 * error occurs. Issue a Write Disable command to protect
>> +		 * against inadvertent writes that can possibly corrupt the
>> +		 * contents of the memory.
>> +		 */
>> +		ret = spi_nor_write_disable(nor);
>> +		if (ret)
>> +			return ret;
>> +
>> +		return -EIO;
>> +	}
>> +
>> +	return !(sr[0] & SR_WIP);
>> +}
>> +
>>  /**
>>   * spi_nor_sr_ready() - Query the Status Register to see if the flash is ready
>>   * for new commands.
>> @@ -546,7 +628,19 @@ static void spi_nor_clear_sr(struct spi_nor *nor)
>>   */
>>  static int spi_nor_sr_ready(struct spi_nor *nor)
>>  {
>> -	int ret = spi_nor_read_sr(nor, nor->bouncebuf);
>> +	int ret;
>> +	const struct flash_info *tmpinfo = nor->info ? nor->info : spi_nor_read_id(nor);
>> +
>> +	if (IS_ERR_OR_NULL(tmpinfo))
>> +		return -ENOENT;
>> +
>> +	if (!strcmp(tmpinfo->name, "s25fl064l")
>> +			|| !strcmp(tmpinfo->name, "s25fl128l")
>> +			|| !strcmp(tmpinfo->name, "s25fl256l")) {
>> +		return spi_nor_s25fl_l_sr_ready(nor);
>> +	}
> 
> No, we can't accept flash name comparisons in the SPI NOR core.
> If CLSR and RDSR2 are just spansion specific, we can provide a sr_ready
> function pointer that can be filled by spansion flashes. Or some other
> method depending on the CLSR and RDSR2 exposure through other
> manufacturers.
> 
> Ideally one would skim through at least 2 - 3 datasheets from each
> manufacturer available in SPI NOR. Preferable each datasheet from
> a different manufacturer family. Unfortunately I'm not aware of any
> standard that describes all the supported SPI NOR commands.
> If you find this overwhelming, I can share the workload with you,
> but at best effort. If you go through this by yourself, please
> save the name of the datasheet flashes that you go through.
> 

Agree with Tudor. There is quite a bit of variation even within
Cypress/Spansion devices. S28 series of flashes have these error bits
within SR1 register. See: https://www.cypress.com/file/513996/download

So, this cannot be in SPI NOR core.

spi_nor_xread_sr(), spi_nor_fsr_ready() and spi_nor_clear_sr() are all
vendor/family specific and should be moved to appropriate vendor
specific drivers.

Would highly appreciate it, if you could fix these up as part of your
current work. Thanks!

Regards
Vignesh

[...]

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2021-01-24  6:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-16 15:39 [PATCH] mtd: spi-nor: Use CLSR command for FL-L chips yaliang.wang
2021-01-23 17:45 ` Tudor.Ambarus
2021-01-24  6:12   ` Vignesh Raghavendra [this message]
2021-01-26  2:06     ` Wang, Yaliang
2021-01-26  8:51       ` Tudor.Ambarus
2021-02-23 16:36         ` Yaliang.Wang
2021-02-23 17:31           ` Tudor.Ambarus
2021-02-24 16:24             ` Yaliang.Wang
2021-02-24 16:30               ` Tudor.Ambarus
2021-03-29 13:12                 ` Tudor.Ambarus
2021-03-29 16:53                   ` Wang, Yaliang

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=d2a66253-e755-280f-8f79-d141b3169c56@ti.com \
    --to=vigneshr@ti.com \
    --cc=Tudor.Ambarus@microchip.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=yaliang.wang@windriver.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