blob: d91d77a0974db9aae7c022dc30f13b2e5251494b [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>
20#include <string.h>
21#include <halt.h>
22#include "mainboard.h"
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010023#include <edid.h>
Vladimir Serbinenkobddf86a2017-05-13 20:21:37 +000024#include <arch/io.h>
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010025
26static void init_gfx(void)
27{
Vladimir Serbinenkobddf86a2017-05-13 20:21:37 +000028 uint32_t *pl111;
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010029 struct edid edid;
30 /* width is at most 4096 */
31 /* height is at most 1024 */
32 int width = 800, height = 600;
33 uint32_t framebuffer = 0x4c000000;
34 pl111 = (uint32_t *) 0x10020000;
Vladimir Serbinenkobddf86a2017-05-13 20:21:37 +000035 write32(pl111, (width / 4) - 4);
36 write32(pl111 + 1, height - 1);
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010037 /* registers 2, 3 and 5 are ignored by qemu. Set them correctly if
38 we ever go for real hw. */
39 /* framebuffer adress offset. Has to be in vram. */
Vladimir Serbinenkobddf86a2017-05-13 20:21:37 +000040 write32(pl111 + 4, framebuffer);
41 write32(pl111 + 7, 0);
42 write32(pl111 + 10, 0xff);
43 write32(pl111 + 6, (5 << 1) | 0x801);
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010044
45 edid.framebuffer_bits_per_pixel = 32;
46 edid.bytes_per_line = width * 4;
47 edid.x_resolution = width;
48 edid.y_resolution = height;
49
50 set_vbe_mode_info_valid(&edid, framebuffer);
51}
Vladimir Serbinenko77231332016-02-19 22:50:50 +010052
Elyes HAOUAS5cb876c2018-06-08 18:31:43 +020053static void mainboard_enable(struct device *dev)
Vladimir Serbinenko77231332016-02-19 22:50:50 +010054{
55 int discovered;
56 if (!dev) {
57 printk(BIOS_EMERG, "No dev0; die\n");
58 halt();
59 }
60
61 discovered = probe_ramsize();
62 printk(BIOS_DEBUG, "%d MiB of RAM discovered\n", discovered);
63 ram_resource(dev, 0, 0x60000000 >> 10, discovered << 10);
64 cbmem_recovery(0);
Vladimir Serbinenko2a59a442016-02-19 15:21:49 +010065 init_gfx();
Vladimir Serbinenko77231332016-02-19 22:50:50 +010066}
67
68struct chip_operations mainboard_ops = {
69 .enable_dev = mainboard_enable,
70};