blob: c1fcc6ad5903970294c0fd8cb915172cf5063a05 [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>
24
25static void init_gfx(void)
26{
27 volatile uint32_t *pl111;
28 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;
34 pl111[0] = (width / 4) - 4;
35 pl111[1] = height - 1;
36 /* registers 2, 3 and 5 are ignored by qemu. Set them correctly if
37 we ever go for real hw. */
38 /* framebuffer adress offset. Has to be in vram. */
39 pl111[4] = framebuffer;
40 pl111[7] = 0;
41 pl111[10] = 0xff;
42 pl111[6] = (5 << 1) | 0x801;
43
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
52static void mainboard_enable(device_t dev)
53{
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};