utx8245.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * (C) Copyright 2001
  3. * Rob Taylor, Flying Pig Systems. robt@flyingpig.com.
  4. *
  5. * (C) Copyright 2002
  6. * Gregory E. Allen, gallen@arlut.utexas.edu
  7. * Matthew E. Karger, karger@arlut.utexas.edu
  8. * Applied Research Laboratories, The University of Texas at Austin
  9. *
  10. * See file CREDITS for list of people who contributed to this
  11. * project.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation; either version 2 of
  16. * the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  26. * MA 02111-1307 USA
  27. */
  28. #include <common.h>
  29. #include <mpc824x.h>
  30. #include <asm/processor.h>
  31. #include <asm/io.h>
  32. #include <pci.h>
  33. #define SAVE_SZ 32
  34. int checkboard(void)
  35. {
  36. ulong busfreq = get_bus_freq(0);
  37. char buf[32];
  38. printf("Board: UTX8245 Local Bus at %s MHz\n", strmhz(buf, busfreq));
  39. return 0;
  40. }
  41. long int initdram(int board_type)
  42. {
  43. #if 1
  44. int i, cnt;
  45. volatile uchar *base = CFG_SDRAM_BASE;
  46. volatile ulong *addr;
  47. ulong save[SAVE_SZ];
  48. ulong val, ret = 0;
  49. for (i=0; i<SAVE_SZ; i++) {save[i] = 0;} /* clear table */
  50. for (i=0, cnt=(CFG_MAX_RAM_SIZE / sizeof(long)) >> 1; cnt > 0; cnt >>= 1)
  51. {
  52. addr = (volatile ulong *)base + cnt;
  53. save[i++] = *addr;
  54. *addr = ~cnt;
  55. }
  56. addr = (volatile ulong *)base;
  57. save[i] = *addr;
  58. *addr = 0;
  59. if (*addr != 0)
  60. {
  61. *addr = save[i];
  62. goto Done;
  63. }
  64. for (cnt = 1; cnt < CFG_MAX_RAM_SIZE / sizeof(long); cnt <<= 1)
  65. {
  66. addr = (volatile ulong *)base + cnt;
  67. val = *addr;
  68. *addr = save[--i];
  69. if (val != ~cnt)
  70. {
  71. ulong new_bank0_end = cnt * sizeof(long) - 1;
  72. ulong mear1 = mpc824x_mpc107_getreg(MEAR1);
  73. ulong emear1 = mpc824x_mpc107_getreg(EMEAR1);
  74. mear1 = (mear1 & 0xFFFFFF00) |
  75. ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT);
  76. emear1 = (emear1 & 0xFFFFFF00) |
  77. ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT);
  78. mpc824x_mpc107_setreg(MEAR1, mear1);
  79. mpc824x_mpc107_setreg(EMEAR1, emear1);
  80. ret = cnt * sizeof(long);
  81. goto Done;
  82. }
  83. }
  84. ret = CFG_MAX_RAM_SIZE;
  85. Done:
  86. return ret;
  87. #else
  88. return (CFG_MAX_RAM_SIZE);
  89. #endif
  90. }
  91. /*
  92. * Initialize PCI Devices, report devices found.
  93. */
  94. static struct pci_config_table pci_utx8245_config_table[] = {
  95. #ifndef CONFIG_PCI_PNP
  96. { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  97. pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
  98. PCI_ENET0_MEMADDR,
  99. PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER }},
  100. { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  101. pci_cfgfunc_config_device, { PCI_FIREWIRE_IOADDR,
  102. PCI_FIREWIRE_MEMADDR,
  103. PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER }},
  104. #endif /*CONFIG_PCI_PNP*/
  105. { }
  106. };
  107. static void pci_utx8245_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
  108. {
  109. if (PCI_DEV(dev) == 11)
  110. /* assign serial interrupt line 9 (int25) to FireWire */
  111. pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, 25);
  112. else if (PCI_DEV(dev) == 12)
  113. /* assign serial interrupt line 8 (int24) to Ethernet */
  114. pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, 24);
  115. }
  116. static struct pci_controller utx8245_hose = {
  117. #ifndef CONFIG_PCI_PNP
  118. config_table: pci_utx8245_config_table,
  119. fixup_irq: pci_utx8245_fixup_irq,
  120. write_byte: pci_hose_write_config_byte
  121. #endif /*CONFIG_PCI_PNP*/
  122. };
  123. void pci_init_board (void)
  124. {
  125. pci_mpc824x_init(&utx8245_hose);
  126. icache_enable();
  127. }