blob: e8d065b466792558259845f35b66299e6eefa2c0 [file] [log] [blame]
Angel Pons8a3453f2020-04-02 23:48:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Elyes HAOUASbf0970e2019-03-21 11:10:03 +01003
Timothy Pearson04cf4492015-09-05 17:38:09 -05004#include <arch/io.h>
5#include <edid.h>
Timothy Pearson04cf4492015-09-05 17:38:09 -05006#include <console/console.h>
7#include <device/device.h>
8#include <device/pci.h>
9#include <device/pci_ids.h>
Timothy Pearson04cf4492015-09-05 17:38:09 -050010#include <pc80/vga.h>
11
12#include "../common/aspeed_coreboot.h"
13#include "../common/ast_drv.h"
14
Elyes HAOUASc80435d2018-05-04 18:41:10 +020015static void aspeed_ast2050_set_resources(struct device *dev)
Timothy Pearson04cf4492015-09-05 17:38:09 -050016{
17 /* Reserve VGA regions */
18 mmio_resource(dev, 3, 0xa0000 >> 10, 0x1ffff >> 10);
19
20 /* Run standard resource set routine */
21 pci_dev_set_resources(dev);
22}
23
24static void aspeed_ast2050_init(struct device *dev)
25{
Timothy Pearson04cf4492015-09-05 17:38:09 -050026 struct drm_device drm_dev;
27
28 drm_dev.pdev = dev;
29
30 printk(BIOS_INFO, "ASpeed AST2050: initializing video device\n");
Elyes HAOUAS1a7623b2019-05-22 21:05:24 +020031 ast_driver_load(&drm_dev, 0);
Timothy Pearson04cf4492015-09-05 17:38:09 -050032
33 /* Unlock extended configuration registers */
34 outb(0x80, 0x3d4); outb(0xa8, 0x3d5);
35
36 /* Set CRT Request Threshold */
37 outb(0xa6, 0x3d4); outb(0x2f, 0x3d5);
38 outb(0xa7, 0x3d4); outb(0x3f, 0x3d5);
39
Patrick Rudolphf1a4ae02019-09-30 11:02:04 +020040 if (CONFIG(VGA_TEXT_FRAMEBUFFER)) {
41 /* Initialize standard VGA text mode */
42 vga_io_init();
Timothy Pearson04cf4492015-09-05 17:38:09 -050043
Patrick Rudolphf1a4ae02019-09-30 11:02:04 +020044 vga_textmode_init();
45 printk(BIOS_INFO, "ASpeed VGA text mode initialized\n");
46
47 /* if we don't have console, at least print something... */
48 vga_line_write(0, "ASpeed VGA text mode initialized");
49 } else if (CONFIG(GENERIC_LINEAR_FRAMEBUFFER)) {
50 ast_driver_framebuffer_init(&drm_dev, 0);
51 printk(BIOS_INFO, "ASpeed high resolution framebuffer initialized\n");
52 }
Timothy Pearson04cf4492015-09-05 17:38:09 -050053}
54
55static struct device_operations aspeed_ast2050_ops = {
56 .read_resources = pci_dev_read_resources,
57 .set_resources = aspeed_ast2050_set_resources,
58 .enable_resources = pci_dev_enable_resources,
59 .init = aspeed_ast2050_init,
Timothy Pearson04cf4492015-09-05 17:38:09 -050060};
61
62static const struct pci_driver aspeed_ast2050_driver __pci_driver = {
Martin Rothb9810a42017-07-23 20:00:04 -060063 .ops = &aspeed_ast2050_ops,
64 .vendor = PCI_VENDOR_ID_ASPEED,
65 .device = PCI_DEVICE_ID_ASPEED_AST2050_VGA,
Timothy Pearson04cf4492015-09-05 17:38:09 -050066};