From bda9cd70a702b652de318b369ef7b55202fbf49b Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 3 Feb 2020 19:30:27 +0900 Subject: [PATCH] uniphier: make NAND controller base address configurable The next SoC does not support the NAND controller, but make the base address configurable for consistency and future proof. Change-Id: I776e43ff2b0408577919b0b72849c3e1e5ce0758 Signed-off-by: Masahiro Yamada --- plat/socionext/uniphier/uniphier.h | 3 ++- plat/socionext/uniphier/uniphier_io_storage.c | 4 ++-- plat/socionext/uniphier/uniphier_nand.c | 18 +++++++++++++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/plat/socionext/uniphier/uniphier.h b/plat/socionext/uniphier/uniphier.h index 8d5aa86ac..808b850d6 100644 --- a/plat/socionext/uniphier/uniphier.h +++ b/plat/socionext/uniphier/uniphier.h @@ -40,7 +40,8 @@ void uniphier_console_setup(void); struct io_block_dev_spec; int uniphier_emmc_init(unsigned int soc, struct io_block_dev_spec **block_dev_spec); -int uniphier_nand_init(struct io_block_dev_spec **block_dev_spec); +int uniphier_nand_init(unsigned int soc, + struct io_block_dev_spec **block_dev_spec); int uniphier_usb_init(unsigned int soc, struct io_block_dev_spec **block_dev_spec); diff --git a/plat/socionext/uniphier/uniphier_io_storage.c b/plat/socionext/uniphier/uniphier_io_storage.c index b2e2c5515..96180f159 100644 --- a/plat/socionext/uniphier/uniphier_io_storage.c +++ b/plat/socionext/uniphier/uniphier_io_storage.c @@ -261,12 +261,12 @@ static int uniphier_io_emmc_setup(unsigned int soc, size_t buffer_offset) return uniphier_io_block_setup(0x20000, block_dev_spec, buffer_offset); } -static int uniphier_io_nand_setup(unsigned int soc_id, size_t buffer_offset) +static int uniphier_io_nand_setup(unsigned int soc, size_t buffer_offset) { struct io_block_dev_spec *block_dev_spec; int ret; - ret = uniphier_nand_init(&block_dev_spec); + ret = uniphier_nand_init(soc, &block_dev_spec); if (ret) return ret; diff --git a/plat/socionext/uniphier/uniphier_nand.c b/plat/socionext/uniphier/uniphier_nand.c index 3925177ed..71cb96c0a 100644 --- a/plat/socionext/uniphier/uniphier_nand.c +++ b/plat/socionext/uniphier/uniphier_nand.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include #include #include @@ -237,8 +238,7 @@ static int uniphier_nand_hw_init(struct uniphier_nand *nand) for (i = 0; i < ARRAY_SIZE(nand->bbt); i++) nand->bbt[i] = UNIPHIER_NAND_BBT_UNKNOWN; - nand->host_base = 0x68000000; - nand->reg_base = 0x68100000; + nand->reg_base = nand->host_base + 0x100000; nand->pages_per_block = mmio_read_32(nand->reg_base + DENALI_PAGES_PER_BLOCK); @@ -255,10 +255,22 @@ static int uniphier_nand_hw_init(struct uniphier_nand *nand) return 0; } -int uniphier_nand_init(struct io_block_dev_spec **block_dev_spec) +static const uintptr_t uniphier_nand_base[] = { + [UNIPHIER_SOC_LD11] = 0x68000000, + [UNIPHIER_SOC_LD20] = 0x68000000, + [UNIPHIER_SOC_PXS3] = 0x68000000, +}; + +int uniphier_nand_init(unsigned int soc, + struct io_block_dev_spec **block_dev_spec) { int ret; + assert(soc < ARRAY_SIZE(uniphier_nand_base)); + uniphier_nand.host_base = uniphier_nand_base[soc]; + if (!uniphier_nand.host_base) + return -ENOTSUP; + ret = uniphier_nand_hw_init(&uniphier_nand); if (ret) return ret;