// SPDX-License-Identifier: GPL-2.0-only1/*2* Minimalist driver for a generic PCI-to-EISA bridge.3*4* (C) 2003 Marc Zyngier <[email protected]>5*6* Ivan Kokshaysky <[email protected]> :7* Generalisation from i82375 to PCI_CLASS_BRIDGE_EISA.8*/910#include <linux/kernel.h>11#include <linux/device.h>12#include <linux/eisa.h>13#include <linux/pci.h>14#include <linux/module.h>15#include <linux/init.h>1617/* There is only *one* pci_eisa device per machine, right ? */18static struct eisa_root_device pci_eisa_root;1920static int __init pci_eisa_init(struct pci_dev *pdev)21{22struct resource *res, *bus_res = NULL;23int rc;2425if ((rc = pci_enable_device (pdev))) {26dev_err(&pdev->dev, "Could not enable device\n");27return rc;28}2930/*31* The Intel 82375 PCI-EISA bridge is a subtractive-decode PCI32* device, so the resources available on EISA are the same as those33* available on the 82375 bus. This works the same as a PCI-PCI34* bridge in subtractive-decode mode (see pci_read_bridge_bases()).35* We assume other PCI-EISA bridges are similar.36*37* eisa_root_register() can only deal with a single io port resource,38* so we use the first valid io port resource.39*/40pci_bus_for_each_resource(pdev->bus, res)41if (res && (res->flags & IORESOURCE_IO)) {42bus_res = res;43break;44}4546if (!bus_res) {47dev_err(&pdev->dev, "No resources available\n");48return -1;49}5051pci_eisa_root.dev = &pdev->dev;52pci_eisa_root.res = bus_res;53pci_eisa_root.bus_base_addr = bus_res->start;54pci_eisa_root.slots = EISA_MAX_SLOTS;55pci_eisa_root.dma_mask = pdev->dma_mask;56dev_set_drvdata(pci_eisa_root.dev, &pci_eisa_root);5758if (eisa_root_register (&pci_eisa_root)) {59dev_err(&pdev->dev, "Could not register EISA root\n");60return -1;61}6263return 0;64}6566/*67* We have to call pci_eisa_init_early() before pnpacpi_init()/isapnp_init().68* Otherwise pnp resource will get enabled early and could prevent eisa69* to be initialized.70* Also need to make sure pci_eisa_init_early() is called after71* x86/pci_subsys_init().72* So need to use subsys_initcall_sync with it.73*/74static int __init pci_eisa_init_early(void)75{76struct pci_dev *dev = NULL;77int ret;7879for_each_pci_dev(dev)80if ((dev->class >> 8) == PCI_CLASS_BRIDGE_EISA) {81ret = pci_eisa_init(dev);82if (ret)83return ret;84}8586return 0;87}88subsys_initcall_sync(pci_eisa_init_early);899091