pci.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * (C) Copyright 2002 ELTEC Elektronik AG
  3. * Frank Gottschling <fgottschling@eltec.de>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. /*
  24. * PCI initialisation for the MPC10x.
  25. */
  26. #include <common.h>
  27. #include <pci.h>
  28. #include <mpc106.h>
  29. #ifdef CONFIG_PCI
  30. struct pci_controller local_hose;
  31. void pci_init(void)
  32. {
  33. struct pci_controller* hose = (struct pci_controller *)&local_hose;
  34. u32 reg32;
  35. u16 reg16;
  36. hose->first_busno = 0;
  37. hose->last_busno = 0xff;
  38. pci_set_region(hose->regions + 0,
  39. CFG_PCI_MEMORY_BUS,
  40. CFG_PCI_MEMORY_PHYS,
  41. /*
  42. * Attention: pci_hose_phys_to_bus() failes in address compare,
  43. * so we need (CFG_PCI_MEMORY_SIZE-1)
  44. */
  45. CFG_PCI_MEMORY_SIZE-1,
  46. PCI_REGION_MEM | PCI_REGION_MEMORY);
  47. /* PCI memory space */
  48. pci_set_region(hose->regions + 1,
  49. CFG_PCI_MEM_BUS,
  50. CFG_PCI_MEM_PHYS,
  51. CFG_PCI_MEM_SIZE,
  52. PCI_REGION_MEM);
  53. /* ISA/PCI memory space */
  54. pci_set_region(hose->regions + 2,
  55. CFG_ISA_MEM_BUS,
  56. CFG_ISA_MEM_PHYS,
  57. CFG_ISA_MEM_SIZE,
  58. PCI_REGION_MEM);
  59. /* PCI I/O space */
  60. pci_set_region(hose->regions + 3,
  61. CFG_PCI_IO_BUS,
  62. CFG_PCI_IO_PHYS,
  63. CFG_PCI_IO_SIZE,
  64. PCI_REGION_IO);
  65. /* ISA/PCI I/O space */
  66. pci_set_region(hose->regions + 4,
  67. CFG_ISA_IO_BUS,
  68. CFG_ISA_IO_PHYS,
  69. CFG_ISA_IO_SIZE,
  70. PCI_REGION_IO);
  71. hose->region_count = 5;
  72. pci_setup_indirect(hose,
  73. MPC106_REG_ADDR,
  74. MPC106_REG_DATA);
  75. pci_register_hose(hose);
  76. hose->last_busno = pci_hose_scan(hose);
  77. /* Initialises the MPC10x PCI Configuration regs. */
  78. pci_read_config_dword (PCI_BDF(0,0,0), PCI_PICR2, &reg32);
  79. reg32 |= PICR2_CF_SNOOP_WS(3) |
  80. PICR2_CF_FLUSH_L2 |
  81. PICR2_CF_L2_HIT_DELAY(3) |
  82. PICR2_CF_APHASE_WS(3);
  83. reg32 &= ~(PICR2_L2_EN | PICR2_L2_UPDATE_EN);
  84. pci_write_config_dword (PCI_BDF(0,0,0), PCI_PICR2, reg32);
  85. pci_read_config_word (PCI_BDF(0,0,0), PCI_COMMAND, &reg16);
  86. reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
  87. pci_write_config_word(PCI_BDF(0,0,0), PCI_COMMAND, reg16);
  88. /* Clear non-reserved bits in status register */
  89. pci_write_config_word(PCI_BDF(0,0,0), PCI_STATUS, 0xffff);
  90. pci_read_config_dword (PCI_BDF(0,0,0), PCI_PICR1, &reg32);
  91. reg32 |= PICR1_CF_CBA(63) |
  92. PICR1_CF_BREAD_WS(2) |
  93. PICR1_MCP_EN |
  94. PICR1_CF_DPARK |
  95. PICR1_PROC_TYPE_604 |
  96. PICR1_CF_LOOP_SNOOP |
  97. PICR1_CF_APARK;
  98. pci_write_config_dword (PCI_BDF(0,0,0), PCI_PICR1, reg32);
  99. }
  100. #endif /* CONFIG_PCI */