Lines Matching full:nor
7 #include <linux/mtd/spi-nor.h>
32 /* Micron ST SPI NOR flash operations. */
51 static int micron_st_nor_octal_dtr_en(struct spi_nor *nor) in micron_st_nor_octal_dtr_en() argument
54 u8 *buf = nor->bouncebuf; in micron_st_nor_octal_dtr_en()
56 u8 addr_mode_nbytes = nor->params->addr_mode_nbytes; in micron_st_nor_octal_dtr_en()
63 ret = spi_nor_write_any_volatile_reg(nor, &op, nor->reg_proto); in micron_st_nor_octal_dtr_en()
71 ret = spi_nor_write_any_volatile_reg(nor, &op, nor->reg_proto); in micron_st_nor_octal_dtr_en()
76 ret = spi_nor_read_id(nor, 0, 8, buf, SNOR_PROTO_8_8_8_DTR); in micron_st_nor_octal_dtr_en()
78 dev_dbg(nor->dev, "error %d reading JEDEC ID after enabling 8D-8D-8D mode\n", ret); in micron_st_nor_octal_dtr_en()
82 if (memcmp(buf, nor->info->id->bytes, nor->info->id->len)) in micron_st_nor_octal_dtr_en()
88 static int micron_st_nor_octal_dtr_dis(struct spi_nor *nor) in micron_st_nor_octal_dtr_dis() argument
91 u8 *buf = nor->bouncebuf; in micron_st_nor_octal_dtr_dis()
105 MICRON_ST_NOR_WR_ANY_REG_OP(nor->addr_nbytes, in micron_st_nor_octal_dtr_dis()
107 ret = spi_nor_write_any_volatile_reg(nor, &op, SNOR_PROTO_8_8_8_DTR); in micron_st_nor_octal_dtr_dis()
112 ret = spi_nor_read_id(nor, 0, 0, buf, SNOR_PROTO_1_1_1); in micron_st_nor_octal_dtr_dis()
114 dev_dbg(nor->dev, "error %d reading JEDEC ID after disabling 8D-8D-8D mode\n", ret); in micron_st_nor_octal_dtr_dis()
118 if (memcmp(buf, nor->info->id->bytes, nor->info->id->len)) in micron_st_nor_octal_dtr_dis()
124 static int micron_st_nor_set_octal_dtr(struct spi_nor *nor, bool enable) in micron_st_nor_set_octal_dtr() argument
126 return enable ? micron_st_nor_octal_dtr_en(nor) : in micron_st_nor_set_octal_dtr()
127 micron_st_nor_octal_dtr_dis(nor); in micron_st_nor_set_octal_dtr()
130 static void mt35xu512aba_default_init(struct spi_nor *nor) in mt35xu512aba_default_init() argument
132 nor->params->set_octal_dtr = micron_st_nor_set_octal_dtr; in mt35xu512aba_default_init()
135 static int mt35xu512aba_post_sfdp_fixup(struct spi_nor *nor) in mt35xu512aba_post_sfdp_fixup() argument
138 nor->params->hwcaps.mask |= SNOR_HWCAPS_READ_8_8_8_DTR; in mt35xu512aba_post_sfdp_fixup()
139 spi_nor_set_read_settings(&nor->params->reads[SNOR_CMD_READ_8_8_8_DTR], in mt35xu512aba_post_sfdp_fixup()
143 nor->cmd_ext_type = SPI_NOR_EXT_REPEAT; in mt35xu512aba_post_sfdp_fixup()
144 nor->params->rdsr_dummy = 8; in mt35xu512aba_post_sfdp_fixup()
145 nor->params->rdsr_addr_nbytes = 0; in mt35xu512aba_post_sfdp_fixup()
152 nor->params->quad_enable = NULL; in mt35xu512aba_post_sfdp_fixup()
184 static int mt25qu512a_post_bfpt_fixup(struct spi_nor *nor, in mt25qu512a_post_bfpt_fixup() argument
188 nor->flags &= ~SNOR_F_HAS_16BIT_SR; in mt25qu512a_post_bfpt_fixup()
196 static int st_nor_four_die_late_init(struct spi_nor *nor) in st_nor_four_die_late_init() argument
198 struct spi_nor_flash_parameter *params = nor->params; in st_nor_four_die_late_init()
209 return spi_nor_set_4byte_addr_mode(nor, true); in st_nor_four_die_late_init()
212 static int st_nor_two_die_late_init(struct spi_nor *nor) in st_nor_two_die_late_init() argument
214 struct spi_nor_flash_parameter *params = nor->params; in st_nor_two_die_late_init()
225 return spi_nor_set_4byte_addr_mode(nor, true); in st_nor_two_die_late_init()
504 * @nor: pointer to 'struct spi_nor'
511 static int micron_st_nor_read_fsr(struct spi_nor *nor, u8 *fsr) in micron_st_nor_read_fsr() argument
515 if (nor->spimem) { in micron_st_nor_read_fsr()
518 if (nor->reg_proto == SNOR_PROTO_8_8_8_DTR) { in micron_st_nor_read_fsr()
519 op.addr.nbytes = nor->params->rdsr_addr_nbytes; in micron_st_nor_read_fsr()
520 op.dummy.nbytes = nor->params->rdsr_dummy; in micron_st_nor_read_fsr()
528 spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); in micron_st_nor_read_fsr()
530 ret = spi_mem_exec_op(nor->spimem, &op); in micron_st_nor_read_fsr()
532 ret = spi_nor_controller_ops_read_reg(nor, SPINOR_OP_RDFSR, fsr, in micron_st_nor_read_fsr()
537 dev_dbg(nor->dev, "error %d reading FSR\n", ret); in micron_st_nor_read_fsr()
544 * @nor: pointer to 'struct spi_nor'.
546 static void micron_st_nor_clear_fsr(struct spi_nor *nor) in micron_st_nor_clear_fsr() argument
550 if (nor->spimem) { in micron_st_nor_clear_fsr()
553 spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); in micron_st_nor_clear_fsr()
555 ret = spi_mem_exec_op(nor->spimem, &op); in micron_st_nor_clear_fsr()
557 ret = spi_nor_controller_ops_write_reg(nor, SPINOR_OP_CLFSR, in micron_st_nor_clear_fsr()
562 dev_dbg(nor->dev, "error %d clearing FSR\n", ret); in micron_st_nor_clear_fsr()
569 * @nor: pointer to 'struct spi_nor'.
573 static int micron_st_nor_ready(struct spi_nor *nor) in micron_st_nor_ready() argument
577 sr_ready = spi_nor_sr_ready(nor); in micron_st_nor_ready()
581 ret = micron_st_nor_read_fsr(nor, nor->bouncebuf); in micron_st_nor_ready()
593 if (nor->bouncebuf[0] & (FSR_E_ERR | FSR_P_ERR)) { in micron_st_nor_ready()
594 if (nor->bouncebuf[0] & FSR_E_ERR) in micron_st_nor_ready()
595 dev_err(nor->dev, "Erase operation failed.\n"); in micron_st_nor_ready()
597 dev_err(nor->dev, "Program operation failed.\n"); in micron_st_nor_ready()
599 if (nor->bouncebuf[0] & FSR_PT_ERR) in micron_st_nor_ready()
600 dev_err(nor->dev, in micron_st_nor_ready()
603 micron_st_nor_clear_fsr(nor); in micron_st_nor_ready()
611 ret = spi_nor_write_disable(nor); in micron_st_nor_ready()
618 return sr_ready && !!(nor->bouncebuf[0] & FSR_READY); in micron_st_nor_ready()
621 static void micron_st_nor_default_init(struct spi_nor *nor) in micron_st_nor_default_init() argument
623 nor->flags |= SNOR_F_HAS_LOCK; in micron_st_nor_default_init()
624 nor->flags &= ~SNOR_F_HAS_16BIT_SR; in micron_st_nor_default_init()
625 nor->params->quad_enable = NULL; in micron_st_nor_default_init()
628 static int micron_st_nor_late_init(struct spi_nor *nor) in micron_st_nor_late_init() argument
630 struct spi_nor_flash_parameter *params = nor->params; in micron_st_nor_late_init()
632 if (nor->info->mfr_flags & USE_FSR) in micron_st_nor_late_init()