cpu.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. #include "initcode.h"
  21. ulong bfin_poweron_retx;
  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. /*
  43. * Make sure our async settings are committed. Some bootroms
  44. * (like the BF537) will reset some registers on us after it
  45. * has finished loading the LDR. Or if we're booting over
  46. * JTAG, the initcode never got a chance to run. Or if we
  47. * aren't booting from parallel flash, the initcode skipped
  48. * this step completely.
  49. */
  50. program_async_controller(NULL);
  51. /* Save RETX so we can pass it while booting Linux */
  52. bfin_poweron_retx = bootflag;
  53. #ifdef CONFIG_DEBUG_DUMP
  54. /* Turn on hardware trace buffer */
  55. bfin_write_TBUFCTL(TBUFPWR | TBUFEN);
  56. #endif
  57. #ifndef CONFIG_PANIC_HANG
  58. /* Reset upon a double exception rather than just hanging.
  59. * Do not do bfin_read on SWRST as that will reset status bits.
  60. */
  61. # ifdef SWRST
  62. bfin_write_SWRST(DOUBLE_FAULT);
  63. # endif
  64. #endif
  65. serial_early_puts("Board init flash\n");
  66. board_init_f(bootflag);
  67. }
  68. int exception_init(void)
  69. {
  70. bfin_write_EVT3(trap);
  71. return 0;
  72. }
  73. int irq_init(void)
  74. {
  75. #ifdef SIC_IMASK0
  76. bfin_write_SIC_IMASK0(0);
  77. bfin_write_SIC_IMASK1(0);
  78. # ifdef SIC_IMASK2
  79. bfin_write_SIC_IMASK2(0);
  80. # endif
  81. #elif defined(SICA_IMASK0)
  82. bfin_write_SICA_IMASK0(0);
  83. bfin_write_SICA_IMASK1(0);
  84. #elif defined(SIC_IMASK)
  85. bfin_write_SIC_IMASK(0);
  86. #endif
  87. /* Set up a dummy NMI handler if needed. */
  88. if (CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_BYPASS || ANOMALY_05000219)
  89. bfin_write_EVT2(evt_nmi); /* NMI */
  90. bfin_write_EVT5(evt_default); /* hardware error */
  91. bfin_write_EVT6(evt_default); /* core timer */
  92. bfin_write_EVT7(evt_default);
  93. bfin_write_EVT8(evt_default);
  94. bfin_write_EVT9(evt_default);
  95. bfin_write_EVT10(evt_default);
  96. bfin_write_EVT11(evt_default);
  97. bfin_write_EVT12(evt_default);
  98. bfin_write_EVT13(evt_default);
  99. bfin_write_EVT14(evt_default);
  100. bfin_write_EVT15(evt_default);
  101. bfin_write_ILAT(0);
  102. CSYNC();
  103. /* enable hardware error irq */
  104. irq_flags = 0x3f;
  105. local_irq_enable();
  106. return 0;
  107. }