Patrick Georgi | 02363b5 | 2020-05-05 20:48:50 +0200 | [diff] [blame] | 1 | /* This file is part of the coreboot project. */ |
Vladimir Serbinenko | 7723133 | 2016-02-19 22:50:50 +0100 | [diff] [blame] | 2 | /* |
Vladimir Serbinenko | 7723133 | 2016-02-19 22:50:50 +0100 | [diff] [blame] | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; version 2 or, at your option, any later |
| 7 | * version of the License. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | */ |
| 14 | |
| 15 | #include <console/console.h> |
| 16 | #include <device/device.h> |
| 17 | #include <cbmem.h> |
Vladimir Serbinenko | 7723133 | 2016-02-19 22:50:50 +0100 | [diff] [blame] | 18 | #include <halt.h> |
Vladimir Serbinenko | 2a59a44 | 2016-02-19 15:21:49 +0100 | [diff] [blame] | 19 | #include <edid.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 20 | #include <device/mmio.h> |
Patrick Rudolph | bd4bcab | 2019-06-30 22:12:15 +0200 | [diff] [blame] | 21 | #include <ramdetect.h> |
| 22 | #include <symbols.h> |
Vladimir Serbinenko | 2a59a44 | 2016-02-19 15:21:49 +0100 | [diff] [blame] | 23 | |
| 24 | static void init_gfx(void) |
| 25 | { |
Vladimir Serbinenko | bddf86a | 2017-05-13 20:21:37 +0000 | [diff] [blame] | 26 | uint32_t *pl111; |
Vladimir Serbinenko | 2a59a44 | 2016-02-19 15:21:49 +0100 | [diff] [blame] | 27 | struct edid edid; |
| 28 | /* width is at most 4096 */ |
| 29 | /* height is at most 1024 */ |
| 30 | int width = 800, height = 600; |
| 31 | uint32_t framebuffer = 0x4c000000; |
| 32 | pl111 = (uint32_t *) 0x10020000; |
Vladimir Serbinenko | bddf86a | 2017-05-13 20:21:37 +0000 | [diff] [blame] | 33 | write32(pl111, (width / 4) - 4); |
| 34 | write32(pl111 + 1, height - 1); |
Vladimir Serbinenko | 2a59a44 | 2016-02-19 15:21:49 +0100 | [diff] [blame] | 35 | /* registers 2, 3 and 5 are ignored by qemu. Set them correctly if |
| 36 | we ever go for real hw. */ |
Elyes HAOUAS | 08fc8ff | 2018-08-07 12:19:10 +0200 | [diff] [blame] | 37 | /* framebuffer address offset. Has to be in vram. */ |
Vladimir Serbinenko | bddf86a | 2017-05-13 20:21:37 +0000 | [diff] [blame] | 38 | write32(pl111 + 4, framebuffer); |
| 39 | write32(pl111 + 7, 0); |
| 40 | write32(pl111 + 10, 0xff); |
| 41 | write32(pl111 + 6, (5 << 1) | 0x801); |
Vladimir Serbinenko | 2a59a44 | 2016-02-19 15:21:49 +0100 | [diff] [blame] | 42 | |
| 43 | edid.framebuffer_bits_per_pixel = 32; |
| 44 | edid.bytes_per_line = width * 4; |
| 45 | edid.x_resolution = width; |
| 46 | edid.y_resolution = height; |
| 47 | |
| 48 | set_vbe_mode_info_valid(&edid, framebuffer); |
| 49 | } |
Vladimir Serbinenko | 7723133 | 2016-02-19 22:50:50 +0100 | [diff] [blame] | 50 | |
Elyes HAOUAS | 5cb876c | 2018-06-08 18:31:43 +0200 | [diff] [blame] | 51 | static void mainboard_enable(struct device *dev) |
Vladimir Serbinenko | 7723133 | 2016-02-19 22:50:50 +0100 | [diff] [blame] | 52 | { |
| 53 | int discovered; |
| 54 | if (!dev) { |
| 55 | printk(BIOS_EMERG, "No dev0; die\n"); |
| 56 | halt(); |
| 57 | } |
| 58 | |
Patrick Rudolph | bd4bcab | 2019-06-30 22:12:15 +0200 | [diff] [blame] | 59 | discovered = probe_ramsize((uintptr_t)_dram, CONFIG_DRAM_SIZE_MB); |
Vladimir Serbinenko | 7723133 | 2016-02-19 22:50:50 +0100 | [diff] [blame] | 60 | printk(BIOS_DEBUG, "%d MiB of RAM discovered\n", discovered); |
| 61 | ram_resource(dev, 0, 0x60000000 >> 10, discovered << 10); |
| 62 | cbmem_recovery(0); |
Vladimir Serbinenko | 2a59a44 | 2016-02-19 15:21:49 +0100 | [diff] [blame] | 63 | init_gfx(); |
Vladimir Serbinenko | 7723133 | 2016-02-19 22:50:50 +0100 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | struct chip_operations mainboard_ops = { |
| 67 | .enable_dev = mainboard_enable, |
| 68 | }; |