blob: 5e9b3208c6aaf5a7e8e1f366f1c408faf4697023 [file] [log] [blame]
Angel Pons585495e2020-04-03 01:21:38 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Stefan Reinauer597ff872013-01-07 13:21:22 -08003
Stefan Reinauer4a3bb762004-06-28 11:57:31 +00004#include <device/device.h>
Stefan Reinauerd56981f2007-10-22 10:07:46 +00005#include <device/pci.h>
Stefan Reinauerd56981f2007-10-22 10:07:46 +00006#include <device/pci_ops.h>
Stefan Reinauer65e9bc12009-03-13 17:00:46 +00007#include <pc80/keyboard.h>
Stefan Reinauer4a3bb762004-06-28 11:57:31 +00008
Gerd Hoffmann082d2a02013-05-29 14:59:36 +02009static const unsigned char qemu_i440fx_irqs[] = {
10 11, 10, 10, 11,
11 11, 10, 10, 11,
12};
Ronald G. Minnich rminnich4a8523a2009-04-07 02:18:13 +000013
Elyes HAOUAS5cb876c2018-06-08 18:31:43 +020014static void qemu_nb_init(struct device *dev)
Stefan Reinauerd56981f2007-10-22 10:07:46 +000015{
Kevin O'Connor31b2e8f2010-09-06 20:20:47 +000016 /* Map memory at 0xc0000 - 0xfffff */
17 int i;
18 uint8_t v = pci_read_config8(dev, 0x59);
19 v |= 0x30;
20 pci_write_config8(dev, 0x59, v);
Elyes HAOUAS6350a2e2016-09-16 20:49:38 +020021 for (i = 0; i < 6; i++)
Kevin O'Connor31b2e8f2010-09-06 20:20:47 +000022 pci_write_config8(dev, 0x5a + i, 0x33);
Aaron Lwe2342f8b2008-05-06 15:02:22 +000023
Stefan Reinauer65e9bc12009-03-13 17:00:46 +000024 /* This sneaked in here, because Qemu does not
25 * emulate a SuperIO chip
26 */
Timothy Pearson448e3862015-11-24 14:12:01 -060027 pc_keyboard_init(NO_AUX_DEVICE);
Ronald G. Minnich rminnich4a8523a2009-04-07 02:18:13 +000028
Gerd Hoffmann082d2a02013-05-29 14:59:36 +020029 /* setup IRQ routing */
30 for (i = 0; i < 32; i++)
Kyösti Mälkkic19d6a62019-07-04 21:39:28 +030031 pci_assign_irqs(pcidev_on_root(i, 0), qemu_i440fx_irqs + (i % 4));
Stefan Reinauerd56981f2007-10-22 10:07:46 +000032}
33
Kevin O'Connor31b2e8f2010-09-06 20:20:47 +000034static struct device_operations nb_operations = {
Gerd Hoffmann7fd1bee2013-06-17 10:03:17 +020035 .read_resources = pci_dev_read_resources,
36 .set_resources = pci_dev_set_resources,
37 .enable_resources = pci_dev_enable_resources,
38 .init = qemu_nb_init,
Kevin O'Connor31b2e8f2010-09-06 20:20:47 +000039 .ops_pci = 0,
40};
41
42static const struct pci_driver nb_driver __pci_driver = {
43 .ops = &nb_operations,
44 .vendor = 0x8086,
45 .device = 0x1237,
46};