[U-Boot] [PATCH 0/3] ARM: uniphier: updates for v2017.03 MW

Masahiro Yamada (3): ARM: uniphier: do not use RAM that exceeds 32 bit address range ARM: uniphier: enable CONFIG_MMC_SDHCI_SDMA for ARMv8 SoCs ARM: uniphier: hide memory top by platform hook instead of CONFIG
arch/arm/mach-uniphier/dram_init.c | 24 ++++++++++++++++++++++++ configs/uniphier_v8_defconfig | 1 + include/configs/uniphier.h | 2 -- 3 files changed, 25 insertions(+), 2 deletions(-)

LD20 / PXs3 boards are equipped with a large amount of memory beyond the 32 bit address range. U-Boot relocates itself to the end of the available RAM.
This is a problem for DMA engines that only support 32 bit physical address, like the SDMA of SDHCI controllers.
In fact, U-Boot does not need to run at the very end of RAM. It is rather troublesome for drivers with DMA engines because U-Boot does not have API like dma_set_mask(), so DMA silently fails, making the driver debugging difficult.
Hide the memory region that exceeds the 32 bit address range. It can be done by simply carving out gd->ram_size. It would also possible to override get_effective_memsize() or to define CONFIG_MAX_MEM_MAPPED, but dram_init() is a good enough place to do this job.
Signed-off-by: Masahiro Yamada yamada.masahiro@socionext.com ---
arch/arm/mach-uniphier/dram_init.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
diff --git a/arch/arm/mach-uniphier/dram_init.c b/arch/arm/mach-uniphier/dram_init.c index e9672d2..cb35dab 100644 --- a/arch/arm/mach-uniphier/dram_init.c +++ b/arch/arm/mach-uniphier/dram_init.c @@ -205,6 +205,7 @@ int dram_init(void) return ret;
for (i = 0; i < ARRAY_SIZE(dram_map); i++) { + unsigned long max_size;
if (!dram_map[i].size) break; @@ -218,6 +219,22 @@ int dram_init(void) dram_map[i].base) break;
+ /* + * Do not use memory that exceeds 32bit address range. U-Boot + * relocates itself to the end of the effectively available RAM. + * This could be a problem for DMA engines that do not support + * 64bit address (SDMA of SDHCI, UniPhier AV-ether, etc.) + */ + if (dram_map[i].base >= 1ULL << 32) + break; + + max_size = (1ULL << 32) - dram_map[i].base; + + if (dram_map[i].size > max_size) { + gd->ram_size += max_size; + break; + } + gd->ram_size += dram_map[i].size; }

I did not enable SDMA when I added sdhci-cadence support because LD20 boards are equipped with a large amount memory beyond 32 bit address range, but SDMA does not support the 64bit address. U-Boot relocates itself to the end of effectively available RAM. This would make the MMC enumeration fail because the buffer for EXT_CSD allocated in the stack would go too high, then SDMA would fail to transfer data.
Recent SDHCI-compatible controllers support ADMA, but unfortunately U-Boot does not support ADMA.
In the previous commit, I hided the DRAM area that exceeds the 32 bit address range. Now, I can enable CONFIG_MMC_SDHCI_SDMA.
Signed-off-by: Masahiro Yamada yamada.masahiro@socionext.com ---
configs/uniphier_v8_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/uniphier_v8_defconfig b/configs/uniphier_v8_defconfig index bbcf3b0..2edc3a9 100644 --- a/configs/uniphier_v8_defconfig +++ b/configs/uniphier_v8_defconfig @@ -34,6 +34,7 @@ CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=10 CONFIG_MMC_UNIPHIER=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_CADENCE=y +CONFIG_MMC_SDHCI_SDMA=y CONFIG_NAND=y CONFIG_NAND_DENALI_DT=y CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8

I do not see a good reason to do this by a CONFIG option that affects all SoCs. The ram_size can be adjusted by dram_init() at run-time.
Signed-off-by: Masahiro Yamada yamada.masahiro@socionext.com ---
arch/arm/mach-uniphier/dram_init.c | 7 +++++++ include/configs/uniphier.h | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-uniphier/dram_init.c b/arch/arm/mach-uniphier/dram_init.c index cb35dab..f678114 100644 --- a/arch/arm/mach-uniphier/dram_init.c +++ b/arch/arm/mach-uniphier/dram_init.c @@ -238,6 +238,13 @@ int dram_init(void) gd->ram_size += dram_map[i].size; }
+ /* + * LD20 uses the last 64 byte for each channel for dynamic + * DDR PHY training + */ + if (uniphier_get_soc_id() == UNIPHIER_LD20_ID) + gd->ram_size -= 64; + return 0; }
diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index 12cbe9b..5ab06f6 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -215,8 +215,6 @@
#define CONFIG_SYS_SDRAM_BASE 0x80000000 #define CONFIG_NR_DRAM_BANKS 3 -/* for LD20; the last 64 byte is used for dynamic DDR PHY training */ -#define CONFIG_SYS_MEM_TOP_HIDE 64
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_TEXT_BASE)

2018-01-06 22:59 GMT+09:00 Masahiro Yamada yamada.masahiro@socionext.com:
Masahiro Yamada (3): ARM: uniphier: do not use RAM that exceeds 32 bit address range ARM: uniphier: enable CONFIG_MMC_SDHCI_SDMA for ARMv8 SoCs ARM: uniphier: hide memory top by platform hook instead of CONFIG
arch/arm/mach-uniphier/dram_init.c | 24 ++++++++++++++++++++++++ configs/uniphier_v8_defconfig | 1 + include/configs/uniphier.h | 2 -- 3 files changed, 25 insertions(+), 2 deletions(-)
Applied to u-boot-uniphier.
participants (1)
-
Masahiro Yamada