Marek Behún | e577cc3 | 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 | |
Tom Rini | 676ea8b | 2024-04-30 07:35:44 -0600 | [diff] [blame] | 6 | #include <config.h> |
Marek Behún | e577cc3 | 2020-04-08 19:25:18 +0200 | [diff] [blame] | 7 | #include <asm/arch/cpu.h> |
| 8 | #include <asm/arch/soc.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 9 | #include <asm/global_data.h> |
Tom Rini | 676ea8b | 2024-04-30 07:35:44 -0600 | [diff] [blame] | 10 | #include <asm/u-boot.h> |
Simon Glass | 6b9f010 | 2020-05-10 11:40:06 -0600 | [diff] [blame] | 11 | #include <asm/ptrace.h> |
Marek Behún | e577cc3 | 2020-04-08 19:25:18 +0200 | [diff] [blame] | 12 | #include <asm/system.h> |
| 13 | #include <linux/sizes.h> |
| 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
| 17 | #define MV_SIP_DRAM_SIZE 0x82000010 |
| 18 | |
| 19 | u64 a8k_dram_scan_ap_sz(void) |
| 20 | { |
| 21 | struct pt_regs pregs; |
| 22 | |
| 23 | pregs.regs[0] = MV_SIP_DRAM_SIZE; |
| 24 | pregs.regs[1] = SOC_REGS_PHY_BASE; |
| 25 | smc_call(&pregs); |
| 26 | |
| 27 | return pregs.regs[0]; |
| 28 | } |
| 29 | |
| 30 | int a8k_dram_init_banksize(void) |
| 31 | { |
| 32 | /* |
| 33 | * The firmware (ATF) leaves a 1G whole above the 3G mark for IO |
| 34 | * devices. Higher RAM is mapped at 4G. |
| 35 | * |
| 36 | * Config 2 DRAM banks: |
| 37 | * Bank 0 - max size 4G - 1G |
| 38 | * Bank 1 - ram size - 4G + 1G |
| 39 | */ |
| 40 | phys_size_t max_bank0_size = SZ_4G - SZ_1G; |
| 41 | |
Tom Rini | bb4dd96 | 2022-11-16 13:10:37 -0500 | [diff] [blame] | 42 | gd->bd->bi_dram[0].start = CFG_SYS_SDRAM_BASE; |
Marek Behún | e577cc3 | 2020-04-08 19:25:18 +0200 | [diff] [blame] | 43 | if (gd->ram_size <= max_bank0_size) { |
| 44 | gd->bd->bi_dram[0].size = gd->ram_size; |
| 45 | return 0; |
| 46 | } |
| 47 | |
| 48 | gd->bd->bi_dram[0].size = max_bank0_size; |
| 49 | if (CONFIG_NR_DRAM_BANKS > 1) { |
| 50 | gd->bd->bi_dram[1].start = SZ_4G; |
| 51 | gd->bd->bi_dram[1].size = gd->ram_size - max_bank0_size; |
| 52 | } |
| 53 | |
| 54 | return 0; |
| 55 | } |