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