pci.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
  4. */
  5. #include <common.h>
  6. #include <asm/mmu.h>
  7. #include <asm/io.h>
  8. #include <mpc83xx.h>
  9. #include <pci.h>
  10. #include <i2c.h>
  11. #include <asm/fsl_i2c.h>
  12. static struct pci_region pci1_regions[] = {
  13. {
  14. bus_start: CONFIG_SYS_PCI1_MEM_BASE,
  15. phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
  16. size: CONFIG_SYS_PCI1_MEM_SIZE,
  17. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  18. },
  19. {
  20. bus_start: CONFIG_SYS_PCI1_IO_BASE,
  21. phys_start: CONFIG_SYS_PCI1_IO_PHYS,
  22. size: CONFIG_SYS_PCI1_IO_SIZE,
  23. flags: PCI_REGION_IO
  24. },
  25. {
  26. bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
  27. phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
  28. size: CONFIG_SYS_PCI1_MMIO_SIZE,
  29. flags: PCI_REGION_MEM
  30. },
  31. };
  32. #ifdef CONFIG_MPC83XX_PCI2
  33. static struct pci_region pci2_regions[] = {
  34. {
  35. bus_start: CONFIG_SYS_PCI2_MEM_BASE,
  36. phys_start: CONFIG_SYS_PCI2_MEM_PHYS,
  37. size: CONFIG_SYS_PCI2_MEM_SIZE,
  38. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  39. },
  40. {
  41. bus_start: CONFIG_SYS_PCI2_IO_BASE,
  42. phys_start: CONFIG_SYS_PCI2_IO_PHYS,
  43. size: CONFIG_SYS_PCI2_IO_SIZE,
  44. flags: PCI_REGION_IO
  45. },
  46. {
  47. bus_start: CONFIG_SYS_PCI2_MMIO_BASE,
  48. phys_start: CONFIG_SYS_PCI2_MMIO_PHYS,
  49. size: CONFIG_SYS_PCI2_MMIO_SIZE,
  50. flags: PCI_REGION_MEM
  51. },
  52. };
  53. #endif
  54. void pci_init_board(void)
  55. {
  56. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  57. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  58. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  59. #ifndef CONFIG_MPC83XX_PCI2
  60. struct pci_region *reg[] = { pci1_regions };
  61. #else
  62. struct pci_region *reg[] = { pci1_regions, pci2_regions };
  63. #endif
  64. u8 reg8;
  65. #if defined(CONFIG_SYS_I2C)
  66. i2c_set_bus_num(1);
  67. /* Read the PCI_M66EN jumper setting */
  68. if ((i2c_read(CONFIG_SYS_I2C_8574_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0) ||
  69. (i2c_read(CONFIG_SYS_I2C_8574A_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0)) {
  70. if (reg8 & I2C_8574_PCI66)
  71. clk->occr = 0xff000000; /* 66 MHz PCI */
  72. else
  73. clk->occr = 0xff600001; /* 33 MHz PCI */
  74. } else {
  75. clk->occr = 0xff600001; /* 33 MHz PCI */
  76. }
  77. #else
  78. clk->occr = 0xff000000; /* 66 MHz PCI */
  79. #endif
  80. udelay(2000);
  81. /* Configure PCI Local Access Windows */
  82. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  83. pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
  84. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  85. pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_32M;
  86. udelay(2000);
  87. #ifndef CONFIG_MPC83XX_PCI2
  88. mpc83xx_pci_init(1, reg);
  89. #else
  90. mpc83xx_pci_init(2, reg);
  91. #endif
  92. }