blob: f651b9909414d9246c0c213a9051da12cbdb5a06 [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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
Paul Menzela46a7122013-02-23 18:37:27 +010018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Stefan Reinauer597ff872013-01-07 13:21:22 -080019 */
20
Stefan Reinauer4a3bb762004-06-28 11:57:31 +000021#include <device/device.h>
Stefan Reinauerd56981f2007-10-22 10:07:46 +000022#include <device/pci.h>
23#include <device/pci_ids.h>
24#include <device/pci_ops.h>
Stefan Reinauer65e9bc12009-03-13 17:00:46 +000025#include <pc80/keyboard.h>
Stefan Reinauerd56981f2007-10-22 10:07:46 +000026#include <arch/io.h>
Stefan Reinauer4a3bb762004-06-28 11:57:31 +000027
Gerd Hoffmann082d2a02013-05-29 14:59:36 +020028static const unsigned char qemu_i440fx_irqs[] = {
29 11, 10, 10, 11,
30 11, 10, 10, 11,
31};
Ronald G. Minnich rminnich4a8523a2009-04-07 02:18:13 +000032
Kevin O'Connor31b2e8f2010-09-06 20:20:47 +000033static void qemu_nb_init(device_t dev)
Stefan Reinauerd56981f2007-10-22 10:07:46 +000034{
Kevin O'Connor31b2e8f2010-09-06 20:20:47 +000035 /* Map memory at 0xc0000 - 0xfffff */
36 int i;
37 uint8_t v = pci_read_config8(dev, 0x59);
38 v |= 0x30;
39 pci_write_config8(dev, 0x59, v);
40 for (i=0; i<6; i++)
41 pci_write_config8(dev, 0x5a + i, 0x33);
Aaron Lwe2342f8b2008-05-06 15:02:22 +000042
Stefan Reinauer65e9bc12009-03-13 17:00:46 +000043 /* This sneaked in here, because Qemu does not
44 * emulate a SuperIO chip
45 */
Stefan Reinauer740b5872010-02-23 20:31:37 +000046 pc_keyboard_init(0);
Ronald G. Minnich rminnich4a8523a2009-04-07 02:18:13 +000047
Gerd Hoffmann082d2a02013-05-29 14:59:36 +020048 /* setup IRQ routing */
49 for (i = 0; i < 32; i++)
50 pci_assign_irqs(0, i, qemu_i440fx_irqs + (i % 4));
Stefan Reinauerd56981f2007-10-22 10:07:46 +000051}
52
Kevin O'Connor31b2e8f2010-09-06 20:20:47 +000053static struct device_operations nb_operations = {
54 .read_resources = pci_dev_read_resources,
55 .set_resources = pci_dev_set_resources,
56 .enable_resources = pci_dev_enable_resources,
57 .init = qemu_nb_init,
58 .ops_pci = 0,
59};
60
61static const struct pci_driver nb_driver __pci_driver = {
62 .ops = &nb_operations,
63 .vendor = 0x8086,
64 .device = 0x1237,
65};