Lines Matching full:nor
7 #include <linux/mtd/spi-nor.h>
28 /* Cypress SPI NOR flash operations. */
47 static int cypress_nor_octal_dtr_en(struct spi_nor *nor) in cypress_nor_octal_dtr_en() argument
50 u8 *buf = nor->bouncebuf; in cypress_nor_octal_dtr_en()
58 ret = spi_nor_write_any_volatile_reg(nor, &op, nor->reg_proto); in cypress_nor_octal_dtr_en()
62 nor->read_dummy = 24; in cypress_nor_octal_dtr_en()
69 ret = spi_nor_write_any_volatile_reg(nor, &op, nor->reg_proto); in cypress_nor_octal_dtr_en()
74 ret = spi_nor_read_id(nor, 4, 3, buf, SNOR_PROTO_8_8_8_DTR); in cypress_nor_octal_dtr_en()
76 dev_dbg(nor->dev, "error %d reading JEDEC ID after enabling 8D-8D-8D mode\n", ret); in cypress_nor_octal_dtr_en()
80 if (memcmp(buf, nor->info->id, nor->info->id_len)) in cypress_nor_octal_dtr_en()
86 static int cypress_nor_octal_dtr_dis(struct spi_nor *nor) in cypress_nor_octal_dtr_dis() argument
89 u8 *buf = nor->bouncebuf; in cypress_nor_octal_dtr_dis()
101 ret = spi_nor_write_any_volatile_reg(nor, &op, SNOR_PROTO_8_8_8_DTR); in cypress_nor_octal_dtr_dis()
106 ret = spi_nor_read_id(nor, 0, 0, buf, SNOR_PROTO_1_1_1); in cypress_nor_octal_dtr_dis()
108 dev_dbg(nor->dev, "error %d reading JEDEC ID after disabling 8D-8D-8D mode\n", ret); in cypress_nor_octal_dtr_dis()
112 if (memcmp(buf, nor->info->id, nor->info->id_len)) in cypress_nor_octal_dtr_dis()
121 * @nor: pointer to a 'struct spi_nor'
132 static int cypress_nor_quad_enable_volatile(struct spi_nor *nor) in cypress_nor_quad_enable_volatile() argument
135 u8 addr_mode_nbytes = nor->params->addr_mode_nbytes; in cypress_nor_quad_enable_volatile()
142 nor->bouncebuf); in cypress_nor_quad_enable_volatile()
144 ret = spi_nor_read_any_reg(nor, &op, nor->reg_proto); in cypress_nor_quad_enable_volatile()
148 if (nor->bouncebuf[0] & SPINOR_REG_CYPRESS_CFR1V_QUAD_EN) in cypress_nor_quad_enable_volatile()
152 nor->bouncebuf[0] |= SPINOR_REG_CYPRESS_CFR1V_QUAD_EN; in cypress_nor_quad_enable_volatile()
156 nor->bouncebuf); in cypress_nor_quad_enable_volatile()
157 ret = spi_nor_write_any_volatile_reg(nor, &op, nor->reg_proto); in cypress_nor_quad_enable_volatile()
161 cfr1v_written = nor->bouncebuf[0]; in cypress_nor_quad_enable_volatile()
167 nor->bouncebuf); in cypress_nor_quad_enable_volatile()
168 ret = spi_nor_read_any_reg(nor, &op, nor->reg_proto); in cypress_nor_quad_enable_volatile()
172 if (nor->bouncebuf[0] != cfr1v_written) { in cypress_nor_quad_enable_volatile()
173 dev_err(nor->dev, "CFR1: Read back test failed\n"); in cypress_nor_quad_enable_volatile()
183 * @nor: pointer to a 'struct spi_nor'
191 static int cypress_nor_set_page_size(struct spi_nor *nor) in cypress_nor_set_page_size() argument
195 nor->bouncebuf); in cypress_nor_set_page_size()
198 ret = spi_nor_read_any_reg(nor, &op, nor->reg_proto); in cypress_nor_set_page_size()
202 if (nor->bouncebuf[0] & SPINOR_REG_CYPRESS_CFR3V_PGSZ) in cypress_nor_set_page_size()
203 nor->params->page_size = 512; in cypress_nor_set_page_size()
205 nor->params->page_size = 256; in cypress_nor_set_page_size()
211 s25hx_t_post_bfpt_fixup(struct spi_nor *nor, in s25hx_t_post_bfpt_fixup() argument
216 nor->params->quad_enable = cypress_nor_quad_enable_volatile; in s25hx_t_post_bfpt_fixup()
218 return cypress_nor_set_page_size(nor); in s25hx_t_post_bfpt_fixup()
221 static void s25hx_t_post_sfdp_fixup(struct spi_nor *nor) in s25hx_t_post_sfdp_fixup() argument
224 nor->params->erase_map.erase_type; in s25hx_t_post_sfdp_fixup()
245 static void s25hx_t_late_init(struct spi_nor *nor) in s25hx_t_late_init() argument
247 struct spi_nor_flash_parameter *params = nor->params; in s25hx_t_late_init()
264 * @nor: pointer to a 'struct spi_nor'
272 static int cypress_nor_octal_dtr_enable(struct spi_nor *nor, bool enable) in cypress_nor_octal_dtr_enable() argument
274 return enable ? cypress_nor_octal_dtr_en(nor) : in cypress_nor_octal_dtr_enable()
275 cypress_nor_octal_dtr_dis(nor); in cypress_nor_octal_dtr_enable()
278 static void s28hs512t_default_init(struct spi_nor *nor) in s28hs512t_default_init() argument
280 nor->params->octal_dtr_enable = cypress_nor_octal_dtr_enable; in s28hs512t_default_init()
281 nor->params->writesize = 16; in s28hs512t_default_init()
284 static void s28hs512t_post_sfdp_fixup(struct spi_nor *nor) in s28hs512t_post_sfdp_fixup() argument
290 if (nor->params->reads[SNOR_CMD_READ_8_8_8_DTR].opcode == 0) in s28hs512t_post_sfdp_fixup()
291 nor->params->reads[SNOR_CMD_READ_8_8_8_DTR].opcode = in s28hs512t_post_sfdp_fixup()
295 spi_nor_set_pp_settings(&nor->params->page_programs[SNOR_CMD_PP], in s28hs512t_post_sfdp_fixup()
301 spi_nor_set_pp_settings(&nor->params->page_programs[SNOR_CMD_PP_8_8_8_DTR], in s28hs512t_post_sfdp_fixup()
309 nor->params->rdsr_addr_nbytes = 4; in s28hs512t_post_sfdp_fixup()
312 static int s28hs512t_post_bfpt_fixup(struct spi_nor *nor, in s28hs512t_post_bfpt_fixup() argument
316 return cypress_nor_set_page_size(nor); in s28hs512t_post_bfpt_fixup()
326 s25fs_s_nor_post_bfpt_fixups(struct spi_nor *nor, in s25fs_s_nor_post_bfpt_fixups() argument
336 nor->params->page_size = 256; in s25fs_s_nor_post_bfpt_fixups()
465 * @nor: pointer to 'struct spi_nor'.
467 static void spansion_nor_clear_sr(struct spi_nor *nor) in spansion_nor_clear_sr() argument
471 if (nor->spimem) { in spansion_nor_clear_sr()
474 spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); in spansion_nor_clear_sr()
476 ret = spi_mem_exec_op(nor->spimem, &op); in spansion_nor_clear_sr()
478 ret = spi_nor_controller_ops_write_reg(nor, SPINOR_OP_CLSR, in spansion_nor_clear_sr()
483 dev_dbg(nor->dev, "error %d clearing SR\n", ret); in spansion_nor_clear_sr()
489 * @nor: pointer to 'struct spi_nor'.
493 static int spansion_nor_sr_ready_and_clear(struct spi_nor *nor) in spansion_nor_sr_ready_and_clear() argument
497 ret = spi_nor_read_sr(nor, nor->bouncebuf); in spansion_nor_sr_ready_and_clear()
501 if (nor->bouncebuf[0] & (SR_E_ERR | SR_P_ERR)) { in spansion_nor_sr_ready_and_clear()
502 if (nor->bouncebuf[0] & SR_E_ERR) in spansion_nor_sr_ready_and_clear()
503 dev_err(nor->dev, "Erase Error occurred\n"); in spansion_nor_sr_ready_and_clear()
505 dev_err(nor->dev, "Programming Error occurred\n"); in spansion_nor_sr_ready_and_clear()
507 spansion_nor_clear_sr(nor); in spansion_nor_sr_ready_and_clear()
515 ret = spi_nor_write_disable(nor); in spansion_nor_sr_ready_and_clear()
522 return !(nor->bouncebuf[0] & SR_WIP); in spansion_nor_sr_ready_and_clear()
525 static void spansion_nor_late_init(struct spi_nor *nor) in spansion_nor_late_init() argument
527 if (nor->params->size > SZ_16M) { in spansion_nor_late_init()
528 nor->flags |= SNOR_F_4B_OPCODES; in spansion_nor_late_init()
530 nor->erase_opcode = SPINOR_OP_SE; in spansion_nor_late_init()
531 nor->mtd.erasesize = nor->info->sector_size; in spansion_nor_late_init()
534 if (nor->info->mfr_flags & USE_CLSR) in spansion_nor_late_init()
535 nor->params->ready = spansion_nor_sr_ready_and_clear; in spansion_nor_late_init()