* [U-Boot] [PATCH] mtd: cfi: Zap cfi_flash_base in DM case
@ 2017-09-12 17:09 Marek Vasut
2017-09-26 15:57 ` Stefan Roese
0 siblings, 1 reply; 2+ messages in thread
From: Marek Vasut @ 2017-09-12 17:09 UTC (permalink / raw)
To: u-boot
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 <marek.vasut+renesas@gmail.com>
---
drivers/mtd/cfi_flash.c | 10 +++++-----
include/flash.h | 4 ++++
2 files changed, 9 insertions(+), 5 deletions(-)
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;
}
diff --git a/include/flash.h b/include/flash.h
index f53fe91349..0eedb1efa8 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -47,6 +47,10 @@ typedef struct {
#ifdef CONFIG_MTD
struct mtd_info *mtd;
#endif
+#ifdef CONFIG_CFI_FLASH /* DM-specific parts */
+ struct udevice *dev;
+ phys_addr_t base;
+#endif
} flash_info_t;
extern flash_info_t flash_info[]; /* info for FLASH chips */
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH] mtd: cfi: Zap cfi_flash_base in DM case
2017-09-12 17:09 [U-Boot] [PATCH] mtd: cfi: Zap cfi_flash_base in DM case Marek Vasut
@ 2017-09-26 15:57 ` Stefan Roese
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Roese @ 2017-09-26 15:57 UTC (permalink / raw)
To: u-boot
On 12.09.2017 19:09, Marek Vasut wrote:
> 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 <marek.vasut+renesas@gmail.com>
Applied to u-boot-cfi-flash/master.
Thanks,
Stefan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-26 15:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-12 17:09 [U-Boot] [PATCH] mtd: cfi: Zap cfi_flash_base in DM case Marek Vasut
2017-09-26 15:57 ` Stefan Roese
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.