pci.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright 2004 Freescale Semiconductor.
  3. * Copyright (C) 2003 Motorola Inc.
  4. * Xianghua Xiao (x.xiao@motorola.com)
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. /*
  25. * PCI Configuration space access support for MPC85xx PCI Bridge
  26. */
  27. #include <common.h>
  28. #include <asm/cpm_85xx.h>
  29. #include <pci.h>
  30. #if defined(CONFIG_PCI)
  31. /*
  32. * Initialize PCI Devices, report devices found.
  33. */
  34. #ifndef CONFIG_PCI_PNP
  35. static struct pci_config_table pci_mpc85xxads_config_table[] = {
  36. {PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  37. PCI_IDSEL_NUMBER, PCI_ANY_ID,
  38. pci_cfgfunc_config_device, {PCI_ENET0_IOADDR,
  39. PCI_ENET0_MEMADDR,
  40. PCI_COMMAND_MEMORY |
  41. PCI_COMMAND_MASTER}},
  42. {}
  43. };
  44. #endif
  45. struct pci_controller local_hose = {
  46. #ifndef CONFIG_PCI_PNP
  47. config_table: pci_mpc85xxads_config_table,
  48. #endif
  49. };
  50. void pci_init_board (void)
  51. {
  52. struct pci_controller *hose = (struct pci_controller *) &local_hose;
  53. volatile immap_t *immap = (immap_t *) CFG_CCSRBAR;
  54. volatile ccsr_pcix_t *pcix = &immap->im_pcix;
  55. u16 reg16;
  56. hose->first_busno = 0;
  57. hose->last_busno = 0xff;
  58. pci_set_region (hose->regions + 0,
  59. CFG_PCI1_MEM_BASE,
  60. CFG_PCI1_MEM_PHYS, CFG_PCI1_MEM_SIZE, PCI_REGION_MEM);
  61. pci_set_region (hose->regions + 1,
  62. CFG_PCI1_IO_BASE,
  63. CFG_PCI1_IO_PHYS, CFG_PCI1_IO_SIZE, PCI_REGION_IO);
  64. hose->region_count = 2;
  65. pci_setup_indirect (hose, (CFG_IMMR + 0x8000), (CFG_IMMR + 0x8004));
  66. pci_read_config_word (PCI_BDF (0, 0, 0), PCI_COMMAND, &reg16);
  67. reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
  68. pci_write_config_word (PCI_BDF (0, 0, 0), PCI_COMMAND, reg16);
  69. /*
  70. * Clear non-reserved bits in status register.
  71. */
  72. pci_write_config_word (PCI_BDF (0, 0, 0), PCI_STATUS, 0xffff);
  73. pci_write_config_byte (PCI_BDF (0, 0, 0), PCI_LATENCY_TIMER, 0x80);
  74. pcix->potar1 = (CFG_PCI1_MEM_BASE >> 12) & 0x000fffff;
  75. pcix->potear1 = 0x00000000;
  76. pcix->powbar1 = (CFG_PCI1_MEM_BASE >> 12) & 0x000fffff;
  77. pcix->powbear1 = 0x00000000;
  78. pcix->powar1 = 0x8004401c; /* 512M MEM space */
  79. pcix->potar2 = (CFG_PCI1_IO_BASE >> 12) & 0x000fffff;
  80. pcix->potear2 = 0x00000000;
  81. pcix->powbar2 = (CFG_PCI1_IO_BASE >> 12) & 0x000fffff;
  82. pcix->powbear2 = 0x00000000;
  83. pcix->powar2 = 0x80088017; /* 16M IO space */
  84. pcix->pitar1 = 0x00000000;
  85. pcix->piwbar1 = 0x00000000;
  86. pcix->piwar1 = 0xa0F5501f;
  87. /*
  88. * Hose scan.
  89. */
  90. pci_register_hose (hose);
  91. hose->last_busno = pci_hose_scan (hose);
  92. }
  93. #endif /* CONFIG_PCI */