blob: 7ead9a832fb0380bae37f1e53e850b6646316023 [file] [log] [blame]
Angel Pons8a3453f2020-04-02 23:48:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Elyes HAOUASbf0970e2019-03-21 11:10:03 +01002
Timothy Pearson04cf4492015-09-05 17:38:09 -05003#include <arch/io.h>
4#include <edid.h>
Timothy Pearson04cf4492015-09-05 17:38:09 -05005#include <console/console.h>
6#include <device/device.h>
7#include <device/pci.h>
8#include <device/pci_ids.h>
Timothy Pearson04cf4492015-09-05 17:38:09 -05009#include <pc80/vga.h>
10
11#include "../common/aspeed_coreboot.h"
12#include "../common/ast_drv.h"
13
Furquan Shaikh1dac6052020-05-13 10:46:17 -070014static void aspeed_ast2050_read_resources(struct device *dev)
Timothy Pearson04cf4492015-09-05 17:38:09 -050015{
16 /* Reserve VGA regions */
17 mmio_resource(dev, 3, 0xa0000 >> 10, 0x1ffff >> 10);
18
Furquan Shaikh1dac6052020-05-13 10:46:17 -070019 /* Run standard resource read routine */
20 pci_dev_read_resources(dev);
Timothy Pearson04cf4492015-09-05 17:38:09 -050021}
22
23static void aspeed_ast2050_init(struct device *dev)
24{
Timothy Pearson04cf4492015-09-05 17:38:09 -050025 struct drm_device drm_dev;
26
27 drm_dev.pdev = dev;
28
29 printk(BIOS_INFO, "ASpeed AST2050: initializing video device\n");
Elyes HAOUAS1a7623b2019-05-22 21:05:24 +020030 ast_driver_load(&drm_dev, 0);
Timothy Pearson04cf4492015-09-05 17:38:09 -050031
32 /* Unlock extended configuration registers */
33 outb(0x80, 0x3d4); outb(0xa8, 0x3d5);
34
35 /* Set CRT Request Threshold */
36 outb(0xa6, 0x3d4); outb(0x2f, 0x3d5);
37 outb(0xa7, 0x3d4); outb(0x3f, 0x3d5);
38
Patrick Rudolphf1a4ae02019-09-30 11:02:04 +020039 if (CONFIG(VGA_TEXT_FRAMEBUFFER)) {
40 /* Initialize standard VGA text mode */
41 vga_io_init();
Timothy Pearson04cf4492015-09-05 17:38:09 -050042
Patrick Rudolphf1a4ae02019-09-30 11:02:04 +020043 vga_textmode_init();
44 printk(BIOS_INFO, "ASpeed VGA text mode initialized\n");
45
46 /* if we don't have console, at least print something... */
47 vga_line_write(0, "ASpeed VGA text mode initialized");
48 } else if (CONFIG(GENERIC_LINEAR_FRAMEBUFFER)) {
49 ast_driver_framebuffer_init(&drm_dev, 0);
50 printk(BIOS_INFO, "ASpeed high resolution framebuffer initialized\n");
51 }
Timothy Pearson04cf4492015-09-05 17:38:09 -050052}
53
54static struct device_operations aspeed_ast2050_ops = {
Furquan Shaikh1dac6052020-05-13 10:46:17 -070055 .read_resources = aspeed_ast2050_read_resources,
56 .set_resources = pci_dev_set_resources,
Timothy Pearson04cf4492015-09-05 17:38:09 -050057 .enable_resources = pci_dev_enable_resources,
58 .init = aspeed_ast2050_init,
Timothy Pearson04cf4492015-09-05 17:38:09 -050059};
60
61static const struct pci_driver aspeed_ast2050_driver __pci_driver = {
Martin Rothb9810a42017-07-23 20:00:04 -060062 .ops = &aspeed_ast2050_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010063 .vendor = PCI_VID_ASPEED,
64 .device = PCI_DID_ASPEED_AST2050_VGA,
Timothy Pearson04cf4492015-09-05 17:38:09 -050065};