Skip to content

Commit

Permalink
Kconfig: spi_nor: Remove Erase configuration from Kconfig
Browse files Browse the repository at this point in the history
Configuration of Erase command is specified in DTS. Hence
the corresponding changes in Kconfig are removed.

Signed-off-by: Rajavardhan Gundi <[email protected]>
  • Loading branch information
rgundi authored and nashif committed Jan 17, 2019
1 parent 74895bc commit f5b60ee
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 32 deletions.
4 changes: 0 additions & 4 deletions boards/xtensa/intel_s1000_crb/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,6 @@ config SPI_NOR_PAGE_SIZE
config SPI_NOR_SECTOR_SIZE
default 4096

choice SPI_NOR_BLOCK_ERASE_SIZE
default SPI_NOR_BLOCK_ERASE_64K
endchoice

config FLASH_HAS_PAGE_LAYOUT
def_bool y

Expand Down
21 changes: 0 additions & 21 deletions drivers/flash/Kconfig.nor
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,4 @@ config SPI_NOR_SECTOR_SIZE
help
This option specifies sector size of SPI flash

choice SPI_NOR_BLOCK_ERASE_SIZE
prompt "Select Block size for erasing"

config SPI_NOR_BLOCK_ERASE_32K
bool "Select 32K block erase"
help
This Enables 32K Block erase

config SPI_NOR_BLOCK_ERASE_64K
bool "Select 64K block erase"
help
This Enables 64K Block erase

endchoice

config SPI_NOR_BLOCK_ERASE_SIZE
int
default 2 if SPI_NOR_BLOCK_ERASE_32K
default 4 if SPI_NOR_BLOCK_ERASE_64K
help
This option specifies block size of SPI flash
endif # SPI_NOR
11 changes: 5 additions & 6 deletions drivers/flash/spi_nor.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
#define MASK_32K 0x7FFF
#define MASK_64K 0xFFFF

#define BLOCK_ERASE_32K BIT(1)
#define BLOCK_ERASE_64K BIT(2)

#define SPI_NOR_MAX_ADDR_WIDTH 4
#define SECTORS_COUNT (KB(CONFIG_FLASH_SIZE) / CONFIG_SPI_NOR_SECTOR_SIZE)

Expand Down Expand Up @@ -275,14 +272,16 @@ static int spi_nor_erase(struct device *dev, off_t addr, size_t size)
/* chip erase */
spi_nor_cmd_write(dev, SPI_NOR_CMD_CE);
size -= (params->sector_size * params->n_sectors);
} else if ((params->flag & BLOCK_ERASE_64K) && (size >= SZ_64K)
} else if ((FLASH_ERASE_BLOCK_SIZE == SZ_64K)
&& (size >= SZ_64K)
&& ((addr & MASK_64K) == 0)) {
/* 64 KiB block erase */
spi_nor_cmd_addr_write(dev, SPI_NOR_CMD_BE, addr,
NULL, 0);
addr += SZ_64K;
size -= SZ_64K;
} else if ((params->flag & BLOCK_ERASE_32K) && (size >= SZ_32K)
} else if ((FLASH_ERASE_BLOCK_SIZE == SZ_32K)
&& (size >= SZ_32K)
&& ((addr & MASK_32K) == 0)) {
/* 32 KiB block erase */
spi_nor_cmd_addr_write(dev, SPI_NOR_CMD_BE_32K, addr,
Expand Down Expand Up @@ -412,7 +411,7 @@ static const struct flash_driver_api spi_nor_api = {
static const struct spi_nor_config flash_id = {
JEDEC_ID(CONFIG_SPI_NOR_JEDEC_ID),
CONFIG_SPI_NOR_PAGE_SIZE, CONFIG_SPI_NOR_SECTOR_SIZE,
SECTORS_COUNT, CONFIG_SPI_NOR_BLOCK_ERASE_SIZE,
SECTORS_COUNT,
};

static struct spi_nor_data spi_nor_memory_data;
Expand Down
1 change: 0 additions & 1 deletion drivers/flash/spi_nor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ struct spi_nor_config {
u32_t page_size;
u32_t sector_size;
u32_t n_sectors;
u32_t flag;
};

/* Status register bits */
Expand Down

0 comments on commit f5b60ee

Please sign in to comment.