2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2010-06-17 14:06:07 +00:00
|
|
|
/*
|
2011-04-22 17:41:02 +00:00
|
|
|
* Copyright (C) 2010 Albert ARIBAUD <albert.u.boot@aribaud.net>
|
2010-06-17 14:06:07 +00:00
|
|
|
*
|
|
|
|
* Based on original Kirkwood support which is
|
|
|
|
* (C) Copyright 2009
|
|
|
|
* Marvell Semiconductor <www.marvell.com>
|
|
|
|
* Written-by: Prafulla Wadaskar <prafulla@marvell.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <config.h>
|
2019-12-28 17:45:05 +00:00
|
|
|
#include <init.h>
|
2011-10-24 16:27:32 +00:00
|
|
|
#include <asm/arch/cpu.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2010-06-17 14:06:07 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* orion5x_sdram_bar - reads SDRAM Base Address Register
|
|
|
|
*/
|
|
|
|
u32 orion5x_sdram_bar(enum memory_bank bank)
|
|
|
|
{
|
|
|
|
struct orion5x_ddr_addr_decode_registers *winregs =
|
|
|
|
(struct orion5x_ddr_addr_decode_registers *)
|
2011-04-13 18:24:53 +00:00
|
|
|
ORION5X_DRAM_BASE;
|
2010-06-17 14:06:07 +00:00
|
|
|
|
|
|
|
u32 result = 0;
|
|
|
|
u32 enable = 0x01 & winregs[bank].size;
|
|
|
|
|
|
|
|
if ((!enable) || (bank > BANK3))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
result = winregs[bank].base;
|
|
|
|
return result;
|
|
|
|
}
|
2010-09-17 11:10:42 +00:00
|
|
|
int dram_init (void)
|
|
|
|
{
|
|
|
|
/* dram_init must store complete ramsize in gd->ram_size */
|
|
|
|
gd->ram_size = get_ram_size(
|
2011-07-03 05:55:33 +00:00
|
|
|
(long *) orion5x_sdram_bar(0),
|
2022-12-04 15:04:51 +00:00
|
|
|
CFG_MAX_RAM_BANK_SIZE);
|
2010-09-17 11:10:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-31 14:40:32 +00:00
|
|
|
int dram_init_banksize(void)
|
2010-09-17 11:10:42 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
|
|
|
|
gd->bd->bi_dram[i].start = orion5x_sdram_bar(i);
|
|
|
|
gd->bd->bi_dram[i].size = get_ram_size(
|
2011-07-03 05:55:33 +00:00
|
|
|
(long *) (gd->bd->bi_dram[i].start),
|
2022-12-04 15:04:51 +00:00
|
|
|
CFG_MAX_RAM_BANK_SIZE);
|
2010-09-17 11:10:42 +00:00
|
|
|
}
|
2017-03-31 14:40:32 +00:00
|
|
|
|
|
|
|
return 0;
|
2010-09-17 11:10:42 +00:00
|
|
|
}
|