Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Minimalist driver for a generic PCI-to-EISA bridge. |
| 3 | * |
| 4 | * (C) 2003 Marc Zyngier <maz@wild-wind.fr.eu.org> |
| 5 | * |
| 6 | * This code is released under the GPL version 2. |
| 7 | * |
| 8 | * Ivan Kokshaysky <ink@jurassic.park.msu.ru> : |
| 9 | * Generalisation from i82375 to PCI_CLASS_BRIDGE_EISA. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/device.h> |
| 14 | #include <linux/eisa.h> |
| 15 | #include <linux/pci.h> |
| 16 | #include <linux/module.h> |
| 17 | #include <linux/init.h> |
| 18 | |
| 19 | /* There is only *one* pci_eisa device per machine, right ? */ |
| 20 | static struct eisa_root_device pci_eisa_root; |
| 21 | |
Yinghai Lu | c5fb301 | 2013-03-27 21:28:05 -0700 | [diff] [blame] | 22 | static int __init pci_eisa_init(struct pci_dev *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | { |
Yinghai Lu | 2cfda63 | 2013-04-01 11:48:59 -0600 | [diff] [blame] | 24 | int rc, i; |
| 25 | struct resource *res, *bus_res = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | if ((rc = pci_enable_device (pdev))) { |
Bjorn Helgaas | 4cf9f24 | 2013-04-15 14:33:42 -0600 | [diff] [blame] | 28 | dev_err(&pdev->dev, "Could not enable device\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | return rc; |
| 30 | } |
| 31 | |
Yinghai Lu | 2cfda63 | 2013-04-01 11:48:59 -0600 | [diff] [blame] | 32 | /* |
| 33 | * The Intel 82375 PCI-EISA bridge is a subtractive-decode PCI |
| 34 | * device, so the resources available on EISA are the same as those |
| 35 | * available on the 82375 bus. This works the same as a PCI-PCI |
| 36 | * bridge in subtractive-decode mode (see pci_read_bridge_bases()). |
| 37 | * We assume other PCI-EISA bridges are similar. |
| 38 | * |
| 39 | * eisa_root_register() can only deal with a single io port resource, |
| 40 | * so we use the first valid io port resource. |
| 41 | */ |
| 42 | pci_bus_for_each_resource(pdev->bus, res, i) |
| 43 | if (res && (res->flags & IORESOURCE_IO)) { |
| 44 | bus_res = res; |
| 45 | break; |
| 46 | } |
| 47 | |
| 48 | if (!bus_res) { |
| 49 | dev_err(&pdev->dev, "No resources available\n"); |
| 50 | return -1; |
| 51 | } |
| 52 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | pci_eisa_root.dev = &pdev->dev; |
Yinghai Lu | 2cfda63 | 2013-04-01 11:48:59 -0600 | [diff] [blame] | 54 | pci_eisa_root.res = bus_res; |
| 55 | pci_eisa_root.bus_base_addr = bus_res->start; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | pci_eisa_root.slots = EISA_MAX_SLOTS; |
| 57 | pci_eisa_root.dma_mask = pdev->dma_mask; |
Greg Kroah-Hartman | 4b9d0d3 | 2009-04-30 14:43:31 -0700 | [diff] [blame] | 58 | dev_set_drvdata(pci_eisa_root.dev, &pci_eisa_root); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | if (eisa_root_register (&pci_eisa_root)) { |
Bjorn Helgaas | 4cf9f24 | 2013-04-15 14:33:42 -0600 | [diff] [blame] | 61 | dev_err(&pdev->dev, "Could not register EISA root\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | return -1; |
| 63 | } |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | |
Yinghai Lu | c5fb301 | 2013-03-27 21:28:05 -0700 | [diff] [blame] | 68 | /* |
| 69 | * We have to call pci_eisa_init_early() before pnpacpi_init()/isapnp_init(). |
| 70 | * Otherwise pnp resource will get enabled early and could prevent eisa |
| 71 | * to be initialized. |
| 72 | * Also need to make sure pci_eisa_init_early() is called after |
| 73 | * x86/pci_subsys_init(). |
| 74 | * So need to use subsys_initcall_sync with it. |
| 75 | */ |
| 76 | static int __init pci_eisa_init_early(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | { |
Yinghai Lu | c5fb301 | 2013-03-27 21:28:05 -0700 | [diff] [blame] | 78 | struct pci_dev *dev = NULL; |
| 79 | int ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
Yinghai Lu | c5fb301 | 2013-03-27 21:28:05 -0700 | [diff] [blame] | 81 | for_each_pci_dev(dev) |
| 82 | if ((dev->class >> 8) == PCI_CLASS_BRIDGE_EISA) { |
| 83 | ret = pci_eisa_init(dev); |
| 84 | if (ret) |
| 85 | return ret; |
| 86 | } |
| 87 | |
| 88 | return 0; |
| 89 | } |
| 90 | subsys_initcall_sync(pci_eisa_init_early); |