Angel Pons | 8a3453f | 2020-04-02 23:48:19 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Elyes HAOUAS | bf0970e | 2019-03-21 11:10:03 +0100 | [diff] [blame] | 2 | |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 3 | #include <arch/io.h> |
| 4 | #include <edid.h> |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 5 | #include <console/console.h> |
| 6 | #include <device/device.h> |
| 7 | #include <device/pci.h> |
| 8 | #include <device/pci_ids.h> |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 9 | #include <pc80/vga.h> |
| 10 | |
| 11 | #include "../common/aspeed_coreboot.h" |
| 12 | #include "../common/ast_drv.h" |
| 13 | |
Elyes HAOUAS | c80435d | 2018-05-04 18:41:10 +0200 | [diff] [blame] | 14 | static void aspeed_ast2050_set_resources(struct device *dev) |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 15 | { |
| 16 | /* Reserve VGA regions */ |
| 17 | mmio_resource(dev, 3, 0xa0000 >> 10, 0x1ffff >> 10); |
| 18 | |
| 19 | /* Run standard resource set routine */ |
| 20 | pci_dev_set_resources(dev); |
| 21 | } |
| 22 | |
| 23 | static void aspeed_ast2050_init(struct device *dev) |
| 24 | { |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 25 | struct drm_device drm_dev; |
| 26 | |
| 27 | drm_dev.pdev = dev; |
| 28 | |
| 29 | printk(BIOS_INFO, "ASpeed AST2050: initializing video device\n"); |
Elyes HAOUAS | 1a7623b | 2019-05-22 21:05:24 +0200 | [diff] [blame] | 30 | ast_driver_load(&drm_dev, 0); |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 31 | |
| 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 Rudolph | f1a4ae0 | 2019-09-30 11:02:04 +0200 | [diff] [blame] | 39 | if (CONFIG(VGA_TEXT_FRAMEBUFFER)) { |
| 40 | /* Initialize standard VGA text mode */ |
| 41 | vga_io_init(); |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 42 | |
Patrick Rudolph | f1a4ae0 | 2019-09-30 11:02:04 +0200 | [diff] [blame] | 43 | 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 Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | static struct device_operations aspeed_ast2050_ops = { |
| 55 | .read_resources = pci_dev_read_resources, |
| 56 | .set_resources = aspeed_ast2050_set_resources, |
| 57 | .enable_resources = pci_dev_enable_resources, |
| 58 | .init = aspeed_ast2050_init, |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | static const struct pci_driver aspeed_ast2050_driver __pci_driver = { |
Martin Roth | b9810a4 | 2017-07-23 20:00:04 -0600 | [diff] [blame] | 62 | .ops = &aspeed_ast2050_ops, |
| 63 | .vendor = PCI_VENDOR_ID_ASPEED, |
| 64 | .device = PCI_DEVICE_ID_ASPEED_AST2050_VGA, |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 65 | }; |