elppc.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * (C) Copyright 2002 ELTEC Elektronik AG
  3. * Frank Gottschling <fgottschling@eltec.de>
  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. #include <common.h>
  24. #include <command.h>
  25. #include <mpc106.h>
  26. #include <video_fb.h>
  27. #include <netdev.h>
  28. DECLARE_GLOBAL_DATA_PTR;
  29. /* ------------------------------------------------------------------------- */
  30. int checkboard (void)
  31. {
  32. puts ("Board: ELTEC PowerPC\n");
  33. return (0);
  34. }
  35. /* ------------------------------------------------------------------------- */
  36. int checkflash (void)
  37. {
  38. /* TODO */
  39. printf ("Test not implemented !\n");
  40. return (0);
  41. }
  42. /* ------------------------------------------------------------------------- */
  43. static unsigned int mpc106_read_cfg_dword (unsigned int reg)
  44. {
  45. unsigned int reg_addr = MPC106_REG | (reg & 0xFFFFFFFC);
  46. out32r (MPC106_REG_ADDR, reg_addr);
  47. return (in32r (MPC106_REG_DATA | (reg & 0x3)));
  48. }
  49. /* ------------------------------------------------------------------------- */
  50. long int dram_size (int board_type)
  51. {
  52. /*
  53. * No actual initialisation to do - done when setting up
  54. * PICRs MCCRs ME/SARs etc in asm_init.S.
  55. */
  56. register unsigned long i, msar1, mear1, memSize;
  57. #if defined(CONFIG_SYS_MEMTEST)
  58. register unsigned long reg;
  59. printf ("Testing DRAM\n");
  60. /* write each mem addr with it's address */
  61. for (reg = CONFIG_SYS_MEMTEST_START; reg < CONFIG_SYS_MEMTEST_END; reg += 4)
  62. *reg = reg;
  63. for (reg = CONFIG_SYS_MEMTEST_START; reg < CONFIG_SYS_MEMTEST_END; reg += 4) {
  64. if (*reg != reg)
  65. return -1;
  66. }
  67. #endif
  68. /*
  69. * Since MPC107 memory controller chip has already been set to
  70. * control all memory, just read and interpret its memory boundery register.
  71. */
  72. memSize = 0;
  73. msar1 = mpc106_read_cfg_dword (MPC106_MSAR1);
  74. mear1 = mpc106_read_cfg_dword (MPC106_MEAR1);
  75. i = mpc106_read_cfg_dword (MPC106_MBER) & 0xf;
  76. do {
  77. if (i & 0x01) /* is bank enabled ? */
  78. memSize += (mear1 & 0xff) - (msar1 & 0xff) + 1;
  79. msar1 >>= 8;
  80. mear1 >>= 8;
  81. i >>= 1;
  82. } while (i);
  83. return (memSize * 0x100000);
  84. }
  85. /* ------------------------------------------------------------------------- */
  86. phys_size_t initdram (int board_type)
  87. {
  88. return dram_size (board_type);
  89. }
  90. /* ------------------------------------------------------------------------- */
  91. /*
  92. * The BAB 911 can be reset by writing bit 0 of the Processor Initialization
  93. * Register PI in the MPC 107 (at offset 0x41090 of the Embedded Utilities
  94. * Memory Block).
  95. */
  96. int do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  97. {
  98. out8 (MPC107_EUMB_PI, 1);
  99. return (0);
  100. }
  101. /* ------------------------------------------------------------------------- */
  102. #if defined(CONFIG_WATCHDOG)
  103. /*
  104. * Since the 7xx CPUs don't have an internal watchdog, this function is
  105. * board specific.
  106. */
  107. void watchdog_reset (void)
  108. {
  109. }
  110. #endif /* CONFIG_WATCHDOG */
  111. /* ------------------------------------------------------------------------- */
  112. void after_reloc (ulong dest_addr)
  113. {
  114. /*
  115. * Jump to the main U-Boot board init code
  116. */
  117. board_init_r ((gd_t *)gd, dest_addr);
  118. }
  119. /* ------------------------------------------------------------------------- */
  120. #ifdef CONFIG_CONSOLE_EXTRA_INFO
  121. extern GraphicDevice smi;
  122. void video_get_info_str (int line_number, char *info)
  123. {
  124. /* init video info strings for graphic console */
  125. switch (line_number) {
  126. case 1:
  127. sprintf (info, " MPC7xx V%d.%d at %d / %d MHz",
  128. (get_pvr () >> 8) & 0xFF, get_pvr () & 0xFF, 400, 100);
  129. return;
  130. case 2:
  131. sprintf (info, " ELTEC ELPPC with %ld MB DRAM and %ld MB FLASH",
  132. dram_size (0) / 0x100000, flash_init () / 0x100000);
  133. return;
  134. case 3:
  135. sprintf (info, " %s", smi.modeIdent);
  136. return;
  137. }
  138. /* no more info lines */
  139. *info = 0;
  140. return;
  141. }
  142. #endif
  143. int board_eth_init(bd_t *bis)
  144. {
  145. return pci_eth_init(bis);
  146. }