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. |
| 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 Menzel | a46a712 | 2013-02-23 18:37:27 +0100 | [diff] [blame^] | 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Stefan Reinauer | 597ff87 | 2013-01-07 13:21:22 -0800 | [diff] [blame] | 19 | */ |
| 20 | |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 21 | #include <console/console.h> |
Stefan Reinauer | 4a3bb76 | 2004-06-28 11:57:31 +0000 | [diff] [blame] | 22 | #include <device/device.h> |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 23 | #include <device/pci.h> |
| 24 | #include <device/pci_ids.h> |
| 25 | #include <device/pci_ops.h> |
Stefan Reinauer | 65e9bc1 | 2009-03-13 17:00:46 +0000 | [diff] [blame] | 26 | #include <pc80/keyboard.h> |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 27 | #include <arch/io.h> |
Stefan Reinauer | 4a3bb76 | 2004-06-28 11:57:31 +0000 | [diff] [blame] | 28 | |
Ronald G. Minnich rminnich | 4a8523a | 2009-04-07 02:18:13 +0000 | [diff] [blame] | 29 | /* not sure how these are routed in qemu */ |
| 30 | static const unsigned char enetIrqs[4] = { 11, 0, 0, 0 }; |
| 31 | |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 32 | static void qemu_nb_init(device_t dev) |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 33 | { |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 34 | /* Map memory at 0xc0000 - 0xfffff */ |
| 35 | int i; |
| 36 | uint8_t v = pci_read_config8(dev, 0x59); |
| 37 | v |= 0x30; |
| 38 | pci_write_config8(dev, 0x59, v); |
| 39 | for (i=0; i<6; i++) |
| 40 | pci_write_config8(dev, 0x5a + i, 0x33); |
Aaron Lwe | 2342f8b | 2008-05-06 15:02:22 +0000 | [diff] [blame] | 41 | |
Stefan Reinauer | 65e9bc1 | 2009-03-13 17:00:46 +0000 | [diff] [blame] | 42 | /* This sneaked in here, because Qemu does not |
| 43 | * emulate a SuperIO chip |
| 44 | */ |
Stefan Reinauer | 740b587 | 2010-02-23 20:31:37 +0000 | [diff] [blame] | 45 | pc_keyboard_init(0); |
Ronald G. Minnich rminnich | 4a8523a | 2009-04-07 02:18:13 +0000 | [diff] [blame] | 46 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 47 | /* The PIRQ table is not working well for interrupt routing purposes. |
| 48 | * so we'll just set the IRQ directly. |
Stefan Reinauer | 597ff87 | 2013-01-07 13:21:22 -0800 | [diff] [blame] | 49 | */ |
| 50 | printk(BIOS_INFO, "Setting up ethernet...\n"); |
Ronald G. Minnich rminnich | 4a8523a | 2009-04-07 02:18:13 +0000 | [diff] [blame] | 51 | pci_assign_irqs(0, 3, enetIrqs); |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 52 | } |
| 53 | |
Kevin O'Connor | 31b2e8f | 2010-09-06 20:20:47 +0000 | [diff] [blame] | 54 | static struct device_operations nb_operations = { |
| 55 | .read_resources = pci_dev_read_resources, |
| 56 | .set_resources = pci_dev_set_resources, |
| 57 | .enable_resources = pci_dev_enable_resources, |
| 58 | .init = qemu_nb_init, |
| 59 | .ops_pci = 0, |
| 60 | }; |
| 61 | |
| 62 | static const struct pci_driver nb_driver __pci_driver = { |
| 63 | .ops = &nb_operations, |
| 64 | .vendor = 0x8086, |
| 65 | .device = 0x1237, |
| 66 | }; |
| 67 | |
| 68 | static void qemu_init(device_t dev) |
| 69 | { |
| 70 | /* The VGA OPROM already lives at 0xc0000, |
| 71 | * force coreboot to use it. |
| 72 | */ |
| 73 | dev->on_mainboard = 1; |
| 74 | |
| 75 | /* Now do the usual initialization */ |
| 76 | pci_dev_init(dev); |
| 77 | } |
| 78 | |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 79 | static struct device_operations vga_operations = { |
| 80 | .read_resources = pci_dev_read_resources, |
| 81 | .set_resources = pci_dev_set_resources, |
| 82 | .enable_resources = pci_dev_enable_resources, |
Ronald G. Minnich rminnich | 4a8523a | 2009-04-07 02:18:13 +0000 | [diff] [blame] | 83 | .init = qemu_init, |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 84 | .ops_pci = 0, |
| 85 | }; |
| 86 | |
Stefan Reinauer | f1cf1f7 | 2007-10-24 09:08:58 +0000 | [diff] [blame] | 87 | static const struct pci_driver vga_driver __pci_driver = { |
Stefan Reinauer | d56981f | 2007-10-22 10:07:46 +0000 | [diff] [blame] | 88 | .ops = &vga_operations, |
| 89 | .vendor = 0x1013, |
| 90 | .device = 0x00b8, |
| 91 | }; |
| 92 | |