+void pci_dev_enable_resources(struct device *dev)
+{
+ const struct pci_operations *ops;
+ u16 command;
+
+ /* Set the subsystem vendor and device ID for mainboard devices. */
+ ops = ops_pci(dev);
+ if (dev->on_mainboard && ops && ops->set_subsystem) {
+ printk(BIOS_DEBUG, "%s subsystem <- %04x/%04x\n",
+ dev_path(dev), dev->subsystem_vendor,
+ dev->subsystem_device);
+ ops->set_subsystem(dev, dev->subsystem_vendor,
+ dev->subsystem_device);
+ }
+ command = pci_read_config16(dev, PCI_COMMAND);
+ command |= dev->command;
+
+ /* v3 has
+ * command |= (PCI_COMMAND_PARITY + PCI_COMMAND_SERR); // Error check.
+ */
+
+ printk(BIOS_DEBUG, "%s cmd <- %02x\n", dev_path(dev), command);
+ pci_write_config16(dev, PCI_COMMAND, command);
+}
+
+void pci_bus_enable_resources(struct device *dev)
+{
+ u16 ctrl;
+
+ /*
+ * Enable I/O in command register if there is VGA card
+ * connected with (even it does not claim I/O resource).
+ */
+ if (dev->link_list->bridge_ctrl & PCI_BRIDGE_CTL_VGA)
+ dev->command |= PCI_COMMAND_IO;
+ ctrl = pci_read_config16(dev, PCI_BRIDGE_CONTROL);
+ ctrl |= dev->link_list->bridge_ctrl;
+ ctrl |= (PCI_BRIDGE_CTL_PARITY + PCI_BRIDGE_CTL_SERR); /* Error check. */
+ printk(BIOS_DEBUG, "%s bridge ctrl <- %04x\n", dev_path(dev), ctrl);
+ pci_write_config16(dev, PCI_BRIDGE_CONTROL, ctrl);
+
+ pci_dev_enable_resources(dev);
+}
+
+void pci_bus_reset(struct bus *bus)
+{
+ u16 ctl;
+
+ ctl = pci_read_config16(bus->dev, PCI_BRIDGE_CONTROL);
+ ctl |= PCI_BRIDGE_CTL_BUS_RESET;
+ pci_write_config16(bus->dev, PCI_BRIDGE_CONTROL, ctl);
+ mdelay(10);
+
+ ctl &= ~PCI_BRIDGE_CTL_BUS_RESET;
+ pci_write_config16(bus->dev, PCI_BRIDGE_CONTROL, ctl);
+ delay(1);
+}
+
+void pci_dev_set_subsystem(struct device *dev, unsigned vendor, unsigned device)
+{
+ pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
+ ((device & 0xffff) << 16) | (vendor & 0xffff));
+}
+
+/** Default handler: only runs the relevant PCI BIOS. */
+void pci_dev_init(struct device *dev)
+{
+#if CONFIG_PCI_ROM_RUN == 1 || CONFIG_VGA_ROM_RUN == 1
+ struct rom_header *rom, *ram;
+
+ if (CONFIG_PCI_ROM_RUN != 1 && /* Only execute VGA ROMs. */
+ ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA))
+ return;
+
+ if (CONFIG_VGA_ROM_RUN != 1 && /* Only execute non-VGA ROMs. */
+ ((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA))
+ return;
+
+#if CONFIG_CHROMEOS
+ /* In ChromeOS we want to boot blazingly fast. Therefore
+ * we don't run (VGA) option ROMs, unless we have to print
+ * something on the screen before the kernel is loaded.
+ */
+ if (!developer_mode_enabled() && !recovery_mode_enabled())
+ return;
+#endif
+
+ rom = pci_rom_probe(dev);
+ if (rom == NULL)
+ return;
+
+ ram = pci_rom_load(dev, rom);
+ if (ram == NULL)
+ return;
+
+#if CONFIG_HAVE_ACPI_RESUME && !CONFIG_S3_VGA_ROM_RUN
+ /* If S3_VGA_ROM_RUN is disabled, skip running VGA option
+ * ROMs when coming out of an S3 resume.
+ */
+ if ((acpi_slp_type == 3) &&
+ ((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA))
+ return;
+#endif
+ run_bios(dev, (unsigned long)ram);
+#endif /* CONFIG_PCI_ROM_RUN || CONFIG_VGA_ROM_RUN */
+}
+
+/** Default device operation for PCI devices */
+static struct pci_operations pci_dev_ops_pci = {
+ .set_subsystem = pci_dev_set_subsystem,
+};
+