pci.c 2.8 KB

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