broadcom_bus.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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/delay.h>
  12. #include <linux/dmi.h>
  13. #include <linux/pci.h>
  14. #include <linux/init.h>
  15. #include <asm/pci_x86.h>
  16. #include "bus_numa.h"
  17. static void __devinit cnb20le_res(struct pci_dev *dev)
  18. {
  19. struct pci_root_info *info;
  20. struct resource res;
  21. u16 word1, word2;
  22. u8 fbus, lbus;
  23. int i;
  24. /*
  25. * The x86_pci_root_bus_res_quirks() function already refuses to use
  26. * this information if ACPI _CRS was used. Therefore, we don't bother
  27. * checking if ACPI is enabled, and just generate the information
  28. * for both the ACPI _CRS and no ACPI cases.
  29. */
  30. info = &pci_root_info[pci_root_num];
  31. pci_root_num++;
  32. /* read the PCI bus numbers */
  33. pci_read_config_byte(dev, 0x44, &fbus);
  34. pci_read_config_byte(dev, 0x45, &lbus);
  35. info->bus_min = fbus;
  36. info->bus_max = lbus;
  37. /*
  38. * Add the legacy IDE ports on bus 0
  39. *
  40. * These do not exist anywhere in the bridge registers, AFAICT. I do
  41. * not have the datasheet, so this is the best I can do.
  42. */
  43. if (fbus == 0) {
  44. update_res(info, 0x01f0, 0x01f7, IORESOURCE_IO, 0);
  45. update_res(info, 0x03f6, 0x03f6, IORESOURCE_IO, 0);
  46. update_res(info, 0x0170, 0x0177, IORESOURCE_IO, 0);
  47. update_res(info, 0x0376, 0x0376, IORESOURCE_IO, 0);
  48. update_res(info, 0xffa0, 0xffaf, IORESOURCE_IO, 0);
  49. }
  50. /* read the non-prefetchable memory window */
  51. pci_read_config_word(dev, 0xc0, &word1);
  52. pci_read_config_word(dev, 0xc2, &word2);
  53. if (word1 != word2) {
  54. res.start = (word1 << 16) | 0x0000;
  55. res.end = (word2 << 16) | 0xffff;
  56. res.flags = IORESOURCE_MEM;
  57. update_res(info, res.start, res.end, res.flags, 0);
  58. }
  59. /* read the prefetchable memory window */
  60. pci_read_config_word(dev, 0xc4, &word1);
  61. pci_read_config_word(dev, 0xc6, &word2);
  62. if (word1 != word2) {
  63. res.start = (word1 << 16) | 0x0000;
  64. res.end = (word2 << 16) | 0xffff;
  65. res.flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
  66. update_res(info, res.start, res.end, res.flags, 0);
  67. }
  68. /* read the IO port window */
  69. pci_read_config_word(dev, 0xd0, &word1);
  70. pci_read_config_word(dev, 0xd2, &word2);
  71. if (word1 != word2) {
  72. res.start = word1;
  73. res.end = word2;
  74. res.flags = IORESOURCE_IO;
  75. update_res(info, res.start, res.end, res.flags, 0);
  76. }
  77. /* print information about this host bridge */
  78. res.start = fbus;
  79. res.end = lbus;
  80. res.flags = IORESOURCE_BUS;
  81. dev_info(&dev->dev, "CNB20LE PCI Host Bridge (domain %04x %pR)\n",
  82. pci_domain_nr(dev->bus), &res);
  83. for (i = 0; i < info->res_num; i++)
  84. dev_info(&dev->dev, "host bridge window %pR\n", &info->res[i]);
  85. }
  86. DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_LE,
  87. cnb20le_res);