Angel Pons | 585495e | 2020-04-03 01:21:38 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Stefan Reinauer | 597ff87 | 2013-01-07 13:21:22 -0800 | [diff] [blame] | 3 | |
Stefan Reinauer | 4a3bb76 | 2004-06-28 11:57:31 +0000 | [diff] [blame] | 4 | #include <device/device.h> |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 5 | #include <device/pci.h> |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 6 | #include <device/pci_ops.h> |
Stefan Reinauer | 65e9bc1 | 2009-03-13 17:00:46 +0000 | [diff] [blame] | 7 | #include <pc80/keyboard.h> |
Stefan Reinauer | 4a3bb76 | 2004-06-28 11:57:31 +0000 | [diff] [blame] | 8 | |
Gerd Hoffmann | 082d2a0 | 2013-05-29 14:59:36 +0200 | [diff] [blame] | 9 | static const unsigned char qemu_i440fx_irqs[] = { |
| 10 | 11, 10, 10, 11, |
| 11 | 11, 10, 10, 11, |
| 12 | }; |
Ronald G. Minnich rminnich | 4a8523a | 2009-04-07 02:18:13 +0000 | [diff] [blame] | 13 | |
Elyes HAOUAS | 5cb876c | 2018-06-08 18:31:43 +0200 | [diff] [blame] | 14 | static void qemu_nb_init(struct device *dev) |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 15 | { |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 16 | /* 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 HAOUAS | 6350a2e | 2016-09-16 20:49:38 +0200 | [diff] [blame] | 21 | for (i = 0; i < 6; i++) |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 22 | pci_write_config8(dev, 0x5a + i, 0x33); |
Aaron Lwe | 2342f8b | 2008-05-06 15:02:22 +0000 | [diff] [blame] | 23 | |
Stefan Reinauer | 65e9bc1 | 2009-03-13 17:00:46 +0000 | [diff] [blame] | 24 | /* This sneaked in here, because Qemu does not |
| 25 | * emulate a SuperIO chip |
| 26 | */ |
Timothy Pearson | 448e386 | 2015-11-24 14:12:01 -0600 | [diff] [blame] | 27 | pc_keyboard_init(NO_AUX_DEVICE); |
Ronald G. Minnich rminnich | 4a8523a | 2009-04-07 02:18:13 +0000 | [diff] [blame] | 28 | |
Gerd Hoffmann | 082d2a0 | 2013-05-29 14:59:36 +0200 | [diff] [blame] | 29 | /* setup IRQ routing */ |
| 30 | for (i = 0; i < 32; i++) |
Kyösti Mälkki | c19d6a6 | 2019-07-04 21:39:28 +0300 | [diff] [blame] | 31 | pci_assign_irqs(pcidev_on_root(i, 0), qemu_i440fx_irqs + (i % 4)); |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 32 | } |
| 33 | |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 34 | static struct device_operations nb_operations = { |
Gerd Hoffmann | 7fd1bee | 2013-06-17 10:03:17 +0200 | [diff] [blame] | 35 | .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'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 39 | .ops_pci = 0, |
| 40 | }; |
| 41 | |
| 42 | static const struct pci_driver nb_driver __pci_driver = { |
| 43 | .ops = &nb_operations, |
| 44 | .vendor = 0x8086, |
| 45 | .device = 0x1237, |
| 46 | }; |