blob: b7d339725b2cd6cc634a55d8ffee59ead4306dae [file] [log] [blame]
Patrick Georgi02363b52020-05-05 20:48:50 +02001/* This file is part of the coreboot project. */
Vladimir Serbinenko77231332016-02-19 22:50:50 +01002/*
Vladimir Serbinenko77231332016-02-19 22:50:50 +01003 *
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 Serbinenko77231332016-02-19 22:50:50 +010018#include <halt.h>
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010019#include <edid.h>
Kyösti Mälkki13f66502019-03-03 08:01:05 +020020#include <device/mmio.h>
Patrick Rudolphbd4bcab2019-06-30 22:12:15 +020021#include <ramdetect.h>
22#include <symbols.h>
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010023
24static void init_gfx(void)
25{
Vladimir Serbinenkobddf86a2017-05-13 20:21:37 +000026 uint32_t *pl111;
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010027 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 Serbinenkobddf86a2017-05-13 20:21:37 +000033 write32(pl111, (width / 4) - 4);
34 write32(pl111 + 1, height - 1);
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010035 /* registers 2, 3 and 5 are ignored by qemu. Set them correctly if
36 we ever go for real hw. */
Elyes HAOUAS08fc8ff2018-08-07 12:19:10 +020037 /* framebuffer address offset. Has to be in vram. */
Vladimir Serbinenkobddf86a2017-05-13 20:21:37 +000038 write32(pl111 + 4, framebuffer);
39 write32(pl111 + 7, 0);
40 write32(pl111 + 10, 0xff);
41 write32(pl111 + 6, (5 << 1) | 0x801);
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010042
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 Serbinenko77231332016-02-19 22:50:50 +010050
Elyes HAOUAS5cb876c2018-06-08 18:31:43 +020051static void mainboard_enable(struct device *dev)
Vladimir Serbinenko77231332016-02-19 22:50:50 +010052{
53 int discovered;
54 if (!dev) {
55 printk(BIOS_EMERG, "No dev0; die\n");
56 halt();
57 }
58
Patrick Rudolphbd4bcab2019-06-30 22:12:15 +020059 discovered = probe_ramsize((uintptr_t)_dram, CONFIG_DRAM_SIZE_MB);
Vladimir Serbinenko77231332016-02-19 22:50:50 +010060 printk(BIOS_DEBUG, "%d MiB of RAM discovered\n", discovered);
61 ram_resource(dev, 0, 0x60000000 >> 10, discovered << 10);
62 cbmem_recovery(0);
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010063 init_gfx();
Vladimir Serbinenko77231332016-02-19 22:50:50 +010064}
65
66struct chip_operations mainboard_ops = {
67 .enable_dev = mainboard_enable,
68};