intel_bus.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * to read io range from IOH pci conf, need to do it after mmconfig is there
  3. */
  4. #include <linux/delay.h>
  5. #include <linux/dmi.h>
  6. #include <linux/pci.h>
  7. #include <linux/init.h>
  8. #include <asm/pci_x86.h>
  9. #include "bus_numa.h"
  10. static inline void print_ioh_resources(struct pci_root_info *info)
  11. {
  12. int res_num;
  13. int busnum;
  14. int i;
  15. printk(KERN_DEBUG "IOH bus: [%02x, %02x]\n",
  16. info->bus_min, info->bus_max);
  17. res_num = info->res_num;
  18. busnum = info->bus_min;
  19. for (i = 0; i < res_num; i++) {
  20. struct resource *res;
  21. res = &info->res[i];
  22. printk(KERN_DEBUG "IOH bus: %02x index %x %s: [%llx, %llx]\n",
  23. busnum, i,
  24. (res->flags & IORESOURCE_IO) ? "io port" :
  25. "mmio",
  26. res->start, res->end);
  27. }
  28. }
  29. #define IOH_LIO 0x108
  30. #define IOH_LMMIOL 0x10c
  31. #define IOH_LMMIOH 0x110
  32. #define IOH_LMMIOH_BASEU 0x114
  33. #define IOH_LMMIOH_LIMITU 0x118
  34. #define IOH_LCFGBUS 0x11c
  35. static void __devinit pci_root_bus_res(struct pci_dev *dev)
  36. {
  37. u16 word;
  38. u32 dword;
  39. struct pci_root_info *info;
  40. u16 io_base, io_end;
  41. u32 mmiol_base, mmiol_end;
  42. u64 mmioh_base, mmioh_end;
  43. int bus_base, bus_end;
  44. /* some sys doesn't get mmconf enabled */
  45. if (dev->cfg_size < 0x120)
  46. return;
  47. if (pci_root_num >= PCI_ROOT_NR) {
  48. printk(KERN_DEBUG "intel_bus.c: PCI_ROOT_NR is too small\n");
  49. return;
  50. }
  51. info = &pci_root_info[pci_root_num];
  52. pci_root_num++;
  53. pci_read_config_word(dev, IOH_LCFGBUS, &word);
  54. bus_base = (word & 0xff);
  55. bus_end = (word & 0xff00) >> 8;
  56. sprintf(info->name, "PCI Bus #%02x", bus_base);
  57. info->bus_min = bus_base;
  58. info->bus_max = bus_end;
  59. pci_read_config_word(dev, IOH_LIO, &word);
  60. io_base = (word & 0xf0) << (12 - 4);
  61. io_end = (word & 0xf000) | 0xfff;
  62. update_res(info, io_base, io_end, IORESOURCE_IO, 0);
  63. pci_read_config_dword(dev, IOH_LMMIOL, &dword);
  64. mmiol_base = (dword & 0xff00) << (24 - 8);
  65. mmiol_end = (dword & 0xff000000) | 0xffffff;
  66. update_res(info, mmiol_base, mmiol_end, IORESOURCE_MEM, 0);
  67. pci_read_config_dword(dev, IOH_LMMIOH, &dword);
  68. mmioh_base = ((u64)(dword & 0xfc00)) << (26 - 10);
  69. mmioh_end = ((u64)(dword & 0xfc000000) | 0x3ffffff);
  70. pci_read_config_dword(dev, IOH_LMMIOH_BASEU, &dword);
  71. mmioh_base |= ((u64)(dword & 0x7ffff)) << 32;
  72. pci_read_config_dword(dev, IOH_LMMIOH_LIMITU, &dword);
  73. mmioh_end |= ((u64)(dword & 0x7ffff)) << 32;
  74. update_res(info, mmioh_base, mmioh_end, IORESOURCE_MEM, 0);
  75. print_ioh_resources(info);
  76. }
  77. /* intel IOH */
  78. DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x342e, pci_root_bus_res);