cpu.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * (C) Copyright 2000-2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.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. /*
  24. * CPU specific code for the MPC5xxx CPUs
  25. */
  26. #include <common.h>
  27. #include <watchdog.h>
  28. #include <command.h>
  29. #include <mpc5xxx.h>
  30. #include <asm/processor.h>
  31. #if defined(CONFIG_OF_FLAT_TREE)
  32. #include <ft_build.h>
  33. #endif
  34. DECLARE_GLOBAL_DATA_PTR;
  35. int checkcpu (void)
  36. {
  37. ulong clock = gd->cpu_clk;
  38. char buf[32];
  39. #ifndef CONFIG_MGT5100
  40. uint svr, pvr;
  41. #endif
  42. puts ("CPU: ");
  43. #ifdef CONFIG_MGT5100
  44. puts (CPU_ID_STR);
  45. printf (" (JTAG ID %08lx)", *(vu_long *)MPC5XXX_CDM_JTAGID);
  46. #else
  47. svr = get_svr();
  48. pvr = get_pvr();
  49. switch (pvr) {
  50. case PVR_5200:
  51. printf("MPC5200");
  52. break;
  53. case PVR_5200B:
  54. printf("MPC5200B");
  55. break;
  56. default:
  57. printf("Unknown MPC5xxx");
  58. break;
  59. }
  60. printf (" v%d.%d, Core v%d.%d", SVR_MJREV (svr), SVR_MNREV (svr),
  61. PVR_MAJ(pvr), PVR_MIN(pvr));
  62. #endif
  63. printf (" at %s MHz\n", strmhz (buf, clock));
  64. return 0;
  65. }
  66. /* ------------------------------------------------------------------------- */
  67. int
  68. do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  69. {
  70. ulong msr;
  71. /* Interrupts and MMU off */
  72. __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
  73. msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
  74. __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
  75. /* Charge the watchdog timer */
  76. *(vu_long *)(MPC5XXX_GPT0_COUNTER) = 0x0001000f;
  77. *(vu_long *)(MPC5XXX_GPT0_ENABLE) = 0x9004; /* wden|ce|timer_ms */
  78. while(1);
  79. return 1;
  80. }
  81. /* ------------------------------------------------------------------------- */
  82. /*
  83. * Get timebase clock frequency (like cpu_clk in Hz)
  84. *
  85. */
  86. unsigned long get_tbclk (void)
  87. {
  88. ulong tbclk;
  89. tbclk = (gd->bus_clk + 3L) / 4L;
  90. return (tbclk);
  91. }
  92. /* ------------------------------------------------------------------------- */
  93. #ifdef CONFIG_OF_FLAT_TREE
  94. void
  95. ft_cpu_setup(void *blob, bd_t *bd)
  96. {
  97. u32 *p;
  98. int len;
  99. /* Core XLB bus frequency */
  100. p = ft_get_prop(blob, "/cpus/" OF_CPU "/bus-frequency", &len);
  101. if (p != NULL)
  102. *p = cpu_to_be32(bd->bi_busfreq);
  103. /* SOC peripherals use the IPB bus frequency */
  104. p = ft_get_prop(blob, "/" OF_SOC "/bus-frequency", &len);
  105. if (p != NULL)
  106. *p = cpu_to_be32(bd->bi_ipbfreq);
  107. p = ft_get_prop(blob, "/" OF_SOC "/ethernet@3000/mac-address", &len);
  108. if (p != NULL)
  109. memcpy(p, bd->bi_enetaddr, 6);
  110. p = ft_get_prop(blob, "/" OF_SOC "/ethernet@3000/local-mac-address", &len);
  111. if (p != NULL)
  112. memcpy(p, bd->bi_enetaddr, 6);
  113. }
  114. #endif