pci.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2005
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
  6. */
  7. #include <asm/mmu.h>
  8. #include <asm/io.h>
  9. #include <common.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. /*
  35. * pci_init_board()
  36. *
  37. * NOTICE: MPC8349 internally has two PCI controllers (PCI1 and PCI2) but since
  38. * per TQM834x design physical connections to external devices (PCI sockets)
  39. * are routed only to the PCI1 we do not account for the second one - this code
  40. * supports PCI1 module only. Should support for the PCI2 be required in the
  41. * future it needs a separate pci_controller structure (above) and handling -
  42. * please refer to other boards' implementation for dual PCI host controllers,
  43. * for example board/Marvell/db64360/pci.c, pci_init_board()
  44. *
  45. */
  46. void
  47. pci_init_board(void)
  48. {
  49. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  50. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  51. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  52. struct pci_region *reg[] = { pci1_regions };
  53. u32 reg32;
  54. /*
  55. * Configure PCI controller and PCI_CLK_OUTPUT
  56. *
  57. * WARNING! only PCI_CLK_OUTPUT1 is enabled here as this is the one
  58. * line actually used for clocking all external PCI devices in TQM83xx.
  59. * Enabling other PCI_CLK_OUTPUT lines may lead to board's hang for
  60. * unknown reasons - particularly PCI_CLK_OUTPUT6 and PCI_CLK_OUTPUT7
  61. * are known to hang the board; this issue is under investigation
  62. * (13 oct 05)
  63. */
  64. reg32 = OCCR_PCICOE1;
  65. #if 0
  66. /* enabling all PCI_CLK_OUTPUT lines HANGS the board... */
  67. reg32 = 0xff000000;
  68. #endif
  69. if (clk->spmr & SPMR_CKID) {
  70. /* PCI Clock is half CONFIG_83XX_CLKIN so need to set up OCCR
  71. * fields accordingly */
  72. reg32 |= (OCCR_PCI1CR | OCCR_PCI2CR);
  73. reg32 |= (OCCR_PCICD0 | OCCR_PCICD1 | OCCR_PCICD2 \
  74. | OCCR_PCICD3 | OCCR_PCICD4 | OCCR_PCICD5 \
  75. | OCCR_PCICD6 | OCCR_PCICD7);
  76. }
  77. clk->occr = reg32;
  78. udelay(2000);
  79. /* Configure PCI Local Access Windows */
  80. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  81. pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_512M;
  82. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  83. pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_16M;
  84. udelay(2000);
  85. mpc83xx_pci_init(1, reg);
  86. }