Skip to content

Commit

Permalink
mtd: spi-nor: Set Upper flash to Quad and 4Byte Mode in stacked conne…
Browse files Browse the repository at this point in the history
…ction mode

When two flashes are connected in stacked mode, spi-nor framework was only
configuring the lower flash into quad mode and 4Byte Mode. This resulted in
read/write failure on the upper flash while issuing quad read/write
commands. This patch fixes the issue by setting both the flashes to quad
mode and 4Byte Mode.

Signed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@xilinx.com>
  • Loading branch information
Amit Kumar Mahapatra authored and Michal Simek committed Jan 25, 2022
1 parent 99cdfc8 commit 889bf0c
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion drivers/mtd/spi-nor/core.c
Expand Up @@ -3102,14 +3102,22 @@ static int spi_nor_octal_dtr_enable(struct spi_nor *nor, bool enable)
*/
static int spi_nor_quad_enable(struct spi_nor *nor)
{
int err;

if (!nor->params->quad_enable)
return 0;

if (!(spi_nor_get_protocol_width(nor->read_proto) == 4 ||
spi_nor_get_protocol_width(nor->write_proto) == 4))
return 0;

return nor->params->quad_enable(nor);
err = nor->params->quad_enable(nor);
if (nor->isstacked) {
nor->spimem->spi->master->flags |= SPI_MASTER_U_PAGE;
err = nor->params->quad_enable(nor);
nor->spimem->spi->master->flags &= ~SPI_MASTER_U_PAGE;
}
return err;
}

static int spi_nor_init(struct spi_nor *nor)
Expand Down Expand Up @@ -3353,6 +3361,13 @@ static int spi_nor_set_addr_width(struct spi_nor *nor)

nor->addr_width = 3;
nor->params->set_4byte_addr_mode(nor, false);
if (nor->isstacked) {
nor->spimem->spi->master->flags |=
SPI_MASTER_U_PAGE;
nor->params->set_4byte_addr_mode(nor, false);
nor->spimem->spi->master->flags &=
~SPI_MASTER_U_PAGE;
}
status = read_ear(nor, (struct flash_info *)nor->info);
if (status < 0)
dev_warn(nor->dev, "failed to read ear reg\n");
Expand All @@ -3368,6 +3383,14 @@ static int spi_nor_set_addr_width(struct spi_nor *nor)
if (nor->jedec_id == CFI_MFR_AMD ||
nor->info->flags & SPI_NOR_4B_OPCODES) {
spi_nor_set_4byte_opcodes(nor);
nor->params->set_4byte_addr_mode(nor, true);
if (nor->isstacked) {
nor->spimem->spi->master->flags |=
SPI_MASTER_U_PAGE;
nor->params->set_4byte_addr_mode(nor, true);
nor->spimem->spi->master->flags &=
~SPI_MASTER_U_PAGE;
}
} else {
np_spi = of_get_next_parent(np);
if (of_property_match_string(np_spi,
Expand Down

0 comments on commit 889bf0c

Please sign in to comment.