Commit c8f22b02 authored by Boris Brezillon's avatar Boris Brezillon

Merge tag 'spi-nor/for-4.16' of git://git.infradead.org/linux-mtd into mtd/next

Pull spi-nor changes from Cyrille Pitchen:

"
  This pull-request contains the following notable changes:

  Core changes:
  * Add support to new ISSI and Cypress/Spansion memory parts.
  * Fix support of Micron memories by checking error bits in the FSR.
  * Fix update of block-protection bits by reading back the SR.
  * Restore the internal state of the SPI flash memory when removing the
    device.

  Driver changes:
  * Maintenance for Freescale, Intel and Metiatek drivers.
  * Add support of the direct access mode for the Cadence QSPI controller.
"
parents 0aede42e 23bae78e
...@@ -12,7 +12,7 @@ Required properties: ...@@ -12,7 +12,7 @@ Required properties:
- reg-names: Should contain the reg names "QuadSPI" and "QuadSPI-memory" - reg-names: Should contain the reg names "QuadSPI" and "QuadSPI-memory"
- interrupts : Should contain the interrupt for the device - interrupts : Should contain the interrupt for the device
- clocks : The clocks needed by the QuadSPI controller - clocks : The clocks needed by the QuadSPI controller
- clock-names : the name of the clocks - clock-names : Should contain the name of the clocks: "qspi_en" and "qspi".
Optional properties: Optional properties:
- fsl,qspi-has-second-chip: The controller has two buses, bus A and bus B. - fsl,qspi-has-second-chip: The controller has two buses, bus A and bus B.
......
...@@ -60,3 +60,6 @@ The main API is spi_nor_scan(). Before you call the hook, a driver should ...@@ -60,3 +60,6 @@ The main API is spi_nor_scan(). Before you call the hook, a driver should
initialize the necessary fields for spi_nor{}. Please see initialize the necessary fields for spi_nor{}. Please see
drivers/mtd/spi-nor/spi-nor.c for detail. Please also refer to fsl-quadspi.c drivers/mtd/spi-nor/spi-nor.c for detail. Please also refer to fsl-quadspi.c
when you want to write a new driver for a SPI NOR controller. when you want to write a new driver for a SPI NOR controller.
Another API is spi_nor_restore(), this is used to restore the status of SPI
flash chip such as addressing mode. Call it whenever detach the driver from
device or reboot the system.
...@@ -307,10 +307,18 @@ static int m25p_remove(struct spi_device *spi) ...@@ -307,10 +307,18 @@ static int m25p_remove(struct spi_device *spi)
{ {
struct m25p *flash = spi_get_drvdata(spi); struct m25p *flash = spi_get_drvdata(spi);
spi_nor_restore(&flash->spi_nor);
/* Clean up MTD stuff. */ /* Clean up MTD stuff. */
return mtd_device_unregister(&flash->spi_nor.mtd); return mtd_device_unregister(&flash->spi_nor.mtd);
} }
static void m25p_shutdown(struct spi_device *spi)
{
struct m25p *flash = spi_get_drvdata(spi);
spi_nor_restore(&flash->spi_nor);
}
/* /*
* Do NOT add to this array without reading the following: * Do NOT add to this array without reading the following:
* *
...@@ -386,6 +394,7 @@ static struct spi_driver m25p80_driver = { ...@@ -386,6 +394,7 @@ static struct spi_driver m25p80_driver = {
.id_table = m25p_ids, .id_table = m25p_ids,
.probe = m25p_probe, .probe = m25p_probe,
.remove = m25p_remove, .remove = m25p_remove,
.shutdown = m25p_shutdown,
/* REVISIT: many of these chips have deep power-down modes, which /* REVISIT: many of these chips have deep power-down modes, which
* should clearly be entered on suspend() to minimize power use. * should clearly be entered on suspend() to minimize power use.
......
...@@ -58,6 +58,7 @@ struct cqspi_flash_pdata { ...@@ -58,6 +58,7 @@ struct cqspi_flash_pdata {
u8 data_width; u8 data_width;
u8 cs; u8 cs;
bool registered; bool registered;
bool use_direct_mode;
}; };
struct cqspi_st { struct cqspi_st {
...@@ -68,6 +69,7 @@ struct cqspi_st { ...@@ -68,6 +69,7 @@ struct cqspi_st {
void __iomem *iobase; void __iomem *iobase;
void __iomem *ahb_base; void __iomem *ahb_base;
resource_size_t ahb_size;
struct completion transfer_complete; struct completion transfer_complete;
struct mutex bus_mutex; struct mutex bus_mutex;
...@@ -103,6 +105,7 @@ struct cqspi_st { ...@@ -103,6 +105,7 @@ struct cqspi_st {
/* Register map */ /* Register map */
#define CQSPI_REG_CONFIG 0x00 #define CQSPI_REG_CONFIG 0x00
#define CQSPI_REG_CONFIG_ENABLE_MASK BIT(0) #define CQSPI_REG_CONFIG_ENABLE_MASK BIT(0)
#define CQSPI_REG_CONFIG_ENB_DIR_ACC_CTRL BIT(7)
#define CQSPI_REG_CONFIG_DECODE_MASK BIT(9) #define CQSPI_REG_CONFIG_DECODE_MASK BIT(9)
#define CQSPI_REG_CONFIG_CHIPSELECT_LSB 10 #define CQSPI_REG_CONFIG_CHIPSELECT_LSB 10
#define CQSPI_REG_CONFIG_DMA_MASK BIT(15) #define CQSPI_REG_CONFIG_DMA_MASK BIT(15)
...@@ -450,8 +453,7 @@ static int cqspi_command_write_addr(struct spi_nor *nor, ...@@ -450,8 +453,7 @@ static int cqspi_command_write_addr(struct spi_nor *nor,
return cqspi_exec_flash_cmd(cqspi, reg); return cqspi_exec_flash_cmd(cqspi, reg);
} }
static int cqspi_indirect_read_setup(struct spi_nor *nor, static int cqspi_read_setup(struct spi_nor *nor)
const unsigned int from_addr)
{ {
struct cqspi_flash_pdata *f_pdata = nor->priv; struct cqspi_flash_pdata *f_pdata = nor->priv;
struct cqspi_st *cqspi = f_pdata->cqspi; struct cqspi_st *cqspi = f_pdata->cqspi;
...@@ -459,8 +461,6 @@ static int cqspi_indirect_read_setup(struct spi_nor *nor, ...@@ -459,8 +461,6 @@ static int cqspi_indirect_read_setup(struct spi_nor *nor,
unsigned int dummy_clk = 0; unsigned int dummy_clk = 0;
unsigned int reg; unsigned int reg;
writel(from_addr, reg_base + CQSPI_REG_INDIRECTRDSTARTADDR);
reg = nor->read_opcode << CQSPI_REG_RD_INSTR_OPCODE_LSB; reg = nor->read_opcode << CQSPI_REG_RD_INSTR_OPCODE_LSB;
reg |= cqspi_calc_rdreg(nor, nor->read_opcode); reg |= cqspi_calc_rdreg(nor, nor->read_opcode);
...@@ -493,8 +493,8 @@ static int cqspi_indirect_read_setup(struct spi_nor *nor, ...@@ -493,8 +493,8 @@ static int cqspi_indirect_read_setup(struct spi_nor *nor,
return 0; return 0;
} }
static int cqspi_indirect_read_execute(struct spi_nor *nor, static int cqspi_indirect_read_execute(struct spi_nor *nor, u8 *rxbuf,
u8 *rxbuf, const unsigned n_rx) loff_t from_addr, const size_t n_rx)
{ {
struct cqspi_flash_pdata *f_pdata = nor->priv; struct cqspi_flash_pdata *f_pdata = nor->priv;
struct cqspi_st *cqspi = f_pdata->cqspi; struct cqspi_st *cqspi = f_pdata->cqspi;
...@@ -504,6 +504,7 @@ static int cqspi_indirect_read_execute(struct spi_nor *nor, ...@@ -504,6 +504,7 @@ static int cqspi_indirect_read_execute(struct spi_nor *nor,
unsigned int bytes_to_read = 0; unsigned int bytes_to_read = 0;
int ret = 0; int ret = 0;
writel(from_addr, reg_base + CQSPI_REG_INDIRECTRDSTARTADDR);
writel(remaining, reg_base + CQSPI_REG_INDIRECTRDBYTES); writel(remaining, reg_base + CQSPI_REG_INDIRECTRDBYTES);
/* Clear all interrupts. */ /* Clear all interrupts. */
...@@ -570,8 +571,7 @@ static int cqspi_indirect_read_execute(struct spi_nor *nor, ...@@ -570,8 +571,7 @@ static int cqspi_indirect_read_execute(struct spi_nor *nor,
return ret; return ret;
} }
static int cqspi_indirect_write_setup(struct spi_nor *nor, static int cqspi_write_setup(struct spi_nor *nor)
const unsigned int to_addr)
{ {
unsigned int reg; unsigned int reg;
struct cqspi_flash_pdata *f_pdata = nor->priv; struct cqspi_flash_pdata *f_pdata = nor->priv;
...@@ -584,8 +584,6 @@ static int cqspi_indirect_write_setup(struct spi_nor *nor, ...@@ -584,8 +584,6 @@ static int cqspi_indirect_write_setup(struct spi_nor *nor,
reg = cqspi_calc_rdreg(nor, nor->program_opcode); reg = cqspi_calc_rdreg(nor, nor->program_opcode);
writel(reg, reg_base + CQSPI_REG_RD_INSTR); writel(reg, reg_base + CQSPI_REG_RD_INSTR);
writel(to_addr, reg_base + CQSPI_REG_INDIRECTWRSTARTADDR);
reg = readl(reg_base + CQSPI_REG_SIZE); reg = readl(reg_base + CQSPI_REG_SIZE);
reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK; reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK;
reg |= (nor->addr_width - 1); reg |= (nor->addr_width - 1);
...@@ -593,8 +591,8 @@ static int cqspi_indirect_write_setup(struct spi_nor *nor, ...@@ -593,8 +591,8 @@ static int cqspi_indirect_write_setup(struct spi_nor *nor,
return 0; return 0;
} }
static int cqspi_indirect_write_execute(struct spi_nor *nor, static int cqspi_indirect_write_execute(struct spi_nor *nor, loff_t to_addr,
const u8 *txbuf, const unsigned n_tx) const u8 *txbuf, const size_t n_tx)
{ {
const unsigned int page_size = nor->page_size; const unsigned int page_size = nor->page_size;
struct cqspi_flash_pdata *f_pdata = nor->priv; struct cqspi_flash_pdata *f_pdata = nor->priv;
...@@ -604,6 +602,7 @@ static int cqspi_indirect_write_execute(struct spi_nor *nor, ...@@ -604,6 +602,7 @@ static int cqspi_indirect_write_execute(struct spi_nor *nor,
unsigned int write_bytes; unsigned int write_bytes;
int ret; int ret;
writel(to_addr, reg_base + CQSPI_REG_INDIRECTWRSTARTADDR);
writel(remaining, reg_base + CQSPI_REG_INDIRECTWRBYTES); writel(remaining, reg_base + CQSPI_REG_INDIRECTWRBYTES);
/* Clear all interrupts. */ /* Clear all interrupts. */
...@@ -894,17 +893,22 @@ static int cqspi_set_protocol(struct spi_nor *nor, const int read) ...@@ -894,17 +893,22 @@ static int cqspi_set_protocol(struct spi_nor *nor, const int read)
static ssize_t cqspi_write(struct spi_nor *nor, loff_t to, static ssize_t cqspi_write(struct spi_nor *nor, loff_t to,
size_t len, const u_char *buf) size_t len, const u_char *buf)
{ {
struct cqspi_flash_pdata *f_pdata = nor->priv;
struct cqspi_st *cqspi = f_pdata->cqspi;
int ret; int ret;
ret = cqspi_set_protocol(nor, 0); ret = cqspi_set_protocol(nor, 0);
if (ret) if (ret)
return ret; return ret;
ret = cqspi_indirect_write_setup(nor, to); ret = cqspi_write_setup(nor);
if (ret) if (ret)
return ret; return ret;
ret = cqspi_indirect_write_execute(nor, buf, len); if (f_pdata->use_direct_mode)
memcpy_toio(cqspi->ahb_base + to, buf, len);
else
ret = cqspi_indirect_write_execute(nor, to, buf, len);
if (ret) if (ret)
return ret; return ret;
...@@ -914,17 +918,22 @@ static ssize_t cqspi_write(struct spi_nor *nor, loff_t to, ...@@ -914,17 +918,22 @@ static ssize_t cqspi_write(struct spi_nor *nor, loff_t to,
static ssize_t cqspi_read(struct spi_nor *nor, loff_t from, static ssize_t cqspi_read(struct spi_nor *nor, loff_t from,
size_t len, u_char *buf) size_t len, u_char *buf)
{ {
struct cqspi_flash_pdata *f_pdata = nor->priv;
struct cqspi_st *cqspi = f_pdata->cqspi;
int ret; int ret;
ret = cqspi_set_protocol(nor, 1); ret = cqspi_set_protocol(nor, 1);
if (ret) if (ret)
return ret; return ret;
ret = cqspi_indirect_read_setup(nor, from); ret = cqspi_read_setup(nor);
if (ret) if (ret)
return ret; return ret;
ret = cqspi_indirect_read_execute(nor, buf, len); if (f_pdata->use_direct_mode)
memcpy_fromio(buf, cqspi->ahb_base + from, len);
else
ret = cqspi_indirect_read_execute(nor, buf, from, len);
if (ret) if (ret)
return ret; return ret;
...@@ -1059,6 +1068,8 @@ static int cqspi_of_get_pdata(struct platform_device *pdev) ...@@ -1059,6 +1068,8 @@ static int cqspi_of_get_pdata(struct platform_device *pdev)
static void cqspi_controller_init(struct cqspi_st *cqspi) static void cqspi_controller_init(struct cqspi_st *cqspi)
{ {
u32 reg;
cqspi_controller_enable(cqspi, 0); cqspi_controller_enable(cqspi, 0);
/* Configure the remap address register, no remap */ /* Configure the remap address register, no remap */
...@@ -1081,6 +1092,11 @@ static void cqspi_controller_init(struct cqspi_st *cqspi) ...@@ -1081,6 +1092,11 @@ static void cqspi_controller_init(struct cqspi_st *cqspi)
writel(cqspi->fifo_depth * cqspi->fifo_width / 8, writel(cqspi->fifo_depth * cqspi->fifo_width / 8,
cqspi->iobase + CQSPI_REG_INDIRECTWRWATERMARK); cqspi->iobase + CQSPI_REG_INDIRECTWRWATERMARK);
/* Enable Direct Access Controller */
reg = readl(cqspi->iobase + CQSPI_REG_CONFIG);
reg |= CQSPI_REG_CONFIG_ENB_DIR_ACC_CTRL;
writel(reg, cqspi->iobase + CQSPI_REG_CONFIG);
cqspi_controller_enable(cqspi, 1); cqspi_controller_enable(cqspi, 1);
} }
...@@ -1156,6 +1172,12 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi, struct device_node *np) ...@@ -1156,6 +1172,12 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi, struct device_node *np)
goto err; goto err;
f_pdata->registered = true; f_pdata->registered = true;
if (mtd->size <= cqspi->ahb_size) {
f_pdata->use_direct_mode = true;
dev_dbg(nor->dev, "using direct mode for %s\n",
mtd->name);
}
} }
return 0; return 0;
...@@ -1215,6 +1237,7 @@ static int cqspi_probe(struct platform_device *pdev) ...@@ -1215,6 +1237,7 @@ static int cqspi_probe(struct platform_device *pdev)
dev_err(dev, "Cannot remap AHB address.\n"); dev_err(dev, "Cannot remap AHB address.\n");
return PTR_ERR(cqspi->ahb_base); return PTR_ERR(cqspi->ahb_base);
} }
cqspi->ahb_size = resource_size(res_ahb);
init_completion(&cqspi->transfer_complete); init_completion(&cqspi->transfer_complete);
......
...@@ -801,10 +801,10 @@ static int fsl_qspi_nor_setup_last(struct fsl_qspi *q) ...@@ -801,10 +801,10 @@ static int fsl_qspi_nor_setup_last(struct fsl_qspi *q)
} }
static const struct of_device_id fsl_qspi_dt_ids[] = { static const struct of_device_id fsl_qspi_dt_ids[] = {
{ .compatible = "fsl,vf610-qspi", .data = (void *)&vybrid_data, }, { .compatible = "fsl,vf610-qspi", .data = &vybrid_data, },
{ .compatible = "fsl,imx6sx-qspi", .data = (void *)&imx6sx_data, }, { .compatible = "fsl,imx6sx-qspi", .data = &imx6sx_data, },
{ .compatible = "fsl,imx7d-qspi", .data = (void *)&imx7d_data, }, { .compatible = "fsl,imx7d-qspi", .data = &imx7d_data, },
{ .compatible = "fsl,imx6ul-qspi", .data = (void *)&imx6ul_data, }, { .compatible = "fsl,imx6ul-qspi", .data = &imx6ul_data, },
{ .compatible = "fsl,ls1021a-qspi", .data = (void *)&ls1021a_data, }, { .compatible = "fsl,ls1021a-qspi", .data = (void *)&ls1021a_data, },
{ /* sentinel */ } { /* sentinel */ }
}; };
......
...@@ -138,7 +138,6 @@ ...@@ -138,7 +138,6 @@
* @erase_64k: 64k erase supported * @erase_64k: 64k erase supported
* @opcodes: Opcodes which are supported. This are programmed by BIOS * @opcodes: Opcodes which are supported. This are programmed by BIOS
* before it locks down the controller. * before it locks down the controller.
* @preopcodes: Preopcodes which are supported.
*/ */
struct intel_spi { struct intel_spi {
struct device *dev; struct device *dev;
...@@ -155,7 +154,6 @@ struct intel_spi { ...@@ -155,7 +154,6 @@ struct intel_spi {
bool swseq_erase; bool swseq_erase;
bool erase_64k; bool erase_64k;
u8 opcodes[8]; u8 opcodes[8];
u8 preopcodes[2];
}; };
static bool writeable; static bool writeable;
...@@ -400,10 +398,6 @@ static int intel_spi_init(struct intel_spi *ispi) ...@@ -400,10 +398,6 @@ static int intel_spi_init(struct intel_spi *ispi)
ispi->opcodes[i] = opmenu0 >> i * 8; ispi->opcodes[i] = opmenu0 >> i * 8;
ispi->opcodes[i + 4] = opmenu1 >> i * 8; ispi->opcodes[i + 4] = opmenu1 >> i * 8;
} }
val = readl(ispi->sregs + PREOP_OPTYPE);
ispi->preopcodes[0] = val;
ispi->preopcodes[1] = val >> 8;
} }
} }
......
This diff is collapsed.
...@@ -330,8 +330,22 @@ static inline int spi_nor_fsr_ready(struct spi_nor *nor) ...@@ -330,8 +330,22 @@ static inline int spi_nor_fsr_ready(struct spi_nor *nor)
int fsr = read_fsr(nor); int fsr = read_fsr(nor);
if (fsr < 0) if (fsr < 0)
return fsr; return fsr;
else
return fsr & FSR_READY; if (fsr & (FSR_E_ERR | FSR_P_ERR)) {
if (fsr & FSR_E_ERR)
dev_err(nor->dev, "Erase operation failed.\n");
else
dev_err(nor->dev, "Program operation failed.\n");
if (fsr & FSR_PT_ERR)
dev_err(nor->dev,
"Attempted to modify a protected sector.\n");
nor->write_reg(nor, SPINOR_OP_CLFSR, NULL, 0);
return -EIO;
}
return fsr & FSR_READY;
} }
static int spi_nor_ready(struct spi_nor *nor) static int spi_nor_ready(struct spi_nor *nor)
...@@ -552,6 +566,27 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) ...@@ -552,6 +566,27 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
return ret; return ret;
} }
/* Write status register and ensure bits in mask match written values */
static int write_sr_and_check(struct spi_nor *nor, u8 status_new, u8 mask)
{
int ret;
write_enable(nor);
ret = write_sr(nor, status_new);
if (ret)
return ret;
ret = spi_nor_wait_till_ready(nor);
if (ret)
return ret;
ret = read_sr(nor);
if (ret < 0)
return ret;
return ((ret & mask) != (status_new & mask)) ? -EIO : 0;
}
static void stm_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs, static void stm_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs,
uint64_t *len) uint64_t *len)
{ {
...@@ -650,7 +685,6 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) ...@@ -650,7 +685,6 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
loff_t lock_len; loff_t lock_len;
bool can_be_top = true, can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB; bool can_be_top = true, can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB;
bool use_top; bool use_top;
int ret;
status_old = read_sr(nor); status_old = read_sr(nor);
if (status_old < 0) if (status_old < 0)
...@@ -714,11 +748,7 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) ...@@ -714,11 +748,7 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
if ((status_new & mask) < (status_old & mask)) if ((status_new & mask) < (status_old & mask))
return -EINVAL; return -EINVAL;
write_enable(nor); return write_sr_and_check(nor, status_new, mask);
ret = write_sr(nor, status_new);
if (ret)
return ret;
return spi_nor_wait_till_ready(nor);
} }
/* /*
...@@ -735,7 +765,6 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) ...@@ -735,7 +765,6 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)
loff_t lock_len; loff_t lock_len;
bool can_be_top = true, can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB; bool can_be_top = true, can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB;
bool use_top; bool use_top;
int ret;
status_old = read_sr(nor); status_old = read_sr(nor);
if (status_old < 0) if (status_old < 0)
...@@ -802,11 +831,7 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) ...@@ -802,11 +831,7 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)
if ((status_new & mask) > (status_old & mask)) if ((status_new & mask) > (status_old & mask))
return -EINVAL; return -EINVAL;
write_enable(nor); return write_sr_and_check(nor, status_new, mask);
ret = write_sr(nor, status_new);
if (ret)
return ret;
return spi_nor_wait_till_ready(nor);
} }
/* /*
...@@ -1020,7 +1045,13 @@ static const struct flash_info spi_nor_ids[] = { ...@@ -1020,7 +1045,13 @@ static const struct flash_info spi_nor_ids[] = {
{ "640s33b", INFO(0x898913, 0, 64 * 1024, 128, 0) }, { "640s33b", INFO(0x898913, 0, 64 * 1024, 128, 0) },
/* ISSI */ /* ISSI */
{ "is25cd512", INFO(0x7f9d20, 0, 32 * 1024, 2, SECT_4K) }, { "is25cd512", INFO(0x7f9d20, 0, 32 * 1024, 2, SECT_4K) },
{ "is25lq040b", INFO(0x9d4013, 0, 64 * 1024, 8,
SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
{ "is25lp080d", INFO(0x9d6014, 0, 64 * 1024, 16,
SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
{ "is25lp128", INFO(0x9d6018, 0, 64 * 1024, 256,
SECT_4K | SPI_NOR_DUAL_READ) },
/* Macronix */ /* Macronix */
{ "mx25l512e", INFO(0xc22010, 0, 64 * 1024, 1, SECT_4K) }, { "mx25l512e", INFO(0xc22010, 0, 64 * 1024, 1, SECT_4K) },
...@@ -1065,7 +1096,7 @@ static const struct flash_info spi_nor_ids[] = { ...@@ -1065,7 +1096,7 @@ static const struct flash_info spi_nor_ids[] = {
{ "pm25lv010", INFO(0, 0, 32 * 1024, 4, SECT_4K_PMC) }, { "pm25lv010", INFO(0, 0, 32 * 1024, 4, SECT_4K_PMC) },
{ "pm25lq032", INFO(0x7f9d46, 0, 64 * 1024, 64, SECT_4K) }, { "pm25lq032", INFO(0x7f9d46, 0, 64 * 1024, 64, SECT_4K) },
/* Spansion -- single (large) sector size only, at least /* Spansion/Cypress -- single (large) sector size only, at least
* for the chips listed here (without boot sectors). * for the chips listed here (without boot sectors).
*/ */
{ "s25sl032p", INFO(0x010215, 0x4d00, 64 * 1024, 64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "s25sl032p", INFO(0x010215, 0x4d00, 64 * 1024, 64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
...@@ -1094,6 +1125,8 @@ static const struct flash_info spi_nor_ids[] = { ...@@ -1094,6 +1125,8 @@ static const struct flash_info spi_nor_ids[] = {
{ "s25fl204k", INFO(0x014013, 0, 64 * 1024, 8, SECT_4K | SPI_NOR_DUAL_READ) }, { "s25fl204k", INFO(0x014013, 0, 64 * 1024, 8, SECT_4K | SPI_NOR_DUAL_READ) },
{ "s25fl208k", INFO(0x014014, 0, 64 * 1024, 16, SECT_4K | SPI_NOR_DUAL_READ) }, { "s25fl208k", INFO(0x014014, 0, 64 * 1024, 16, SECT_4K | SPI_NOR_DUAL_READ) },
{ "s25fl064l", INFO(0x016017, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, { "s25fl064l", INFO(0x016017, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
{ "s25fl128l", INFO(0x016018, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
{ "s25fl256l", INFO(0x016019, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
/* SST -- large erase sizes are "overlays", "sectors" are 4K */ /* SST -- large erase sizes are "overlays", "sectors" are 4K */
{ "sst25vf040b", INFO(0xbf258d, 0, 64 * 1024, 8, SECT_4K | SST_WRITE) }, { "sst25vf040b", INFO(0xbf258d, 0, 64 * 1024, 8, SECT_4K | SST_WRITE) },
...@@ -2713,6 +2746,16 @@ static void spi_nor_resume(struct mtd_info *mtd) ...@@ -2713,6 +2746,16 @@ static void spi_nor_resume(struct mtd_info *mtd)
dev_err(dev, "resume() failed\n"); dev_err(dev, "resume() failed\n");
} }
void spi_nor_restore(struct spi_nor *nor)
{
/* restore the addressing mode */
if ((nor->addr_width == 4) &&
(JEDEC_MFR(nor->info) != SNOR_MFR_SPANSION) &&
!(nor->info->flags & SPI_NOR_4B_OPCODES))
set_4byte(nor, nor->info, 0);
}
EXPORT_SYMBOL_GPL(spi_nor_restore);
int spi_nor_scan(struct spi_nor *nor, const char *name, int spi_nor_scan(struct spi_nor *nor, const char *name,
const struct spi_nor_hwcaps *hwcaps) const struct spi_nor_hwcaps *hwcaps)
{ {
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#define SPINOR_OP_RDSFDP 0x5a /* Read SFDP */ #define SPINOR_OP_RDSFDP 0x5a /* Read SFDP */
#define SPINOR_OP_RDCR 0x35 /* Read configuration register */ #define SPINOR_OP_RDCR 0x35 /* Read configuration register */
#define SPINOR_OP_RDFSR 0x70 /* Read flag status register */ #define SPINOR_OP_RDFSR 0x70 /* Read flag status register */
#define SPINOR_OP_CLFSR 0x50 /* Clear flag status register */
/* 4-byte address opcodes - used on Spansion and some Macronix flashes. */ /* 4-byte address opcodes - used on Spansion and some Macronix flashes. */
#define SPINOR_OP_READ_4B 0x13 /* Read data bytes (low frequency) */ #define SPINOR_OP_READ_4B 0x13 /* Read data bytes (low frequency) */
...@@ -130,7 +131,10 @@ ...@@ -130,7 +131,10 @@
#define EVCR_QUAD_EN_MICRON BIT(7) /* Micron Quad I/O */ #define EVCR_QUAD_EN_MICRON BIT(7) /* Micron Quad I/O */
/* Flag Status Register bits */ /* Flag Status Register bits */
#define FSR_READY BIT(7) #define FSR_READY BIT(7) /* Device status, 0 = Busy, 1 = Ready */
#define FSR_E_ERR BIT(5) /* Erase operation status */
#define FSR_P_ERR BIT(4) /* Program operation status */
#define FSR_PT_ERR BIT(1) /* Protection error bit */
/* Configuration Register bits. */ /* Configuration Register bits. */
#define CR_QUAD_EN_SPAN BIT(1) /* Spansion Quad I/O */ #define CR_QUAD_EN_SPAN BIT(1) /* Spansion Quad I/O */
...@@ -399,4 +403,10 @@ struct spi_nor_hwcaps { ...@@ -399,4 +403,10 @@ struct spi_nor_hwcaps {
int spi_nor_scan(struct spi_nor *nor, const char *name, int spi_nor_scan(struct spi_nor *nor, const char *name,
const struct spi_nor_hwcaps *hwcaps); const struct spi_nor_hwcaps *hwcaps);
/**
* spi_nor_restore_addr_mode() - restore the status of SPI NOR
* @nor: the spi_nor structure
*/
void spi_nor_restore(struct spi_nor *nor);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment