blob: 0b3689731ea1b79fdae43a46800966e0d8c9b707 [file] [log] [blame]
Stefan Reinauer597ff872013-01-07 13:21:22 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2004 Stefan Reinauer <stefan.reinauer@coreboot.org>
5 * Copyright (C) 2010 Kevin O'Connor <kevin@koconnor.net>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Stefan Reinauer597ff872013-01-07 13:21:22 -080015 */
16
Stefan Reinauer4a3bb762004-06-28 11:57:31 +000017#include <device/device.h>
Stefan Reinauerd56981f2007-10-22 10:07:46 +000018#include <device/pci.h>
Stefan Reinauerd56981f2007-10-22 10:07:46 +000019#include <device/pci_ops.h>
Stefan Reinauer65e9bc12009-03-13 17:00:46 +000020#include <pc80/keyboard.h>
Stefan Reinauer4a3bb762004-06-28 11:57:31 +000021
Gerd Hoffmann082d2a02013-05-29 14:59:36 +020022static const unsigned char qemu_i440fx_irqs[] = {
23 11, 10, 10, 11,
24 11, 10, 10, 11,
25};
Ronald G. Minnich rminnich4a8523a2009-04-07 02:18:13 +000026
Elyes HAOUAS5cb876c2018-06-08 18:31:43 +020027static void qemu_nb_init(struct device *dev)
Stefan Reinauerd56981f2007-10-22 10:07:46 +000028{
Kevin O'Connor31b2e8f2010-09-06 20:20:47 +000029 /* Map memory at 0xc0000 - 0xfffff */
30 int i;
31 uint8_t v = pci_read_config8(dev, 0x59);
32 v |= 0x30;
33 pci_write_config8(dev, 0x59, v);
Elyes HAOUAS6350a2e2016-09-16 20:49:38 +020034 for (i = 0; i < 6; i++)
Kevin O'Connor31b2e8f2010-09-06 20:20:47 +000035 pci_write_config8(dev, 0x5a + i, 0x33);
Aaron Lwe2342f8b2008-05-06 15:02:22 +000036
Stefan Reinauer65e9bc12009-03-13 17:00:46 +000037 /* This sneaked in here, because Qemu does not
38 * emulate a SuperIO chip
39 */
Timothy Pearson448e3862015-11-24 14:12:01 -060040 pc_keyboard_init(NO_AUX_DEVICE);
Ronald G. Minnich rminnich4a8523a2009-04-07 02:18:13 +000041
Gerd Hoffmann082d2a02013-05-29 14:59:36 +020042 /* setup IRQ routing */
43 for (i = 0; i < 32; i++)
Kyösti Mälkkic19d6a62019-07-04 21:39:28 +030044 pci_assign_irqs(pcidev_on_root(i, 0), qemu_i440fx_irqs + (i % 4));
Stefan Reinauerd56981f2007-10-22 10:07:46 +000045}
46
Kevin O'Connor31b2e8f2010-09-06 20:20:47 +000047static struct device_operations nb_operations = {
Gerd Hoffmann7fd1bee2013-06-17 10:03:17 +020048 .read_resources = pci_dev_read_resources,
49 .set_resources = pci_dev_set_resources,
50 .enable_resources = pci_dev_enable_resources,
51 .init = qemu_nb_init,
Kevin O'Connor31b2e8f2010-09-06 20:20:47 +000052 .ops_pci = 0,
53};
54
55static const struct pci_driver nb_driver __pci_driver = {
56 .ops = &nb_operations,
57 .vendor = 0x8086,
58 .device = 0x1237,
59};