cpu.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Copyright (C) 2004-2006 Freescale Semiconductor, Inc.
  3. * (C) Copyright 2007 DENX Software Engineering
  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 MPC512x family.
  25. *
  26. * Derived from the MPC83xx code.
  27. */
  28. #include <common.h>
  29. #include <command.h>
  30. #include <mpc512x.h>
  31. #include <asm/processor.h>
  32. #if defined(CONFIG_OF_LIBFDT)
  33. #include <fdt_support.h>
  34. #endif
  35. DECLARE_GLOBAL_DATA_PTR;
  36. int checkcpu (void)
  37. {
  38. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  39. ulong clock = gd->cpu_clk;
  40. u32 pvr = get_pvr ();
  41. u32 spridr = immr->sysconf.spridr;
  42. char buf[32];
  43. puts ("CPU: ");
  44. switch (spridr & 0xffff0000) {
  45. case SPR_5121E:
  46. puts ("MPC5121e ");
  47. break;
  48. default:
  49. printf ("Unknown part ID %08x ", spridr & 0xffff0000);
  50. }
  51. printf ("rev. %d.%d, Core ", SVR_MJREV (spridr), SVR_MNREV (spridr));
  52. switch (pvr & 0xffff0000) {
  53. case PVR_E300C4:
  54. puts ("e300c4 ");
  55. break;
  56. default:
  57. puts ("unknown ");
  58. }
  59. printf ("at %s MHz, CSB at %3d MHz\n", strmhz(buf, clock),
  60. gd->csb_clk / 1000000);
  61. return 0;
  62. }
  63. int
  64. do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  65. {
  66. ulong msr;
  67. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  68. /* Interrupts and MMU off */
  69. __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
  70. msr &= ~( MSR_EE | MSR_IR | MSR_DR);
  71. __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
  72. /*
  73. * Enable Reset Control Reg - "RSTE" is the magic word that let us go
  74. */
  75. immap->reset.rpr = 0x52535445;
  76. /* Verify Reset Control Reg is enabled */
  77. while (!((immap->reset.rcer) & RCER_CRE))
  78. ;
  79. printf ("Resetting the board.\n");
  80. udelay(200);
  81. /* Perform reset */
  82. immap->reset.rcr = RCR_SWHR;
  83. /* Unreached... */
  84. return 1;
  85. }
  86. /*
  87. * Get timebase clock frequency (like cpu_clk in Hz)
  88. */
  89. unsigned long get_tbclk (void)
  90. {
  91. ulong tbclk;
  92. tbclk = (gd->bus_clk + 3L) / 4L;
  93. return tbclk;
  94. }
  95. #if defined(CONFIG_WATCHDOG)
  96. void watchdog_reset (void)
  97. {
  98. int re_enable = disable_interrupts ();
  99. /* Reset watchdog */
  100. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  101. immr->wdt.swsrr = 0x556c;
  102. immr->wdt.swsrr = 0xaa39;
  103. if (re_enable)
  104. enable_interrupts ();
  105. }
  106. #endif
  107. #ifdef CONFIG_OF_LIBFDT
  108. void ft_cpu_setup(void *blob, bd_t *bd)
  109. {
  110. char * cpu_path = "/cpus/" OF_CPU;
  111. char * eth_path = "/" OF_SOC "/ethernet@2800";
  112. do_fixup_by_path_u32(blob, cpu_path, "timebase-frequency", OF_TBCLK, 1);
  113. do_fixup_by_path_u32(blob, cpu_path, "bus-frequency", bd->bi_busfreq, 1);
  114. do_fixup_by_path_u32(blob, cpu_path, "ref-frequency", CFG_MPC512X_CLKIN, 1);
  115. do_fixup_by_path_u32(blob, cpu_path, "clock-frequency", bd->bi_intfreq, 1);
  116. do_fixup_by_path_u32(blob, "/" OF_SOC, "bus-frequency", bd->bi_ipsfreq, 1);
  117. do_fixup_by_path_u32(blob, "/" OF_SOC, "ref-frequency", CFG_MPC512X_CLKIN, 1);
  118. do_fixup_by_path(blob, eth_path, "address", bd->bi_enetaddr, 6, 0);
  119. do_fixup_by_path(blob, eth_path, "local-mac-address", bd->bi_enetaddr, 6, 0);
  120. }
  121. #endif