cu824.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * (C) Copyright 2001
  3. * Rob Taylor, Flying Pig Systems. robt@flyingpig.com.
  4. *
  5. * (C) Copyright 2001, 2002
  6. * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <mpc824x.h>
  27. #include <asm/processor.h>
  28. #include <pci.h>
  29. #define BOARD_REV_REG 0xFE80002B
  30. int checkboard (void)
  31. {
  32. DECLARE_GLOBAL_DATA_PTR;
  33. char revision = *(volatile char *)(BOARD_REV_REG);
  34. char buf[32];
  35. puts ("Board: CU824 ");
  36. printf("Revision %d ", revision);
  37. printf("Local Bus at %s MHz\n", strmhz(buf, gd->bus_clk));
  38. return 0;
  39. }
  40. long int initdram(int board_type)
  41. {
  42. int i, cnt;
  43. volatile uchar * base = CFG_SDRAM_BASE;
  44. volatile ulong * addr;
  45. ulong save[32];
  46. ulong val, ret = 0;
  47. for (i=0, cnt=(CFG_MAX_RAM_SIZE / sizeof(long)) >> 1; cnt > 0; cnt >>= 1) {
  48. addr = (volatile ulong *)base + cnt;
  49. save[i++] = *addr;
  50. *addr = ~cnt;
  51. }
  52. addr = (volatile ulong *)base;
  53. save[i] = *addr;
  54. *addr = 0;
  55. if (*addr != 0) {
  56. *addr = save[i];
  57. goto Done;
  58. }
  59. for (cnt = 1; cnt <= CFG_MAX_RAM_SIZE / sizeof(long); cnt <<= 1) {
  60. addr = (volatile ulong *)base + cnt;
  61. val = *addr;
  62. *addr = save[--i];
  63. if (val != ~cnt) {
  64. ulong new_bank0_end = cnt * sizeof(long) - 1;
  65. ulong mear1 = mpc824x_mpc107_getreg(MEAR1);
  66. ulong emear1 = mpc824x_mpc107_getreg(EMEAR1);
  67. mear1 = (mear1 & 0xFFFFFF00) |
  68. ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT);
  69. emear1 = (emear1 & 0xFFFFFF00) |
  70. ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT);
  71. mpc824x_mpc107_setreg(MEAR1, mear1);
  72. mpc824x_mpc107_setreg(EMEAR1, emear1);
  73. ret = cnt * sizeof(long);
  74. goto Done;
  75. }
  76. }
  77. ret = CFG_MAX_RAM_SIZE;
  78. Done:
  79. return ret;
  80. }
  81. /*
  82. * Initialize PCI Devices, report devices found.
  83. */
  84. #ifndef CONFIG_PCI_PNP
  85. static struct pci_config_table pci_sandpoint_config_table[] = {
  86. { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x0f, PCI_ANY_ID,
  87. pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
  88. PCI_ENET0_MEMADDR,
  89. PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER }},
  90. { }
  91. };
  92. #endif
  93. struct pci_controller hose = {
  94. #ifndef CONFIG_PCI_PNP
  95. config_table: pci_sandpoint_config_table,
  96. #endif
  97. };
  98. void pci_init_board(void)
  99. {
  100. pci_mpc824x_init(&hose);
  101. }