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