broadcom_bus.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Read address ranges from a Broadcom CNB20LE Host Bridge
  3. *
  4. * Copyright (c) 2010 Ira W. Snyder <iws@ovro.caltech.edu>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. */
  11. #include <linux/acpi.h>
  12. #include <linux/delay.h>
  13. #include <linux/dmi.h>
  14. #include <linux/pci.h>
  15. #include <linux/init.h>
  16. #include <asm/pci_x86.h>
  17. #include "bus_numa.h"
  18. static void __devinit cnb20le_res(struct pci_dev *dev)
  19. {
  20. struct pci_root_info *info;
  21. struct resource res;
  22. u16 word1, word2;
  23. u8 fbus, lbus;
  24. int i;
  25. #ifdef CONFIG_ACPI
  26. /*
  27. * We should get host bridge information from ACPI unless the BIOS
  28. * doesn't support it.
  29. */
  30. if (acpi_os_get_root_pointer())
  31. return;
  32. #endif
  33. info = &pci_root_info[pci_root_num];
  34. pci_root_num++;
  35. /* read the PCI bus numbers */
  36. pci_read_config_byte(dev, 0x44, &fbus);
  37. pci_read_config_byte(dev, 0x45, &lbus);
  38. info->bus_min = fbus;
  39. info->bus_max = lbus;
  40. /*
  41. * Add the legacy IDE ports on bus 0
  42. *
  43. * These do not exist anywhere in the bridge registers, AFAICT. I do
  44. * not have the datasheet, so this is the best I can do.
  45. */
  46. if (fbus == 0) {
  47. update_res(info, 0x01f0, 0x01f7, IORESOURCE_IO, 0);
  48. update_res(info, 0x03f6, 0x03f6, IORESOURCE_IO, 0);
  49. update_res(info, 0x0170, 0x0177, IORESOURCE_IO, 0);
  50. update_res(info, 0x0376, 0x0376, IORESOURCE_IO, 0);
  51. update_res(info, 0xffa0, 0xffaf, IORESOURCE_IO, 0);
  52. }
  53. /* read the non-prefetchable memory window */
  54. pci_read_config_word(dev, 0xc0, &word1);
  55. pci_read_config_word(dev, 0xc2, &word2);
  56. if (word1 != word2) {
  57. res.start = (word1 << 16) | 0x0000;
  58. res.end = (word2 << 16) | 0xffff;
  59. res.flags = IORESOURCE_MEM;
  60. update_res(info, res.start, res.end, res.flags, 0);
  61. }
  62. /* read the prefetchable memory window */
  63. pci_read_config_word(dev, 0xc4, &word1);
  64. pci_read_config_word(dev, 0xc6, &word2);
  65. if (word1 != word2) {
  66. res.start = (word1 << 16) | 0x0000;
  67. res.end = (word2 << 16) | 0xffff;
  68. res.flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
  69. update_res(info, res.start, res.end, res.flags, 0);
  70. }
  71. /* read the IO port window */
  72. pci_read_config_word(dev, 0xd0, &word1);
  73. pci_read_config_word(dev, 0xd2, &word2);
  74. if (word1 != word2) {
  75. res.start = word1;
  76. res.end = word2;
  77. res.flags = IORESOURCE_IO;
  78. update_res(info, res.start, res.end, res.flags, 0);
  79. }
  80. /* print information about this host bridge */
  81. res.start = fbus;
  82. res.end = lbus;
  83. res.flags = IORESOURCE_BUS;
  84. dev_info(&dev->dev, "CNB20LE PCI Host Bridge (domain %04x %pR)\n",
  85. pci_domain_nr(dev->bus), &res);
  86. for (i = 0; i < info->res_num; i++)
  87. dev_info(&dev->dev, "host bridge window %pR\n", &info->res[i]);
  88. }
  89. DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_LE,
  90. cnb20le_res);