Hi Ilya, On Thursday 21 October 2010 17:20:12 Ilya Yanok wrote: > On some boards we have flash mapped high in the address space with > considerably small window (say 0xFE000000 and 32MB). When we install > bigger chip (say 64MB) on such a board strange things happen > (flash_write() doesn't work at all, for ex). That's because cfi_flash > driver doesn't care about window size at all. > Of course, cleanest solution would probably be to just extend address > window to be able to map the whole flash but for legacy/compatibility > reasons some people prefer just truncate the flash size and never use > the upper part. > This patch adds an option for cfi_flash driver to handle this situation > properly. To achieve this we add the new function cfi_flash_bank_size() > which can be provided by the board code and weak-aliased to default > implementation that returns value from the CONFIG_SYS_FLASH_BANKS_SIZES > array if it's defined or 0 otherwise (the last case is added for > compatibility). > If non-zero flash bank size is provided and detected chip size is bigger > than provided address window size the warning will be displayed and > flash chip will be truncated. > > Signed-off-by: Ilya Yanok <ya...@emcraft.com> > --- > drivers/mtd/cfi_flash.c | 28 +++++++++++++++++++++++----- > 1 files changed, 23 insertions(+), 5 deletions(-) > > diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c > index 798902f..c444b53 100644 > --- a/drivers/mtd/cfi_flash.c > +++ b/drivers/mtd/cfi_flash.c > @@ -85,6 +85,17 @@ static phys_addr_t __cfi_flash_bank_addr(int i) > phys_addr_t cfi_flash_bank_addr(int i) > __attribute__((weak, alias("__cfi_flash_bank_addr"))); > > +static phys_addr_t __cfi_flash_bank_size(int i) > +{ > +#ifdef CONFIG_SYS_FLASH_BANKS_SIZES > + return ((unsigned long [])CONFIG_SYS_FLASH_BANKS_SIZES)[i]; > +#else > + return 0; > +#endif > +} > +phys_addr_t cfi_flash_bank_size(int i) > + __attribute__((weak, alias("__cfi_flash_bank_size")));
Please use a consistent type here (phys_addr_t vs. unsigned long). unsigned long seems to be the correct one looking at the caller function. Otherwise: Acked-by: Stefan Roese <s...@denx.de> Wolfgang, feel free to pull this directly if you like. Cheers, Stefan -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: off...@denx.de _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot