blob: 33f65db48ea48786aa2cec98d78e810f122b58da [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Albert Aribaud0c61e6f2010-06-17 19:36:07 +05302/*
Albert ARIBAUD57b4bce2011-04-22 19:41:02 +02003 * Copyright (C) 2010 Albert ARIBAUD <albert.u.boot@aribaud.net>
Albert Aribaud0c61e6f2010-06-17 19:36:07 +05304 *
5 * Based on original Kirkwood support which is
6 * (C) Copyright 2009
7 * Marvell Semiconductor <www.marvell.com>
8 * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
Albert Aribaud0c61e6f2010-06-17 19:36:07 +05309 */
10
11#include <common.h>
12#include <config.h>
Simon Glass9b4a2052019-12-28 10:45:05 -070013#include <init.h>
Lei Wen5ff8b352011-10-24 16:27:32 +000014#include <asm/arch/cpu.h>
Albert Aribaud0c61e6f2010-06-17 19:36:07 +053015
16DECLARE_GLOBAL_DATA_PTR;
17
18/*
19 * orion5x_sdram_bar - reads SDRAM Base Address Register
20 */
21u32 orion5x_sdram_bar(enum memory_bank bank)
22{
23 struct orion5x_ddr_addr_decode_registers *winregs =
24 (struct orion5x_ddr_addr_decode_registers *)
Rogan Dawes286a5b22011-04-13 23:54:53 +053025 ORION5X_DRAM_BASE;
Albert Aribaud0c61e6f2010-06-17 19:36:07 +053026
27 u32 result = 0;
28 u32 enable = 0x01 & winregs[bank].size;
29
30 if ((!enable) || (bank > BANK3))
31 return 0;
32
33 result = winregs[bank].base;
34 return result;
35}
Heiko Schocherab86f722010-09-17 13:10:42 +020036int dram_init (void)
37{
38 /* dram_init must store complete ramsize in gd->ram_size */
39 gd->ram_size = get_ram_size(
Albert ARIBAUDa55d23c2011-07-03 05:55:33 +000040 (long *) orion5x_sdram_bar(0),
Heiko Schocherab86f722010-09-17 13:10:42 +020041 CONFIG_MAX_RAM_BANK_SIZE);
42 return 0;
43}
44
Simon Glass76b00ac2017-03-31 08:40:32 -060045int dram_init_banksize(void)
Heiko Schocherab86f722010-09-17 13:10:42 +020046{
47 int i;
48
49 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
50 gd->bd->bi_dram[i].start = orion5x_sdram_bar(i);
51 gd->bd->bi_dram[i].size = get_ram_size(
Albert ARIBAUDa55d23c2011-07-03 05:55:33 +000052 (long *) (gd->bd->bi_dram[i].start),
Heiko Schocherab86f722010-09-17 13:10:42 +020053 CONFIG_MAX_RAM_BANK_SIZE);
54 }
Simon Glass76b00ac2017-03-31 08:40:32 -060055
56 return 0;
Heiko Schocherab86f722010-09-17 13:10:42 +020057}