blob: 4230146b0c5284c5391cca429880553e2b7535d2 [file] [log] [blame]
Timothy Pearson04cf4492015-09-05 17:38:09 -05001/*
2 * This file is part of the coreboot project.
3 *
Timothy Pearson04cf4492015-09-05 17:38:09 -05004 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
Timothy Pearson04cf4492015-09-05 17:38:09 -050012 */
Elyes HAOUASbf0970e2019-03-21 11:10:03 +010013
Timothy Pearson04cf4492015-09-05 17:38:09 -050014#include <arch/io.h>
15#include <edid.h>
Timothy Pearson04cf4492015-09-05 17:38:09 -050016#include <console/console.h>
17#include <device/device.h>
18#include <device/pci.h>
19#include <device/pci_ids.h>
Timothy Pearson04cf4492015-09-05 17:38:09 -050020#include <pc80/vga.h>
21
22#include "../common/aspeed_coreboot.h"
23#include "../common/ast_drv.h"
24
Elyes HAOUASc80435d2018-05-04 18:41:10 +020025static void aspeed_ast2050_set_resources(struct device *dev)
Timothy Pearson04cf4492015-09-05 17:38:09 -050026{
27 /* Reserve VGA regions */
28 mmio_resource(dev, 3, 0xa0000 >> 10, 0x1ffff >> 10);
29
30 /* Run standard resource set routine */
31 pci_dev_set_resources(dev);
32}
33
34static void aspeed_ast2050_init(struct device *dev)
35{
Timothy Pearson04cf4492015-09-05 17:38:09 -050036 struct drm_device drm_dev;
37
38 drm_dev.pdev = dev;
39
40 printk(BIOS_INFO, "ASpeed AST2050: initializing video device\n");
Elyes HAOUAS1a7623b2019-05-22 21:05:24 +020041 ast_driver_load(&drm_dev, 0);
Timothy Pearson04cf4492015-09-05 17:38:09 -050042
43 /* Unlock extended configuration registers */
44 outb(0x80, 0x3d4); outb(0xa8, 0x3d5);
45
46 /* Set CRT Request Threshold */
47 outb(0xa6, 0x3d4); outb(0x2f, 0x3d5);
48 outb(0xa7, 0x3d4); outb(0x3f, 0x3d5);
49
Patrick Rudolphf1a4ae02019-09-30 11:02:04 +020050 if (CONFIG(VGA_TEXT_FRAMEBUFFER)) {
51 /* Initialize standard VGA text mode */
52 vga_io_init();
Timothy Pearson04cf4492015-09-05 17:38:09 -050053
Patrick Rudolphf1a4ae02019-09-30 11:02:04 +020054 vga_textmode_init();
55 printk(BIOS_INFO, "ASpeed VGA text mode initialized\n");
56
57 /* if we don't have console, at least print something... */
58 vga_line_write(0, "ASpeed VGA text mode initialized");
59 } else if (CONFIG(GENERIC_LINEAR_FRAMEBUFFER)) {
60 ast_driver_framebuffer_init(&drm_dev, 0);
61 printk(BIOS_INFO, "ASpeed high resolution framebuffer initialized\n");
62 }
Timothy Pearson04cf4492015-09-05 17:38:09 -050063}
64
65static struct device_operations aspeed_ast2050_ops = {
66 .read_resources = pci_dev_read_resources,
67 .set_resources = aspeed_ast2050_set_resources,
68 .enable_resources = pci_dev_enable_resources,
69 .init = aspeed_ast2050_init,
Timothy Pearson04cf4492015-09-05 17:38:09 -050070};
71
72static const struct pci_driver aspeed_ast2050_driver __pci_driver = {
Martin Rothb9810a42017-07-23 20:00:04 -060073 .ops = &aspeed_ast2050_ops,
74 .vendor = PCI_VENDOR_ID_ASPEED,
75 .device = PCI_DEVICE_ID_ASPEED_AST2050_VGA,
Timothy Pearson04cf4492015-09-05 17:38:09 -050076};