cpu.c 2.7 KB

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