mtd: spi-nor: move spi_nor_write_ear() to winbond module
The "Extended Address Register" is winbond specific. If the flash is larger than 16MiB and is used in 3 byte address mode, it is used to set the remaining address bits. Move the write_ear() function, the opcode macros and the spimem op template into the winbond module and rename them accordingly. Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Pratyush Yadav <p.yadav@ti.com> Reviewed-by: Pratyush Yadav <p.yadav@ti.com> Link: https://lore.kernel.org/r/20220429100153.2338501-1-michael@walle.cc
This commit is contained in:
Родитель
5ad784d990
Коммит
94f697c538
|
@ -570,36 +570,6 @@ static int spansion_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* spi_nor_write_ear() - Write Extended Address Register.
|
|
||||||
* @nor: pointer to 'struct spi_nor'.
|
|
||||||
* @ear: value to write to the Extended Address Register.
|
|
||||||
*
|
|
||||||
* Return: 0 on success, -errno otherwise.
|
|
||||||
*/
|
|
||||||
int spi_nor_write_ear(struct spi_nor *nor, u8 ear)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
nor->bouncebuf[0] = ear;
|
|
||||||
|
|
||||||
if (nor->spimem) {
|
|
||||||
struct spi_mem_op op = SPI_NOR_WREAR_OP(nor->bouncebuf);
|
|
||||||
|
|
||||||
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
|
|
||||||
|
|
||||||
ret = spi_mem_exec_op(nor->spimem, &op);
|
|
||||||
} else {
|
|
||||||
ret = spi_nor_controller_ops_write_reg(nor, SPINOR_OP_WREAR,
|
|
||||||
nor->bouncebuf, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
dev_dbg(nor->dev, "error %d writing EAR\n", ret);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* spi_nor_sr_ready() - Query the Status Register to see if the flash is ready
|
* spi_nor_sr_ready() - Query the Status Register to see if the flash is ready
|
||||||
* for new commands.
|
* for new commands.
|
||||||
|
|
|
@ -72,12 +72,6 @@
|
||||||
SPI_MEM_OP_NO_DUMMY, \
|
SPI_MEM_OP_NO_DUMMY, \
|
||||||
SPI_MEM_OP_DATA_OUT(1, buf, 0))
|
SPI_MEM_OP_DATA_OUT(1, buf, 0))
|
||||||
|
|
||||||
#define SPI_NOR_WREAR_OP(buf) \
|
|
||||||
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WREAR, 0), \
|
|
||||||
SPI_MEM_OP_NO_ADDR, \
|
|
||||||
SPI_MEM_OP_NO_DUMMY, \
|
|
||||||
SPI_MEM_OP_DATA_OUT(1, buf, 0))
|
|
||||||
|
|
||||||
#define SPI_NOR_GBULK_OP \
|
#define SPI_NOR_GBULK_OP \
|
||||||
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_GBULK, 0), \
|
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_GBULK, 0), \
|
||||||
SPI_MEM_OP_NO_ADDR, \
|
SPI_MEM_OP_NO_ADDR, \
|
||||||
|
@ -636,7 +630,6 @@ void spi_nor_spimem_setup_op(const struct spi_nor *nor,
|
||||||
int spi_nor_write_enable(struct spi_nor *nor);
|
int spi_nor_write_enable(struct spi_nor *nor);
|
||||||
int spi_nor_write_disable(struct spi_nor *nor);
|
int spi_nor_write_disable(struct spi_nor *nor);
|
||||||
int spi_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable);
|
int spi_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable);
|
||||||
int spi_nor_write_ear(struct spi_nor *nor, u8 ear);
|
|
||||||
int spi_nor_wait_till_ready(struct spi_nor *nor);
|
int spi_nor_wait_till_ready(struct spi_nor *nor);
|
||||||
int spi_nor_global_block_unlock(struct spi_nor *nor);
|
int spi_nor_global_block_unlock(struct spi_nor *nor);
|
||||||
int spi_nor_lock_and_prep(struct spi_nor *nor);
|
int spi_nor_lock_and_prep(struct spi_nor *nor);
|
||||||
|
|
|
@ -8,6 +8,15 @@
|
||||||
|
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
|
||||||
|
#define WINBOND_NOR_OP_RDEAR 0xc8 /* Read Extended Address Register */
|
||||||
|
#define WINBOND_NOR_OP_WREAR 0xc5 /* Write Extended Address Register */
|
||||||
|
|
||||||
|
#define WINBOND_NOR_WREAR_OP(buf) \
|
||||||
|
SPI_MEM_OP(SPI_MEM_OP_CMD(WINBOND_NOR_OP_WREAR, 0), \
|
||||||
|
SPI_MEM_OP_NO_ADDR, \
|
||||||
|
SPI_MEM_OP_NO_DUMMY, \
|
||||||
|
SPI_MEM_OP_DATA_OUT(1, buf, 0))
|
||||||
|
|
||||||
static int
|
static int
|
||||||
w25q256_post_bfpt_fixups(struct spi_nor *nor,
|
w25q256_post_bfpt_fixups(struct spi_nor *nor,
|
||||||
const struct sfdp_parameter_header *bfpt_header,
|
const struct sfdp_parameter_header *bfpt_header,
|
||||||
|
@ -129,6 +138,37 @@ static const struct flash_info winbond_nor_parts[] = {
|
||||||
SPI_NOR_QUAD_READ) },
|
SPI_NOR_QUAD_READ) },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* winbond_nor_write_ear() - Write Extended Address Register.
|
||||||
|
* @nor: pointer to 'struct spi_nor'.
|
||||||
|
* @ear: value to write to the Extended Address Register.
|
||||||
|
*
|
||||||
|
* Return: 0 on success, -errno otherwise.
|
||||||
|
*/
|
||||||
|
static int winbond_nor_write_ear(struct spi_nor *nor, u8 ear)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
nor->bouncebuf[0] = ear;
|
||||||
|
|
||||||
|
if (nor->spimem) {
|
||||||
|
struct spi_mem_op op = WINBOND_NOR_WREAR_OP(nor->bouncebuf);
|
||||||
|
|
||||||
|
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
|
||||||
|
|
||||||
|
ret = spi_mem_exec_op(nor->spimem, &op);
|
||||||
|
} else {
|
||||||
|
ret = spi_nor_controller_ops_write_reg(nor,
|
||||||
|
WINBOND_NOR_OP_WREAR,
|
||||||
|
nor->bouncebuf, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
dev_dbg(nor->dev, "error %d writing EAR\n", ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* winbond_nor_set_4byte_addr_mode() - Set 4-byte address mode for Winbond
|
* winbond_nor_set_4byte_addr_mode() - Set 4-byte address mode for Winbond
|
||||||
* flashes.
|
* flashes.
|
||||||
|
@ -155,7 +195,7 @@ static int winbond_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = spi_nor_write_ear(nor, 0);
|
ret = winbond_nor_write_ear(nor, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,6 @@
|
||||||
#define SPINOR_OP_RDID 0x9f /* Read JEDEC ID */
|
#define SPINOR_OP_RDID 0x9f /* Read JEDEC ID */
|
||||||
#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_RDEAR 0xc8 /* Read Extended Address Register */
|
|
||||||
#define SPINOR_OP_WREAR 0xc5 /* Write Extended Address Register */
|
|
||||||
#define SPINOR_OP_SRSTEN 0x66 /* Software Reset Enable */
|
#define SPINOR_OP_SRSTEN 0x66 /* Software Reset Enable */
|
||||||
#define SPINOR_OP_SRST 0x99 /* Software Reset */
|
#define SPINOR_OP_SRST 0x99 /* Software Reset */
|
||||||
#define SPINOR_OP_GBULK 0x98 /* Global Block Unlock */
|
#define SPINOR_OP_GBULK 0x98 /* Global Block Unlock */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче