From 4a70d2622377fd04cd72d1da568acf71d23e02b6 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 12 Aug 2016 19:19:03 +0900 Subject: [PATCH 01/11] mmc: uniphier-sd: add static qualifiers to probe and remove callbacks They are both only referenced in this file. Signed-off-by: Masahiro Yamada --- drivers/mmc/uniphier-sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c index 2a4837840a..f06e737295 100644 --- a/drivers/mmc/uniphier-sd.c +++ b/drivers/mmc/uniphier-sd.c @@ -646,7 +646,7 @@ static const struct mmc_ops uniphier_sd_ops = { .getcd = uniphier_sd_getcd, }; -int uniphier_sd_probe(struct udevice *dev) +static int uniphier_sd_probe(struct udevice *dev) { struct uniphier_sd_priv *priv = dev_get_priv(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); @@ -731,7 +731,7 @@ int uniphier_sd_probe(struct udevice *dev) return 0; } -int uniphier_sd_remove(struct udevice *dev) +static int uniphier_sd_remove(struct udevice *dev) { struct uniphier_sd_priv *priv = dev_get_priv(dev); From 3937404f8b80eb482661a182ebb774e96356c607 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 25 Aug 2016 14:52:35 +0900 Subject: [PATCH 02/11] mmc: uniphier-sd: migrate to CONFIG_DM_MMC_OPS Catch up with the DM migration. As struct dm_mmc_ops does not have .init callback, call the init function directly from the probe function. Signed-off-by: Masahiro Yamada --- drivers/mmc/Kconfig | 1 + drivers/mmc/uniphier-sd.c | 97 ++++++++++++++++++++------------------- 2 files changed, 51 insertions(+), 47 deletions(-) diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index 3616deedf3..a71afa59be 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -80,6 +80,7 @@ config ROCKCHIP_SDHCI config MMC_UNIPHIER bool "UniPhier SD/MMC Host Controller support" depends on ARCH_UNIPHIER + select DM_MMC_OPS help This selects support for the SD/MMC Host Controller on UniPhier SoCs. diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c index f06e737295..b8e784f59c 100644 --- a/drivers/mmc/uniphier-sd.c +++ b/drivers/mmc/uniphier-sd.c @@ -122,7 +122,6 @@ DECLARE_GLOBAL_DATA_PTR; struct uniphier_sd_priv { struct mmc_config cfg; struct mmc *mmc; - struct udevice *dev; void __iomem *regbase; unsigned long mclk; unsigned int version; @@ -152,8 +151,9 @@ static void __dma_unmap_single(dma_addr_t addr, size_t size, invalidate_dcache_range(addr, addr + size); } -static int uniphier_sd_check_error(struct uniphier_sd_priv *priv) +static int uniphier_sd_check_error(struct udevice *dev) { + struct uniphier_sd_priv *priv = dev_get_priv(dev); u32 info2 = readl(priv->regbase + UNIPHIER_SD_INFO2); if (info2 & UNIPHIER_SD_INFO2_ERR_RTO) { @@ -166,38 +166,39 @@ static int uniphier_sd_check_error(struct uniphier_sd_priv *priv) } if (info2 & UNIPHIER_SD_INFO2_ERR_TO) { - dev_err(priv->dev, "timeout error\n"); + dev_err(dev, "timeout error\n"); return -ETIMEDOUT; } if (info2 & (UNIPHIER_SD_INFO2_ERR_END | UNIPHIER_SD_INFO2_ERR_CRC | UNIPHIER_SD_INFO2_ERR_IDX)) { - dev_err(priv->dev, "communication out of sync\n"); + dev_err(dev, "communication out of sync\n"); return -EILSEQ; } if (info2 & (UNIPHIER_SD_INFO2_ERR_ILA | UNIPHIER_SD_INFO2_ERR_ILR | UNIPHIER_SD_INFO2_ERR_ILW)) { - dev_err(priv->dev, "illegal access\n"); + dev_err(dev, "illegal access\n"); return -EIO; } return 0; } -static int uniphier_sd_wait_for_irq(struct uniphier_sd_priv *priv, - unsigned int reg, u32 flag) +static int uniphier_sd_wait_for_irq(struct udevice *dev, unsigned int reg, + u32 flag) { + struct uniphier_sd_priv *priv = dev_get_priv(dev); long wait = 1000000; int ret; while (!(readl(priv->regbase + reg) & flag)) { if (wait-- < 0) { - dev_err(priv->dev, "timeout\n"); + dev_err(dev, "timeout\n"); return -ETIMEDOUT; } - ret = uniphier_sd_check_error(priv); + ret = uniphier_sd_check_error(dev); if (ret) return ret; @@ -207,14 +208,14 @@ static int uniphier_sd_wait_for_irq(struct uniphier_sd_priv *priv, return 0; } -static int uniphier_sd_pio_read_one_block(struct mmc *mmc, u32 **pbuf, +static int uniphier_sd_pio_read_one_block(struct udevice *dev, u32 **pbuf, uint blocksize) { - struct uniphier_sd_priv *priv = mmc->priv; + struct uniphier_sd_priv *priv = dev_get_priv(dev); int i, ret; /* wait until the buffer is filled with data */ - ret = uniphier_sd_wait_for_irq(priv, UNIPHIER_SD_INFO2, + ret = uniphier_sd_wait_for_irq(dev, UNIPHIER_SD_INFO2, UNIPHIER_SD_INFO2_BRE); if (ret) return ret; @@ -237,14 +238,14 @@ static int uniphier_sd_pio_read_one_block(struct mmc *mmc, u32 **pbuf, return 0; } -static int uniphier_sd_pio_write_one_block(struct mmc *mmc, const u32 **pbuf, - uint blocksize) +static int uniphier_sd_pio_write_one_block(struct udevice *dev, + const u32 **pbuf, uint blocksize) { - struct uniphier_sd_priv *priv = mmc->priv; + struct uniphier_sd_priv *priv = dev_get_priv(dev); int i, ret; /* wait until the buffer becomes empty */ - ret = uniphier_sd_wait_for_irq(priv, UNIPHIER_SD_INFO2, + ret = uniphier_sd_wait_for_irq(dev, UNIPHIER_SD_INFO2, UNIPHIER_SD_INFO2_BWE); if (ret) return ret; @@ -263,7 +264,7 @@ static int uniphier_sd_pio_write_one_block(struct mmc *mmc, const u32 **pbuf, return 0; } -static int uniphier_sd_pio_xfer(struct mmc *mmc, struct mmc_data *data) +static int uniphier_sd_pio_xfer(struct udevice *dev, struct mmc_data *data) { u32 *dest = (u32 *)data->dest; const u32 *src = (const u32 *)data->src; @@ -271,10 +272,10 @@ static int uniphier_sd_pio_xfer(struct mmc *mmc, struct mmc_data *data) for (i = 0; i < data->blocks; i++) { if (data->flags & MMC_DATA_READ) - ret = uniphier_sd_pio_read_one_block(mmc, &dest, + ret = uniphier_sd_pio_read_one_block(dev, &dest, data->blocksize); else - ret = uniphier_sd_pio_write_one_block(mmc, &src, + ret = uniphier_sd_pio_write_one_block(dev, &src, data->blocksize); if (ret) return ret; @@ -306,14 +307,15 @@ static void uniphier_sd_dma_start(struct uniphier_sd_priv *priv, writel(UNIPHIER_SD_DMA_CTL_START, priv->regbase + UNIPHIER_SD_DMA_CTL); } -static int uniphier_sd_dma_wait_for_irq(struct uniphier_sd_priv *priv, u32 flag, +static int uniphier_sd_dma_wait_for_irq(struct udevice *dev, u32 flag, unsigned int blocks) { + struct uniphier_sd_priv *priv = dev_get_priv(dev); long wait = 1000000 + 10 * blocks; while (!(readl(priv->regbase + UNIPHIER_SD_DMA_INFO1) & flag)) { if (wait-- < 0) { - dev_err(priv->dev, "timeout during DMA\n"); + dev_err(dev, "timeout during DMA\n"); return -ETIMEDOUT; } @@ -321,16 +323,16 @@ static int uniphier_sd_dma_wait_for_irq(struct uniphier_sd_priv *priv, u32 flag, } if (readl(priv->regbase + UNIPHIER_SD_DMA_INFO2)) { - dev_err(priv->dev, "error during DMA\n"); + dev_err(dev, "error during DMA\n"); return -EIO; } return 0; } -static int uniphier_sd_dma_xfer(struct mmc *mmc, struct mmc_data *data) +static int uniphier_sd_dma_xfer(struct udevice *dev, struct mmc_data *data) { - struct uniphier_sd_priv *priv = mmc->priv; + struct uniphier_sd_priv *priv = dev_get_priv(dev); size_t len = data->blocks * data->blocksize; void *buf; enum dma_data_direction dir; @@ -358,7 +360,7 @@ static int uniphier_sd_dma_xfer(struct mmc *mmc, struct mmc_data *data) uniphier_sd_dma_start(priv, dma_addr); - ret = uniphier_sd_dma_wait_for_irq(priv, poll_flag, data->blocks); + ret = uniphier_sd_dma_wait_for_irq(dev, poll_flag, data->blocks); __dma_unmap_single(dma_addr, len, dir); @@ -384,15 +386,15 @@ static bool uniphier_sd_addr_is_dmaable(unsigned long addr) return true; } -static int uniphier_sd_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, +static int uniphier_sd_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data) { - struct uniphier_sd_priv *priv = mmc->priv; + struct uniphier_sd_priv *priv = dev_get_priv(dev); int ret; u32 tmp; if (readl(priv->regbase + UNIPHIER_SD_INFO2) & UNIPHIER_SD_INFO2_CBSY) { - dev_err(priv->dev, "command busy\n"); + dev_err(dev, "command busy\n"); return -EBUSY; } @@ -446,15 +448,15 @@ static int uniphier_sd_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, tmp |= UNIPHIER_SD_CMD_RSP_R3; break; default: - dev_err(priv->dev, "unknown response type\n"); + dev_err(dev, "unknown response type\n"); return -EINVAL; } - dev_dbg(priv->dev, "sending CMD%d (SD_CMD=%08x, SD_ARG=%08x)\n", + dev_dbg(dev, "sending CMD%d (SD_CMD=%08x, SD_ARG=%08x)\n", cmd->cmdidx, tmp, cmd->cmdarg); writel(tmp, priv->regbase + UNIPHIER_SD_CMD); - ret = uniphier_sd_wait_for_irq(priv, UNIPHIER_SD_INFO1, + ret = uniphier_sd_wait_for_irq(dev, UNIPHIER_SD_INFO1, UNIPHIER_SD_INFO1_RSP); if (ret) return ret; @@ -481,11 +483,11 @@ static int uniphier_sd_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, /* use DMA if the HW supports it and the buffer is aligned */ if (priv->caps & UNIPHIER_SD_CAP_DMA_INTERNAL && uniphier_sd_addr_is_dmaable((long)data->src)) - ret = uniphier_sd_dma_xfer(mmc, data); + ret = uniphier_sd_dma_xfer(dev, data); else - ret = uniphier_sd_pio_xfer(mmc, data); + ret = uniphier_sd_pio_xfer(dev, data); - ret = uniphier_sd_wait_for_irq(priv, UNIPHIER_SD_INFO1, + ret = uniphier_sd_wait_for_irq(dev, UNIPHIER_SD_INFO1, UNIPHIER_SD_INFO1_CMP); if (ret) return ret; @@ -581,11 +583,12 @@ static void uniphier_sd_set_clk_rate(struct uniphier_sd_priv *priv, writel(tmp, priv->regbase + UNIPHIER_SD_CLKCTL); } -static void uniphier_sd_set_ios(struct mmc *mmc) +static int uniphier_sd_set_ios(struct udevice *dev) { - struct uniphier_sd_priv *priv = mmc->priv; + struct uniphier_sd_priv *priv = dev_get_priv(dev); + struct mmc *mmc = mmc_get_mmc_dev(dev); - dev_dbg(priv->dev, "clock %uHz, DDRmode %d, width %u\n", + dev_dbg(dev, "clock %uHz, DDRmode %d, width %u\n", mmc->clock, mmc->ddr_mode, mmc->bus_width); uniphier_sd_set_bus_width(priv, mmc); @@ -593,11 +596,12 @@ static void uniphier_sd_set_ios(struct mmc *mmc) uniphier_sd_set_clk_rate(priv, mmc); udelay(1000); + + return 0; } -static int uniphier_sd_init(struct mmc *mmc) +static int uniphier_sd_init(struct uniphier_sd_priv *priv) { - struct uniphier_sd_priv *priv = mmc->priv; u32 tmp; /* soft reset of the host */ @@ -628,9 +632,9 @@ static int uniphier_sd_init(struct mmc *mmc) return 0; } -static int uniphier_sd_getcd(struct mmc *mmc) +static int uniphier_sd_get_cd(struct udevice *dev) { - struct uniphier_sd_priv *priv = mmc->priv; + struct uniphier_sd_priv *priv = dev_get_priv(dev); if (priv->caps & UNIPHIER_SD_CAP_NONREMOVABLE) return 1; @@ -639,11 +643,10 @@ static int uniphier_sd_getcd(struct mmc *mmc) UNIPHIER_SD_INFO1_CD); } -static const struct mmc_ops uniphier_sd_ops = { +static const struct dm_mmc_ops uniphier_sd_ops = { .send_cmd = uniphier_sd_send_cmd, .set_ios = uniphier_sd_set_ios, - .init = uniphier_sd_init, - .getcd = uniphier_sd_getcd, + .get_cd = uniphier_sd_get_cd, }; static int uniphier_sd_probe(struct udevice *dev) @@ -654,8 +657,6 @@ static int uniphier_sd_probe(struct udevice *dev) struct clk clk; int ret; - priv->dev = dev; - base = dev_get_addr(dev); if (base == FDT_ADDR_T_NONE) return -EINVAL; @@ -686,7 +687,6 @@ static int uniphier_sd_probe(struct udevice *dev) } priv->cfg.name = dev->name; - priv->cfg.ops = &uniphier_sd_ops; priv->cfg.host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS; switch (fdtdec_get_int(gd->fdt_blob, dev->of_offset, "bus-width", 1)) { @@ -715,6 +715,8 @@ static int uniphier_sd_probe(struct udevice *dev) priv->caps |= UNIPHIER_SD_CAP_DIV1024; } + uniphier_sd_init(priv); + priv->cfg.voltages = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34; priv->cfg.f_min = priv->mclk / (priv->caps & UNIPHIER_SD_CAP_DIV1024 ? 1024 : 512); @@ -752,4 +754,5 @@ U_BOOT_DRIVER(uniphier_mmc) = { .probe = uniphier_sd_probe, .remove = uniphier_sd_remove, .priv_auto_alloc_size = sizeof(struct uniphier_sd_priv), + .ops = &uniphier_sd_ops, }; From 4eb008460cf4b9da316d97874a32680209324107 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 25 Aug 2016 14:52:36 +0900 Subject: [PATCH 03/11] mmc: uniphier-sd: move uniphier_sd_init() below No more reason to define this function above the ops structure. Move it near the caller. Also, change its return type to void because it never fails. Signed-off-by: Masahiro Yamada --- drivers/mmc/uniphier-sd.c | 40 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c index b8e784f59c..b254c70857 100644 --- a/drivers/mmc/uniphier-sd.c +++ b/drivers/mmc/uniphier-sd.c @@ -600,7 +600,24 @@ static int uniphier_sd_set_ios(struct udevice *dev) return 0; } -static int uniphier_sd_init(struct uniphier_sd_priv *priv) +static int uniphier_sd_get_cd(struct udevice *dev) +{ + struct uniphier_sd_priv *priv = dev_get_priv(dev); + + if (priv->caps & UNIPHIER_SD_CAP_NONREMOVABLE) + return 1; + + return !!(readl(priv->regbase + UNIPHIER_SD_INFO1) & + UNIPHIER_SD_INFO1_CD); +} + +static const struct dm_mmc_ops uniphier_sd_ops = { + .send_cmd = uniphier_sd_send_cmd, + .set_ios = uniphier_sd_set_ios, + .get_cd = uniphier_sd_get_cd, +}; + +static void uniphier_sd_host_init(struct uniphier_sd_priv *priv) { u32 tmp; @@ -628,27 +645,8 @@ static int uniphier_sd_init(struct uniphier_sd_priv *priv) tmp |= UNIPHIER_SD_DMA_MODE_ADDR_INC; writel(tmp, priv->regbase + UNIPHIER_SD_DMA_MODE); } - - return 0; } -static int uniphier_sd_get_cd(struct udevice *dev) -{ - struct uniphier_sd_priv *priv = dev_get_priv(dev); - - if (priv->caps & UNIPHIER_SD_CAP_NONREMOVABLE) - return 1; - - return !!(readl(priv->regbase + UNIPHIER_SD_INFO1) & - UNIPHIER_SD_INFO1_CD); -} - -static const struct dm_mmc_ops uniphier_sd_ops = { - .send_cmd = uniphier_sd_send_cmd, - .set_ios = uniphier_sd_set_ios, - .get_cd = uniphier_sd_get_cd, -}; - static int uniphier_sd_probe(struct udevice *dev) { struct uniphier_sd_priv *priv = dev_get_priv(dev); @@ -715,7 +713,7 @@ static int uniphier_sd_probe(struct udevice *dev) priv->caps |= UNIPHIER_SD_CAP_DIV1024; } - uniphier_sd_init(priv); + uniphier_sd_host_init(priv); priv->cfg.voltages = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34; priv->cfg.f_min = priv->mclk / From 8be12e28394efce2844e0a08e8c6e38e60f36d31 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 25 Aug 2016 14:52:37 +0900 Subject: [PATCH 04/11] mmc: uniphier-sd: return error code if unsupported width is given With the CONFIG_DM_MMC_OPS migration, the .set_ios callback can return an integer now. Return an appropriate error value rather than sudden death by BUG(). Signed-off-by: Masahiro Yamada --- drivers/mmc/uniphier-sd.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c index b254c70857..40a5c85e37 100644 --- a/drivers/mmc/uniphier-sd.c +++ b/drivers/mmc/uniphier-sd.c @@ -496,8 +496,8 @@ static int uniphier_sd_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, return ret; } -static void uniphier_sd_set_bus_width(struct uniphier_sd_priv *priv, - struct mmc *mmc) +static int uniphier_sd_set_bus_width(struct uniphier_sd_priv *priv, + struct mmc *mmc) { u32 val, tmp; @@ -512,14 +512,15 @@ static void uniphier_sd_set_bus_width(struct uniphier_sd_priv *priv, val = UNIPHIER_SD_OPTION_WIDTH_8; break; default: - BUG(); - break; + return -EINVAL; } tmp = readl(priv->regbase + UNIPHIER_SD_OPTION); tmp &= ~UNIPHIER_SD_OPTION_WIDTH_MASK; tmp |= val; writel(tmp, priv->regbase + UNIPHIER_SD_OPTION); + + return 0; } static void uniphier_sd_set_ddr_mode(struct uniphier_sd_priv *priv, @@ -587,11 +588,14 @@ static int uniphier_sd_set_ios(struct udevice *dev) { struct uniphier_sd_priv *priv = dev_get_priv(dev); struct mmc *mmc = mmc_get_mmc_dev(dev); + int ret; dev_dbg(dev, "clock %uHz, DDRmode %d, width %u\n", mmc->clock, mmc->ddr_mode, mmc->bus_width); - uniphier_sd_set_bus_width(priv, mmc); + ret = uniphier_sd_set_bus_width(priv, mmc); + if (ret) + return ret; uniphier_sd_set_ddr_mode(priv, mmc); uniphier_sd_set_clk_rate(priv, mmc); From 4a89a24e26670921614a83098e5c0692de2be86e Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 25 Aug 2016 14:52:38 +0900 Subject: [PATCH 05/11] mmc: uniphier-sd: just return if already set to desired clock rate With this, we can save unnecessary udelay(). Signed-off-by: Masahiro Yamada --- drivers/mmc/uniphier-sd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c index 40a5c85e37..701b26f44c 100644 --- a/drivers/mmc/uniphier-sd.c +++ b/drivers/mmc/uniphier-sd.c @@ -571,6 +571,9 @@ static void uniphier_sd_set_clk_rate(struct uniphier_sd_priv *priv, val = UNIPHIER_SD_CLKCTL_DIV1024; tmp = readl(priv->regbase + UNIPHIER_SD_CLKCTL); + if (tmp & UNIPHIER_SD_CLKCTL_SCLKEN && + (tmp & UNIPHIER_SD_CLKCTL_DIV_MASK) == val) + return; /* stop the clock before changing its rate to avoid a glitch signal */ tmp &= ~UNIPHIER_SD_CLKCTL_SCLKEN; @@ -582,6 +585,8 @@ static void uniphier_sd_set_clk_rate(struct uniphier_sd_priv *priv, tmp |= UNIPHIER_SD_CLKCTL_SCLKEN; writel(tmp, priv->regbase + UNIPHIER_SD_CLKCTL); + + udelay(1000); } static int uniphier_sd_set_ios(struct udevice *dev) @@ -599,8 +604,6 @@ static int uniphier_sd_set_ios(struct udevice *dev) uniphier_sd_set_ddr_mode(priv, mmc); uniphier_sd_set_clk_rate(priv, mmc); - udelay(1000); - return 0; } From 928f3248b3e81a9fdaa818cf3aa02e5daef7015d Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 25 Aug 2016 21:03:41 +0900 Subject: [PATCH 06/11] ARM: uniphier: support system reset functionality for PSCI This supports the system reset via PSCI for ARMv7 SoCs. Because the system reset is not supported on PSCI 0.1, let's define CONFIG_ARMV7_PSCI_1_0. (it is supported since PSCI 0.2, but there is no CONFIG to enable it in U-Boot for now.) Signed-off-by: Masahiro Yamada --- arch/arm/mach-uniphier/arm32/psci.c | 5 +++++ arch/arm/mach-uniphier/reset.c | 14 ++++++++++++-- include/configs/uniphier.h | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-uniphier/arm32/psci.c b/arch/arm/mach-uniphier/arm32/psci.c index 633a3e0840..e6682657be 100644 --- a/arch/arm/mach-uniphier/arm32/psci.c +++ b/arch/arm/mach-uniphier/arm32/psci.c @@ -151,3 +151,8 @@ int __secure psci_cpu_on(u32 function_id, u32 cpuid, u32 entry_point) return PSCI_RET_SUCCESS; } + +void __secure psci_system_reset(u32 function_id) +{ + reset_cpu(0); +} diff --git a/arch/arm/mach-uniphier/reset.c b/arch/arm/mach-uniphier/reset.c index b5825bc0c7..43e27d12c3 100644 --- a/arch/arm/mach-uniphier/reset.c +++ b/arch/arm/mach-uniphier/reset.c @@ -1,15 +1,25 @@ /* - * Copyright (C) 2012-2015 Masahiro Yamada + * Copyright (C) 2012-2014 Panasonic Corporation + * Copyright (C) 2015-2016 Socionext Inc. + * Author: Masahiro Yamada * * SPDX-License-Identifier: GPL-2.0+ */ #include #include +#include #include "sc-regs.h" -void reset_cpu(unsigned long ignored) +/* If PSCI is enabled, this is used for SYSTEM_RESET function */ +#ifdef CONFIG_ARMV7_PSCI +#define __SECURE __secure +#else +#define __SECURE +#endif + +void __SECURE reset_cpu(unsigned long ignored) { u32 tmp; diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index 0f5b20ff48..184704bbf8 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -12,6 +12,7 @@ #define __CONFIG_UNIPHIER_COMMON_H__ #define CONFIG_ARMV7_PSCI +#define CONFIG_ARMV7_PSCI_1_0 #define CONFIG_ARMV7_PSCI_NR_CPUS 4 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 10 From 499c8679be13383c44a1f277d5b0d7c63b6b2008 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 25 Aug 2016 17:02:31 +0900 Subject: [PATCH 07/11] ARM: uniphier: display revision of Micro Support Card 3.6.x kindly The revision of the original support card (rev 3.5, rev 3.6) fits in the 8 bit width revision register. When it was extended in a weird way, it was versioned in the format of "3.6.x" (where it should have been "3.7", of course). What is worse, only the sub-level version "6.x" was recorded in the 8 bit width register, completely ignoring the compatibility of the revision register format. This patch saves madly-versioned support cards by assuming the major version "3" when the MSB 4 bit of the register is read as "6". With this, the support card revision that were displayed as "6.10" is now corrected to "3.6.10". Signed-off-by: Masahiro Yamada --- arch/arm/mach-uniphier/micro-support-card.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-uniphier/micro-support-card.c b/arch/arm/mach-uniphier/micro-support-card.c index eeb515aa00..6987d1e0f8 100644 --- a/arch/arm/mach-uniphier/micro-support-card.c +++ b/arch/arm/mach-uniphier/micro-support-card.c @@ -1,5 +1,7 @@ /* - * Copyright (C) 2012-2015 Masahiro Yamada + * Copyright (C) 2012-2015 Panasonic Corporation + * Copyright (C) 2015-2016 Socionext Inc. + * Author: Masahiro Yamada * * SPDX-License-Identifier: GPL-2.0+ */ @@ -38,7 +40,12 @@ static int support_card_show_revision(void) u32 revision; revision = readl(MICRO_SUPPORT_CARD_REVISION); - printf("(CPLD version %d.%d)\n", revision >> 4, revision & 0xf); + revision &= 0xff; + + /* revision 3.6.x card changed the revision format */ + printf("(CPLD version %s%d.%d)\n", revision >> 4 == 6 ? "3." : "", + revision >> 4, revision & 0xf); + return 0; } From e8811fc06c5191a8c54eb0d3a4e6abaa2f0f122b Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 25 Aug 2016 17:02:32 +0900 Subject: [PATCH 08/11] ARM: uniphier: increase CONFIG_SYS_MALLOC_F_LEN for sLD3 Commit 76c52ce29fd7 ("ARM: uniphier: increase CONFIG_SYS_MALLOC_F_LEN to bind all nodes") missed to increase this config for sLD3. This change is needed to add "u-boot,dm-pre-reloc" to some nodes; more devices are bound, more malloc memory is needed. Signed-off-by: Masahiro Yamada --- configs/uniphier_sld3_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/uniphier_sld3_defconfig b/configs/uniphier_sld3_defconfig index 598cde2106..4cbd01ceb6 100644 --- a/configs/uniphier_sld3_defconfig +++ b/configs/uniphier_sld3_defconfig @@ -1,5 +1,6 @@ CONFIG_ARM=y CONFIG_ARCH_UNIPHIER=y +CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_ARCH_UNIPHIER_SLD3=y CONFIG_MICRO_SUPPORT_CARD=y CONFIG_SYS_TEXT_BASE=0x84000000 From f0633533d55a0b488d14a08d6625785fe09f42c1 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 25 Aug 2016 17:02:33 +0900 Subject: [PATCH 09/11] ARM: dts: uniphier: add u-boot, dm-pre-reloc to use eMMC boot on sLD3 The eMMC on sLD3 is assigned with dedicated pins (only multiplexed with GPIO), so it shouldn't hurt to enable eMMC on SPL all the time. Signed-off-by: Masahiro Yamada --- arch/arm/dts/uniphier-ph1-sld3-ref.dts | 8 ++++++++ arch/arm/dts/uniphier-ph1-sld3.dtsi | 1 + 2 files changed, 9 insertions(+) diff --git a/arch/arm/dts/uniphier-ph1-sld3-ref.dts b/arch/arm/dts/uniphier-ph1-sld3-ref.dts index 099df83033..0863588d99 100644 --- a/arch/arm/dts/uniphier-ph1-sld3-ref.dts +++ b/arch/arm/dts/uniphier-ph1-sld3-ref.dts @@ -85,3 +85,11 @@ &serial0 { u-boot,dm-pre-reloc; }; + +&mio { + u-boot,dm-pre-reloc; +}; + +&emmc { + u-boot,dm-pre-reloc; +}; diff --git a/arch/arm/dts/uniphier-ph1-sld3.dtsi b/arch/arm/dts/uniphier-ph1-sld3.dtsi index c3adaf170b..6a95541311 100644 --- a/arch/arm/dts/uniphier-ph1-sld3.dtsi +++ b/arch/arm/dts/uniphier-ph1-sld3.dtsi @@ -61,6 +61,7 @@ #size-cells = <1>; ranges; interrupt-parent = <&intc>; + u-boot,dm-pre-reloc; timer@20000200 { compatible = "arm,cortex-a9-global-timer"; From 85dc2fe119657b1e02ff88345dced4f37e4bd174 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 25 Aug 2016 19:00:37 +0900 Subject: [PATCH 10/11] ARM: uniphier: change UNIPHIER_SERIAL to default y option This is very likely to be necessary for normal use cases. Set its default to 'y' for shorter defconfig files. Signed-off-by: Masahiro Yamada --- configs/uniphier_ld11_defconfig | 1 - configs/uniphier_ld20_defconfig | 1 - configs/uniphier_ld4_sld8_defconfig | 1 - configs/uniphier_pro4_defconfig | 1 - configs/uniphier_pxs2_ld6b_defconfig | 1 - configs/uniphier_sld3_defconfig | 1 - drivers/serial/Kconfig | 1 + 7 files changed, 1 insertion(+), 6 deletions(-) diff --git a/configs/uniphier_ld11_defconfig b/configs/uniphier_ld11_defconfig index 57b9c07c77..9b32d68617 100644 --- a/configs/uniphier_ld11_defconfig +++ b/configs/uniphier_ld11_defconfig @@ -25,7 +25,6 @@ CONFIG_MISC=y CONFIG_I2C_EEPROM=y CONFIG_PINCTRL=y CONFIG_SPL_PINCTRL=y -CONFIG_UNIPHIER_SERIAL=y CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/uniphier_ld20_defconfig b/configs/uniphier_ld20_defconfig index e6aa525ca5..7623381019 100644 --- a/configs/uniphier_ld20_defconfig +++ b/configs/uniphier_ld20_defconfig @@ -26,7 +26,6 @@ CONFIG_I2C_EEPROM=y CONFIG_MMC_UNIPHIER=y CONFIG_PINCTRL=y CONFIG_SPL_PINCTRL=y -CONFIG_UNIPHIER_SERIAL=y CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_STORAGE=y diff --git a/configs/uniphier_ld4_sld8_defconfig b/configs/uniphier_ld4_sld8_defconfig index 47b577af7c..f51e0da723 100644 --- a/configs/uniphier_ld4_sld8_defconfig +++ b/configs/uniphier_ld4_sld8_defconfig @@ -31,7 +31,6 @@ CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8 CONFIG_SPL_NAND_DENALI=y CONFIG_PINCTRL=y CONFIG_SPL_PINCTRL=y -CONFIG_UNIPHIER_SERIAL=y CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/uniphier_pro4_defconfig b/configs/uniphier_pro4_defconfig index e156ec533a..c47d02fc2a 100644 --- a/configs/uniphier_pro4_defconfig +++ b/configs/uniphier_pro4_defconfig @@ -30,7 +30,6 @@ CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8 CONFIG_SPL_NAND_DENALI=y CONFIG_PINCTRL=y CONFIG_SPL_PINCTRL=y -CONFIG_UNIPHIER_SERIAL=y CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_STORAGE=y diff --git a/configs/uniphier_pxs2_ld6b_defconfig b/configs/uniphier_pxs2_ld6b_defconfig index f943516a90..9eebad1776 100644 --- a/configs/uniphier_pxs2_ld6b_defconfig +++ b/configs/uniphier_pxs2_ld6b_defconfig @@ -31,7 +31,6 @@ CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8 CONFIG_SPL_NAND_DENALI=y CONFIG_PINCTRL=y CONFIG_SPL_PINCTRL=y -CONFIG_UNIPHIER_SERIAL=y CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_STORAGE=y diff --git a/configs/uniphier_sld3_defconfig b/configs/uniphier_sld3_defconfig index 4cbd01ceb6..6f31dd4cfc 100644 --- a/configs/uniphier_sld3_defconfig +++ b/configs/uniphier_sld3_defconfig @@ -29,7 +29,6 @@ CONFIG_NAND_DENALI=y CONFIG_SYS_NAND_DENALI_64BIT=y CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8 CONFIG_SPL_NAND_DENALI=y -CONFIG_UNIPHIER_SERIAL=y CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_EHCI_HCD=y diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 9ff7234d61..ab5df70bfc 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -344,6 +344,7 @@ config SANDBOX_SERIAL config UNIPHIER_SERIAL bool "Support for UniPhier on-chip UART" depends on ARCH_UNIPHIER + default y help If you have a UniPhier based board and want to use the on-chip serial ports, say Y to this option. If unsure, say N. From 8d11f804130d27a8f5ed6954f3a8a7f62a10ac45 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 28 Aug 2016 12:44:41 +0900 Subject: [PATCH 11/11] ARM: uniphier: enable CONFIG_CMD_CACHE This will be useful, for example, to load firmware to DRAM and make it visible to other agents. Signed-off-by: Masahiro Yamada --- configs/uniphier_ld11_defconfig | 1 + configs/uniphier_ld20_defconfig | 1 + configs/uniphier_ld4_sld8_defconfig | 1 + configs/uniphier_pro4_defconfig | 1 + configs/uniphier_pxs2_ld6b_defconfig | 1 + configs/uniphier_sld3_defconfig | 1 + 6 files changed, 6 insertions(+) diff --git a/configs/uniphier_ld11_defconfig b/configs/uniphier_ld11_defconfig index 9b32d68617..d593f1bfac 100644 --- a/configs/uniphier_ld11_defconfig +++ b/configs/uniphier_ld11_defconfig @@ -15,6 +15,7 @@ CONFIG_CMD_USB=y CONFIG_CMD_GPIO=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_PING=y +CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y # CONFIG_CMD_MISC is not set CONFIG_CMD_FAT=y diff --git a/configs/uniphier_ld20_defconfig b/configs/uniphier_ld20_defconfig index 7623381019..d6443fd04b 100644 --- a/configs/uniphier_ld20_defconfig +++ b/configs/uniphier_ld20_defconfig @@ -15,6 +15,7 @@ CONFIG_CMD_USB=y CONFIG_CMD_GPIO=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_PING=y +CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y # CONFIG_CMD_MISC is not set CONFIG_CMD_FAT=y diff --git a/configs/uniphier_ld4_sld8_defconfig b/configs/uniphier_ld4_sld8_defconfig index f51e0da723..6c9f0f4146 100644 --- a/configs/uniphier_ld4_sld8_defconfig +++ b/configs/uniphier_ld4_sld8_defconfig @@ -17,6 +17,7 @@ CONFIG_CMD_USB=y CONFIG_CMD_GPIO=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_PING=y +CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y # CONFIG_CMD_MISC is not set CONFIG_CMD_FAT=y diff --git a/configs/uniphier_pro4_defconfig b/configs/uniphier_pro4_defconfig index c47d02fc2a..d65da62828 100644 --- a/configs/uniphier_pro4_defconfig +++ b/configs/uniphier_pro4_defconfig @@ -16,6 +16,7 @@ CONFIG_CMD_USB=y CONFIG_CMD_GPIO=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_PING=y +CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y # CONFIG_CMD_MISC is not set CONFIG_CMD_FAT=y diff --git a/configs/uniphier_pxs2_ld6b_defconfig b/configs/uniphier_pxs2_ld6b_defconfig index 9eebad1776..e07a9ba09a 100644 --- a/configs/uniphier_pxs2_ld6b_defconfig +++ b/configs/uniphier_pxs2_ld6b_defconfig @@ -17,6 +17,7 @@ CONFIG_CMD_USB=y CONFIG_CMD_GPIO=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_PING=y +CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y # CONFIG_CMD_MISC is not set CONFIG_CMD_FAT=y diff --git a/configs/uniphier_sld3_defconfig b/configs/uniphier_sld3_defconfig index 6f31dd4cfc..6ce26bfacf 100644 --- a/configs/uniphier_sld3_defconfig +++ b/configs/uniphier_sld3_defconfig @@ -17,6 +17,7 @@ CONFIG_CMD_USB=y CONFIG_CMD_GPIO=y CONFIG_CMD_TFTPPUT=y CONFIG_CMD_PING=y +CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y # CONFIG_CMD_MISC is not set CONFIG_CMD_FAT=y