blob: d329e5affbe5a661a471c963e303ba672e78f434 [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
Paul Menzelfeecdc22020-06-20 23:01:37 +020029 /* This sneaked in here, because Qemu does not emulate a SuperIO chip. */
Timothy Pearson448e3862015-11-24 14:12:01 -060030 pc_keyboard_init(NO_AUX_DEVICE);
Gerd Hoffmannee941b382013-06-07 16:03:44 +020031
32 /* setup IRQ routing for pci slots */
33 for (i = 0; i < 25; i++)
Kyösti Mälkkic19d6a62019-07-04 21:39:28 +030034 pci_assign_irqs(pcidev_on_root(i, 0), qemu_q35_irqs + (i % 4));
Gerd Hoffmannee941b382013-06-07 16:03:44 +020035 /* setup IRQ routing southbridge devices */
36 for (i = 25; i < 32; i++)
Kyösti Mälkkic19d6a62019-07-04 21:39:28 +030037 pci_assign_irqs(pcidev_on_root(i, 0), qemu_q35_irqs);
Gerd Hoffmannee941b382013-06-07 16:03:44 +020038}
39
40static void qemu_nb_read_resources(struct device *dev)
41{
42 pci_dev_read_resources(dev);
43
44 /* reserve mmconfig */
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030045 fixed_mem_resource(dev, 2, CONFIG_MMCONF_BASE_ADDRESS >> 10, 0x10000000 >> 10,
Gerd Hoffmannee941b382013-06-07 16:03:44 +020046 IORESOURCE_RESERVE);
47}
48
49
50static struct device_operations nb_operations = {
51 .read_resources = qemu_nb_read_resources,
52 .set_resources = pci_dev_set_resources,
53 .enable_resources = pci_dev_enable_resources,
54 .init = qemu_nb_init,
Gerd Hoffmannee941b382013-06-07 16:03:44 +020055};
56
57static const struct pci_driver nb_driver __pci_driver = {
58 .ops = &nb_operations,
59 .vendor = 0x8086,
60 .device = 0x29c0,
61};