Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Bin Meng | 2229c4c | 2015-05-07 21:34:08 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com> |
Bin Meng | 2229c4c | 2015-05-07 21:34:08 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <asm/post.h> |
| 8 | #include <asm/arch/qemu.h> |
| 9 | |
| 10 | DECLARE_GLOBAL_DATA_PTR; |
| 11 | |
| 12 | int dram_init(void) |
| 13 | { |
| 14 | u32 ram; |
| 15 | |
| 16 | outb(HIGH_RAM_ADDR, CMOS_ADDR_PORT); |
| 17 | ram = ((u32)inb(CMOS_DATA_PORT)) << 14; |
| 18 | outb(LOW_RAM_ADDR, CMOS_ADDR_PORT); |
| 19 | ram |= ((u32)inb(CMOS_DATA_PORT)) << 6; |
| 20 | ram += 16 * 1024; |
| 21 | |
| 22 | gd->ram_size = ram * 1024; |
| 23 | post_code(POST_DRAM); |
| 24 | |
| 25 | return 0; |
| 26 | } |
| 27 | |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 28 | int dram_init_banksize(void) |
Bin Meng | 2229c4c | 2015-05-07 21:34:08 +0800 | [diff] [blame] | 29 | { |
| 30 | gd->bd->bi_dram[0].start = 0; |
| 31 | gd->bd->bi_dram[0].size = gd->ram_size; |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 32 | |
| 33 | return 0; |
Bin Meng | 2229c4c | 2015-05-07 21:34:08 +0800 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | /* |
| 37 | * This function looks for the highest region of memory lower than 4GB which |
| 38 | * has enough space for U-Boot where U-Boot is aligned on a page boundary. |
| 39 | * It overrides the default implementation found elsewhere which simply |
| 40 | * picks the end of ram, wherever that may be. The location of the stack, |
| 41 | * the relocation address, and how far U-Boot is moved by relocation are |
| 42 | * set in the global data structure. |
| 43 | */ |
| 44 | ulong board_get_usable_ram_top(ulong total_size) |
| 45 | { |
| 46 | return gd->ram_size; |
| 47 | } |