a3000.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * (C) Copyright 2001
  3. * Rob Taylor, Flying Pig Systems. robt@flyingpig.com.
  4. *
  5. * Modified during 2003 by
  6. * Ken Chou, kchou@ieee.org
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <mpc824x.h>
  28. #include <pci.h>
  29. int checkboard (void)
  30. {
  31. ulong busfreq = get_bus_freq(0);
  32. char buf[32];
  33. printf("Board: A3000 Local Bus at %s MHz\n", strmhz(buf, busfreq));
  34. return 0;
  35. }
  36. long int initdram (int board_type)
  37. {
  38. int i, cnt;
  39. volatile uchar * base= CFG_SDRAM_BASE;
  40. volatile ulong * addr;
  41. ulong save[32];
  42. ulong val, ret = 0;
  43. for (i=0, cnt=(CFG_MAX_RAM_SIZE / sizeof(long)) >> 1; cnt > 0; cnt >>= 1) {
  44. addr = (volatile ulong *)base + cnt;
  45. save[i++] = *addr;
  46. *addr = ~cnt;
  47. }
  48. addr = (volatile ulong *)base;
  49. save[i] = *addr;
  50. *addr = 0;
  51. if (*addr != 0) {
  52. *addr = save[i];
  53. goto Done;
  54. }
  55. for (cnt = 1; cnt <= CFG_MAX_RAM_SIZE / sizeof(long); cnt <<= 1) {
  56. addr = (volatile ulong *)base + cnt;
  57. val = *addr;
  58. *addr = save[--i];
  59. if (val != ~cnt) {
  60. ulong new_bank0_end = cnt * sizeof(long) - 1;
  61. ulong mear1 = mpc824x_mpc107_getreg(MEAR1);
  62. ulong emear1 = mpc824x_mpc107_getreg(EMEAR1);
  63. mear1 = (mear1 & 0xFFFFFF00) |
  64. ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT);
  65. emear1 = (emear1 & 0xFFFFFF00) |
  66. ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT);
  67. mpc824x_mpc107_setreg(MEAR1, mear1);
  68. mpc824x_mpc107_setreg(EMEAR1, emear1);
  69. ret = cnt * sizeof(long);
  70. goto Done;
  71. }
  72. }
  73. ret = CFG_MAX_RAM_SIZE;
  74. Done:
  75. return ret;
  76. }
  77. /*
  78. * Initialize PCI Devices
  79. */
  80. #ifndef CONFIG_PCI_PNP
  81. static struct pci_config_table pci_a3000_config_table[] = {
  82. /* vendor, device, class */
  83. /* bus, dev, func */
  84. { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_83815, PCI_ANY_ID,
  85. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, /* dp83815 eth0 divice */
  86. pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
  87. PCI_ENET0_MEMADDR,
  88. PCI_COMMAND_IO |
  89. PCI_COMMAND_MEMORY |
  90. PCI_COMMAND_MASTER }},
  91. { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  92. PCI_ANY_ID, 0x14, PCI_ANY_ID, /* PCI slot1 */
  93. pci_cfgfunc_config_device, { PCI_ENET1_IOADDR,
  94. PCI_ENET1_MEMADDR,
  95. PCI_COMMAND_IO |
  96. PCI_COMMAND_MEMORY |
  97. PCI_COMMAND_MASTER }},
  98. { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  99. PCI_ANY_ID, 0x15, PCI_ANY_ID, /* PCI slot2 */
  100. pci_cfgfunc_config_device, { PCI_ENET2_IOADDR,
  101. PCI_ENET2_MEMADDR,
  102. PCI_COMMAND_IO |
  103. PCI_COMMAND_MEMORY |
  104. PCI_COMMAND_MASTER }},
  105. { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  106. PCI_ANY_ID, 0x16, PCI_ANY_ID, /* PCI slot3 */
  107. pci_cfgfunc_config_device, { PCI_ENET3_IOADDR,
  108. PCI_ENET3_MEMADDR,
  109. PCI_COMMAND_IO |
  110. PCI_COMMAND_MEMORY |
  111. PCI_COMMAND_MASTER }},
  112. { }
  113. };
  114. #endif
  115. struct pci_controller hose = {
  116. #ifndef CONFIG_PCI_PNP
  117. config_table: pci_a3000_config_table,
  118. #endif
  119. };
  120. void pci_init_board(void)
  121. {
  122. pci_mpc824x_init(&hose);
  123. }