blob: 67a1a803fee2e96c83850ebc386eca0a302345ca [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 <stdlib.h>
Timothy Pearson04cf4492015-09-05 17:38:09 -050015#include <arch/io.h>
16#include <edid.h>
Timothy Pearson04cf4492015-09-05 17:38:09 -050017#include <console/console.h>
18#include <device/device.h>
19#include <device/pci.h>
20#include <device/pci_ids.h>
Timothy Pearson04cf4492015-09-05 17:38:09 -050021#include <pc80/vga.h>
22
23#include "../common/aspeed_coreboot.h"
24#include "../common/ast_drv.h"
25
Elyes HAOUASc80435d2018-05-04 18:41:10 +020026static void aspeed_ast2050_set_resources(struct device *dev)
Timothy Pearson04cf4492015-09-05 17:38:09 -050027{
28 /* Reserve VGA regions */
29 mmio_resource(dev, 3, 0xa0000 >> 10, 0x1ffff >> 10);
30
31 /* Run standard resource set routine */
32 pci_dev_set_resources(dev);
33}
34
35static void aspeed_ast2050_init(struct device *dev)
36{
Timothy Pearson04cf4492015-09-05 17:38:09 -050037 struct drm_device drm_dev;
38
39 drm_dev.pdev = dev;
40
41 printk(BIOS_INFO, "ASpeed AST2050: initializing video device\n");
Elyes HAOUAS1a7623b2019-05-22 21:05:24 +020042 ast_driver_load(&drm_dev, 0);
Timothy Pearson04cf4492015-09-05 17:38:09 -050043
44 /* Unlock extended configuration registers */
45 outb(0x80, 0x3d4); outb(0xa8, 0x3d5);
46
47 /* Set CRT Request Threshold */
48 outb(0xa6, 0x3d4); outb(0x2f, 0x3d5);
49 outb(0xa7, 0x3d4); outb(0x3f, 0x3d5);
50
Patrick Rudolphf1a4ae02019-09-30 11:02:04 +020051 if (CONFIG(VGA_TEXT_FRAMEBUFFER)) {
52 /* Initialize standard VGA text mode */
53 vga_io_init();
Timothy Pearson04cf4492015-09-05 17:38:09 -050054
Patrick Rudolphf1a4ae02019-09-30 11:02:04 +020055 vga_textmode_init();
56 printk(BIOS_INFO, "ASpeed VGA text mode initialized\n");
57
58 /* if we don't have console, at least print something... */
59 vga_line_write(0, "ASpeed VGA text mode initialized");
60 } else if (CONFIG(GENERIC_LINEAR_FRAMEBUFFER)) {
61 ast_driver_framebuffer_init(&drm_dev, 0);
62 printk(BIOS_INFO, "ASpeed high resolution framebuffer initialized\n");
63 }
Timothy Pearson04cf4492015-09-05 17:38:09 -050064}
65
66static struct device_operations aspeed_ast2050_ops = {
67 .read_resources = pci_dev_read_resources,
68 .set_resources = aspeed_ast2050_set_resources,
69 .enable_resources = pci_dev_enable_resources,
70 .init = aspeed_ast2050_init,
71 .scan_bus = 0,
72};
73
74static const struct pci_driver aspeed_ast2050_driver __pci_driver = {
Martin Rothb9810a42017-07-23 20:00:04 -060075 .ops = &aspeed_ast2050_ops,
76 .vendor = PCI_VENDOR_ID_ASPEED,
77 .device = PCI_DEVICE_ID_ASPEED_AST2050_VGA,
Timothy Pearson04cf4492015-09-05 17:38:09 -050078};