From 58d702274c09c8dc45c14141acd2c70bb578c5b2 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 20 Apr 2018 17:42:29 +0900 Subject: [PATCH 1/7] ARM: uniphier: increase CONFIG_SYS_MONITOR_LEN With the recent changes, the size of the U-Boot proper image for uniphier_v7_defconfig exceeded the current limit, 512KB, then SPL fails to load the whole of the U-Boot proper. Increase the size. Signed-off-by: Masahiro Yamada --- include/configs/uniphier.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index 1b4140de06..a00bfd97bd 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -33,7 +33,7 @@ #define CONFIG_SYS_MAX_FLASH_SECT 256 #define CONFIG_SYS_MONITOR_BASE 0 -#define CONFIG_SYS_MONITOR_LEN 0x00080000 /* 512KB */ +#define CONFIG_SYS_MONITOR_LEN 0x00090000 /* 576KB */ #define CONFIG_SYS_FLASH_BASE 0 /* From 30b5d9aa9aee9853b6b51d93ddf16d762d20c538 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 20 Apr 2018 18:14:24 +0900 Subject: [PATCH 2/7] mmc: tmio: move clk_enable() to each driver's probe function I need to differentiate the clock handling for uniphier-sd. Move it to each driver's probe function from the tmio common code so that renesas-sdhi will not be affected. Signed-off-by: Masahiro Yamada --- drivers/mmc/renesas-sdhi.c | 23 +++++++++++++++++++++++ drivers/mmc/tmio-common.c | 22 ---------------------- drivers/mmc/uniphier-sd.c | 25 +++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c index 56a43ca7d3..8e49b2f73c 100644 --- a/drivers/mmc/renesas-sdhi.c +++ b/drivers/mmc/renesas-sdhi.c @@ -330,8 +330,10 @@ static const struct udevice_id renesas_sdhi_match[] = { static int renesas_sdhi_probe(struct udevice *dev) { + struct tmio_sd_priv *priv = dev_get_priv(dev); u32 quirks = dev_get_driver_data(dev); struct fdt_resource reg_res; + struct clk clk; DECLARE_GLOBAL_DATA_PTR; int ret; @@ -348,6 +350,27 @@ static int renesas_sdhi_probe(struct udevice *dev) quirks |= TMIO_SD_CAP_16BIT; } + ret = clk_get_by_index(dev, 0, &clk); + if (ret < 0) { + dev_err(dev, "failed to get host clock\n"); + return ret; + } + + /* set to max rate */ + priv->mclk = clk_set_rate(&clk, ULONG_MAX); + if (IS_ERR_VALUE(priv->mclk)) { + dev_err(dev, "failed to set rate for host clock\n"); + clk_free(&clk); + return priv->mclk; + } + + ret = clk_enable(&clk); + clk_free(&clk); + if (ret) { + dev_err(dev, "failed to enable host clock\n"); + return ret; + } + ret = tmio_sd_probe(dev, quirks); #if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) if (!ret) diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c index 5f1c9c0bd4..4ea6612142 100644 --- a/drivers/mmc/tmio-common.c +++ b/drivers/mmc/tmio-common.c @@ -713,7 +713,6 @@ int tmio_sd_probe(struct udevice *dev, u32 quirks) struct tmio_sd_priv *priv = dev_get_priv(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); fdt_addr_t base; - struct clk clk; int ret; base = devfdt_get_addr(dev); @@ -728,27 +727,6 @@ int tmio_sd_probe(struct udevice *dev, u32 quirks) device_get_supply_regulator(dev, "vqmmc-supply", &priv->vqmmc_dev); #endif - ret = clk_get_by_index(dev, 0, &clk); - if (ret < 0) { - dev_err(dev, "failed to get host clock\n"); - return ret; - } - - /* set to max rate */ - priv->mclk = clk_set_rate(&clk, ULONG_MAX); - if (IS_ERR_VALUE(priv->mclk)) { - dev_err(dev, "failed to set rate for host clock\n"); - clk_free(&clk); - return priv->mclk; - } - - ret = clk_enable(&clk); - clk_free(&clk); - if (ret) { - dev_err(dev, "failed to enable host clock\n"); - return ret; - } - ret = mmc_of_parse(dev, &plat->cfg); if (ret < 0) { dev_err(dev, "failed to parse host caps\n"); diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c index 47379b0328..bc6e41dbf6 100644 --- a/drivers/mmc/uniphier-sd.c +++ b/drivers/mmc/uniphier-sd.c @@ -32,6 +32,31 @@ static const struct udevice_id uniphier_sd_match[] = { static int uniphier_sd_probe(struct udevice *dev) { + struct tmio_sd_priv *priv = dev_get_priv(dev); + struct clk clk; + int ret; + + ret = clk_get_by_index(dev, 0, &clk); + if (ret < 0) { + dev_err(dev, "failed to get host clock\n"); + return ret; + } + + /* set to max rate */ + priv->mclk = clk_set_rate(&clk, ULONG_MAX); + if (IS_ERR_VALUE(priv->mclk)) { + dev_err(dev, "failed to set rate for host clock\n"); + clk_free(&clk); + return priv->mclk; + } + + ret = clk_enable(&clk); + clk_free(&clk); + if (ret) { + dev_err(dev, "failed to enable host clock\n"); + return ret; + } + return tmio_sd_probe(dev, 0); } From fc2d0302b666cd127fca3a8a800f33841de11c41 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 20 Apr 2018 18:14:25 +0900 Subject: [PATCH 3/7] mmc: uniphier-sd: skip clock set-up for SPL The size of SPL is hitting the limit (64KB) for uniphier_v7_defconfig. When booting from SD/eMMC, obviously its clock has been properly set up by the boot ROM. Acutually, no need to re-initialize the clock in SPL. Using a clock driver would generalize the SoC specific code, but solving the memory footprint problem would win. Signed-off-by: Masahiro Yamada --- drivers/mmc/uniphier-sd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c index bc6e41dbf6..61f8da4e41 100644 --- a/drivers/mmc/uniphier-sd.c +++ b/drivers/mmc/uniphier-sd.c @@ -33,6 +33,7 @@ static const struct udevice_id uniphier_sd_match[] = { static int uniphier_sd_probe(struct udevice *dev) { struct tmio_sd_priv *priv = dev_get_priv(dev); +#ifndef CONFIG_SPL_BUILD struct clk clk; int ret; @@ -56,6 +57,9 @@ static int uniphier_sd_probe(struct udevice *dev) dev_err(dev, "failed to enable host clock\n"); return ret; } +#else + priv->mclk = 100000000; +#endif return tmio_sd_probe(dev, 0); } From 2a819b90858a1f5c3f9fd919b89fc9c6091264fb Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 20 Apr 2018 18:14:26 +0900 Subject: [PATCH 4/7] ARM: dts: uniphier: drop u-boot, dm-pre-reloc from SD/eMMC clock node Now that the SD/eMMC driver does not use the clock driver in SPL, remove u-boot,dm-pre-reloc properties to let the fdtgrep tool drop the unnecessary nodes. Signed-off-by: Masahiro Yamada --- arch/arm/dts/uniphier-v7-u-boot.dtsi | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/arch/arm/dts/uniphier-v7-u-boot.dtsi b/arch/arm/dts/uniphier-v7-u-boot.dtsi index 0094a455d2..9459bf0377 100644 --- a/arch/arm/dts/uniphier-v7-u-boot.dtsi +++ b/arch/arm/dts/uniphier-v7-u-boot.dtsi @@ -14,22 +14,6 @@ u-boot,dm-pre-reloc; }; - mioctrl@59810000 { - u-boot,dm-pre-reloc; - - clock { - u-boot,dm-pre-reloc; - }; - }; - - sdctrl@59810000 { - u-boot,dm-pre-reloc; - - clock { - u-boot,dm-pre-reloc; - }; - }; - soc-glue@5f800000 { u-boot,dm-pre-reloc; From 045e4fcb44cd040f0ebbdee3cb54d553a7168fd3 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 20 Apr 2018 18:14:27 +0900 Subject: [PATCH 5/7] clk: uniphier: disable SPL_CLK The last clock consumer in SPL, SD/eMMC driver, gave up using the clock driver. The clock driver is only used in U-Boot proper. Signed-off-by: Masahiro Yamada --- drivers/clk/uniphier/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/clk/uniphier/Kconfig b/drivers/clk/uniphier/Kconfig index 3666d8414c..a26ca8c1cd 100644 --- a/drivers/clk/uniphier/Kconfig +++ b/drivers/clk/uniphier/Kconfig @@ -2,7 +2,6 @@ config CLK_UNIPHIER def_bool y depends on ARCH_UNIPHIER select CLK - select SPL_CLK if SPL help Support for clock controllers on UniPhier SoCs. Say Y if you want to control clocks provided by System Control From fbe73dc88de4311f989b9d3c00b5cba9a2c5acb4 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 20 Apr 2018 18:38:27 +0900 Subject: [PATCH 6/7] ARM: uniphier: select a correct mmc device before flashing images Some boards support an SD card and an eMMC device at the same time. Since both belong to 'mmc', they are identified by a device number. When the device number of the eMMC is 1 instead 0, "mmc dev" command must be performed to switch the target device before flashing images. Signed-off-by: Masahiro Yamada --- include/configs/uniphier.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index a00bfd97bd..42c51fb4a2 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -186,6 +186,7 @@ "setexpr tmp_addr $nor_base + 0x70000 && " \ "tftpboot $tmp_addr $third_image\0" \ "emmcupdate=mmcsetn &&" \ + "mmc dev $mmc_first_dev &&" \ "mmc partconf $mmc_first_dev 0 1 1 &&" \ "tftpboot $second_image && " \ "mmc write $loadaddr 0 100 && " \ From 3ce5b1a8d86d46f4a390e31e52b7ba441fdb229e Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 23 Apr 2018 15:10:51 +0900 Subject: [PATCH 7/7] ARM: uniphier: move SPL stack address Currently, the address region, 0xf8000 - 0x100000, is used for SPL stack for the 32bit SoCs. Because the U-Boot proper image starts from 0x70000, the maximum size of the U-Boot proper image is 544KB (0x70000 - 0xf8000) for the NOR boot mode. Now uniphier_v7_defconfig is almost hitting this size limit. Changing CONFIG_SPL_STACK can raise the size limit with less impact. With this, the size limit will increase to 576KB (0x70000 - 0x100000). If we need to increase it even more, we would be able to change CONFIG_SYS_UBOOT_BASE at the cost of the flashing command changes. Signed-off-by: Masahiro Yamada --- include/configs/uniphier.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index 42c51fb4a2..c39f13bf6b 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -220,7 +220,7 @@ #define CONFIG_SPL_TEXT_BASE 0x00100000 #endif -#define CONFIG_SPL_STACK (0x00100000) +#define CONFIG_SPL_STACK (0x00200000) #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x20000