blob: 977725d2465d40a9a5b4b427ffb353d39acdc2ee [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Vladimir Serbinenko77231332016-02-19 22:50:50 +01002
3#include <console/console.h>
4#include <device/device.h>
5#include <cbmem.h>
Vladimir Serbinenko77231332016-02-19 22:50:50 +01006#include <halt.h>
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +01007#include <edid.h>
Kyösti Mälkki13f66502019-03-03 08:01:05 +02008#include <device/mmio.h>
Patrick Rudolphbd4bcab2019-06-30 22:12:15 +02009#include <ramdetect.h>
10#include <symbols.h>
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010011
12static void init_gfx(void)
13{
Vladimir Serbinenkobddf86a2017-05-13 20:21:37 +000014 uint32_t *pl111;
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010015 struct edid edid;
16 /* width is at most 4096 */
17 /* height is at most 1024 */
18 int width = 800, height = 600;
19 uint32_t framebuffer = 0x4c000000;
20 pl111 = (uint32_t *) 0x10020000;
Vladimir Serbinenkobddf86a2017-05-13 20:21:37 +000021 write32(pl111, (width / 4) - 4);
22 write32(pl111 + 1, height - 1);
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010023 /* registers 2, 3 and 5 are ignored by qemu. Set them correctly if
24 we ever go for real hw. */
Elyes HAOUAS08fc8ff2018-08-07 12:19:10 +020025 /* framebuffer address offset. Has to be in vram. */
Vladimir Serbinenkobddf86a2017-05-13 20:21:37 +000026 write32(pl111 + 4, framebuffer);
27 write32(pl111 + 7, 0);
28 write32(pl111 + 10, 0xff);
29 write32(pl111 + 6, (5 << 1) | 0x801);
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010030
31 edid.framebuffer_bits_per_pixel = 32;
32 edid.bytes_per_line = width * 4;
33 edid.x_resolution = width;
34 edid.y_resolution = height;
35
36 set_vbe_mode_info_valid(&edid, framebuffer);
37}
Vladimir Serbinenko77231332016-02-19 22:50:50 +010038
Elyes HAOUAS5cb876c2018-06-08 18:31:43 +020039static void mainboard_enable(struct device *dev)
Vladimir Serbinenko77231332016-02-19 22:50:50 +010040{
41 int discovered;
42 if (!dev) {
43 printk(BIOS_EMERG, "No dev0; die\n");
44 halt();
45 }
46
Patrick Rudolphbd4bcab2019-06-30 22:12:15 +020047 discovered = probe_ramsize((uintptr_t)_dram, CONFIG_DRAM_SIZE_MB);
Vladimir Serbinenko77231332016-02-19 22:50:50 +010048 printk(BIOS_DEBUG, "%d MiB of RAM discovered\n", discovered);
49 ram_resource(dev, 0, 0x60000000 >> 10, discovered << 10);
50 cbmem_recovery(0);
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010051 init_gfx();
Vladimir Serbinenko77231332016-02-19 22:50:50 +010052}
53
54struct chip_operations mainboard_ops = {
55 .enable_dev = mainboard_enable,
56};