pci.c 2.5 KB

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