blob: cc14dd8e7b37a680c786707bf56fbd4a87143b6d [file] [log] [blame]
Vladimir Serbinenko77231332016-02-19 22:50:50 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2016 Vladimir Serbinenko <phcoder@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 or, at your option, any later
9 * version of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <console/console.h>
18#include <device/device.h>
19#include <cbmem.h>
Vladimir Serbinenko77231332016-02-19 22:50:50 +010020#include <halt.h>
21#include "mainboard.h"
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010022#include <edid.h>
Kyösti Mälkki13f66502019-03-03 08:01:05 +020023#include <device/mmio.h>
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010024
25static void init_gfx(void)
26{
Vladimir Serbinenkobddf86a2017-05-13 20:21:37 +000027 uint32_t *pl111;
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010028 struct edid edid;
29 /* width is at most 4096 */
30 /* height is at most 1024 */
31 int width = 800, height = 600;
32 uint32_t framebuffer = 0x4c000000;
33 pl111 = (uint32_t *) 0x10020000;
Vladimir Serbinenkobddf86a2017-05-13 20:21:37 +000034 write32(pl111, (width / 4) - 4);
35 write32(pl111 + 1, height - 1);
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010036 /* registers 2, 3 and 5 are ignored by qemu. Set them correctly if
37 we ever go for real hw. */
Elyes HAOUAS08fc8ff2018-08-07 12:19:10 +020038 /* framebuffer address offset. Has to be in vram. */
Vladimir Serbinenkobddf86a2017-05-13 20:21:37 +000039 write32(pl111 + 4, framebuffer);
40 write32(pl111 + 7, 0);
41 write32(pl111 + 10, 0xff);
42 write32(pl111 + 6, (5 << 1) | 0x801);
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010043
44 edid.framebuffer_bits_per_pixel = 32;
45 edid.bytes_per_line = width * 4;
46 edid.x_resolution = width;
47 edid.y_resolution = height;
48
49 set_vbe_mode_info_valid(&edid, framebuffer);
50}
Vladimir Serbinenko77231332016-02-19 22:50:50 +010051
Elyes HAOUAS5cb876c2018-06-08 18:31:43 +020052static void mainboard_enable(struct device *dev)
Vladimir Serbinenko77231332016-02-19 22:50:50 +010053{
54 int discovered;
55 if (!dev) {
56 printk(BIOS_EMERG, "No dev0; die\n");
57 halt();
58 }
59
60 discovered = probe_ramsize();
61 printk(BIOS_DEBUG, "%d MiB of RAM discovered\n", discovered);
62 ram_resource(dev, 0, 0x60000000 >> 10, discovered << 10);
63 cbmem_recovery(0);
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010064 init_gfx();
Vladimir Serbinenko77231332016-02-19 22:50:50 +010065}
66
67struct chip_operations mainboard_ops = {
68 .enable_dev = mainboard_enable,
69};