Angel Pons | 585495e | 2020-04-03 01:21:38 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 2 | |
| 3 | #include <device/device.h> |
| 4 | #include <device/pci.h> |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 5 | #include <device/pci_ops.h> |
| 6 | #include <pc80/keyboard.h> |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 7 | |
| 8 | #define Q35_PAM0 0x90 |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 9 | |
| 10 | static const unsigned char qemu_q35_irqs[] = { |
| 11 | 10, 10, 11, 11, |
| 12 | 10, 10, 11, 11, |
| 13 | }; |
| 14 | |
Elyes HAOUAS | 5cb876c | 2018-06-08 18:31:43 +0200 | [diff] [blame] | 15 | static void qemu_nb_init(struct device *dev) |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 16 | { |
| 17 | /* Map memory at 0xc0000 - 0xfffff */ |
| 18 | int i; |
| 19 | uint8_t v = pci_read_config8(dev, Q35_PAM0); |
| 20 | v |= 0x30; |
| 21 | pci_write_config8(dev, Q35_PAM0, v); |
| 22 | pci_write_config8(dev, Q35_PAM0 + 1, 0x33); |
| 23 | pci_write_config8(dev, Q35_PAM0 + 2, 0x33); |
| 24 | pci_write_config8(dev, Q35_PAM0 + 3, 0x33); |
| 25 | pci_write_config8(dev, Q35_PAM0 + 4, 0x33); |
| 26 | pci_write_config8(dev, Q35_PAM0 + 5, 0x33); |
| 27 | pci_write_config8(dev, Q35_PAM0 + 6, 0x33); |
| 28 | |
| 29 | /* This sneaked in here, because Qemu does not |
| 30 | * emulate a SuperIO chip |
| 31 | */ |
Timothy Pearson | 448e386 | 2015-11-24 14:12:01 -0600 | [diff] [blame] | 32 | pc_keyboard_init(NO_AUX_DEVICE); |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 33 | |
| 34 | /* setup IRQ routing for pci slots */ |
| 35 | for (i = 0; i < 25; i++) |
Kyösti Mälkki | c19d6a6 | 2019-07-04 21:39:28 +0300 | [diff] [blame] | 36 | pci_assign_irqs(pcidev_on_root(i, 0), qemu_q35_irqs + (i % 4)); |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 37 | /* setup IRQ routing southbridge devices */ |
| 38 | for (i = 25; i < 32; i++) |
Kyösti Mälkki | c19d6a6 | 2019-07-04 21:39:28 +0300 | [diff] [blame] | 39 | pci_assign_irqs(pcidev_on_root(i, 0), qemu_q35_irqs); |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | static void qemu_nb_read_resources(struct device *dev) |
| 43 | { |
| 44 | pci_dev_read_resources(dev); |
| 45 | |
| 46 | /* reserve mmconfig */ |
Kyösti Mälkki | b9646a2 | 2013-07-03 08:06:32 +0300 | [diff] [blame] | 47 | fixed_mem_resource(dev, 2, CONFIG_MMCONF_BASE_ADDRESS >> 10, 0x10000000 >> 10, |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 48 | IORESOURCE_RESERVE); |
| 49 | } |
| 50 | |
| 51 | |
| 52 | static struct device_operations nb_operations = { |
| 53 | .read_resources = qemu_nb_read_resources, |
| 54 | .set_resources = pci_dev_set_resources, |
| 55 | .enable_resources = pci_dev_enable_resources, |
| 56 | .init = qemu_nb_init, |
Gerd Hoffmann | ee941b38 | 2013-06-07 16:03:44 +0200 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | static const struct pci_driver nb_driver __pci_driver = { |
| 60 | .ops = &nb_operations, |
| 61 | .vendor = 0x8086, |
| 62 | .device = 0x29c0, |
| 63 | }; |