Simplify a few code chunks, fix whitespace and indentation.
[coreboot.git] / src / mainboard / emulation / qemu-x86 / mainboard.c
1 #include <console/console.h>
2 #include <device/device.h>
3 #include <device/pci.h>
4 #include <device/pci_ids.h>
5 #include <device/pci_ops.h>
6 #include <pc80/keyboard.h>
7 #include <arch/io.h>
8 #include "chip.h"
9
10 /* not sure how these are routed in qemu */
11 static const unsigned char enetIrqs[4] = { 11, 0, 0, 0 };
12
13 static void qemu_nb_init(device_t dev)
14 {
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);
22
23         /* This sneaked in here, because Qemu does not
24          * emulate a SuperIO chip
25          */
26         pc_keyboard_init(0);
27
28         /* The PIRQ table is not working well for interrupt routing purposes.
29          * so we'll just set the IRQ directly.
30         */
31         printk(BIOS_INFO, "setting ethernet\n");
32         pci_assign_irqs(0, 3, enetIrqs);
33 }
34
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
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,
64         .init             = qemu_init,
65         .ops_pci          = 0,
66 };
67
68 static const struct pci_driver vga_driver __pci_driver = {
69         .ops = &vga_operations,
70         .vendor = 0x1013,
71         .device = 0x00b8,
72 };
73
74 struct chip_operations mainboard_ops = {
75         CHIP_NAME("QEMU Mainboard")
76 };
77