blob: c7e983ab6c5cb465378959ea76471b50c2cf68ef [file] [log] [blame]
Angel Pons585495e2020-04-03 01:21:38 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Gerd Hoffmannee941b382013-06-07 16:03:44 +02002
3#include <device/device.h>
4#include <device/pci.h>
Gerd Hoffmannee941b382013-06-07 16:03:44 +02005#include <device/pci_ops.h>
6#include <pc80/keyboard.h>
Gerd Hoffmannee941b382013-06-07 16:03:44 +02007
8#define Q35_PAM0 0x90
Gerd Hoffmannee941b382013-06-07 16:03:44 +02009
10static const unsigned char qemu_q35_irqs[] = {
11 10, 10, 11, 11,
12 10, 10, 11, 11,
13};
14
Elyes HAOUAS5cb876c2018-06-08 18:31:43 +020015static void qemu_nb_init(struct device *dev)
Gerd Hoffmannee941b382013-06-07 16:03:44 +020016{
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 Pearson448e3862015-11-24 14:12:01 -060032 pc_keyboard_init(NO_AUX_DEVICE);
Gerd Hoffmannee941b382013-06-07 16:03:44 +020033
34 /* setup IRQ routing for pci slots */
35 for (i = 0; i < 25; i++)
Kyösti Mälkkic19d6a62019-07-04 21:39:28 +030036 pci_assign_irqs(pcidev_on_root(i, 0), qemu_q35_irqs + (i % 4));
Gerd Hoffmannee941b382013-06-07 16:03:44 +020037 /* setup IRQ routing southbridge devices */
38 for (i = 25; i < 32; i++)
Kyösti Mälkkic19d6a62019-07-04 21:39:28 +030039 pci_assign_irqs(pcidev_on_root(i, 0), qemu_q35_irqs);
Gerd Hoffmannee941b382013-06-07 16:03:44 +020040}
41
42static void qemu_nb_read_resources(struct device *dev)
43{
44 pci_dev_read_resources(dev);
45
46 /* reserve mmconfig */
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030047 fixed_mem_resource(dev, 2, CONFIG_MMCONF_BASE_ADDRESS >> 10, 0x10000000 >> 10,
Gerd Hoffmannee941b382013-06-07 16:03:44 +020048 IORESOURCE_RESERVE);
49}
50
51
52static 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 Hoffmannee941b382013-06-07 16:03:44 +020057};
58
59static const struct pci_driver nb_driver __pci_driver = {
60 .ops = &nb_operations,
61 .vendor = 0x8086,
62 .device = 0x29c0,
63};