Vladimir Serbinenko | 7723133 | 2016-02-19 22:50:50 +0100 | [diff] [blame] | 1 | /* |
| 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 Serbinenko | 2a59a44 | 2016-02-19 15:21:49 +0100 | [diff] [blame] | 23 | #include <edid.h> |
Vladimir Serbinenko | bddf86a | 2017-05-13 20:21:37 +0000 | [diff] [blame] | 24 | #include <arch/io.h> |
Vladimir Serbinenko | 2a59a44 | 2016-02-19 15:21:49 +0100 | [diff] [blame] | 25 | |
| 26 | static void init_gfx(void) |
| 27 | { |
Vladimir Serbinenko | bddf86a | 2017-05-13 20:21:37 +0000 | [diff] [blame] | 28 | uint32_t *pl111; |
Vladimir Serbinenko | 2a59a44 | 2016-02-19 15:21:49 +0100 | [diff] [blame] | 29 | 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 Serbinenko | bddf86a | 2017-05-13 20:21:37 +0000 | [diff] [blame] | 35 | write32(pl111, (width / 4) - 4); |
| 36 | write32(pl111 + 1, height - 1); |
Vladimir Serbinenko | 2a59a44 | 2016-02-19 15:21:49 +0100 | [diff] [blame] | 37 | /* 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 Serbinenko | bddf86a | 2017-05-13 20:21:37 +0000 | [diff] [blame] | 40 | write32(pl111 + 4, framebuffer); |
| 41 | write32(pl111 + 7, 0); |
| 42 | write32(pl111 + 10, 0xff); |
| 43 | write32(pl111 + 6, (5 << 1) | 0x801); |
Vladimir Serbinenko | 2a59a44 | 2016-02-19 15:21:49 +0100 | [diff] [blame] | 44 | |
| 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 Serbinenko | 7723133 | 2016-02-19 22:50:50 +0100 | [diff] [blame] | 52 | |
| 53 | static void mainboard_enable(device_t dev) |
| 54 | { |
| 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 Serbinenko | 2a59a44 | 2016-02-19 15:21:49 +0100 | [diff] [blame] | 65 | init_gfx(); |
Vladimir Serbinenko | 7723133 | 2016-02-19 22:50:50 +0100 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | struct chip_operations mainboard_ops = { |
| 69 | .enable_dev = mainboard_enable, |
| 70 | }; |