ppc4xx/fdt/flash: Change fdt_fixup_nor_flash_node() to not rely on cs size
PATCH v2 1/1 ppc4xx/fdt/flash: Change fdt_fixup_nor_flash_node() to not rely on cs size
This patch changes the behaviour of the fdt_fixup_nor_flash_node() function. Now it doesn't patch the size of the "reg" property with the chip-select size, but with the size returned from the new function flash_get_bank_size(). This function will return per weak default the flash size of the bank (bank = chip-select numer) detected by the flash driver. If this does not fit your needs, this function may be overridden by a board specific one.
For this the parameters needed to be changed. So I intentionally squashed the PPC4xx stuff using this routine into this patch. Otherwise it would not be git-bisectable anymore.
The board specific function for the AMCC/APM Ebony eval board is now included in this patch version.
ppc4xx: Add board specific function to return the detected flash size
This function will be called to fixup size of the "reg" property of the NOR flash device tree nodes. Ebony can't use the weak default, since it has a special chip-select to bank-number binding.
---
v2:
- Ebony's board specific function squashed into this patch
arch/powerpc/cpu/ppc4xx/fdt.c | 10 ++++---- board/amcc/ebony/flash.c | 31 +++++++++++++++++++++++++ common/fdt_support.c | 51 +++++++++++++++++++++++++++++++++-------- include/fdt_support.h | 2 +- 4 files changed, 78 insertions(+), 16 deletions(-)
arch/powerpc/cpu/ppc4xx/fdt.c +5 -5
@@ -59,14 +59,14 @@ void __ft_board_setup(void *blob, bd_t *bd) *p++ =0 ; *p++ = bxcr &EBC_BXCR_BAS_MASK ; *p++ =EBC_BXCR_BANK_SIZE (bxcr); + } + } +#ifdef CONFIG_FDT_FIXUP_NOR_FLASH_SIZE -/* Try to update reg property in nor flash node too */ -fdt_fixup_nor_flash_size (blob, i, -EBC_BXCR_BANK_SIZE (bxcr)); +/* Update reg property in all nor flash nodes too */ +fdt_fixup_nor_flash_size (blob);#endif - } - }/* Some 405 PPC's have EBC as direct PLB child in the dts */ if (fdt_path_offset (blob, ebc_path) <0 )
board/amcc/ebony/flash.c +31 -0
@@ -34,6 +34,7 @@#include <common.h> #include <ppc4xx.h> #include <asm/processor.h> +#include <asm/io.h> #undef DEBUG#ifdef DEBUG
@@ -71,6 +72,36 @@ static unsigned long flash_addr_table[8][CONFIG_SYS_MAX_FLASH_BANKS] = {*/ static ulong flash_get_size (vu_long * addr,flash_info_t * info); +/* +* Override the weak default mapping function with a board specific one +*/ +u32 flash_get_bank_size (int cs,int idx) +{ +u8 reg =in_8 ((void *)CONFIG_SYS_FPGA_BASE ); + +if ((reg &BOOT_SMALL_FLASH ) && !(reg &FLASH_ONBD_N )) { +/* +* cs0: small flash (512KiB) +* cs2: 2 * big flash (2 * 2MiB) +*/ +if (cs ==0 ) +return flash_info[2 ].size; +if (cs ==2 ) +return flash_info[0 ].size + flash_info[1 ].size; + }else { +/* +* cs0: 2 * big flash (2 * 2MiB) +* cs2: small flash (512KiB) +*/ +if (cs ==0 ) +return flash_info[0 ].size + flash_info[1 ].size; +if (cs ==2 ) +return flash_info[2 ].size; + } + +return 0 ; +} +unsigned long flash_init (void ) {unsigned long total_b =0 ;
common/fdt_support.c +41 -10
84 lines not on this page · raw message
include/fdt_support.h +1 -1
@@ -79,7 +79,7 @@ void ft_pci_setup(void *blob, bd_t *bd);void set_working_fdt_addr (void *addr);int fdt_resize (void *blob); -int fdt_fixup_nor_flash_size (void *blob,int cs,u32 size); +int fdt_fixup_nor_flash_size (void *blob);void fdt_fixup_mtdparts (void *fdt,void *node_info,int node_info_size);void fdt_del_node_and_alias (void *blob,const char *alias);
Signature · 1 line
1.7.3