Angel Pons | 585495e | 2020-04-03 01:21:38 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 597ff87 | 2013-01-07 13:21:22 -0800 | [diff] [blame] | 2 | |
Stefan Reinauer | 4a3bb76 | 2004-06-28 11:57:31 +0000 | [diff] [blame] | 3 | #include <device/device.h> |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 4 | #include <device/pci.h> |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 5 | #include <device/pci_ops.h> |
Stefan Reinauer | 65e9bc1 | 2009-03-13 17:00:46 +0000 | [diff] [blame] | 6 | #include <pc80/keyboard.h> |
Stefan Reinauer | 4a3bb76 | 2004-06-28 11:57:31 +0000 | [diff] [blame] | 7 | |
Gerd Hoffmann | 082d2a0 | 2013-05-29 14:59:36 +0200 | [diff] [blame] | 8 | static const unsigned char qemu_i440fx_irqs[] = { |
| 9 | 11, 10, 10, 11, |
| 10 | 11, 10, 10, 11, |
| 11 | }; |
Ronald G. Minnich rminnich | 4a8523a | 2009-04-07 02:18:13 +0000 | [diff] [blame] | 12 | |
Elyes HAOUAS | 5cb876c | 2018-06-08 18:31:43 +0200 | [diff] [blame] | 13 | static void qemu_nb_init(struct device *dev) |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 14 | { |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 15 | /* Map memory at 0xc0000 - 0xfffff */ |
| 16 | int i; |
| 17 | uint8_t v = pci_read_config8(dev, 0x59); |
| 18 | v |= 0x30; |
| 19 | pci_write_config8(dev, 0x59, v); |
Elyes HAOUAS | 6350a2e | 2016-09-16 20:49:38 +0200 | [diff] [blame] | 20 | for (i = 0; i < 6; i++) |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 21 | pci_write_config8(dev, 0x5a + i, 0x33); |
Aaron Lwe | 2342f8b | 2008-05-06 15:02:22 +0000 | [diff] [blame] | 22 | |
Paul Menzel | feecdc2 | 2020-06-20 23:01:37 +0200 | [diff] [blame] | 23 | /* This sneaked in here, because Qemu does not emulate a SuperIO chip. */ |
Timothy Pearson | 448e386 | 2015-11-24 14:12:01 -0600 | [diff] [blame] | 24 | pc_keyboard_init(NO_AUX_DEVICE); |
Ronald G. Minnich rminnich | 4a8523a | 2009-04-07 02:18:13 +0000 | [diff] [blame] | 25 | |
Gerd Hoffmann | 082d2a0 | 2013-05-29 14:59:36 +0200 | [diff] [blame] | 26 | /* setup IRQ routing */ |
| 27 | for (i = 0; i < 32; i++) |
Kyösti Mälkki | c19d6a6 | 2019-07-04 21:39:28 +0300 | [diff] [blame] | 28 | pci_assign_irqs(pcidev_on_root(i, 0), qemu_i440fx_irqs + (i % 4)); |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 29 | } |
| 30 | |
Patrick Rudolph | 82e111c | 2021-01-07 14:12:38 +0100 | [diff] [blame] | 31 | static void qemu_nb_read_resources(struct device *dev) |
| 32 | { |
| 33 | pci_dev_read_resources(dev); |
| 34 | |
| 35 | if (CONFIG(ARCH_RAMSTAGE_X86_64)) { |
| 36 | /* Reserve page tables in DRAM. FIXME: Remove once x86_64 page tables reside in CBMEM */ |
| 37 | reserved_ram_resource(dev, 0, CONFIG_ARCH_X86_64_PGTBL_LOC / KiB, |
| 38 | (6 * 0x1000) / KiB); |
| 39 | } |
| 40 | } |
| 41 | |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 42 | static struct device_operations nb_operations = { |
Patrick Rudolph | 82e111c | 2021-01-07 14:12:38 +0100 | [diff] [blame] | 43 | .read_resources = qemu_nb_read_resources, |
Gerd Hoffmann | 7fd1bee | 2013-06-17 10:03:17 +0200 | [diff] [blame] | 44 | .set_resources = pci_dev_set_resources, |
| 45 | .enable_resources = pci_dev_enable_resources, |
| 46 | .init = qemu_nb_init, |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | static const struct pci_driver nb_driver __pci_driver = { |
| 50 | .ops = &nb_operations, |
| 51 | .vendor = 0x8086, |
| 52 | .device = 0x1237, |
| 53 | }; |