Marek BehĂșn | f075b42 | 2020-04-08 19:25:18 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2016 Stefan Roese <sr@denx.de> |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <asm/arch/cpu.h> |
| 8 | #include <asm/arch/soc.h> |
Simon Glass | 25a5818 | 2020-05-10 11:40:06 -0600 | [diff] [blame] | 9 | #include <asm/ptrace.h> |
Marek BehĂșn | f075b42 | 2020-04-08 19:25:18 +0200 | [diff] [blame] | 10 | #include <asm/system.h> |
| 11 | #include <linux/sizes.h> |
| 12 | |
| 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
| 15 | #define MV_SIP_DRAM_SIZE 0x82000010 |
| 16 | |
| 17 | u64 a8k_dram_scan_ap_sz(void) |
| 18 | { |
| 19 | struct pt_regs pregs; |
| 20 | |
| 21 | pregs.regs[0] = MV_SIP_DRAM_SIZE; |
| 22 | pregs.regs[1] = SOC_REGS_PHY_BASE; |
| 23 | smc_call(&pregs); |
| 24 | |
| 25 | return pregs.regs[0]; |
| 26 | } |
| 27 | |
| 28 | int a8k_dram_init_banksize(void) |
| 29 | { |
| 30 | /* |
| 31 | * The firmware (ATF) leaves a 1G whole above the 3G mark for IO |
| 32 | * devices. Higher RAM is mapped at 4G. |
| 33 | * |
| 34 | * Config 2 DRAM banks: |
| 35 | * Bank 0 - max size 4G - 1G |
| 36 | * Bank 1 - ram size - 4G + 1G |
| 37 | */ |
| 38 | phys_size_t max_bank0_size = SZ_4G - SZ_1G; |
| 39 | |
| 40 | gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; |
| 41 | if (gd->ram_size <= max_bank0_size) { |
| 42 | gd->bd->bi_dram[0].size = gd->ram_size; |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | gd->bd->bi_dram[0].size = max_bank0_size; |
| 47 | if (CONFIG_NR_DRAM_BANKS > 1) { |
| 48 | gd->bd->bi_dram[1].start = SZ_4G; |
| 49 | gd->bd->bi_dram[1].size = gd->ram_size - max_bank0_size; |
| 50 | } |
| 51 | |
| 52 | return 0; |
| 53 | } |