pci.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright (C) 2003 Motorola Inc.
  3. * Xianghua Xiao (x.xiao@motorola.com)
  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 Configuration space access support for MPC85xx PCI Bridge
  25. */
  26. #include <common.h>
  27. #include <asm/cpm_85xx.h>
  28. #include <pci.h>
  29. #if defined(CONFIG_PCI)
  30. /*
  31. * Initialize PCI Devices, report devices found.
  32. */
  33. #ifndef CONFIG_PCI_PNP
  34. static struct pci_config_table pci_mpc85xxads_config_table[] = {
  35. { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_IDSEL_NUMBER, PCI_ANY_ID,
  36. pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
  37. PCI_ENET0_MEMADDR,
  38. PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER }},
  39. { }
  40. };
  41. #endif
  42. struct pci_controller local_hose = {
  43. #ifndef CONFIG_PCI_PNP
  44. config_table: pci_mpc85xxads_config_table,
  45. #endif
  46. };
  47. void pci_init_board(void)
  48. {
  49. struct pci_controller* hose = (struct pci_controller *)&local_hose;
  50. volatile immap_t *immap = (immap_t *)CFG_CCSRBAR;
  51. volatile ccsr_pcix_t *pcix = &immap->im_pcix;
  52. u16 reg16;
  53. hose->first_busno = 0;
  54. hose->last_busno = 0xff;
  55. pci_set_region(hose->regions + 0,
  56. CFG_PCI_MEM_BASE,
  57. CFG_PCI_MEM_PHYS,
  58. (CFG_PCI_MEM_SIZE/2),
  59. PCI_REGION_MEM);
  60. pci_set_region(hose->regions + 1,
  61. (CFG_PCI_MEM_BASE+0x08000000),
  62. (CFG_PCI_MEM_PHYS+0x08000000),
  63. 0x1000000, /* 16M */
  64. PCI_REGION_IO);
  65. hose->region_count = 2;
  66. pci_setup_indirect(hose,
  67. (CFG_IMMR+0x8000),
  68. (CFG_IMMR+0x8004));
  69. pci_register_hose(hose);
  70. hose->last_busno = pci_hose_scan(hose);
  71. pci_read_config_word (PCI_BDF(0,0,0), PCI_COMMAND, &reg16);
  72. reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
  73. pci_write_config_word(PCI_BDF(0,0,0), PCI_COMMAND, reg16);
  74. /* Clear non-reserved bits in status register */
  75. pci_write_config_word(PCI_BDF(0,0,0), PCI_STATUS, 0xffff);
  76. pci_write_config_byte(PCI_BDF(0,0,0), PCI_LATENCY_TIMER,0x80);
  77. pcix->potar1 = (CFG_PCI_MEM_BASE >> 12) & 0x000fffff;
  78. pcix->potear1 = 0x00000000;
  79. pcix->powbar1 = (CFG_PCI_MEM_BASE >> 12) & 0x000fffff;
  80. pcix->powbear1 = 0x00000000;
  81. pcix->powar1 = 0x8004401a; /* 128M MEM space */
  82. pcix->potar2 = ((CFG_PCI_MEM_BASE + 0x08000000) >> 12) & 0x000fffff;
  83. pcix->potear2 = 0x00000000;
  84. pcix->powbar2 = ((CFG_PCI_MEM_BASE + 0x08000000) >> 12) && 0x000fffff;
  85. pcix->powbear2 = 0x00000000;
  86. pcix->powar2 = 0x80088017; /* 16M IO space */
  87. pcix->pitar1 = 0x00000000;
  88. pcix->piwbar1 = 0x00000000;
  89. pcix->piwar1 = 0xa0F5501f;
  90. }
  91. #endif /* CONFIG_PCI */