public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/5] cfi_flash: handle 'chip size exceeds address window' situation
Date: Fri, 22 Oct 2010 12:39:35 +0200	[thread overview]
Message-ID: <201010221239.36387.sr@denx.de> (raw)
In-Reply-To: <1287674413-3900-5-git-send-email-yanok@emcraft.com>

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 <yanok@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 <sr@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: office at denx.de

  parent reply	other threads:[~2010-10-22 10:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-21 15:20 [U-Boot] Various clean-ups for a4m072 board support Ilya Yanok
2010-10-21 15:20 ` [U-Boot] [PATCH 1/5] a4m072: changes to the default environment Ilya Yanok
2010-10-23 19:27   ` Wolfgang Denk
2010-10-21 15:20 ` [U-Boot] [PATCH 2/5] a4m072: change 'display' command implementation Ilya Yanok
2010-10-23 19:28   ` Wolfgang Denk
2010-10-21 15:20 ` [U-Boot] [PATCH 3/5] led_display: remove unused DISPLAY_MARK define Ilya Yanok
2010-10-23 19:28   ` Wolfgang Denk
2010-10-21 15:20 ` [U-Boot] [PATCH 4/5] cfi_flash: handle 'chip size exceeds address window' situation Ilya Yanok
2010-10-21 20:19   ` Wolfgang Denk
2010-10-22 10:39   ` Stefan Roese [this message]
2010-10-23 19:27     ` Wolfgang Denk
2010-10-23 19:38   ` Wolfgang Denk
2010-10-21 15:20 ` [U-Boot] [PATCH 5/5] a4m072: add CONFIG_SYS_FLASH_BANKS_SIZES define Ilya Yanok
2010-10-23 19:39   ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201010221239.36387.sr@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox