Lines Matching full:nor
8 #include <linux/mtd/spi-nor.h>
144 * @nor: pointer to a 'struct spi_nor'
151 static int spi_nor_read_raw(struct spi_nor *nor, u32 addr, size_t len, u8 *buf) in spi_nor_read_raw() argument
156 ret = spi_nor_read_data(nor, addr, len, buf); in spi_nor_read_raw()
171 * @nor: pointer to a 'struct spi_nor'
182 static int spi_nor_read_sfdp(struct spi_nor *nor, u32 addr, in spi_nor_read_sfdp() argument
188 read_opcode = nor->read_opcode; in spi_nor_read_sfdp()
189 addr_nbytes = nor->addr_nbytes; in spi_nor_read_sfdp()
190 read_dummy = nor->read_dummy; in spi_nor_read_sfdp()
192 nor->read_opcode = SPINOR_OP_RDSFDP; in spi_nor_read_sfdp()
193 nor->addr_nbytes = 3; in spi_nor_read_sfdp()
194 nor->read_dummy = 8; in spi_nor_read_sfdp()
196 ret = spi_nor_read_raw(nor, addr, len, buf); in spi_nor_read_sfdp()
198 nor->read_opcode = read_opcode; in spi_nor_read_sfdp()
199 nor->addr_nbytes = addr_nbytes; in spi_nor_read_sfdp()
200 nor->read_dummy = read_dummy; in spi_nor_read_sfdp()
207 * @nor: pointer to a 'struct spi_nor'
218 static int spi_nor_read_sfdp_dma_unsafe(struct spi_nor *nor, u32 addr, in spi_nor_read_sfdp_dma_unsafe() argument
228 ret = spi_nor_read_sfdp(nor, addr, len, dma_safe_buf); in spi_nor_read_sfdp_dma_unsafe()
312 * @erase: pointer to a structure that describes a SPI NOR erase type
351 * @map: the erase map of the SPI NOR
379 * @map: the erase map of the SPI NOR
406 * @nor: pointer to a 'struct spi_nor'
432 static int spi_nor_parse_bfpt(struct spi_nor *nor, in spi_nor_parse_bfpt() argument
435 struct spi_nor_flash_parameter *params = nor->params; in spi_nor_parse_bfpt()
456 err = spi_nor_read_sfdp_dma_unsafe(nor, addr, len, &bfpt); in spi_nor_parse_bfpt()
486 * Prevent overflows on params->size. Anyway, a NOR of 2^64 in spi_nor_parse_bfpt()
556 return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt); in spi_nor_parse_bfpt()
580 nor->flags |= SNOR_F_HAS_16BIT_SR | SNOR_F_NO_READ_CR; in spi_nor_parse_bfpt()
585 nor->flags &= ~SNOR_F_HAS_16BIT_SR; in spi_nor_parse_bfpt()
590 nor->flags &= ~SNOR_F_HAS_16BIT_SR; in spi_nor_parse_bfpt()
601 nor->flags |= SNOR_F_HAS_16BIT_SR; in spi_nor_parse_bfpt()
607 dev_dbg(nor->dev, "BFPT QER reserved value used\n"); in spi_nor_parse_bfpt()
619 dev_dbg(nor->dev, "BFPT: 4-Byte Address Mode method is not recognized or not implemented\n"); in spi_nor_parse_bfpt()
623 nor->flags |= SNOR_F_SOFT_RESET; in spi_nor_parse_bfpt()
627 return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt); in spi_nor_parse_bfpt()
658 nor->cmd_ext_type = SPI_NOR_EXT_REPEAT; in spi_nor_parse_bfpt()
662 nor->cmd_ext_type = SPI_NOR_EXT_INVERT; in spi_nor_parse_bfpt()
666 dev_dbg(nor->dev, "Reserved command extension used\n"); in spi_nor_parse_bfpt()
670 dev_dbg(nor->dev, "16-bit opcodes not supported\n"); in spi_nor_parse_bfpt()
674 return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt); in spi_nor_parse_bfpt()
680 * @nor: pointer to a 'struct spi_nor'
683 static u8 spi_nor_smpt_addr_nbytes(const struct spi_nor *nor, const u32 settings) in spi_nor_smpt_addr_nbytes() argument
694 return nor->params->addr_mode_nbytes; in spi_nor_smpt_addr_nbytes()
701 * @nor: pointer to a 'struct spi_nor'
706 static u8 spi_nor_smpt_read_dummy(const struct spi_nor *nor, const u32 settings) in spi_nor_smpt_read_dummy() argument
711 return nor->read_dummy; in spi_nor_smpt_read_dummy()
717 * @nor: pointer to a 'struct spi_nor'
723 static const u32 *spi_nor_get_map_in_use(struct spi_nor *nor, const u32 *smpt, in spi_nor_get_map_in_use() argument
739 addr_nbytes = nor->addr_nbytes; in spi_nor_get_map_in_use()
740 read_dummy = nor->read_dummy; in spi_nor_get_map_in_use()
741 read_opcode = nor->read_opcode; in spi_nor_get_map_in_use()
750 nor->addr_nbytes = spi_nor_smpt_addr_nbytes(nor, smpt[i]); in spi_nor_get_map_in_use()
751 nor->read_dummy = spi_nor_smpt_read_dummy(nor, smpt[i]); in spi_nor_get_map_in_use()
752 nor->read_opcode = SMPT_CMD_OPCODE(smpt[i]); in spi_nor_get_map_in_use()
755 err = spi_nor_read_raw(nor, addr, 1, buf); in spi_nor_get_map_in_use()
797 nor->addr_nbytes = addr_nbytes; in spi_nor_get_map_in_use()
798 nor->read_dummy = read_dummy; in spi_nor_get_map_in_use()
799 nor->read_opcode = read_opcode; in spi_nor_get_map_in_use()
805 * @region: pointer to a structure that describes a SPI NOR erase region
806 * @erase: pointer to a structure that describes a SPI NOR erase type
828 * @nor: pointer to a 'struct spi_nor'
833 static int spi_nor_init_non_uniform_erase_map(struct spi_nor *nor, in spi_nor_init_non_uniform_erase_map() argument
836 struct spi_nor_erase_map *map = &nor->params->erase_map; in spi_nor_init_non_uniform_erase_map()
850 region = devm_kcalloc(nor->dev, region_count, sizeof(*region), in spi_nor_init_non_uniform_erase_map()
913 * @nor: pointer to a 'struct spi_nor'
922 static int spi_nor_parse_smpt(struct spi_nor *nor, in spi_nor_parse_smpt() argument
938 ret = spi_nor_read_sfdp(nor, addr, len, smpt); in spi_nor_parse_smpt()
945 sector_map = spi_nor_get_map_in_use(nor, smpt, smpt_header->length); in spi_nor_parse_smpt()
951 ret = spi_nor_init_non_uniform_erase_map(nor, sector_map); in spi_nor_parse_smpt()
955 spi_nor_regions_sort_erase_types(&nor->params->erase_map); in spi_nor_parse_smpt()
964 * @nor: pointer to a 'struct spi_nor'.
970 static int spi_nor_parse_4bait(struct spi_nor *nor, in spi_nor_parse_4bait() argument
997 struct spi_nor_flash_parameter *params = nor->params; in spi_nor_parse_4bait()
1019 ret = spi_nor_read_sfdp(nor, addr, len, dwords); in spi_nor_parse_4bait()
1078 * nor->addr_nbytes value. in spi_nor_parse_4bait()
1133 nor->flags |= SNOR_F_4B_OPCODES | SNOR_F_HAS_4BAIT; in spi_nor_parse_4bait()
1151 * @nor: pointer to a 'struct spi_nor'
1157 static int spi_nor_parse_profile1(struct spi_nor *nor, in spi_nor_parse_profile1() argument
1171 ret = spi_nor_read_sfdp(nor, addr, len, dwords); in spi_nor_parse_profile1()
1182 nor->params->rdsr_dummy = 8; in spi_nor_parse_profile1()
1184 nor->params->rdsr_dummy = 4; in spi_nor_parse_profile1()
1187 nor->params->rdsr_addr_nbytes = 4; in spi_nor_parse_profile1()
1189 nor->params->rdsr_addr_nbytes = 0; in spi_nor_parse_profile1()
1211 dev_dbg(nor->dev, in spi_nor_parse_profile1()
1218 nor->params->hwcaps.mask |= SNOR_HWCAPS_READ_8_8_8_DTR; in spi_nor_parse_profile1()
1219 spi_nor_set_read_settings(&nor->params->reads[SNOR_CMD_READ_8_8_8_DTR], in spi_nor_parse_profile1()
1227 nor->params->hwcaps.mask |= SNOR_HWCAPS_PP_8_8_8_DTR; in spi_nor_parse_profile1()
1239 * @nor: pointer to a 'struct spi_nor'
1245 static int spi_nor_parse_sccr(struct spi_nor *nor, in spi_nor_parse_sccr() argument
1248 struct spi_nor_flash_parameter *params = nor->params; in spi_nor_parse_sccr()
1259 ret = spi_nor_read_sfdp(nor, addr, len, dwords); in spi_nor_parse_sccr()
1267 params->vreg_offset = devm_kmalloc(nor->dev, sizeof(*dwords), in spi_nor_parse_sccr()
1279 nor->flags |= SNOR_F_IO_MODE_EN_VOLATILE; in spi_nor_parse_sccr()
1290 * @nor: pointer to a 'struct spi_nor'
1296 static int spi_nor_parse_sccr_mc(struct spi_nor *nor, in spi_nor_parse_sccr_mc() argument
1299 struct spi_nor_flash_parameter *params = nor->params; in spi_nor_parse_sccr_mc()
1311 ret = spi_nor_read_sfdp(nor, addr, len, dwords); in spi_nor_parse_sccr_mc()
1325 devm_krealloc(nor->dev, params->vreg_offset, in spi_nor_parse_sccr_mc()
1347 * @nor: pointer to a 'struct spi_nor'
1352 static int spi_nor_post_sfdp_fixups(struct spi_nor *nor) in spi_nor_post_sfdp_fixups() argument
1356 if (nor->manufacturer && nor->manufacturer->fixups && in spi_nor_post_sfdp_fixups()
1357 nor->manufacturer->fixups->post_sfdp) { in spi_nor_post_sfdp_fixups()
1358 ret = nor->manufacturer->fixups->post_sfdp(nor); in spi_nor_post_sfdp_fixups()
1363 if (nor->info->fixups && nor->info->fixups->post_sfdp) in spi_nor_post_sfdp_fixups()
1364 return nor->info->fixups->post_sfdp(nor); in spi_nor_post_sfdp_fixups()
1371 * @nor: pointer to a 'struct spi_nor'
1378 int spi_nor_check_sfdp_signature(struct spi_nor *nor) in spi_nor_check_sfdp_signature() argument
1384 err = spi_nor_read_sfdp_dma_unsafe(nor, 0, sizeof(signature), in spi_nor_check_sfdp_signature()
1398 * @nor: pointer to a 'struct spi_nor'
1408 int spi_nor_parse_sfdp(struct spi_nor *nor) in spi_nor_parse_sfdp() argument
1413 struct device *dev = nor->dev; in spi_nor_parse_sfdp()
1420 err = spi_nor_read_sfdp_dma_unsafe(nor, 0, sizeof(header), &header); in spi_nor_parse_sfdp()
1459 err = spi_nor_read_sfdp(nor, sizeof(header), in spi_nor_parse_sfdp()
1509 err = spi_nor_read_sfdp(nor, 0, sfdp_size, sfdp->dwords); in spi_nor_parse_sfdp()
1517 nor->sfdp = sfdp; in spi_nor_parse_sfdp()
1534 err = spi_nor_parse_bfpt(nor, bfpt_header); in spi_nor_parse_sfdp()
1544 err = spi_nor_parse_smpt(nor, param_header); in spi_nor_parse_sfdp()
1548 err = spi_nor_parse_4bait(nor, param_header); in spi_nor_parse_sfdp()
1552 err = spi_nor_parse_profile1(nor, param_header); in spi_nor_parse_sfdp()
1556 err = spi_nor_parse_sccr(nor, param_header); in spi_nor_parse_sfdp()
1560 err = spi_nor_parse_sccr_mc(nor, param_header); in spi_nor_parse_sfdp()
1580 err = spi_nor_post_sfdp_fixups(nor); in spi_nor_parse_sfdp()