cpu.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * U-boot - cpu.c CPU specific functions
  3. *
  4. * Copyright (c) 2005-2008 Analog Devices Inc.
  5. *
  6. * (C) Copyright 2000-2004
  7. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  8. *
  9. * Licensed under the GPL-2 or later.
  10. */
  11. #include <common.h>
  12. #include <command.h>
  13. #include <asm/blackfin.h>
  14. #include <asm/cplb.h>
  15. #include <asm/mach-common/bits/core.h>
  16. #include <asm/mach-common/bits/ebiu.h>
  17. #include <asm/mach-common/bits/trace.h>
  18. #include <asm/serial.h>
  19. #include "cpu.h"
  20. #include "initcode.h"
  21. ulong bfin_poweron_retx;
  22. #if defined(CONFIG_CORE1_RUN) && defined(COREB_L1_CODE_START)
  23. void bfin_core1_start(void)
  24. {
  25. #ifdef BF561_FAMILY
  26. /* Enable core 1 */
  27. bfin_write_SYSCR(bfin_read_SYSCR() & ~0x0020);
  28. #else
  29. /* Enable core 1 */
  30. bfin_write32(RCU0_SVECT1, COREB_L1_CODE_START);
  31. bfin_write32(RCU0_CRCTL, 0);
  32. bfin_write32(RCU0_CRCTL, 0x2);
  33. /* Check if core 1 starts */
  34. while (!(bfin_read32(RCU0_CRSTAT) & 0x2))
  35. continue;
  36. bfin_write32(RCU0_CRCTL, 0);
  37. /* flag to notify cces core 1 application */
  38. bfin_write32(SDU0_MSG_SET, (1 << 19));
  39. #endif
  40. }
  41. #endif
  42. __attribute__ ((__noreturn__))
  43. void cpu_init_f(ulong bootflag, ulong loaded_from_ldr)
  44. {
  45. #ifndef CONFIG_BFIN_BOOTROM_USES_EVT1
  46. /* Build a NOP slide over the LDR jump block. Whee! */
  47. char nops[0xC];
  48. serial_early_puts("NOP Slide\n");
  49. memset(nops, 0x00, sizeof(nops));
  50. memcpy((void *)L1_INST_SRAM, nops, sizeof(nops));
  51. #endif
  52. if (!loaded_from_ldr) {
  53. /* Relocate sections into L1 if the LDR didn't do it -- don't
  54. * check length because the linker script does the size
  55. * checking at build time.
  56. */
  57. serial_early_puts("L1 Relocate\n");
  58. extern char _stext_l1[], _text_l1_lma[], _text_l1_len[];
  59. memcpy(&_stext_l1, &_text_l1_lma, (unsigned long)_text_l1_len);
  60. extern char _sdata_l1[], _data_l1_lma[], _data_l1_len[];
  61. memcpy(&_sdata_l1, &_data_l1_lma, (unsigned long)_data_l1_len);
  62. }
  63. /*
  64. * Make sure our async settings are committed. Some bootroms
  65. * (like the BF537) will reset some registers on us after it
  66. * has finished loading the LDR. Or if we're booting over
  67. * JTAG, the initcode never got a chance to run. Or if we
  68. * aren't booting from parallel flash, the initcode skipped
  69. * this step completely.
  70. */
  71. program_async_controller(NULL);
  72. /* Save RETX so we can pass it while booting Linux */
  73. bfin_poweron_retx = bootflag;
  74. #ifdef CONFIG_DEBUG_DUMP
  75. /* Turn on hardware trace buffer */
  76. bfin_write_TBUFCTL(TBUFPWR | TBUFEN);
  77. #endif
  78. #ifndef CONFIG_PANIC_HANG
  79. /* Reset upon a double exception rather than just hanging.
  80. * Do not do bfin_read on SWRST as that will reset status bits.
  81. */
  82. # ifdef SWRST
  83. bfin_write_SWRST(DOUBLE_FAULT);
  84. # endif
  85. #endif
  86. #if defined(CONFIG_CORE1_RUN) && defined(COREB_L1_CODE_START)
  87. bfin_core1_start();
  88. #endif
  89. serial_early_puts("Board init flash\n");
  90. board_init_f(bootflag);
  91. }
  92. int exception_init(void)
  93. {
  94. bfin_write_EVT3(trap);
  95. return 0;
  96. }
  97. int irq_init(void)
  98. {
  99. #ifdef SIC_IMASK0
  100. bfin_write_SIC_IMASK0(0);
  101. bfin_write_SIC_IMASK1(0);
  102. # ifdef SIC_IMASK2
  103. bfin_write_SIC_IMASK2(0);
  104. # endif
  105. #elif defined(SICA_IMASK0)
  106. bfin_write_SICA_IMASK0(0);
  107. bfin_write_SICA_IMASK1(0);
  108. #elif defined(SIC_IMASK)
  109. bfin_write_SIC_IMASK(0);
  110. #endif
  111. /* Set up a dummy NMI handler if needed. */
  112. if (CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_BYPASS || ANOMALY_05000219)
  113. bfin_write_EVT2(evt_nmi); /* NMI */
  114. bfin_write_EVT5(evt_default); /* hardware error */
  115. bfin_write_EVT6(evt_default); /* core timer */
  116. bfin_write_EVT7(evt_default);
  117. bfin_write_EVT8(evt_default);
  118. bfin_write_EVT9(evt_default);
  119. bfin_write_EVT10(evt_default);
  120. bfin_write_EVT11(evt_default);
  121. bfin_write_EVT12(evt_default);
  122. bfin_write_EVT13(evt_default);
  123. bfin_write_EVT14(evt_default);
  124. bfin_write_EVT15(evt_default);
  125. bfin_write_ILAT(0);
  126. CSYNC();
  127. /* enable hardware error irq */
  128. irq_flags = 0x3f;
  129. local_irq_enable();
  130. return 0;
  131. }