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 | |
Angel Pons | 5124c13 | 2021-06-28 14:11:38 +0200 | [diff] [blame] | 13 | #define D0F0_PAM(x) (0x59 + (x)) /* 0-6 */ |
| 14 | |
Elyes HAOUAS | 5cb876c | 2018-06-08 18:31:43 +0200 | [diff] [blame] | 15 | static void qemu_nb_init(struct device *dev) |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 16 | { |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 17 | /* Map memory at 0xc0000 - 0xfffff */ |
| 18 | int i; |
Angel Pons | 5124c13 | 2021-06-28 14:11:38 +0200 | [diff] [blame] | 19 | pci_or_config8(dev, D0F0_PAM(0), 0x30); |
| 20 | for (i = 1; i <= 6; i++) |
| 21 | pci_write_config8(dev, D0F0_PAM(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 */ |
Angel Pons | c76c59a | 2021-06-28 14:00:57 +0200 | [diff] [blame] | 27 | for (i = 0; i < 32; i++) { |
| 28 | struct device *d = pcidev_on_root(i, 0); |
| 29 | if (d) |
| 30 | pci_assign_irqs(d, qemu_i440fx_irqs + (i % 4)); |
| 31 | } |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 32 | } |
| 33 | |
Patrick Rudolph | 82e111c | 2021-01-07 14:12:38 +0100 | [diff] [blame] | 34 | static void qemu_nb_read_resources(struct device *dev) |
| 35 | { |
| 36 | pci_dev_read_resources(dev); |
| 37 | |
| 38 | if (CONFIG(ARCH_RAMSTAGE_X86_64)) { |
| 39 | /* Reserve page tables in DRAM. FIXME: Remove once x86_64 page tables reside in CBMEM */ |
| 40 | reserved_ram_resource(dev, 0, CONFIG_ARCH_X86_64_PGTBL_LOC / KiB, |
| 41 | (6 * 0x1000) / KiB); |
| 42 | } |
| 43 | } |
| 44 | |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 45 | static struct device_operations nb_operations = { |
Patrick Rudolph | 82e111c | 2021-01-07 14:12:38 +0100 | [diff] [blame] | 46 | .read_resources = qemu_nb_read_resources, |
Gerd Hoffmann | 7fd1bee | 2013-06-17 10:03:17 +0200 | [diff] [blame] | 47 | .set_resources = pci_dev_set_resources, |
| 48 | .enable_resources = pci_dev_enable_resources, |
| 49 | .init = qemu_nb_init, |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | static const struct pci_driver nb_driver __pci_driver = { |
| 53 | .ops = &nb_operations, |
| 54 | .vendor = 0x8086, |
| 55 | .device = 0x1237, |
| 56 | }; |