Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2004 Stefan Reinauer <stefan.reinauer@coreboot.org> |
| 5 | * Copyright (C) 2010 Kevin O'Connor <kevin@koconnor.net> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
Patrick Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 18 | * Foundation, Inc. |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #include <device/device.h> |
| 22 | #include <device/pci.h> |
| 23 | #include <device/pci_ids.h> |
| 24 | #include <device/pci_ops.h> |
| 25 | #include <pc80/keyboard.h> |
| 26 | #include <arch/io.h> |
| 27 | #include <console/console.h> |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 28 | #include <drivers/intel/gma/i915.h> |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 29 | |
| 30 | #define Q35_PAM0 0x90 |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 31 | |
| 32 | static const unsigned char qemu_q35_irqs[] = { |
| 33 | 10, 10, 11, 11, |
| 34 | 10, 10, 11, 11, |
| 35 | }; |
| 36 | |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 37 | struct i915_gpu_controller_info gfx_controller_info = { |
| 38 | .ndid = 3, |
| 39 | .did = { |
| 40 | 0x80000100, 0x80000240, 0x80000410, 0x80000410, 0x00000005 |
| 41 | } |
| 42 | }; |
| 43 | |
| 44 | const struct i915_gpu_controller_info * |
| 45 | intel_gma_get_controller_info(void) |
Vladimir Serbinenko | 53be14c | 2015-05-29 09:16:17 +0200 | [diff] [blame^] | 46 | { |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 47 | return &gfx_controller_info; |
| 48 | } |
| 49 | |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 50 | static void qemu_nb_init(device_t dev) |
| 51 | { |
| 52 | /* Map memory at 0xc0000 - 0xfffff */ |
| 53 | int i; |
| 54 | uint8_t v = pci_read_config8(dev, Q35_PAM0); |
| 55 | v |= 0x30; |
| 56 | pci_write_config8(dev, Q35_PAM0, v); |
| 57 | pci_write_config8(dev, Q35_PAM0 + 1, 0x33); |
| 58 | pci_write_config8(dev, Q35_PAM0 + 2, 0x33); |
| 59 | pci_write_config8(dev, Q35_PAM0 + 3, 0x33); |
| 60 | pci_write_config8(dev, Q35_PAM0 + 4, 0x33); |
| 61 | pci_write_config8(dev, Q35_PAM0 + 5, 0x33); |
| 62 | pci_write_config8(dev, Q35_PAM0 + 6, 0x33); |
| 63 | |
| 64 | /* This sneaked in here, because Qemu does not |
| 65 | * emulate a SuperIO chip |
| 66 | */ |
Edward O'Callaghan | def00be | 2014-04-30 05:01:52 +1000 | [diff] [blame] | 67 | pc_keyboard_init(); |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 68 | |
| 69 | /* setup IRQ routing for pci slots */ |
| 70 | for (i = 0; i < 25; i++) |
| 71 | pci_assign_irqs(0, i, qemu_q35_irqs + (i % 4)); |
| 72 | /* setup IRQ routing southbridge devices */ |
| 73 | for (i = 25; i < 32; i++) |
| 74 | pci_assign_irqs(0, i, qemu_q35_irqs); |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | static void qemu_nb_read_resources(struct device *dev) |
| 78 | { |
| 79 | pci_dev_read_resources(dev); |
| 80 | |
| 81 | /* reserve mmconfig */ |
Kyösti Mälkki | b9646a2 | 2013-07-03 08:06:32 +0300 | [diff] [blame] | 82 | fixed_mem_resource(dev, 2, CONFIG_MMCONF_BASE_ADDRESS >> 10, 0x10000000 >> 10, |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 83 | IORESOURCE_RESERVE); |
| 84 | } |
| 85 | |
| 86 | |
| 87 | static struct device_operations nb_operations = { |
| 88 | .read_resources = qemu_nb_read_resources, |
| 89 | .set_resources = pci_dev_set_resources, |
| 90 | .enable_resources = pci_dev_enable_resources, |
| 91 | .init = qemu_nb_init, |
| 92 | .ops_pci = 0, |
| 93 | }; |
| 94 | |
| 95 | static const struct pci_driver nb_driver __pci_driver = { |
| 96 | .ops = &nb_operations, |
| 97 | .vendor = 0x8086, |
| 98 | .device = 0x29c0, |
| 99 | }; |