blob: ed128f319b73fc8fa370d3eeeeb25024a8dd3250 [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 */
15#include <delay.h>
16#include <stdlib.h>
17#include <string.h>
18#include <arch/io.h>
19#include <edid.h>
20
21#include <console/console.h>
22#include <device/device.h>
23#include <device/pci.h>
24#include <device/pci_ids.h>
25#include <device/pci_ops.h>
26
27#include <pc80/vga.h>
28
29#include "../common/aspeed_coreboot.h"
30#include "../common/ast_drv.h"
31
32static void aspeed_ast2050_set_resources(device_t dev)
33{
34 /* Reserve VGA regions */
35 mmio_resource(dev, 3, 0xa0000 >> 10, 0x1ffff >> 10);
36
37 /* Run standard resource set routine */
38 pci_dev_set_resources(dev);
39}
40
41static void aspeed_ast2050_init(struct device *dev)
42{
43 u8 ret;
44 struct drm_device drm_dev;
45
46 drm_dev.pdev = dev;
47
48 printk(BIOS_INFO, "ASpeed AST2050: initializing video device\n");
49 ret = ast_driver_load(&drm_dev, 0);
50
51 /* Unlock extended configuration registers */
52 outb(0x80, 0x3d4); outb(0xa8, 0x3d5);
53
54 /* Set CRT Request Threshold */
55 outb(0xa6, 0x3d4); outb(0x2f, 0x3d5);
56 outb(0xa7, 0x3d4); outb(0x3f, 0x3d5);
57
58 /* Initialize standard VGA text mode */
59 vga_io_init();
60 vga_textmode_init();
61 printk(BIOS_INFO, "ASpeed VGA text mode initialized\n");
62
63 /* if we don't have console, at least print something... */
64 vga_line_write(0, "ASpeed VGA text mode initialized");
65}
66
67static struct device_operations aspeed_ast2050_ops = {
68 .read_resources = pci_dev_read_resources,
69 .set_resources = aspeed_ast2050_set_resources,
70 .enable_resources = pci_dev_enable_resources,
71 .init = aspeed_ast2050_init,
72 .scan_bus = 0,
73};
74
75static const struct pci_driver aspeed_ast2050_driver __pci_driver = {
Martin Rothb9810a42017-07-23 20:00:04 -060076 .ops = &aspeed_ast2050_ops,
77 .vendor = PCI_VENDOR_ID_ASPEED,
78 .device = PCI_DEVICE_ID_ASPEED_AST2050_VGA,
Timothy Pearson04cf4492015-09-05 17:38:09 -050079};