blob: 21af5c7c80d63f7da124e2afc276fcba7a626c88 [file] [log] [blame]
Timothy Pearson04cf4492015-09-05 17:38:09 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
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 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Timothy Pearson04cf4492015-09-05 17:38:09 -050014 */
Elyes HAOUASbf0970e2019-03-21 11:10:03 +010015
Timothy Pearson04cf4492015-09-05 17:38:09 -050016#include <stdlib.h>
Timothy Pearson04cf4492015-09-05 17:38:09 -050017#include <arch/io.h>
18#include <edid.h>
Timothy Pearson04cf4492015-09-05 17:38:09 -050019#include <console/console.h>
20#include <device/device.h>
21#include <device/pci.h>
22#include <device/pci_ids.h>
23#include <device/pci_ops.h>
Timothy Pearson04cf4492015-09-05 17:38:09 -050024#include <pc80/vga.h>
25
26#include "../common/aspeed_coreboot.h"
27#include "../common/ast_drv.h"
28
Elyes HAOUASc80435d2018-05-04 18:41:10 +020029static void aspeed_ast2050_set_resources(struct device *dev)
Timothy Pearson04cf4492015-09-05 17:38:09 -050030{
31 /* Reserve VGA regions */
32 mmio_resource(dev, 3, 0xa0000 >> 10, 0x1ffff >> 10);
33
34 /* Run standard resource set routine */
35 pci_dev_set_resources(dev);
36}
37
38static void aspeed_ast2050_init(struct device *dev)
39{
Timothy Pearson04cf4492015-09-05 17:38:09 -050040 struct drm_device drm_dev;
41
42 drm_dev.pdev = dev;
43
44 printk(BIOS_INFO, "ASpeed AST2050: initializing video device\n");
Elyes HAOUAS1a7623b2019-05-22 21:05:24 +020045 ast_driver_load(&drm_dev, 0);
Timothy Pearson04cf4492015-09-05 17:38:09 -050046
47 /* Unlock extended configuration registers */
48 outb(0x80, 0x3d4); outb(0xa8, 0x3d5);
49
50 /* Set CRT Request Threshold */
51 outb(0xa6, 0x3d4); outb(0x2f, 0x3d5);
52 outb(0xa7, 0x3d4); outb(0x3f, 0x3d5);
53
54 /* Initialize standard VGA text mode */
55 vga_io_init();
56 vga_textmode_init();
57 printk(BIOS_INFO, "ASpeed VGA text mode initialized\n");
58
59 /* if we don't have console, at least print something... */
60 vga_line_write(0, "ASpeed VGA text mode initialized");
61}
62
63static struct device_operations aspeed_ast2050_ops = {
64 .read_resources = pci_dev_read_resources,
65 .set_resources = aspeed_ast2050_set_resources,
66 .enable_resources = pci_dev_enable_resources,
67 .init = aspeed_ast2050_init,
68 .scan_bus = 0,
69};
70
71static const struct pci_driver aspeed_ast2050_driver __pci_driver = {
Martin Rothb9810a42017-07-23 20:00:04 -060072 .ops = &aspeed_ast2050_ops,
73 .vendor = PCI_VENDOR_ID_ASPEED,
74 .device = PCI_DEVICE_ID_ASPEED_AST2050_VGA,
Timothy Pearson04cf4492015-09-05 17:38:09 -050075};