cpu.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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/mpu.h>
  17. #include <asm/mach-common/bits/trace.h>
  18. #include "cpu.h"
  19. #include "serial.h"
  20. void icache_enable(void)
  21. {
  22. bfin_write_IMEM_CONTROL(bfin_read_IMEM_CONTROL() | (IMC | ENICPLB));
  23. SSYNC();
  24. }
  25. void icache_disable(void)
  26. {
  27. bfin_write_IMEM_CONTROL(bfin_read_IMEM_CONTROL() & ~(IMC | ENICPLB));
  28. SSYNC();
  29. }
  30. int icache_status(void)
  31. {
  32. return bfin_read_IMEM_CONTROL() & ENICPLB;
  33. }
  34. void dcache_enable(void)
  35. {
  36. bfin_write_DMEM_CONTROL(bfin_read_DMEM_CONTROL() | (ACACHE_BCACHE | ENDCPLB | PORT_PREF0));
  37. SSYNC();
  38. }
  39. void dcache_disable(void)
  40. {
  41. bfin_write_DMEM_CONTROL(bfin_read_DMEM_CONTROL() & ~(ACACHE_BCACHE | ENDCPLB | PORT_PREF0));
  42. SSYNC();
  43. }
  44. int dcache_status(void)
  45. {
  46. return bfin_read_DMEM_CONTROL() & ENDCPLB;
  47. }
  48. __attribute__ ((__noreturn__))
  49. void cpu_init_f(ulong bootflag, ulong loaded_from_ldr)
  50. {
  51. /* Build a NOP slide over the LDR jump block. Whee! */
  52. serial_early_puts("NOP Slide\n");
  53. char nops[0xC];
  54. memset(nops, 0x00, sizeof(nops));
  55. extern char _stext_l1;
  56. memcpy(&_stext_l1 - sizeof(nops), nops, sizeof(nops));
  57. if (!loaded_from_ldr) {
  58. /* Relocate sections into L1 if the LDR didn't do it -- don't
  59. * check length because the linker script does the size
  60. * checking at build time.
  61. */
  62. serial_early_puts("L1 Relocate\n");
  63. extern char _stext_l1, _etext_l1, _stext_l1_lma;
  64. memcpy(&_stext_l1, &_stext_l1_lma, (&_etext_l1 - &_stext_l1));
  65. extern char _sdata_l1, _edata_l1, _sdata_l1_lma;
  66. memcpy(&_sdata_l1, &_sdata_l1_lma, (&_edata_l1 - &_sdata_l1));
  67. }
  68. #if defined(__ADSPBF537__) || defined(__ADSPBF536__) || defined(__ADSPBF534__)
  69. /* The BF537 bootrom will reset the EBIU_AMGCTL register on us
  70. * after it has finished loading the LDR. So configure it again.
  71. */
  72. else
  73. bfin_write_EBIU_AMGCTL(CONFIG_EBIU_AMGCTL_VAL);
  74. #endif
  75. #ifdef CONFIG_DEBUG_DUMP
  76. /* Turn on hardware trace buffer */
  77. bfin_write_TBUFCTL(TBUFPWR | TBUFEN);
  78. #endif
  79. #ifndef CONFIG_PANIC_HANG
  80. /* Reset upon a double exception rather than just hanging.
  81. * Do not do bfin_read on SWRST as that will reset status bits.
  82. */
  83. bfin_write_SWRST(DOUBLE_FAULT);
  84. #endif
  85. serial_early_puts("Board init flash\n");
  86. board_init_f(bootflag);
  87. }
  88. int exception_init(void)
  89. {
  90. bfin_write_EVT3(trap);
  91. return 0;
  92. }
  93. int irq_init(void)
  94. {
  95. #ifdef SIC_IMASK0
  96. bfin_write_SIC_IMASK0(0);
  97. bfin_write_SIC_IMASK1(0);
  98. # ifdef SIC_IMASK2
  99. bfin_write_SIC_IMASK2(0);
  100. # endif
  101. #elif defined(SICA_IMASK0)
  102. bfin_write_SICA_IMASK0(0);
  103. bfin_write_SICA_IMASK1(0);
  104. #else
  105. bfin_write_SIC_IMASK(0);
  106. #endif
  107. bfin_write_EVT2(evt_default); /* NMI */
  108. bfin_write_EVT5(evt_default); /* hardware error */
  109. bfin_write_EVT6(evt_default); /* core timer */
  110. bfin_write_EVT7(evt_default);
  111. bfin_write_EVT8(evt_default);
  112. bfin_write_EVT9(evt_default);
  113. bfin_write_EVT10(evt_default);
  114. bfin_write_EVT11(evt_default);
  115. bfin_write_EVT12(evt_default);
  116. bfin_write_EVT13(evt_default);
  117. bfin_write_EVT14(evt_default);
  118. bfin_write_EVT15(evt_default);
  119. bfin_write_ILAT(0);
  120. CSYNC();
  121. /* enable all interrupts except for core timer */
  122. irq_flags = 0xffffffbf;
  123. local_irq_enable();
  124. CSYNC();
  125. return 0;
  126. }