Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Albert Aribaud | 0c61e6f | 2010-06-17 19:36:07 +0530 | [diff] [blame] | 2 | /* |
Albert ARIBAUD | 57b4bce | 2011-04-22 19:41:02 +0200 | [diff] [blame] | 3 | * Copyright (C) 2010 Albert ARIBAUD <albert.u.boot@aribaud.net> |
Albert Aribaud | 0c61e6f | 2010-06-17 19:36:07 +0530 | [diff] [blame] | 4 | * |
| 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 Aribaud | 0c61e6f | 2010-06-17 19:36:07 +0530 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <common.h> |
| 12 | #include <config.h> |
Lei Wen | 5ff8b35 | 2011-10-24 16:27:32 +0000 | [diff] [blame] | 13 | #include <asm/arch/cpu.h> |
Albert Aribaud | 0c61e6f | 2010-06-17 19:36:07 +0530 | [diff] [blame] | 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
| 17 | /* |
| 18 | * orion5x_sdram_bar - reads SDRAM Base Address Register |
| 19 | */ |
| 20 | u32 orion5x_sdram_bar(enum memory_bank bank) |
| 21 | { |
| 22 | struct orion5x_ddr_addr_decode_registers *winregs = |
| 23 | (struct orion5x_ddr_addr_decode_registers *) |
Rogan Dawes | 286a5b2 | 2011-04-13 23:54:53 +0530 | [diff] [blame] | 24 | ORION5X_DRAM_BASE; |
Albert Aribaud | 0c61e6f | 2010-06-17 19:36:07 +0530 | [diff] [blame] | 25 | |
| 26 | u32 result = 0; |
| 27 | u32 enable = 0x01 & winregs[bank].size; |
| 28 | |
| 29 | if ((!enable) || (bank > BANK3)) |
| 30 | return 0; |
| 31 | |
| 32 | result = winregs[bank].base; |
| 33 | return result; |
| 34 | } |
Heiko Schocher | ab86f72 | 2010-09-17 13:10:42 +0200 | [diff] [blame] | 35 | int dram_init (void) |
| 36 | { |
| 37 | /* dram_init must store complete ramsize in gd->ram_size */ |
| 38 | gd->ram_size = get_ram_size( |
Albert ARIBAUD | a55d23c | 2011-07-03 05:55:33 +0000 | [diff] [blame] | 39 | (long *) orion5x_sdram_bar(0), |
Heiko Schocher | ab86f72 | 2010-09-17 13:10:42 +0200 | [diff] [blame] | 40 | CONFIG_MAX_RAM_BANK_SIZE); |
| 41 | return 0; |
| 42 | } |
| 43 | |
Simon Glass | 76b00ac | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 44 | int dram_init_banksize(void) |
Heiko Schocher | ab86f72 | 2010-09-17 13:10:42 +0200 | [diff] [blame] | 45 | { |
| 46 | int i; |
| 47 | |
| 48 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
| 49 | gd->bd->bi_dram[i].start = orion5x_sdram_bar(i); |
| 50 | gd->bd->bi_dram[i].size = get_ram_size( |
Albert ARIBAUD | a55d23c | 2011-07-03 05:55:33 +0000 | [diff] [blame] | 51 | (long *) (gd->bd->bi_dram[i].start), |
Heiko Schocher | ab86f72 | 2010-09-17 13:10:42 +0200 | [diff] [blame] | 52 | CONFIG_MAX_RAM_BANK_SIZE); |
| 53 | } |
Simon Glass | 76b00ac | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 54 | |
| 55 | return 0; |
Heiko Schocher | ab86f72 | 2010-09-17 13:10:42 +0200 | [diff] [blame] | 56 | } |