cpu.c 3.0 KB

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