pci.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
  4. */
  5. #include <init.h>
  6. #include <asm/mmu.h>
  7. #include <asm/io.h>
  8. #include <common.h>
  9. #include <mpc83xx.h>
  10. #include <pci.h>
  11. #include <i2c.h>
  12. #include <asm/fsl_i2c.h>
  13. #include <linux/delay.h>
  14. static struct pci_region pci1_regions[] = {
  15. {
  16. bus_start: CONFIG_SYS_PCI1_MEM_BASE,
  17. phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
  18. size: CONFIG_SYS_PCI1_MEM_SIZE,
  19. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  20. },
  21. {
  22. bus_start: CONFIG_SYS_PCI1_IO_BASE,
  23. phys_start: CONFIG_SYS_PCI1_IO_PHYS,
  24. size: CONFIG_SYS_PCI1_IO_SIZE,
  25. flags: PCI_REGION_IO
  26. },
  27. {
  28. bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
  29. phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
  30. size: CONFIG_SYS_PCI1_MMIO_SIZE,
  31. flags: PCI_REGION_MEM
  32. },
  33. };
  34. #ifdef CONFIG_MPC83XX_PCI2
  35. static struct pci_region pci2_regions[] = {
  36. {
  37. bus_start: CONFIG_SYS_PCI2_MEM_BASE,
  38. phys_start: CONFIG_SYS_PCI2_MEM_PHYS,
  39. size: CONFIG_SYS_PCI2_MEM_SIZE,
  40. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  41. },
  42. {
  43. bus_start: CONFIG_SYS_PCI2_IO_BASE,
  44. phys_start: CONFIG_SYS_PCI2_IO_PHYS,
  45. size: CONFIG_SYS_PCI2_IO_SIZE,
  46. flags: PCI_REGION_IO
  47. },
  48. {
  49. bus_start: CONFIG_SYS_PCI2_MMIO_BASE,
  50. phys_start: CONFIG_SYS_PCI2_MMIO_PHYS,
  51. size: CONFIG_SYS_PCI2_MMIO_SIZE,
  52. flags: PCI_REGION_MEM
  53. },
  54. };
  55. #endif
  56. #ifndef CONFIG_PCISLAVE
  57. void pib_init(void)
  58. {
  59. u8 val8, orig_i2c_bus;
  60. /*
  61. * Assign PIB PMC slot to desired PCI bus
  62. */
  63. /* Switch temporarily to I2C bus #2 */
  64. orig_i2c_bus = i2c_get_bus_num();
  65. i2c_set_bus_num(1);
  66. val8 = 0;
  67. i2c_write(0x23, 0x6, 1, &val8, 1);
  68. i2c_write(0x23, 0x7, 1, &val8, 1);
  69. val8 = 0xff;
  70. i2c_write(0x23, 0x2, 1, &val8, 1);
  71. i2c_write(0x23, 0x3, 1, &val8, 1);
  72. val8 = 0;
  73. i2c_write(0x26, 0x6, 1, &val8, 1);
  74. val8 = 0x34;
  75. i2c_write(0x26, 0x7, 1, &val8, 1);
  76. #if defined(CONFIG_PCI_64BIT)
  77. val8 = 0xf4; /* PMC2:PCI1/64-bit */
  78. #elif defined(CONFIG_PCI_ALL_PCI1)
  79. val8 = 0xf3; /* PMC1:PCI1 PMC2:PCI1 PMC3:PCI1 */
  80. #elif defined(CONFIG_PCI_ONE_PCI1)
  81. val8 = 0xf9; /* PMC1:PCI1 PMC2:PCI2 PMC3:PCI2 */
  82. #else
  83. val8 = 0xf5; /* PMC1:PCI1 PMC2:PCI1 PMC3:PCI2 */
  84. #endif
  85. i2c_write(0x26, 0x2, 1, &val8, 1);
  86. val8 = 0xff;
  87. i2c_write(0x26, 0x3, 1, &val8, 1);
  88. val8 = 0;
  89. i2c_write(0x27, 0x6, 1, &val8, 1);
  90. i2c_write(0x27, 0x7, 1, &val8, 1);
  91. val8 = 0xff;
  92. i2c_write(0x27, 0x2, 1, &val8, 1);
  93. val8 = 0xef;
  94. i2c_write(0x27, 0x3, 1, &val8, 1);
  95. asm("eieio");
  96. #if defined(CONFIG_PCI_64BIT)
  97. printf("PCI1: 64-bit on PMC2\n");
  98. #elif defined(CONFIG_PCI_ALL_PCI1)
  99. printf("PCI1: 32-bit on PMC1, PMC2, PMC3\n");
  100. #elif defined(CONFIG_PCI_ONE_PCI1)
  101. printf("PCI1: 32-bit on PMC1\n");
  102. printf("PCI2: 32-bit on PMC2, PMC3\n");
  103. #else
  104. printf("PCI1: 32-bit on PMC1, PMC2\n");
  105. printf("PCI2: 32-bit on PMC3\n");
  106. #endif
  107. /* Reset to original I2C bus */
  108. i2c_set_bus_num(orig_i2c_bus);
  109. }
  110. #endif /* CONFIG_PCISLAVE */