Angel Pons | 8a3453f | 2020-04-02 23:48:19 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Elyes HAOUAS | bf0970e | 2019-03-21 11:10:03 +0100 | [diff] [blame] | 3 | |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 4 | #include <arch/io.h> |
| 5 | #include <edid.h> |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 6 | #include <console/console.h> |
| 7 | #include <device/device.h> |
| 8 | #include <device/pci.h> |
| 9 | #include <device/pci_ids.h> |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 10 | #include <pc80/vga.h> |
| 11 | |
| 12 | #include "../common/aspeed_coreboot.h" |
| 13 | #include "../common/ast_drv.h" |
| 14 | |
Elyes HAOUAS | c80435d | 2018-05-04 18:41:10 +0200 | [diff] [blame] | 15 | static void aspeed_ast2050_set_resources(struct device *dev) |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 16 | { |
| 17 | /* Reserve VGA regions */ |
| 18 | mmio_resource(dev, 3, 0xa0000 >> 10, 0x1ffff >> 10); |
| 19 | |
| 20 | /* Run standard resource set routine */ |
| 21 | pci_dev_set_resources(dev); |
| 22 | } |
| 23 | |
| 24 | static void aspeed_ast2050_init(struct device *dev) |
| 25 | { |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 26 | struct drm_device drm_dev; |
| 27 | |
| 28 | drm_dev.pdev = dev; |
| 29 | |
| 30 | printk(BIOS_INFO, "ASpeed AST2050: initializing video device\n"); |
Elyes HAOUAS | 1a7623b | 2019-05-22 21:05:24 +0200 | [diff] [blame] | 31 | ast_driver_load(&drm_dev, 0); |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 32 | |
| 33 | /* Unlock extended configuration registers */ |
| 34 | outb(0x80, 0x3d4); outb(0xa8, 0x3d5); |
| 35 | |
| 36 | /* Set CRT Request Threshold */ |
| 37 | outb(0xa6, 0x3d4); outb(0x2f, 0x3d5); |
| 38 | outb(0xa7, 0x3d4); outb(0x3f, 0x3d5); |
| 39 | |
Patrick Rudolph | f1a4ae0 | 2019-09-30 11:02:04 +0200 | [diff] [blame] | 40 | if (CONFIG(VGA_TEXT_FRAMEBUFFER)) { |
| 41 | /* Initialize standard VGA text mode */ |
| 42 | vga_io_init(); |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 43 | |
Patrick Rudolph | f1a4ae0 | 2019-09-30 11:02:04 +0200 | [diff] [blame] | 44 | vga_textmode_init(); |
| 45 | printk(BIOS_INFO, "ASpeed VGA text mode initialized\n"); |
| 46 | |
| 47 | /* if we don't have console, at least print something... */ |
| 48 | vga_line_write(0, "ASpeed VGA text mode initialized"); |
| 49 | } else if (CONFIG(GENERIC_LINEAR_FRAMEBUFFER)) { |
| 50 | ast_driver_framebuffer_init(&drm_dev, 0); |
| 51 | printk(BIOS_INFO, "ASpeed high resolution framebuffer initialized\n"); |
| 52 | } |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | static struct device_operations aspeed_ast2050_ops = { |
| 56 | .read_resources = pci_dev_read_resources, |
| 57 | .set_resources = aspeed_ast2050_set_resources, |
| 58 | .enable_resources = pci_dev_enable_resources, |
| 59 | .init = aspeed_ast2050_init, |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | static const struct pci_driver aspeed_ast2050_driver __pci_driver = { |
Martin Roth | b9810a4 | 2017-07-23 20:00:04 -0600 | [diff] [blame] | 63 | .ops = &aspeed_ast2050_ops, |
| 64 | .vendor = PCI_VENDOR_ID_ASPEED, |
| 65 | .device = PCI_DEVICE_ID_ASPEED_AST2050_VGA, |
Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame] | 66 | }; |