cpu.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * (C) Copyright 2002, 2003 Motorola Inc.
  3. * Xianghua Xiao (X.Xiao@motorola.com)
  4. *
  5. * (C) Copyright 2000
  6. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <watchdog.h>
  28. #include <command.h>
  29. #include <asm/cache.h>
  30. /* ------------------------------------------------------------------------- */
  31. int checkcpu (void)
  32. {
  33. uint pir = get_pir();
  34. uint pvr = get_pvr();
  35. printf("Motorola PowerPC ProcessorID=%08x Rev. ",pir);
  36. switch(pvr) {
  37. default:
  38. printf("PVR=%08x", pvr);
  39. break;
  40. }
  41. printf("\n");
  42. return 0;
  43. }
  44. /* ------------------------------------------------------------------------- */
  45. int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
  46. {
  47. /*
  48. * Initiate hard reset in debug control register DBCR0
  49. * Make sure MSR[DE] = 1
  50. */
  51. __asm__ __volatile__("lis 3, 0x7000" ::: "r3");
  52. mtspr(DBCR0,3);
  53. return 1;
  54. }
  55. /*
  56. * Get timebase clock frequency
  57. */
  58. unsigned long get_tbclk (void)
  59. {
  60. sys_info_t sys_info;
  61. get_sys_info(&sys_info);
  62. return ((sys_info.freqSystemBus + 3L) / 4L);
  63. }
  64. #if defined(CONFIG_WATCHDOG)
  65. void
  66. watchdog_reset(void)
  67. {
  68. int re_enable = disable_interrupts();
  69. reset_85xx_watchdog();
  70. if (re_enable) enable_interrupts();
  71. }
  72. void
  73. reset_85xx_watchdog(void)
  74. {
  75. /*
  76. * Clear TSR(WIS) bit by writing 1
  77. */
  78. unsigned long val;
  79. val = mfspr(tsr);
  80. val |= 0x40000000;
  81. mtspr(tsr, val);
  82. }
  83. #endif /* CONFIG_WATCHDOG */
  84. #if defined(CONFIG_DDR_ECC)
  85. __inline__ void dcbz(const void* addr)
  86. {
  87. __asm__ __volatile__ ("dcbz 0,%0" :: "r" (addr));
  88. }
  89. __inline__ void dcbf(const void* addr)
  90. {
  91. __asm__ __volatile__ ("dcbf 0,%0" :: "r" (addr));
  92. }
  93. void dma_init(void) {
  94. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  95. volatile ccsr_dma_t *dma = &immap->im_dma;
  96. dma->satr0 = 0x02c40000;
  97. dma->datr0 = 0x02c40000;
  98. asm("sync; isync; msync");
  99. return;
  100. }
  101. uint dma_check(void) {
  102. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  103. volatile ccsr_dma_t *dma = &immap->im_dma;
  104. volatile uint status = dma->sr0;
  105. /* While the channel is busy, spin */
  106. while((status & 4) == 4) {
  107. status = dma->sr0;
  108. }
  109. if (status != 0) {
  110. printf ("DMA Error: status = %x\n", status);
  111. }
  112. return status;
  113. }
  114. int dma_xfer(void *dest, uint count, void *src) {
  115. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  116. volatile ccsr_dma_t *dma = &immap->im_dma;
  117. dma->dar0 = (uint) dest;
  118. dma->sar0 = (uint) src;
  119. dma->bcr0 = count;
  120. dma->mr0 = 0xf000004;
  121. asm("sync;isync;msync");
  122. dma->mr0 = 0xf000005;
  123. asm("sync;isync;msync");
  124. return dma_check();
  125. }
  126. #endif