Lines Matching defs:erase

30  * For everything but full-chip erase; probably could be much smaller, but kept
36 * For full-chip erase, calibrated to a 2MB flash (M25P16); should be scaled up
183 return nor->controller_ops->erase(nor, offs);
1172 struct spi_nor_erase_type *erase;
1176 erase = &map->erase_type[i];
1177 erase->opcode =
1178 spi_nor_convert_3to4_erase(erase->opcode);
1310 /* Internal locking helpers for program and erase operations */
1491 } else if (nor->controller_ops->erase) {
1510 * @erase: pointer to a structure that describes a SPI NOR erase type
1516 static u64 spi_nor_div_by_erase_size(const struct spi_nor_erase_type *erase,
1519 /* JEDEC JESD216B Standard imposes erase sizes to be power of 2. */
1520 *remainder = (u32)dividend & erase->size_mask;
1521 return dividend >> erase->size_shift;
1525 * spi_nor_find_best_erase_type() - find the best erase type for the given
1527 * number of bytes to erase. The region in
1530 * @map: the erase map of the SPI NOR
1531 * @region: pointer to a structure that describes a SPI NOR erase region
1533 * @len: number of bytes to erase
1535 * Return: a pointer to the best fitted erase type, NULL otherwise.
1542 const struct spi_nor_erase_type *erase;
1547 * Erase types are ordered by size, with the smallest erase type at
1551 /* Does the erase region support the tested erase type? */
1555 erase = &map->erase_type[i];
1556 if (!erase->size)
1561 return erase;
1563 /* Don't erase more than what the user has asked for. */
1564 if (erase->size > len)
1567 spi_nor_div_by_erase_size(erase, addr, &rem);
1569 return erase;
1576 * spi_nor_init_erase_cmd() - initialize an erase command
1577 * @region: pointer to a structure that describes a SPI NOR erase region
1578 * @erase: pointer to a structure that describes a SPI NOR erase type
1580 * Return: the pointer to the allocated erase command, ERR_PTR(-errno)
1585 const struct spi_nor_erase_type *erase)
1594 cmd->opcode = erase->opcode;
1600 cmd->size = erase->size;
1606 * spi_nor_destroy_erase_cmd_list() - destroy erase command list
1607 * @erase_list: list of erase commands
1620 * spi_nor_init_erase_cmd_list() - initialize erase command list
1622 * @erase_list: list of erase commands to be executed once we validate that the
1623 * erase can be performed
1625 * @len: number of bytes to erase
1627 * Builds the list of best fitted erase commands and verifies if the erase can
1637 const struct spi_nor_erase_type *erase, *prev_erase = NULL;
1649 erase = spi_nor_find_best_erase_type(map, region, addr,
1651 if (!erase)
1654 if (prev_erase != erase || erase->size != cmd->size ||
1656 cmd = spi_nor_init_erase_cmd(region, erase);
1669 prev_erase = erase;
1681 * spi_nor_erase_multi_sectors() - perform a non-uniform erase
1684 * @len: number of bytes to erase
1686 * Build a list of best fitted erase commands and execute it once we validate
1687 * that the erase can be performed.
1787 * one or more erase sectors. Return an error if there is a problem erasing.
1822 /* chip (die) erase? */
1831 * to use "small sector erase", but that's not always optimal.
1834 /* "sector"-at-a-time erase */
1860 /* erase multiple sectors */
2374 * spi_nor_set_erase_type() - set a SPI NOR erase type
2375 * @erase: pointer to a structure that describes a SPI NOR erase type
2376 * @size: the size of the sector/block erased by the erase type
2377 * @opcode: the SPI command op code to erase the sector/block
2379 void spi_nor_set_erase_type(struct spi_nor_erase_type *erase, u32 size,
2382 erase->size = size;
2383 erase->opcode = opcode;
2384 /* JEDEC JESD216B Standard imposes erase sizes to be power of 2. */
2385 erase->size_shift = ffs(erase->size) - 1;
2386 erase->size_mask = (1 << erase->size_shift) - 1;
2390 * spi_nor_mask_erase_type() - mask out a SPI NOR erase type
2391 * @erase: pointer to a structure that describes a SPI NOR erase type
2393 void spi_nor_mask_erase_type(struct spi_nor_erase_type *erase)
2395 erase->size = 0;
2399 * spi_nor_init_uniform_erase_map() - Initialize uniform erase map
2400 * @map: the erase map of the SPI NOR
2401 * @erase_mask: bitmask encoding erase types that can erase the entire
2486 * spi_nor_select_uniform_erase() - select optimum uniform erase type
2487 * @map: the erase map of the SPI NOR
2489 * Once the optimum uniform sector erase command is found, disable all the
2492 * Return: pointer to erase type on success, NULL otherwise.
2497 const struct spi_nor_erase_type *tested_erase, *erase = NULL;
2502 * Search for the biggest erase size, except for when compiled
2511 /* Skip masked erase types. */
2516 * If the current erase size is the 4k one, stop here,
2521 erase = tested_erase;
2526 * Otherwise, the current erase size is still a valid candidate.
2529 if (!erase && tested_erase->size)
2530 erase = tested_erase;
2534 if (!erase)
2538 map->uniform_region.erase_mask = BIT(erase - map->erase_type);
2539 return erase;
2545 const struct spi_nor_erase_type *erase = NULL;
2552 * of the supported erase sizes for all Sector Erase commands.
2554 * manage the SPI flash memory as uniform with a single erase sector
2558 erase = spi_nor_select_uniform_erase(map);
2559 if (!erase)
2561 nor->erase_opcode = erase->opcode;
2562 mtd->erasesize = erase->size;
2568 * maximum erase sector size. No need to set nor->erase_opcode.
2572 erase = &map->erase_type[i];
2577 if (!erase)
2580 mtd->erasesize = erase->size;
2638 "can't select erase settings supported by both the SPI controller and memory.\n");
2775 * smallest erase size starting at BIT(0).