Commit c0abb861 authored by Tudor Ambarus's avatar Tudor Ambarus Committed by Pratyush Yadav

mtd: spi-nor: Introduce templates for SPI NOR operations

Clean the op declaration and hide the details of each op. With this it
results a cleanner, easier to read code. No functional change expected.
Signed-off-by: default avatarTudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: default avatarPratyush Yadav <p.yadav@ti.com>
Acked-by: default avatarMichael Walle <michael@walle.cc>
Acked-by: default avatarPratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20220420103427.47867-10-tudor.ambarus@microchip.com
parent 27ff0d34
...@@ -364,11 +364,7 @@ int spi_nor_write_enable(struct spi_nor *nor) ...@@ -364,11 +364,7 @@ int spi_nor_write_enable(struct spi_nor *nor)
int ret; int ret;
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = SPI_NOR_WREN_OP;
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WREN, 0),
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_NO_DATA);
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
...@@ -395,11 +391,7 @@ int spi_nor_write_disable(struct spi_nor *nor) ...@@ -395,11 +391,7 @@ int spi_nor_write_disable(struct spi_nor *nor)
int ret; int ret;
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = SPI_NOR_WRDI_OP;
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WRDI, 0),
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_NO_DATA);
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
...@@ -459,11 +451,7 @@ int spi_nor_read_sr(struct spi_nor *nor, u8 *sr) ...@@ -459,11 +451,7 @@ int spi_nor_read_sr(struct spi_nor *nor, u8 *sr)
int ret; int ret;
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = SPI_NOR_RDSR_OP(sr);
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDSR, 0),
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_DATA_IN(1, sr, 0));
if (nor->reg_proto == SNOR_PROTO_8_8_8_DTR) { if (nor->reg_proto == SNOR_PROTO_8_8_8_DTR) {
op.addr.nbytes = nor->params->rdsr_addr_nbytes; op.addr.nbytes = nor->params->rdsr_addr_nbytes;
...@@ -503,11 +491,7 @@ int spi_nor_read_cr(struct spi_nor *nor, u8 *cr) ...@@ -503,11 +491,7 @@ int spi_nor_read_cr(struct spi_nor *nor, u8 *cr)
int ret; int ret;
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = SPI_NOR_RDCR_OP(cr);
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDCR, 0),
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_DATA_IN(1, cr, 0));
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
...@@ -536,14 +520,7 @@ int spi_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable) ...@@ -536,14 +520,7 @@ int spi_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
int ret; int ret;
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = SPI_NOR_EN4B_EX4B_OP(enable);
SPI_MEM_OP(SPI_MEM_OP_CMD(enable ?
SPINOR_OP_EN4B :
SPINOR_OP_EX4B,
0),
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_NO_DATA);
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
...@@ -577,11 +554,7 @@ static int spansion_set_4byte_addr_mode(struct spi_nor *nor, bool enable) ...@@ -577,11 +554,7 @@ static int spansion_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
nor->bouncebuf[0] = enable << 7; nor->bouncebuf[0] = enable << 7;
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = SPI_NOR_BRWR_OP(nor->bouncebuf);
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_BRWR, 0),
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_DATA_OUT(1, nor->bouncebuf, 0));
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
...@@ -611,11 +584,7 @@ int spi_nor_write_ear(struct spi_nor *nor, u8 ear) ...@@ -611,11 +584,7 @@ int spi_nor_write_ear(struct spi_nor *nor, u8 ear)
nor->bouncebuf[0] = ear; nor->bouncebuf[0] = ear;
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = SPI_NOR_WREAR_OP(nor->bouncebuf);
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, nor->bouncebuf, 0));
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
...@@ -726,11 +695,7 @@ int spi_nor_global_block_unlock(struct spi_nor *nor) ...@@ -726,11 +695,7 @@ int spi_nor_global_block_unlock(struct spi_nor *nor)
return ret; return ret;
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = SPI_NOR_GBULK_OP;
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_GBULK, 0),
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_NO_DATA);
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
...@@ -765,11 +730,7 @@ int spi_nor_write_sr(struct spi_nor *nor, const u8 *sr, size_t len) ...@@ -765,11 +730,7 @@ int spi_nor_write_sr(struct spi_nor *nor, const u8 *sr, size_t len)
return ret; return ret;
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = SPI_NOR_WRSR_OP(sr, len);
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WRSR, 0),
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_DATA_OUT(len, sr, 0));
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
...@@ -978,11 +939,7 @@ static int spi_nor_write_sr2(struct spi_nor *nor, const u8 *sr2) ...@@ -978,11 +939,7 @@ static int spi_nor_write_sr2(struct spi_nor *nor, const u8 *sr2)
return ret; return ret;
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = SPI_NOR_WRSR2_OP(sr2);
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WRSR2, 0),
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_DATA_OUT(1, sr2, 0));
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
...@@ -1014,11 +971,7 @@ static int spi_nor_read_sr2(struct spi_nor *nor, u8 *sr2) ...@@ -1014,11 +971,7 @@ static int spi_nor_read_sr2(struct spi_nor *nor, u8 *sr2)
int ret; int ret;
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = SPI_NOR_RDSR2_OP(sr2);
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDSR2, 0),
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_DATA_IN(1, sr2, 0));
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
...@@ -1047,11 +1000,7 @@ static int spi_nor_erase_chip(struct spi_nor *nor) ...@@ -1047,11 +1000,7 @@ static int spi_nor_erase_chip(struct spi_nor *nor)
dev_dbg(nor->dev, " %lldKiB\n", (long long)(nor->mtd.size >> 10)); dev_dbg(nor->dev, " %lldKiB\n", (long long)(nor->mtd.size >> 10));
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = SPI_NOR_CHIP_ERASE_OP;
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_CHIP_ERASE, 0),
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_NO_DATA);
spi_nor_spimem_setup_op(nor, &op, nor->write_proto); spi_nor_spimem_setup_op(nor, &op, nor->write_proto);
...@@ -1193,10 +1142,8 @@ int spi_nor_erase_sector(struct spi_nor *nor, u32 addr) ...@@ -1193,10 +1142,8 @@ int spi_nor_erase_sector(struct spi_nor *nor, u32 addr)
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op =
SPI_MEM_OP(SPI_MEM_OP_CMD(nor->erase_opcode, 0), SPI_NOR_SECTOR_ERASE_OP(nor->erase_opcode,
SPI_MEM_OP_ADDR(nor->addr_width, addr, 0), nor->addr_width, addr);
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_NO_DATA);
spi_nor_spimem_setup_op(nor, &op, nor->write_proto); spi_nor_spimem_setup_op(nor, &op, nor->write_proto);
...@@ -1992,10 +1939,7 @@ static int spi_nor_spimem_check_op(struct spi_nor *nor, ...@@ -1992,10 +1939,7 @@ static int spi_nor_spimem_check_op(struct spi_nor *nor,
static int spi_nor_spimem_check_readop(struct spi_nor *nor, static int spi_nor_spimem_check_readop(struct spi_nor *nor,
const struct spi_nor_read_command *read) const struct spi_nor_read_command *read)
{ {
struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(read->opcode, 0), struct spi_mem_op op = SPI_NOR_READ_OP(read->opcode);
SPI_MEM_OP_ADDR(3, 0, 0),
SPI_MEM_OP_DUMMY(1, 0),
SPI_MEM_OP_DATA_IN(2, NULL, 0));
spi_nor_spimem_setup_op(nor, &op, read->proto); spi_nor_spimem_setup_op(nor, &op, read->proto);
...@@ -2018,10 +1962,7 @@ static int spi_nor_spimem_check_readop(struct spi_nor *nor, ...@@ -2018,10 +1962,7 @@ static int spi_nor_spimem_check_readop(struct spi_nor *nor,
static int spi_nor_spimem_check_pp(struct spi_nor *nor, static int spi_nor_spimem_check_pp(struct spi_nor *nor,
const struct spi_nor_pp_command *pp) const struct spi_nor_pp_command *pp)
{ {
struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(pp->opcode, 0), struct spi_mem_op op = SPI_NOR_PP_OP(pp->opcode);
SPI_MEM_OP_ADDR(3, 0, 0),
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_DATA_OUT(2, NULL, 0));
spi_nor_spimem_setup_op(nor, &op, pp->proto); spi_nor_spimem_setup_op(nor, &op, pp->proto);
...@@ -2845,10 +2786,7 @@ static void spi_nor_soft_reset(struct spi_nor *nor) ...@@ -2845,10 +2786,7 @@ static void spi_nor_soft_reset(struct spi_nor *nor)
struct spi_mem_op op; struct spi_mem_op op;
int ret; int ret;
op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRSTEN, 0), op = (struct spi_mem_op)SPINOR_SRSTEN_OP;
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DATA);
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
...@@ -2858,10 +2796,7 @@ static void spi_nor_soft_reset(struct spi_nor *nor) ...@@ -2858,10 +2796,7 @@ static void spi_nor_soft_reset(struct spi_nor *nor)
return; return;
} }
op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRST, 0), op = (struct spi_mem_op)SPINOR_SRST_OP;
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DATA);
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
......
...@@ -18,6 +18,108 @@ ...@@ -18,6 +18,108 @@
SPI_MEM_OP_DUMMY(ndummy, 0), \ SPI_MEM_OP_DUMMY(ndummy, 0), \
SPI_MEM_OP_DATA_IN(len, buf, 0)) SPI_MEM_OP_DATA_IN(len, buf, 0))
#define SPI_NOR_WREN_OP \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WREN, 0), \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_NO_DATA)
#define SPI_NOR_WRDI_OP \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WRDI, 0), \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_NO_DATA)
#define SPI_NOR_RDSR_OP(buf) \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDSR, 0), \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_DATA_IN(1, buf, 0))
#define SPI_NOR_WRSR_OP(buf, len) \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WRSR, 0), \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_DATA_OUT(len, buf, 0))
#define SPI_NOR_RDSR2_OP(buf) \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDSR2, 0), \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_DATA_OUT(1, buf, 0))
#define SPI_NOR_WRSR2_OP(buf) \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WRSR2, 0), \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_DATA_OUT(1, buf, 0))
#define SPI_NOR_RDCR_OP(buf) \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDCR, 0), \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_DATA_IN(1, buf, 0))
#define SPI_NOR_EN4B_EX4B_OP(enable) \
SPI_MEM_OP(SPI_MEM_OP_CMD(enable ? SPINOR_OP_EN4B : SPINOR_OP_EX4B, 0), \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_NO_DATA)
#define SPI_NOR_BRWR_OP(buf) \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_BRWR, 0), \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DUMMY, \
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 \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_GBULK, 0), \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_NO_DATA)
#define SPI_NOR_CHIP_ERASE_OP \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_CHIP_ERASE, 0), \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_NO_DATA)
#define SPI_NOR_SECTOR_ERASE_OP(opcode, addr_width, addr) \
SPI_MEM_OP(SPI_MEM_OP_CMD(opcode, 0), \
SPI_MEM_OP_ADDR(addr_width, addr, 0), \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_NO_DATA)
#define SPI_NOR_READ_OP(opcode) \
SPI_MEM_OP(SPI_MEM_OP_CMD(opcode, 0), \
SPI_MEM_OP_ADDR(3, 0, 0), \
SPI_MEM_OP_DUMMY(1, 0), \
SPI_MEM_OP_DATA_IN(2, NULL, 0))
#define SPI_NOR_PP_OP(opcode) \
SPI_MEM_OP(SPI_MEM_OP_CMD(opcode, 0), \
SPI_MEM_OP_ADDR(3, 0, 0), \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_DATA_OUT(2, NULL, 0))
#define SPINOR_SRSTEN_OP \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRSTEN, 0), \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DATA)
#define SPINOR_SRST_OP \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRST, 0), \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DATA)
enum spi_nor_option_flags { enum spi_nor_option_flags {
SNOR_F_HAS_SR_TB = BIT(0), SNOR_F_HAS_SR_TB = BIT(0),
SNOR_F_NO_OP_CHIP_ERASE = BIT(1), SNOR_F_NO_OP_CHIP_ERASE = BIT(1),
......
...@@ -35,6 +35,18 @@ ...@@ -35,6 +35,18 @@
SPI_MEM_OP_NO_DUMMY, \ SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_DATA_OUT(ndata, buf, 0)) SPI_MEM_OP_DATA_OUT(ndata, buf, 0))
#define MICRON_ST_RDFSR_OP(buf) \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDFSR, 0), \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_DATA_IN(1, buf, 0))
#define MICRON_ST_CLFSR_OP \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_CLFSR, 0), \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_NO_DATA)
static int micron_st_nor_octal_dtr_en(struct spi_nor *nor) static int micron_st_nor_octal_dtr_en(struct spi_nor *nor)
{ {
struct spi_mem_op op; struct spi_mem_op op;
...@@ -324,11 +336,7 @@ static int micron_st_nor_read_fsr(struct spi_nor *nor, u8 *fsr) ...@@ -324,11 +336,7 @@ static int micron_st_nor_read_fsr(struct spi_nor *nor, u8 *fsr)
int ret; int ret;
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = MICRON_ST_RDFSR_OP(fsr);
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDFSR, 0),
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_DATA_IN(1, fsr, 0));
if (nor->reg_proto == SNOR_PROTO_8_8_8_DTR) { if (nor->reg_proto == SNOR_PROTO_8_8_8_DTR) {
op.addr.nbytes = nor->params->rdsr_addr_nbytes; op.addr.nbytes = nor->params->rdsr_addr_nbytes;
...@@ -363,11 +371,7 @@ static void micron_st_nor_clear_fsr(struct spi_nor *nor) ...@@ -363,11 +371,7 @@ static void micron_st_nor_clear_fsr(struct spi_nor *nor)
int ret; int ret;
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = MICRON_ST_CLFSR_OP;
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_CLFSR, 0),
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_NO_DATA);
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
......
...@@ -30,6 +30,18 @@ ...@@ -30,6 +30,18 @@
SPI_MEM_OP_NO_DUMMY, \ SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_DATA_OUT(ndata, buf, 0)) SPI_MEM_OP_DATA_OUT(ndata, buf, 0))
#define CYPRESS_NOR_RD_ANY_REG_OP(naddr, addr, buf) \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RD_ANY_REG, 0), \
SPI_MEM_OP_ADDR(naddr, addr, 0), \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_DATA_IN(1, buf, 0))
#define SPANSION_CLSR_OP \
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_CLSR, 0), \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_NO_DATA)
static int cypress_nor_octal_dtr_en(struct spi_nor *nor) static int cypress_nor_octal_dtr_en(struct spi_nor *nor)
{ {
struct spi_mem_op op; struct spi_mem_op op;
...@@ -165,12 +177,12 @@ static int s28hs512t_post_bfpt_fixup(struct spi_nor *nor, ...@@ -165,12 +177,12 @@ static int s28hs512t_post_bfpt_fixup(struct spi_nor *nor,
* CFR3V[4] and set the correct size. * CFR3V[4] and set the correct size.
*/ */
struct spi_mem_op op = struct spi_mem_op op =
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RD_ANY_REG, 1), CYPRESS_NOR_RD_ANY_REG_OP(3, SPINOR_REG_CYPRESS_CFR3V,
SPI_MEM_OP_ADDR(3, SPINOR_REG_CYPRESS_CFR3V, 1), nor->bouncebuf);
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_DATA_IN(1, nor->bouncebuf, 1));
int ret; int ret;
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
ret = spi_mem_exec_op(nor->spimem, &op); ret = spi_mem_exec_op(nor->spimem, &op);
if (ret) if (ret)
return ret; return ret;
...@@ -320,11 +332,7 @@ static void spansion_nor_clear_sr(struct spi_nor *nor) ...@@ -320,11 +332,7 @@ static void spansion_nor_clear_sr(struct spi_nor *nor)
int ret; int ret;
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = SPANSION_CLSR_OP;
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_CLSR, 0),
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_NO_DATA);
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
......
...@@ -15,6 +15,12 @@ ...@@ -15,6 +15,12 @@
#define XSR_PAGESIZE BIT(0) /* Page size in Po2 or Linear */ #define XSR_PAGESIZE BIT(0) /* Page size in Po2 or Linear */
#define XSR_RDY BIT(7) /* Ready */ #define XSR_RDY BIT(7) /* Ready */
#define XILINX_RDSR_OP(buf) \
SPI_MEM_OP(SPI_MEM_OP_CMD(XILINX_OP_RDSR, 0), \
SPI_MEM_OP_NO_ADDR, \
SPI_MEM_OP_NO_DUMMY, \
SPI_MEM_OP_DATA_IN(1, buf, 0))
#define S3AN_INFO(_jedec_id, _n_sectors, _page_size) \ #define S3AN_INFO(_jedec_id, _n_sectors, _page_size) \
.id = { \ .id = { \
((_jedec_id) >> 16) & 0xff, \ ((_jedec_id) >> 16) & 0xff, \
...@@ -72,11 +78,7 @@ static int xilinx_nor_read_sr(struct spi_nor *nor, u8 *sr) ...@@ -72,11 +78,7 @@ static int xilinx_nor_read_sr(struct spi_nor *nor, u8 *sr)
int ret; int ret;
if (nor->spimem) { if (nor->spimem) {
struct spi_mem_op op = struct spi_mem_op op = XILINX_RDSR_OP(sr);
SPI_MEM_OP(SPI_MEM_OP_CMD(XILINX_OP_RDSR, 0),
SPI_MEM_OP_NO_ADDR,
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_DATA_IN(1, sr, 0));
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
......
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