From 1ec0a37e1cf2add5680b8d7305922c8210c3e2ed Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Tue, 12 Sep 2017 19:09:08 +0200 Subject: mtd: cfi: Zap cfi_flash_base in DM case Embed the flash base into struct flash_info instead of having ad-hoc static array in the code. This does not only remove static variable, but also allows CFI-like controllers, ie. HyperFlash ones, to use most of the CFI flash code by populating the flash_info with matching base address. Signed-off-by: Marek Vasut Signed-off-by: Stefan Roese --- drivers/mtd/cfi_flash.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/mtd') diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index f3bb72788a..df04a425e2 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -111,11 +111,9 @@ static void cfi_flash_init_dm(void) } } -static phys_addr_t cfi_flash_base[CFI_MAX_FLASH_BANKS]; - phys_addr_t cfi_flash_bank_addr(int i) { - return cfi_flash_base[i]; + return flash_info[i].base; } #else __weak phys_addr_t cfi_flash_bank_addr(int i) @@ -2458,10 +2456,12 @@ static int cfi_flash_probe(struct udevice *dev) while (idx < len) { addr = fdt_translate_address((void *)blob, node, cell + idx); - cfi_flash_base[cfi_flash_num_flash_banks++] = addr; + flash_info[cfi_flash_num_flash_banks].dev = dev; + flash_info[cfi_flash_num_flash_banks].base = addr; + cfi_flash_num_flash_banks++; idx += addrc + sizec; } - gd->bd->bi_flashstart = cfi_flash_base[0]; + gd->bd->bi_flashstart = flash_info[0].base; return 0; } -- cgit From 72443c7f7d2174903e73ee88dcb4364e0387bbb2 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Tue, 12 Sep 2017 19:09:31 +0200 Subject: mtd: cfi: Add support for status register polling The status register is optional in the AMD command sets, but it's presence can be checked by reading out CFI table entry 0xc bit 0. If the register is present, prefer using it's bit 7 to determine if the flash is busy over reading the flash ; this is needed ie. on Hyperflash memories. Signed-off-by: Marek Vasut Signed-off-by: Stefan Roese --- drivers/mtd/cfi_flash.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'drivers/mtd') diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index df04a425e2..8a5babea7b 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -544,7 +544,16 @@ static int flash_is_busy (flash_info_t * info, flash_sect_t sect) #ifdef CONFIG_FLASH_CFI_LEGACY case CFI_CMDSET_AMD_LEGACY: #endif - retval = flash_toggle (info, sect, 0, AMD_STATUS_TOGGLE); + if (info->sr_supported) { + flash_write_cmd (info, sect, info->addr_unlock1, + FLASH_CMD_READ_STATUS); + retval = !flash_isset (info, sect, 0, + FLASH_STATUS_DONE); + } else { + retval = flash_toggle (info, sect, 0, + AMD_STATUS_TOGGLE); + } + break; default: retval = 0; @@ -1685,6 +1694,7 @@ static void cmdset_amd_read_jedec_ids(flash_info_t *info) { ushort bankId = 0; uchar manuId; + uchar lsbits; flash_write_cmd(info, 0, 0, AMD_CMD_RESET); flash_unlock_seq(info, 0); @@ -1700,6 +1710,9 @@ static void cmdset_amd_read_jedec_ids(flash_info_t *info) } info->manufacturer_id = manuId; + lsbits = flash_read_uchar(info, FLASH_OFFSET_LOWER_SW_BITS); + info->sr_supported = lsbits & BIT(0); + switch (info->chipwidth){ case FLASH_CFI_8BIT: info->device_id = flash_read_uchar (info, -- cgit