intel_bus.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. if (pci_root_num >= PCI_ROOT_NR) {
  45. printk(KERN_DEBUG "intel_bus.c: PCI_ROOT_NR is too small\n");
  46. return;
  47. }
  48. info = &pci_root_info[pci_root_num];
  49. pci_root_num++;
  50. pci_read_config_word(dev, IOH_LCFGBUS, &word);
  51. bus_base = (word & 0xff);
  52. bus_end = (word & 0xff00) >> 8;
  53. sprintf(info->name, "PCI Bus #%02x", bus_base);
  54. info->bus_min = bus_base;
  55. info->bus_max = bus_end;
  56. pci_read_config_word(dev, IOH_LIO, &word);
  57. io_base = (word & 0xf0) << (12 - 4);
  58. io_end = (word & 0xf000) | 0xfff;
  59. update_res(info, io_base, io_end, IORESOURCE_IO, 0);
  60. pci_read_config_dword(dev, IOH_LMMIOL, &dword);
  61. mmiol_base = (dword & 0xff00) << (24 - 8);
  62. mmiol_end = (dword & 0xff000000) | 0xffffff;
  63. update_res(info, mmiol_base, mmiol_end, IORESOURCE_MEM, 0);
  64. pci_read_config_dword(dev, IOH_LMMIOH, &dword);
  65. mmioh_base = ((u64)(dword & 0xfc00)) << (26 - 10);
  66. mmioh_end = ((u64)(dword & 0xfc000000) | 0x3ffffff);
  67. pci_read_config_dword(dev, IOH_LMMIOH_BASEU, &dword);
  68. mmioh_base |= ((u64)(dword & 0x7ffff)) << 32;
  69. pci_read_config_dword(dev, IOH_LMMIOH_LIMITU, &dword);
  70. mmioh_end |= ((u64)(dword & 0x7ffff)) << 32;
  71. update_res(info, mmioh_base, mmioh_end, IORESOURCE_MEM, 0);
  72. print_ioh_resources(info);
  73. }
  74. /* intel IOH */
  75. DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x342e, pci_root_bus_res);