2020-06-30 10:08:56 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
2020-09-02 06:29:09 +00:00
|
|
|
* Copyright (C) 2020 Stefan Roese <sr@denx.de>
|
2020-06-30 10:08:56 +00:00
|
|
|
*/
|
|
|
|
|
2020-09-02 06:29:09 +00:00
|
|
|
#include <config.h>
|
2020-06-30 10:08:56 +00:00
|
|
|
#include <dm.h>
|
|
|
|
#include <ram.h>
|
|
|
|
#include <asm/global_data.h>
|
|
|
|
#include <linux/compat.h>
|
2020-09-02 06:29:09 +00:00
|
|
|
#include <display_options.h>
|
2020-06-30 10:08:56 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2020-09-02 06:29:09 +00:00
|
|
|
#define UBOOT_RAM_SIZE_MAX 0x10000000ULL
|
|
|
|
|
2020-06-30 10:08:56 +00:00
|
|
|
int dram_init(void)
|
|
|
|
{
|
2020-09-02 06:29:09 +00:00
|
|
|
if (IS_ENABLED(CONFIG_RAM_OCTEON)) {
|
|
|
|
struct ram_info ram;
|
|
|
|
struct udevice *dev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = uclass_get_device(UCLASS_RAM, 0, &dev);
|
|
|
|
if (ret) {
|
|
|
|
debug("DRAM init failed: %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ram_get_info(dev, &ram);
|
|
|
|
if (ret) {
|
|
|
|
debug("Cannot get DRAM size: %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-10-28 14:10:01 +00:00
|
|
|
gd->ram_size = ram.size;
|
2020-09-02 06:29:09 +00:00
|
|
|
debug("SDRAM base=%lx, size=%lx\n",
|
|
|
|
(unsigned long)ram.base, (unsigned long)ram.size);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* No DDR init yet -> run in L2 cache
|
|
|
|
*/
|
|
|
|
gd->ram_size = (4 << 20);
|
|
|
|
gd->bd->bi_dram[0].size = gd->ram_size;
|
|
|
|
gd->bd->bi_dram[1].size = 0;
|
|
|
|
}
|
2020-06-30 10:08:56 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-09-02 06:29:09 +00:00
|
|
|
void board_add_ram_info(int use_default)
|
|
|
|
{
|
|
|
|
if (IS_ENABLED(CONFIG_RAM_OCTEON)) {
|
|
|
|
struct ram_info ram;
|
|
|
|
struct udevice *dev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = uclass_get_device(UCLASS_RAM, 0, &dev);
|
|
|
|
if (ret) {
|
|
|
|
debug("DRAM init failed: %d\n", ret);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ram_get_info(dev, &ram);
|
|
|
|
if (ret) {
|
|
|
|
debug("Cannot get DRAM size: %d\n", ret);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(" (");
|
|
|
|
print_size(ram.size, " total)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-28 14:10:01 +00:00
|
|
|
phys_size_t get_effective_memsize(void)
|
|
|
|
{
|
|
|
|
return UBOOT_RAM_SIZE_MAX;
|
|
|
|
}
|
|
|
|
|
2020-06-30 10:08:56 +00:00
|
|
|
ulong board_get_usable_ram_top(ulong total_size)
|
|
|
|
{
|
2020-09-02 06:29:09 +00:00
|
|
|
if (IS_ENABLED(CONFIG_RAM_OCTEON)) {
|
|
|
|
/* Map a maximum of 256MiB - return not size but address */
|
|
|
|
return CONFIG_SYS_SDRAM_BASE + min(gd->ram_size,
|
|
|
|
UBOOT_RAM_SIZE_MAX);
|
|
|
|
} else {
|
|
|
|
return gd->ram_top;
|
|
|
|
}
|
2020-06-30 10:08:56 +00:00
|
|
|
}
|