cpu.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 "cpu.h"
  19. #include "serial.h"
  20. ulong bfin_poweron_retx;
  21. __attribute__ ((__noreturn__))
  22. void cpu_init_f(ulong bootflag, ulong loaded_from_ldr)
  23. {
  24. extern char _stext_l1;
  25. #ifndef CONFIG_BFIN_BOOTROM_USES_EVT1
  26. /* Build a NOP slide over the LDR jump block. Whee! */
  27. char nops[0xC];
  28. serial_early_puts("NOP Slide\n");
  29. memset(nops, 0x00, sizeof(nops));
  30. memcpy(&_stext_l1 - sizeof(nops), nops, sizeof(nops));
  31. #endif
  32. if (!loaded_from_ldr) {
  33. /* Relocate sections into L1 if the LDR didn't do it -- don't
  34. * check length because the linker script does the size
  35. * checking at build time.
  36. */
  37. serial_early_puts("L1 Relocate\n");
  38. extern char _stext_l1, _etext_l1, _stext_l1_lma;
  39. memcpy(&_stext_l1, &_stext_l1_lma, (&_etext_l1 - &_stext_l1));
  40. extern char _sdata_l1, _edata_l1, _sdata_l1_lma;
  41. memcpy(&_sdata_l1, &_sdata_l1_lma, (&_edata_l1 - &_sdata_l1));
  42. }
  43. #if defined(__ADSPBF537__) || defined(__ADSPBF536__) || defined(__ADSPBF534__)
  44. /* The BF537 bootrom will reset the EBIU_AMGCTL register on us
  45. * after it has finished loading the LDR. So configure it again.
  46. */
  47. else
  48. bfin_write_EBIU_AMGCTL(CONFIG_EBIU_AMGCTL_VAL);
  49. #endif
  50. /* Save RETX so we can pass it while booting Linux */
  51. bfin_poweron_retx = bootflag;
  52. #ifdef CONFIG_DEBUG_DUMP
  53. /* Turn on hardware trace buffer */
  54. bfin_write_TBUFCTL(TBUFPWR | TBUFEN);
  55. #endif
  56. #ifndef CONFIG_PANIC_HANG
  57. /* Reset upon a double exception rather than just hanging.
  58. * Do not do bfin_read on SWRST as that will reset status bits.
  59. */
  60. bfin_write_SWRST(DOUBLE_FAULT);
  61. #endif
  62. serial_early_puts("Board init flash\n");
  63. board_init_f(bootflag);
  64. }
  65. int exception_init(void)
  66. {
  67. bfin_write_EVT3(trap);
  68. return 0;
  69. }
  70. int irq_init(void)
  71. {
  72. #ifdef SIC_IMASK0
  73. bfin_write_SIC_IMASK0(0);
  74. bfin_write_SIC_IMASK1(0);
  75. # ifdef SIC_IMASK2
  76. bfin_write_SIC_IMASK2(0);
  77. # endif
  78. #elif defined(SICA_IMASK0)
  79. bfin_write_SICA_IMASK0(0);
  80. bfin_write_SICA_IMASK1(0);
  81. #else
  82. bfin_write_SIC_IMASK(0);
  83. #endif
  84. bfin_write_EVT2(evt_default); /* NMI */
  85. bfin_write_EVT5(evt_default); /* hardware error */
  86. bfin_write_EVT6(evt_default); /* core timer */
  87. bfin_write_EVT7(evt_default);
  88. bfin_write_EVT8(evt_default);
  89. bfin_write_EVT9(evt_default);
  90. bfin_write_EVT10(evt_default);
  91. bfin_write_EVT11(evt_default);
  92. bfin_write_EVT12(evt_default);
  93. bfin_write_EVT13(evt_default);
  94. bfin_write_EVT14(evt_default);
  95. bfin_write_EVT15(evt_default);
  96. bfin_write_ILAT(0);
  97. CSYNC();
  98. /* enable hardware error irq */
  99. irq_flags = 0x3f;
  100. local_irq_enable();
  101. return 0;
  102. }