blob: 929743ac462087130196167fd0939818ce1fc210 [file] [log] [blame]
Angel Pons585495e2020-04-03 01:21:38 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer597ff872013-01-07 13:21:22 -08002
Stefan Reinauer4a3bb762004-06-28 11:57:31 +00003#include <device/device.h>
Stefan Reinauerd56981f2007-10-22 10:07:46 +00004#include <device/pci.h>
Stefan Reinauerd56981f2007-10-22 10:07:46 +00005#include <device/pci_ops.h>
Stefan Reinauer65e9bc12009-03-13 17:00:46 +00006#include <pc80/keyboard.h>
Stefan Reinauer4a3bb762004-06-28 11:57:31 +00007
Gerd Hoffmann082d2a02013-05-29 14:59:36 +02008static const unsigned char qemu_i440fx_irqs[] = {
9 11, 10, 10, 11,
10 11, 10, 10, 11,
11};
Ronald G. Minnich rminnich4a8523a2009-04-07 02:18:13 +000012
Elyes HAOUAS5cb876c2018-06-08 18:31:43 +020013static void qemu_nb_init(struct device *dev)
Stefan Reinauerd56981f2007-10-22 10:07:46 +000014{
Kevin O'Connor31b2e8f2010-09-06 20:20:47 +000015 /* 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 HAOUAS6350a2e2016-09-16 20:49:38 +020020 for (i = 0; i < 6; i++)
Kevin O'Connor31b2e8f2010-09-06 20:20:47 +000021 pci_write_config8(dev, 0x5a + i, 0x33);
Aaron Lwe2342f8b2008-05-06 15:02:22 +000022
Paul Menzelfeecdc22020-06-20 23:01:37 +020023 /* This sneaked in here, because Qemu does not emulate a SuperIO chip. */
Timothy Pearson448e3862015-11-24 14:12:01 -060024 pc_keyboard_init(NO_AUX_DEVICE);
Ronald G. Minnich rminnich4a8523a2009-04-07 02:18:13 +000025
Gerd Hoffmann082d2a02013-05-29 14:59:36 +020026 /* setup IRQ routing */
27 for (i = 0; i < 32; i++)
Kyösti Mälkkic19d6a62019-07-04 21:39:28 +030028 pci_assign_irqs(pcidev_on_root(i, 0), qemu_i440fx_irqs + (i % 4));
Stefan Reinauerd56981f2007-10-22 10:07:46 +000029}
30
Kevin O'Connor31b2e8f2010-09-06 20:20:47 +000031static struct device_operations nb_operations = {
Gerd Hoffmann7fd1bee2013-06-17 10:03:17 +020032 .read_resources = pci_dev_read_resources,
33 .set_resources = pci_dev_set_resources,
34 .enable_resources = pci_dev_enable_resources,
35 .init = qemu_nb_init,
Kevin O'Connor31b2e8f2010-09-06 20:20:47 +000036};
37
38static const struct pci_driver nb_driver __pci_driver = {
39 .ops = &nb_operations,
40 .vendor = 0x8086,
41 .device = 0x1237,
42};