start.S 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
  4. */
  5. #include <asm-offsets.h>
  6. #include <config.h>
  7. #include <linux/linkage.h>
  8. #include <asm/arcregs.h>
  9. ENTRY(_start)
  10. /* Setup interrupt vector base that matches "__text_start" */
  11. sr __ivt_start, [ARC_AUX_INTR_VEC_BASE]
  12. ; Disable/enable I-cache according to configuration
  13. lr r5, [ARC_BCR_IC_BUILD]
  14. breq r5, 0, 1f ; I$ doesn't exist
  15. lr r5, [ARC_AUX_IC_CTRL]
  16. #if !CONFIG_IS_ENABLED(SYS_ICACHE_OFF)
  17. bclr r5, r5, 0 ; 0 - Enable, 1 is Disable
  18. #else
  19. bset r5, r5, 0 ; I$ exists, but is not used
  20. #endif
  21. sr r5, [ARC_AUX_IC_CTRL]
  22. mov r5, 1
  23. sr r5, [ARC_AUX_IC_IVIC]
  24. ; As per ARC HS databook (see chapter 5.3.3.2)
  25. ; it is required to add 3 NOPs after each write to IC_IVIC.
  26. nop
  27. nop
  28. nop
  29. 1:
  30. ; Disable/enable D-cache according to configuration
  31. lr r5, [ARC_BCR_DC_BUILD]
  32. breq r5, 0, 1f ; D$ doesn't exist
  33. lr r5, [ARC_AUX_DC_CTRL]
  34. bclr r5, r5, 6 ; Invalidate (discard w/o wback)
  35. #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
  36. bclr r5, r5, 0 ; Enable (+Inv)
  37. #else
  38. bset r5, r5, 0 ; Disable (+Inv)
  39. #endif
  40. sr r5, [ARC_AUX_DC_CTRL]
  41. mov r5, 1
  42. sr r5, [ARC_AUX_DC_IVDC]
  43. 1:
  44. #ifdef CONFIG_ISA_ARCV2
  45. ; Disable System-Level Cache (SLC)
  46. lr r5, [ARC_BCR_SLC]
  47. breq r5, 0, 1f ; SLC doesn't exist
  48. lr r5, [ARC_AUX_SLC_CTRL]
  49. bclr r5, r5, 6 ; Invalidate (discard w/o wback)
  50. bclr r5, r5, 0 ; Enable (+Inv)
  51. sr r5, [ARC_AUX_SLC_CTRL]
  52. 1:
  53. #endif
  54. #ifdef CONFIG_ISA_ARCV2
  55. ; In case of DSP extension presence in HW some instructions
  56. ; (related to integer multiply, multiply-accumulate, and divide
  57. ; operation) executes on this DSP execution unit. So their
  58. ; execution will depend on dsp configuration register (DSP_CTRL)
  59. ; As we want these instructions to execute the same way regardless
  60. ; of DSP presence we need to set DSP_CTRL properly.
  61. lr r5, [ARC_AUX_DSP_BUILD]
  62. bmsk r5, r5, 7
  63. breq r5, 0, 1f
  64. mov r5, 0
  65. sr r5, [ARC_AUX_DSP_CTRL]
  66. 1:
  67. #endif
  68. #ifdef __ARC_UNALIGNED__
  69. /*
  70. * Enable handling of unaligned access in the CPU as by default
  71. * this HW feature is disabled while GCC starting from 8.1.0
  72. * unconditionally uses it for ARC HS cores.
  73. */
  74. flag 1 << STATUS_AD_BIT
  75. #endif
  76. /* Establish C runtime stack and frame */
  77. mov %sp, CONFIG_SYS_INIT_SP_ADDR
  78. mov %fp, %sp
  79. /* Allocate reserved area from current top of stack */
  80. mov %r0, %sp
  81. bl board_init_f_alloc_reserve
  82. /* Set stack below reserved area, adjust frame pointer accordingly */
  83. mov %sp, %r0
  84. mov %fp, %sp
  85. /* Initialize reserved area - note: r0 already contains address */
  86. bl board_init_f_init_reserve
  87. #ifdef CONFIG_DEBUG_UART
  88. /* Earliest point to set up early debug uart */
  89. bl debug_uart_init
  90. #endif
  91. /* Zero the one and only argument of "board_init_f" */
  92. mov_s %r0, 0
  93. bl board_init_f
  94. /* We only get here if relocation is disabled by GD_FLG_SKIP_RELOC */
  95. /* Make sure we don't lose GD overwritten by zero new GD */
  96. mov %r0, %r25
  97. mov %r1, 0
  98. bl board_init_r
  99. ENDPROC(_start)
  100. /*
  101. * void board_init_f_r_trampoline(stack-pointer address)
  102. *
  103. * This "function" does not return, instead it continues in RAM
  104. * after relocating the monitor code.
  105. *
  106. * r0 = new stack-pointer
  107. */
  108. ENTRY(board_init_f_r_trampoline)
  109. /* Set up the stack- and frame-pointers */
  110. mov %sp, %r0
  111. mov %fp, %sp
  112. /* Update position of intterupt vector table */
  113. lr %r0, [ARC_AUX_INTR_VEC_BASE]
  114. ld %r1, [%r25, GD_RELOC_OFF]
  115. add %r0, %r0, %r1
  116. sr %r0, [ARC_AUX_INTR_VEC_BASE]
  117. /* Re-enter U-Boot by calling board_init_f_r */
  118. j board_init_f_r
  119. ENDPROC(board_init_f_r_trampoline)