blob: f591410f417a8885d4f14cf47b68fc25dff92b08 [file] [log] [blame]
Patrick Georgi02363b52020-05-05 20:48:50 +02001/* This file is part of the coreboot project. */
Patrick Georgiac959032020-05-05 22:49:26 +02002/* SPDX-License-Identifier: GPL-2.0-only */
Vladimir Serbinenko77231332016-02-19 22:50:50 +01003
4#include <console/console.h>
5#include <device/device.h>
6#include <cbmem.h>
Vladimir Serbinenko77231332016-02-19 22:50:50 +01007#include <halt.h>
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +01008#include <edid.h>
Kyösti Mälkki13f66502019-03-03 08:01:05 +02009#include <device/mmio.h>
Patrick Rudolphbd4bcab2019-06-30 22:12:15 +020010#include <ramdetect.h>
11#include <symbols.h>
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010012
13static void init_gfx(void)
14{
Vladimir Serbinenkobddf86a2017-05-13 20:21:37 +000015 uint32_t *pl111;
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010016 struct edid edid;
17 /* width is at most 4096 */
18 /* height is at most 1024 */
19 int width = 800, height = 600;
20 uint32_t framebuffer = 0x4c000000;
21 pl111 = (uint32_t *) 0x10020000;
Vladimir Serbinenkobddf86a2017-05-13 20:21:37 +000022 write32(pl111, (width / 4) - 4);
23 write32(pl111 + 1, height - 1);
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010024 /* registers 2, 3 and 5 are ignored by qemu. Set them correctly if
25 we ever go for real hw. */
Elyes HAOUAS08fc8ff2018-08-07 12:19:10 +020026 /* framebuffer address offset. Has to be in vram. */
Vladimir Serbinenkobddf86a2017-05-13 20:21:37 +000027 write32(pl111 + 4, framebuffer);
28 write32(pl111 + 7, 0);
29 write32(pl111 + 10, 0xff);
30 write32(pl111 + 6, (5 << 1) | 0x801);
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010031
32 edid.framebuffer_bits_per_pixel = 32;
33 edid.bytes_per_line = width * 4;
34 edid.x_resolution = width;
35 edid.y_resolution = height;
36
37 set_vbe_mode_info_valid(&edid, framebuffer);
38}
Vladimir Serbinenko77231332016-02-19 22:50:50 +010039
Elyes HAOUAS5cb876c2018-06-08 18:31:43 +020040static void mainboard_enable(struct device *dev)
Vladimir Serbinenko77231332016-02-19 22:50:50 +010041{
42 int discovered;
43 if (!dev) {
44 printk(BIOS_EMERG, "No dev0; die\n");
45 halt();
46 }
47
Patrick Rudolphbd4bcab2019-06-30 22:12:15 +020048 discovered = probe_ramsize((uintptr_t)_dram, CONFIG_DRAM_SIZE_MB);
Vladimir Serbinenko77231332016-02-19 22:50:50 +010049 printk(BIOS_DEBUG, "%d MiB of RAM discovered\n", discovered);
50 ram_resource(dev, 0, 0x60000000 >> 10, discovered << 10);
51 cbmem_recovery(0);
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010052 init_gfx();
Vladimir Serbinenko77231332016-02-19 22:50:50 +010053}
54
55struct chip_operations mainboard_ops = {
56 .enable_dev = mainboard_enable,
57};