+// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2012-2015 Panasonic Corporation
* Copyright (C) 2015-2017 Socionext Inc.
* Author: Masahiro Yamada <yamada.masahiro@socionext.com>
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
-#include <fdt_support.h>
-#include <fdtdec.h>
#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/printk.h>
#include <linux/sizes.h>
+#include <asm/global_data.h>
#include "sg-regs.h"
#include "soc-info.h"
-#define pr_warn(fmt, args...) printf(fmt, ##args)
-#define pr_err(fmt, args...) printf(fmt, ##args)
-
DECLARE_GLOBAL_DATA_PTR;
struct uniphier_memif_data {
};
static const struct uniphier_memif_data uniphier_memif_data[] = {
- {
- .soc_id = UNIPHIER_SLD3_ID,
- .sparse_ch1_base = 0xc0000000,
- /*
- * In fact, SLD3 has DRAM ch2, but the memory regions for ch1
- * and ch2 overlap, and host cannot get access to them at the
- * same time. Hide the ch2 from U-Boot.
- */
- },
{
.soc_id = UNIPHIER_LD4_ID,
.sparse_ch1_base = 0xc0000000,
return ret;
for (i = 0; i < ARRAY_SIZE(dram_map); i++) {
+ unsigned long max_size;
if (!dram_map[i].size)
break;
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;
}
+ /*
+ * 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;
}
return 0;
}
-
-#ifdef CONFIG_OF_BOARD_SETUP
-/*
- * The DRAM PHY requires 64 byte scratch area in each DRAM channel
- * for its dynamic PHY training feature.
- */
-int ft_board_setup(void *fdt, bd_t *bd)
-{
- unsigned long rsv_addr;
- const unsigned long rsv_size = 64;
- int i, ret;
-
- if (uniphier_get_soc_id() != UNIPHIER_LD20_ID)
- return 0;
-
- for (i = 0; i < ARRAY_SIZE(gd->bd->bi_dram); i++) {
- if (!gd->bd->bi_dram[i].size)
- continue;
-
- rsv_addr = gd->bd->bi_dram[i].start + gd->bd->bi_dram[i].size;
- rsv_addr -= rsv_size;
-
- ret = fdt_add_mem_rsv(fdt, rsv_addr, rsv_size);
- if (ret)
- return -ENOSPC;
-
- printf(" Reserved memory region for DRAM PHY training: addr=%lx size=%lx\n",
- rsv_addr, rsv_size);
- }
-
- return 0;
-}
-#endif