Lines Matching full:nor

10 #include <linux/mtd/spi-nor.h>
140 * @nor: pointer to a 'struct spi_nor'
147 static int spi_nor_read_raw(struct spi_nor *nor, u32 addr, size_t len, u8 *buf) in spi_nor_read_raw() argument
152 ret = spi_nor_read_data(nor, addr, len, buf); in spi_nor_read_raw()
167 * @nor: pointer to a 'struct spi_nor'
178 static int spi_nor_read_sfdp(struct spi_nor *nor, u32 addr, in spi_nor_read_sfdp() argument
184 read_opcode = nor->read_opcode; in spi_nor_read_sfdp()
185 addr_nbytes = nor->addr_nbytes; in spi_nor_read_sfdp()
186 read_dummy = nor->read_dummy; in spi_nor_read_sfdp()
188 nor->read_opcode = SPINOR_OP_RDSFDP; in spi_nor_read_sfdp()
189 nor->addr_nbytes = 3; in spi_nor_read_sfdp()
190 nor->read_dummy = 8; in spi_nor_read_sfdp()
192 ret = spi_nor_read_raw(nor, addr, len, buf); in spi_nor_read_sfdp()
194 nor->read_opcode = read_opcode; in spi_nor_read_sfdp()
195 nor->addr_nbytes = addr_nbytes; in spi_nor_read_sfdp()
196 nor->read_dummy = read_dummy; in spi_nor_read_sfdp()
203 * @nor: pointer to a 'struct spi_nor'
214 static int spi_nor_read_sfdp_dma_unsafe(struct spi_nor *nor, u32 addr, in spi_nor_read_sfdp_dma_unsafe() argument
224 ret = spi_nor_read_sfdp(nor, addr, len, dma_safe_buf); in spi_nor_read_sfdp_dma_unsafe()
308 * @erase: pointer to a structure that describes a SPI NOR erase type
347 * @map: the erase map of the SPI NOR
375 * @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()
454 err = spi_nor_read_sfdp_dma_unsafe(nor, addr, len, &bfpt); in spi_nor_parse_bfpt()
484 * 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()
613 nor->flags |= SNOR_F_SOFT_RESET; in spi_nor_parse_bfpt()
617 return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt); in spi_nor_parse_bfpt()
622 nor->cmd_ext_type = SPI_NOR_EXT_REPEAT; in spi_nor_parse_bfpt()
626 nor->cmd_ext_type = SPI_NOR_EXT_INVERT; in spi_nor_parse_bfpt()
630 dev_dbg(nor->dev, "Reserved command extension used\n"); in spi_nor_parse_bfpt()
634 dev_dbg(nor->dev, "16-bit opcodes not supported\n"); in spi_nor_parse_bfpt()
638 return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt); in spi_nor_parse_bfpt()
644 * @nor: pointer to a 'struct spi_nor'
647 static u8 spi_nor_smpt_addr_nbytes(const struct spi_nor *nor, const u32 settings) in spi_nor_smpt_addr_nbytes() argument
658 return nor->params->addr_mode_nbytes; in spi_nor_smpt_addr_nbytes()
665 * @nor: pointer to a 'struct spi_nor'
670 static u8 spi_nor_smpt_read_dummy(const struct spi_nor *nor, const u32 settings) in spi_nor_smpt_read_dummy() argument
675 return nor->read_dummy; in spi_nor_smpt_read_dummy()
681 * @nor: pointer to a 'struct spi_nor'
687 static const u32 *spi_nor_get_map_in_use(struct spi_nor *nor, const u32 *smpt, in spi_nor_get_map_in_use() argument
703 addr_nbytes = nor->addr_nbytes; in spi_nor_get_map_in_use()
704 read_dummy = nor->read_dummy; in spi_nor_get_map_in_use()
705 read_opcode = nor->read_opcode; in spi_nor_get_map_in_use()
714 nor->addr_nbytes = spi_nor_smpt_addr_nbytes(nor, smpt[i]); in spi_nor_get_map_in_use()
715 nor->read_dummy = spi_nor_smpt_read_dummy(nor, smpt[i]); in spi_nor_get_map_in_use()
716 nor->read_opcode = SMPT_CMD_OPCODE(smpt[i]); in spi_nor_get_map_in_use()
719 err = spi_nor_read_raw(nor, addr, 1, buf); in spi_nor_get_map_in_use()
761 nor->addr_nbytes = addr_nbytes; in spi_nor_get_map_in_use()
762 nor->read_dummy = read_dummy; in spi_nor_get_map_in_use()
763 nor->read_opcode = read_opcode; in spi_nor_get_map_in_use()
779 * @region: pointer to a structure that describes a SPI NOR erase region
780 * @erase: pointer to a structure that describes a SPI NOR erase type
802 * @nor: pointer to a 'struct spi_nor'
807 static int spi_nor_init_non_uniform_erase_map(struct spi_nor *nor, in spi_nor_init_non_uniform_erase_map() argument
810 struct spi_nor_erase_map *map = &nor->params->erase_map; in spi_nor_init_non_uniform_erase_map()
824 region = devm_kcalloc(nor->dev, region_count, sizeof(*region), in spi_nor_init_non_uniform_erase_map()
886 * @nor: pointer to a 'struct spi_nor'
895 static int spi_nor_parse_smpt(struct spi_nor *nor, in spi_nor_parse_smpt() argument
911 ret = spi_nor_read_sfdp(nor, addr, len, smpt); in spi_nor_parse_smpt()
918 sector_map = spi_nor_get_map_in_use(nor, smpt, smpt_header->length); in spi_nor_parse_smpt()
924 ret = spi_nor_init_non_uniform_erase_map(nor, sector_map); in spi_nor_parse_smpt()
928 spi_nor_regions_sort_erase_types(&nor->params->erase_map); in spi_nor_parse_smpt()
937 * @nor: pointer to a 'struct spi_nor'.
943 static int spi_nor_parse_4bait(struct spi_nor *nor, in spi_nor_parse_4bait() argument
968 struct spi_nor_flash_parameter *params = nor->params; in spi_nor_parse_4bait()
990 ret = spi_nor_read_sfdp(nor, addr, len, dwords); in spi_nor_parse_4bait()
1049 * nor->addr_nbytes value. in spi_nor_parse_4bait()
1104 nor->flags |= SNOR_F_4B_OPCODES | SNOR_F_HAS_4BAIT; in spi_nor_parse_4bait()
1122 * @nor: pointer to a 'struct spi_nor'
1128 static int spi_nor_parse_profile1(struct spi_nor *nor, in spi_nor_parse_profile1() argument
1142 ret = spi_nor_read_sfdp(nor, addr, len, dwords); in spi_nor_parse_profile1()
1153 nor->params->rdsr_dummy = 8; in spi_nor_parse_profile1()
1155 nor->params->rdsr_dummy = 4; in spi_nor_parse_profile1()
1158 nor->params->rdsr_addr_nbytes = 4; in spi_nor_parse_profile1()
1160 nor->params->rdsr_addr_nbytes = 0; in spi_nor_parse_profile1()
1179 dev_dbg(nor->dev, in spi_nor_parse_profile1()
1186 spi_nor_set_read_settings(&nor->params->reads[SNOR_CMD_READ_8_8_8_DTR], in spi_nor_parse_profile1()
1200 * @nor: pointer to a 'struct spi_nor'
1206 static int spi_nor_parse_sccr(struct spi_nor *nor, in spi_nor_parse_sccr() argument
1219 ret = spi_nor_read_sfdp(nor, addr, len, dwords); in spi_nor_parse_sccr()
1226 nor->flags |= SNOR_F_IO_MODE_EN_VOLATILE; in spi_nor_parse_sccr()
1237 * @nor: pointer to a 'struct spi_nor'
1242 static void spi_nor_post_sfdp_fixups(struct spi_nor *nor) in spi_nor_post_sfdp_fixups() argument
1244 if (nor->manufacturer && nor->manufacturer->fixups && in spi_nor_post_sfdp_fixups()
1245 nor->manufacturer->fixups->post_sfdp) in spi_nor_post_sfdp_fixups()
1246 nor->manufacturer->fixups->post_sfdp(nor); in spi_nor_post_sfdp_fixups()
1248 if (nor->info->fixups && nor->info->fixups->post_sfdp) in spi_nor_post_sfdp_fixups()
1249 nor->info->fixups->post_sfdp(nor); in spi_nor_post_sfdp_fixups()
1254 * @nor: pointer to a 'struct spi_nor'
1264 int spi_nor_parse_sfdp(struct spi_nor *nor) in spi_nor_parse_sfdp() argument
1269 struct device *dev = nor->dev; in spi_nor_parse_sfdp()
1276 err = spi_nor_read_sfdp_dma_unsafe(nor, 0, sizeof(header), &header); in spi_nor_parse_sfdp()
1315 err = spi_nor_read_sfdp(nor, sizeof(header), in spi_nor_parse_sfdp()
1365 err = spi_nor_read_sfdp(nor, 0, sfdp_size, sfdp->dwords); in spi_nor_parse_sfdp()
1373 nor->sfdp = sfdp; in spi_nor_parse_sfdp()
1390 err = spi_nor_parse_bfpt(nor, bfpt_header); in spi_nor_parse_sfdp()
1400 err = spi_nor_parse_smpt(nor, param_header); in spi_nor_parse_sfdp()
1404 err = spi_nor_parse_4bait(nor, param_header); in spi_nor_parse_sfdp()
1408 err = spi_nor_parse_profile1(nor, param_header); in spi_nor_parse_sfdp()
1412 err = spi_nor_parse_sccr(nor, param_header); in spi_nor_parse_sfdp()
1432 spi_nor_post_sfdp_fixups(nor); in spi_nor_parse_sfdp()