* Return the status register value.
* Returns negative if error occurred.
*/
-static int read_sr(struct spi_nor *nor)
+static int spi_nor_read_sr(struct spi_nor *nor)
{
int ret;
* Return the status register value.
* Returns negative if error occurred.
*/
-static int read_fsr(struct spi_nor *nor)
+static int spi_nor_read_fsr(struct spi_nor *nor)
{
int ret;
* location. Return the configuration register value.
* Returns negative if error occurred.
*/
-static int read_cr(struct spi_nor *nor)
+static int spi_nor_read_cr(struct spi_nor *nor)
{
int ret;
* Write status register 1 byte
* Returns negative if error occurred.
*/
-static int write_sr(struct spi_nor *nor, u8 val)
+static int spi_nor_write_sr(struct spi_nor *nor, u8 val)
{
nor->bouncebuf[0] = val;
if (nor->spimem) {
* Set write enable latch with Write Enable command.
* Returns negative if error occurred.
*/
-static int write_enable(struct spi_nor *nor)
+static int spi_nor_write_enable(struct spi_nor *nor)
{
if (nor->spimem) {
struct spi_mem_op op =
/*
* Send write disable instruction to the chip.
*/
-static int write_disable(struct spi_nor *nor)
+static int spi_nor_write_disable(struct spi_nor *nor)
{
if (nor->spimem) {
struct spi_mem_op op =
{
int ret;
- write_enable(nor);
+ spi_nor_write_enable(nor);
ret = macronix_set_4byte(nor, enable);
- write_disable(nor);
+ spi_nor_write_disable(nor);
return ret;
}
* Register to be set to 1, so all 3-byte-address reads come from the
* second 16M. We must clear the register to enable normal behavior.
*/
- write_enable(nor);
+ spi_nor_write_enable(nor);
ret = spi_nor_write_ear(nor, 0);
- write_disable(nor);
+ spi_nor_write_disable(nor);
return ret;
}
static int spi_nor_sr_ready(struct spi_nor *nor)
{
- int sr = read_sr(nor);
+ int sr = spi_nor_read_sr(nor);
if (sr < 0)
return sr;
static int spi_nor_fsr_ready(struct spi_nor *nor)
{
- int fsr = read_fsr(nor);
+ int fsr = spi_nor_read_fsr(nor);
if (fsr < 0)
return fsr;
*
* Returns 0 if successful, non-zero otherwise.
*/
-static int erase_chip(struct spi_nor *nor)
+static int spi_nor_erase_chip(struct spi_nor *nor)
{
dev_dbg(nor->dev, " %lldKiB\n", (long long)(nor->mtd.size >> 10));
list_for_each_entry_safe(cmd, next, &erase_list, list) {
nor->erase_opcode = cmd->opcode;
while (cmd->count) {
- write_enable(nor);
+ spi_nor_write_enable(nor);
ret = spi_nor_erase_sector(nor, addr);
if (ret)
if (len == mtd->size && !(nor->flags & SNOR_F_NO_OP_CHIP_ERASE)) {
unsigned long timeout;
- write_enable(nor);
+ spi_nor_write_enable(nor);
- if (erase_chip(nor)) {
+ if (spi_nor_erase_chip(nor)) {
ret = -EIO;
goto erase_err;
}
/* "sector"-at-a-time erase */
} else if (spi_nor_has_uniform_erase(nor)) {
while (len) {
- write_enable(nor);
+ spi_nor_write_enable(nor);
ret = spi_nor_erase_sector(nor, addr);
if (ret)
goto erase_err;
}
- write_disable(nor);
+ spi_nor_write_disable(nor);
erase_err:
spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_ERASE);
}
/* 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)
+static int spi_nor_write_sr_and_check(struct spi_nor *nor, u8 status_new,
+ u8 mask)
{
int ret;
- write_enable(nor);
- ret = write_sr(nor, status_new);
+ spi_nor_write_enable(nor);
+ ret = spi_nor_write_sr(nor, status_new);
if (ret)
return ret;
if (ret)
return ret;
- ret = read_sr(nor);
+ ret = spi_nor_read_sr(nor);
if (ret < 0)
return ret;
bool can_be_top = true, can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB;
bool use_top;
- status_old = read_sr(nor);
+ status_old = spi_nor_read_sr(nor);
if (status_old < 0)
return status_old;
if ((status_new & mask) < (status_old & mask))
return -EINVAL;
- return write_sr_and_check(nor, status_new, mask);
+ return spi_nor_write_sr_and_check(nor, status_new, mask);
}
/*
bool can_be_top = true, can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB;
bool use_top;
- status_old = read_sr(nor);
+ status_old = spi_nor_read_sr(nor);
if (status_old < 0)
return status_old;
if ((status_new & mask) > (status_old & mask))
return -EINVAL;
- return write_sr_and_check(nor, status_new, mask);
+ return spi_nor_write_sr_and_check(nor, status_new, mask);
}
/*
{
int status;
- status = read_sr(nor);
+ status = spi_nor_read_sr(nor);
if (status < 0)
return status;
* second byte will be written to the configuration register.
* Return negative if error occurred.
*/
-static int write_sr_cr(struct spi_nor *nor, u8 *sr_cr)
+static int spi_nor_write_sr_cr(struct spi_nor *nor, u8 *sr_cr)
{
int ret;
- write_enable(nor);
+ spi_nor_write_enable(nor);
if (nor->spimem) {
struct spi_mem_op op =
{
int ret, val;
- val = read_sr(nor);
+ val = spi_nor_read_sr(nor);
if (val < 0)
return val;
if (val & SR_QUAD_EN_MX)
return 0;
- write_enable(nor);
+ spi_nor_write_enable(nor);
- write_sr(nor, val | SR_QUAD_EN_MX);
+ spi_nor_write_sr(nor, val | SR_QUAD_EN_MX);
ret = spi_nor_wait_till_ready(nor);
if (ret)
return ret;
- ret = read_sr(nor);
+ ret = spi_nor_read_sr(nor);
if (!(ret > 0 && (ret & SR_QUAD_EN_MX))) {
dev_err(nor->dev, "Macronix Quad bit not set\n");
return -EINVAL;
* some very old and few memories don't support this instruction. If a pull-up
* resistor is present on the MISO/IO1 line, we might still be able to pass the
* "read back" test because the QSPI memory doesn't recognize the command,
- * so leaves the MISO/IO1 line state unchanged, hence read_cr() returns 0xFF.
+ * so leaves the MISO/IO1 line state unchanged, hence spi_nor_read_cr() returns
+ * 0xFF.
*
* bit 1 of the Configuration Register is the QE bit for Spansion like QSPI
* memories.
sr_cr[0] = 0;
sr_cr[1] = CR_QUAD_EN_SPAN;
- ret = write_sr_cr(nor, sr_cr);
+ ret = spi_nor_write_sr_cr(nor, sr_cr);
if (ret)
return ret;
/* read back and check it */
- ret = read_cr(nor);
+ ret = spi_nor_read_cr(nor);
if (!(ret > 0 && (ret & CR_QUAD_EN_SPAN))) {
dev_err(nor->dev, "Spansion Quad bit not set\n");
return -EINVAL;
int ret;
/* Keep the current value of the Status Register. */
- ret = read_sr(nor);
+ ret = spi_nor_read_sr(nor);
if (ret < 0) {
dev_err(nor->dev, "error while reading status register\n");
return -EINVAL;
sr_cr[0] = ret;
sr_cr[1] = CR_QUAD_EN_SPAN;
- return write_sr_cr(nor, sr_cr);
+ return spi_nor_write_sr_cr(nor, sr_cr);
}
/**
int ret;
/* Check current Quad Enable bit value. */
- ret = read_cr(nor);
+ ret = spi_nor_read_cr(nor);
if (ret < 0) {
dev_err(dev, "error while reading configuration register\n");
return -EINVAL;
sr_cr[1] = ret | CR_QUAD_EN_SPAN;
/* Keep the current value of the Status Register. */
- ret = read_sr(nor);
+ ret = spi_nor_read_sr(nor);
if (ret < 0) {
dev_err(dev, "error while reading status register\n");
return -EINVAL;
}
sr_cr[0] = ret;
- ret = write_sr_cr(nor, sr_cr);
+ ret = spi_nor_write_sr_cr(nor, sr_cr);
if (ret)
return ret;
/* Read back and check it. */
- ret = read_cr(nor);
+ ret = spi_nor_read_cr(nor);
if (!(ret > 0 && (ret & CR_QUAD_EN_SPAN))) {
dev_err(nor->dev, "Spansion Quad bit not set\n");
return -EINVAL;
/* Update the Quad Enable bit. */
*sr2 |= SR2_QUAD_EN_BIT7;
- write_enable(nor);
+ spi_nor_write_enable(nor);
ret = spi_nor_write_sr2(nor, sr2);
if (ret < 0) {
int ret;
u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
- ret = read_sr(nor);
+ ret = spi_nor_read_sr(nor);
if (ret < 0) {
dev_err(nor->dev, "error while reading status register\n");
return ret;
}
- write_enable(nor);
+ spi_nor_write_enable(nor);
- ret = write_sr(nor, ret & ~mask);
+ ret = spi_nor_write_sr(nor, ret & ~mask);
if (ret) {
dev_err(nor->dev, "write to status register failed\n");
return ret;
u8 *sr_cr = nor->bouncebuf;
/* Check current Quad Enable bit value. */
- ret = read_cr(nor);
+ ret = spi_nor_read_cr(nor);
if (ret < 0) {
dev_err(nor->dev,
"error while reading configuration register\n");
if (ret & CR_QUAD_EN_SPAN) {
sr_cr[1] = ret;
- ret = read_sr(nor);
+ ret = spi_nor_read_sr(nor);
if (ret < 0) {
dev_err(nor->dev,
"error while reading status register\n");
}
sr_cr[0] = ret & ~mask;
- ret = write_sr_cr(nor, sr_cr);
+ ret = spi_nor_write_sr_cr(nor, sr_cr);
if (ret)
dev_err(nor->dev, "16-bit write register failed\n");
return ret;
if (ret)
return ret;
- write_enable(nor);
+ spi_nor_write_enable(nor);
nor->sst_write_second = false;
}
nor->sst_write_second = false;
- write_disable(nor);
+ spi_nor_write_disable(nor);
ret = spi_nor_wait_till_ready(nor);
if (ret)
goto sst_write_err;
/* Write out trailing byte if it exists. */
if (actual != len) {
- write_enable(nor);
+ spi_nor_write_enable(nor);
nor->program_opcode = SPINOR_OP_BP;
ret = spi_nor_write_data(nor, to, 1, buf + actual);
ret = spi_nor_wait_till_ready(nor);
if (ret)
goto sst_write_err;
- write_disable(nor);
+ spi_nor_write_disable(nor);
actual += 1;
}
sst_write_err:
addr = spi_nor_convert_addr(nor, addr);
- write_enable(nor);
+ spi_nor_write_enable(nor);
ret = spi_nor_write_data(nor, addr, page_remain, buf + i);
if (ret < 0)
goto write_err;