pci_eisa.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. #include <linux/kernel.h>
  12. #include <linux/device.h>
  13. #include <linux/eisa.h>
  14. #include <linux/pci.h>
  15. #include <linux/module.h>
  16. #include <linux/init.h>
  17. /* There is only *one* pci_eisa device per machine, right ? */
  18. static struct eisa_root_device pci_eisa_root;
  19. static int __init pci_eisa_init(struct pci_dev *pdev)
  20. {
  21. int rc, i;
  22. struct resource *res, *bus_res = NULL;
  23. if ((rc = pci_enable_device (pdev))) {
  24. printk (KERN_ERR "pci_eisa : Could not enable device %s\n",
  25. pci_name(pdev));
  26. return rc;
  27. }
  28. /*
  29. * The Intel 82375 PCI-EISA bridge is a subtractive-decode PCI
  30. * device, so the resources available on EISA are the same as those
  31. * available on the 82375 bus. This works the same as a PCI-PCI
  32. * bridge in subtractive-decode mode (see pci_read_bridge_bases()).
  33. * We assume other PCI-EISA bridges are similar.
  34. *
  35. * eisa_root_register() can only deal with a single io port resource,
  36. * so we use the first valid io port resource.
  37. */
  38. pci_bus_for_each_resource(pdev->bus, res, i)
  39. if (res && (res->flags & IORESOURCE_IO)) {
  40. bus_res = res;
  41. break;
  42. }
  43. if (!bus_res) {
  44. dev_err(&pdev->dev, "No resources available\n");
  45. return -1;
  46. }
  47. pci_eisa_root.dev = &pdev->dev;
  48. pci_eisa_root.res = bus_res;
  49. pci_eisa_root.bus_base_addr = bus_res->start;
  50. pci_eisa_root.slots = EISA_MAX_SLOTS;
  51. pci_eisa_root.dma_mask = pdev->dma_mask;
  52. dev_set_drvdata(pci_eisa_root.dev, &pci_eisa_root);
  53. if (eisa_root_register (&pci_eisa_root)) {
  54. printk (KERN_ERR "pci_eisa : Could not register EISA root\n");
  55. return -1;
  56. }
  57. return 0;
  58. }
  59. /*
  60. * We have to call pci_eisa_init_early() before pnpacpi_init()/isapnp_init().
  61. * Otherwise pnp resource will get enabled early and could prevent eisa
  62. * to be initialized.
  63. * Also need to make sure pci_eisa_init_early() is called after
  64. * x86/pci_subsys_init().
  65. * So need to use subsys_initcall_sync with it.
  66. */
  67. static int __init pci_eisa_init_early(void)
  68. {
  69. struct pci_dev *dev = NULL;
  70. int ret;
  71. for_each_pci_dev(dev)
  72. if ((dev->class >> 8) == PCI_CLASS_BRIDGE_EISA) {
  73. ret = pci_eisa_init(dev);
  74. if (ret)
  75. return ret;
  76. }
  77. return 0;
  78. }
  79. subsys_initcall_sync(pci_eisa_init_early);