1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <arch/io.h>
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <device/pci.h>
7 #include <device/pci_ids.h>
8 #include <pc80/vga.h>
9
10 #include "../common/aspeed_coreboot.h"
11 #include "../common/ast_drv.h"
12
aspeed_ast2050_read_resources(struct device * dev)13 static void aspeed_ast2050_read_resources(struct device *dev)
14 {
15 /* Reserve VGA regions */
16 mmio_from_to(dev, 3, 0xa0000, 0xc0000);
17
18 /* Run standard resource read routine */
19 pci_dev_read_resources(dev);
20 }
21
aspeed_ast2050_init(struct device * dev)22 static void aspeed_ast2050_init(struct device *dev)
23 {
24 struct drm_device drm_dev;
25
26 drm_dev.pdev = dev;
27
28 printk(BIOS_INFO, "ASpeed AST2050: initializing video device\n");
29 ast_driver_load(&drm_dev, 0);
30
31 /* Unlock extended configuration registers */
32 outb(0x80, 0x3d4); outb(0xa8, 0x3d5);
33
34 /* Set CRT Request Threshold */
35 outb(0xa6, 0x3d4); outb(0x2f, 0x3d5);
36 outb(0xa7, 0x3d4); outb(0x3f, 0x3d5);
37
38 if (CONFIG(VGA_TEXT_FRAMEBUFFER)) {
39 /* Initialize standard VGA text mode */
40 vga_io_init();
41
42 vga_textmode_init();
43 printk(BIOS_INFO, "ASpeed VGA text mode initialized\n");
44
45 /* if we don't have console, at least print something... */
46 vga_line_write(0, "ASpeed VGA text mode initialized");
47 } else if (CONFIG(GENERIC_LINEAR_FRAMEBUFFER)) {
48 ast_driver_framebuffer_init(&drm_dev, 0);
49 printk(BIOS_INFO, "ASpeed high resolution framebuffer initialized\n");
50 }
51 }
52
53 static struct device_operations aspeed_ast2050_ops = {
54 .read_resources = aspeed_ast2050_read_resources,
55 .set_resources = pci_dev_set_resources,
56 .enable_resources = pci_dev_enable_resources,
57 .init = aspeed_ast2050_init,
58 };
59
60 static const struct pci_driver aspeed_ast2050_driver __pci_driver = {
61 .ops = &aspeed_ast2050_ops,
62 .vendor = PCI_VID_ASPEED,
63 .device = PCI_DID_ASPEED_AST2050_VGA,
64 };
65