pci.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
  4. */
  5. #include <common.h>
  6. #include <init.h>
  7. #include <linux/delay.h>
  8. #include <asm/mmu.h>
  9. #include <asm/io.h>
  10. #include <mpc83xx.h>
  11. #include <pci.h>
  12. #include <i2c.h>
  13. #include <asm/fsl_i2c.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. void pci_init_board(void)
  57. {
  58. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  59. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  60. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  61. #ifndef CONFIG_MPC83XX_PCI2
  62. struct pci_region *reg[] = { pci1_regions };
  63. #else
  64. struct pci_region *reg[] = { pci1_regions, pci2_regions };
  65. #endif
  66. u8 reg8;
  67. #if defined(CONFIG_SYS_I2C)
  68. i2c_set_bus_num(1);
  69. /* Read the PCI_M66EN jumper setting */
  70. if ((i2c_read(CONFIG_SYS_I2C_8574_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0) ||
  71. (i2c_read(CONFIG_SYS_I2C_8574A_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0)) {
  72. if (reg8 & I2C_8574_PCI66)
  73. clk->occr = 0xff000000; /* 66 MHz PCI */
  74. else
  75. clk->occr = 0xff600001; /* 33 MHz PCI */
  76. } else {
  77. clk->occr = 0xff600001; /* 33 MHz PCI */
  78. }
  79. #else
  80. clk->occr = 0xff000000; /* 66 MHz PCI */
  81. #endif
  82. udelay(2000);
  83. /* Configure PCI Local Access Windows */
  84. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  85. pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
  86. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  87. pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_32M;
  88. udelay(2000);
  89. #ifndef CONFIG_MPC83XX_PCI2
  90. mpc83xx_pci_init(1, reg);
  91. #else
  92. mpc83xx_pci_init(2, reg);
  93. #endif
  94. }