Stefan Reinauer | 597ff87 | 2013-01-07 13:21:22 -0800 | [diff] [blame] | 1 | /* |
| 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 Reinauer | 597ff87 | 2013-01-07 13:21:22 -0800 | [diff] [blame] | 15 | */ |
| 16 | |
Stefan Reinauer | 4a3bb76 | 2004-06-28 11:57:31 +0000 | [diff] [blame] | 17 | #include <device/device.h> |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 18 | #include <device/pci.h> |
| 19 | #include <device/pci_ids.h> |
| 20 | #include <device/pci_ops.h> |
Stefan Reinauer | 65e9bc1 | 2009-03-13 17:00:46 +0000 | [diff] [blame] | 21 | #include <pc80/keyboard.h> |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 22 | #include <arch/io.h> |
Stefan Reinauer | 4a3bb76 | 2004-06-28 11:57:31 +0000 | [diff] [blame] | 23 | |
Gerd Hoffmann | 082d2a0 | 2013-05-29 14:59:36 +0200 | [diff] [blame] | 24 | static const unsigned char qemu_i440fx_irqs[] = { |
| 25 | 11, 10, 10, 11, |
| 26 | 11, 10, 10, 11, |
| 27 | }; |
Ronald G. Minnich rminnich | 4a8523a | 2009-04-07 02:18:13 +0000 | [diff] [blame] | 28 | |
Elyes HAOUAS | 5cb876c | 2018-06-08 18:31:43 +0200 | [diff] [blame^] | 29 | static void qemu_nb_init(struct device *dev) |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 30 | { |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 31 | /* Map memory at 0xc0000 - 0xfffff */ |
| 32 | int i; |
| 33 | uint8_t v = pci_read_config8(dev, 0x59); |
| 34 | v |= 0x30; |
| 35 | pci_write_config8(dev, 0x59, v); |
Elyes HAOUAS | 6350a2e | 2016-09-16 20:49:38 +0200 | [diff] [blame] | 36 | for (i = 0; i < 6; i++) |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 37 | pci_write_config8(dev, 0x5a + i, 0x33); |
Aaron Lwe | 2342f8b | 2008-05-06 15:02:22 +0000 | [diff] [blame] | 38 | |
Stefan Reinauer | 65e9bc1 | 2009-03-13 17:00:46 +0000 | [diff] [blame] | 39 | /* This sneaked in here, because Qemu does not |
| 40 | * emulate a SuperIO chip |
| 41 | */ |
Timothy Pearson | 448e386 | 2015-11-24 14:12:01 -0600 | [diff] [blame] | 42 | pc_keyboard_init(NO_AUX_DEVICE); |
Ronald G. Minnich rminnich | 4a8523a | 2009-04-07 02:18:13 +0000 | [diff] [blame] | 43 | |
Gerd Hoffmann | 082d2a0 | 2013-05-29 14:59:36 +0200 | [diff] [blame] | 44 | /* setup IRQ routing */ |
| 45 | for (i = 0; i < 32; i++) |
| 46 | pci_assign_irqs(0, i, qemu_i440fx_irqs + (i % 4)); |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 49 | static struct device_operations nb_operations = { |
Gerd Hoffmann | 7fd1bee | 2013-06-17 10:03:17 +0200 | [diff] [blame] | 50 | .read_resources = pci_dev_read_resources, |
| 51 | .set_resources = pci_dev_set_resources, |
| 52 | .enable_resources = pci_dev_enable_resources, |
| 53 | .init = qemu_nb_init, |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 54 | .ops_pci = 0, |
| 55 | }; |
| 56 | |
| 57 | static const struct pci_driver nb_driver __pci_driver = { |
| 58 | .ops = &nb_operations, |
| 59 | .vendor = 0x8086, |
| 60 | .device = 0x1237, |
| 61 | }; |