Timothy Pearson | 04cf449 | 2015-09-05 17:38:09 -0500 | [diff] [blame^] | 1 | /* |
| 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. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | #include <delay.h> |
| 20 | #include <stdlib.h> |
| 21 | #include <string.h> |
| 22 | #include <arch/io.h> |
| 23 | #include <edid.h> |
| 24 | |
| 25 | #include <console/console.h> |
| 26 | #include <device/device.h> |
| 27 | #include <device/pci.h> |
| 28 | #include <device/pci_ids.h> |
| 29 | #include <device/pci_ops.h> |
| 30 | |
| 31 | #include <pc80/vga.h> |
| 32 | |
| 33 | #include "../common/aspeed_coreboot.h" |
| 34 | #include "../common/ast_drv.h" |
| 35 | |
| 36 | static void aspeed_ast2050_set_resources(device_t dev) |
| 37 | { |
| 38 | /* Reserve VGA regions */ |
| 39 | mmio_resource(dev, 3, 0xa0000 >> 10, 0x1ffff >> 10); |
| 40 | |
| 41 | /* Run standard resource set routine */ |
| 42 | pci_dev_set_resources(dev); |
| 43 | } |
| 44 | |
| 45 | static void aspeed_ast2050_init(struct device *dev) |
| 46 | { |
| 47 | u8 ret; |
| 48 | struct drm_device drm_dev; |
| 49 | |
| 50 | drm_dev.pdev = dev; |
| 51 | |
| 52 | printk(BIOS_INFO, "ASpeed AST2050: initializing video device\n"); |
| 53 | ret = ast_driver_load(&drm_dev, 0); |
| 54 | |
| 55 | /* Unlock extended configuration registers */ |
| 56 | outb(0x80, 0x3d4); outb(0xa8, 0x3d5); |
| 57 | |
| 58 | /* Set CRT Request Threshold */ |
| 59 | outb(0xa6, 0x3d4); outb(0x2f, 0x3d5); |
| 60 | outb(0xa7, 0x3d4); outb(0x3f, 0x3d5); |
| 61 | |
| 62 | /* Initialize standard VGA text mode */ |
| 63 | vga_io_init(); |
| 64 | vga_textmode_init(); |
| 65 | printk(BIOS_INFO, "ASpeed VGA text mode initialized\n"); |
| 66 | |
| 67 | /* if we don't have console, at least print something... */ |
| 68 | vga_line_write(0, "ASpeed VGA text mode initialized"); |
| 69 | } |
| 70 | |
| 71 | static struct device_operations aspeed_ast2050_ops = { |
| 72 | .read_resources = pci_dev_read_resources, |
| 73 | .set_resources = aspeed_ast2050_set_resources, |
| 74 | .enable_resources = pci_dev_enable_resources, |
| 75 | .init = aspeed_ast2050_init, |
| 76 | .scan_bus = 0, |
| 77 | }; |
| 78 | |
| 79 | static const struct pci_driver aspeed_ast2050_driver __pci_driver = { |
| 80 | .ops = &aspeed_ast2050_ops, |
| 81 | .vendor = PCI_VENDOR_ID_ASPEED, |
| 82 | .device = PCI_DEVICE_ID_ASPEED_AST2050_VGA, |
| 83 | }; |