mtd: spi-nor: add non-uniform sector erase support for s28hs512t
Currently only uniform sector mode erase is supported for s28hs512t and thus non-volatile configuration register(CFR3N) is being modified on each probe to set the flash in uniform sector mode, this is not recommended and is fixed upstream. This commit adds the changes on top of the backported upstream changes to support non-uniform sector erase for s28hs512t to enable non-uniform sector erase depending on the value of configuration register bit CFR3V[3]. Signed-off-by: Vaishnav Achath <vaishnav.a@ti.com>
This commit is contained in:
parent
2da672ad1f
commit
23a01345d9
|
|
@ -3081,6 +3081,13 @@ static int spi_nor_cypress_octal_dtr_enable(struct spi_nor *nor)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int s28hs512t_erase_non_uniform(struct spi_nor *nor, loff_t addr)
|
||||||
|
{
|
||||||
|
/* Factory default configuration: 32 x 4 KiB sectors at bottom. */
|
||||||
|
return spansion_erase_non_uniform(nor, addr, SPINOR_OP_S28_SE_4K,
|
||||||
|
0, SZ_128K);
|
||||||
|
}
|
||||||
|
|
||||||
static int s28hs512t_setup(struct spi_nor *nor, const struct flash_info *info,
|
static int s28hs512t_setup(struct spi_nor *nor, const struct flash_info *info,
|
||||||
const struct spi_nor_flash_parameter *params)
|
const struct spi_nor_flash_parameter *params)
|
||||||
{
|
{
|
||||||
|
|
@ -3094,9 +3101,8 @@ static int s28hs512t_setup(struct spi_nor *nor, const struct flash_info *info,
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Cypress flash also supports hybrid sector sizes. Make sure
|
* Check CFR3V to check if non-uniform sector mode is selected. If it
|
||||||
* uniform sector mode is selected. This is done by setting the bit
|
* is, set the erase hook to the non-uniform erase procedure.
|
||||||
* CFR3N[3].
|
|
||||||
*/
|
*/
|
||||||
op = (struct spi_mem_op)
|
op = (struct spi_mem_op)
|
||||||
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RD_ANY_REG, 1),
|
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RD_ANY_REG, 1),
|
||||||
|
|
@ -3108,27 +3114,8 @@ static int s28hs512t_setup(struct spi_nor *nor, const struct flash_info *info,
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = write_enable(nor);
|
if (!(buf & SPINOR_REG_CYPRESS_CFR3N_UNISECT))
|
||||||
if (ret)
|
nor->erase = s28hs512t_erase_non_uniform;
|
||||||
return ret;
|
|
||||||
|
|
||||||
/* Set the uniform sector mode bit. */
|
|
||||||
buf |= SPINOR_REG_CYPRESS_CFR3N_UNISECT;
|
|
||||||
op = (struct spi_mem_op)
|
|
||||||
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WR_ANY_REG, 1),
|
|
||||||
SPI_MEM_OP_ADDR(addr_width,
|
|
||||||
SPINOR_REG_CYPRESS_CFR3N, 1),
|
|
||||||
SPI_MEM_OP_NO_DUMMY,
|
|
||||||
SPI_MEM_OP_DATA_OUT(1, &buf, 1));
|
|
||||||
ret = spi_mem_exec_op(nor->spi, &op);
|
|
||||||
if (ret) {
|
|
||||||
dev_err(nor->dev, "Failed to change to uniform sector mode\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = spi_nor_wait_till_ready(nor);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return spi_nor_default_setup(nor, info, params);
|
return spi_nor_default_setup(nor, info, params);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -166,6 +166,7 @@
|
||||||
/* For Cypress flash. */
|
/* For Cypress flash. */
|
||||||
#define SPINOR_OP_RD_ANY_REG 0x65 /* Read any register */
|
#define SPINOR_OP_RD_ANY_REG 0x65 /* Read any register */
|
||||||
#define SPINOR_OP_WR_ANY_REG 0x71 /* Write any register */
|
#define SPINOR_OP_WR_ANY_REG 0x71 /* Write any register */
|
||||||
|
#define SPINOR_OP_S28_SE_4K 0x21
|
||||||
#define SPINOR_REG_CYPRESS_CFR2V 0x00800003
|
#define SPINOR_REG_CYPRESS_CFR2V 0x00800003
|
||||||
#define SPINOR_REG_CYPRESS_CFR2V_MEMLAT_11_24 0xb
|
#define SPINOR_REG_CYPRESS_CFR2V_MEMLAT_11_24 0xb
|
||||||
#define SPINOR_REG_CYPRESS_CFR3N 0x00000004
|
#define SPINOR_REG_CYPRESS_CFR3N 0x00000004
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue