start.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 __ARC_UNALIGNED__
  55. /*
  56. * Enable handling of unaligned access in the CPU as by default
  57. * this HW feature is disabled while GCC starting from 8.1.0
  58. * unconditionally uses it for ARC HS cores.
  59. */
  60. flag 1 << STATUS_AD_BIT
  61. #endif
  62. /* Establish C runtime stack and frame */
  63. mov %sp, CONFIG_SYS_INIT_SP_ADDR
  64. mov %fp, %sp
  65. /* Allocate reserved area from current top of stack */
  66. mov %r0, %sp
  67. bl board_init_f_alloc_reserve
  68. /* Set stack below reserved area, adjust frame pointer accordingly */
  69. mov %sp, %r0
  70. mov %fp, %sp
  71. /* Initialize reserved area - note: r0 already contains address */
  72. bl board_init_f_init_reserve
  73. #ifdef CONFIG_DEBUG_UART
  74. /* Earliest point to set up early debug uart */
  75. bl debug_uart_init
  76. #endif
  77. /* Zero the one and only argument of "board_init_f" */
  78. mov_s %r0, 0
  79. bl board_init_f
  80. /* We only get here if relocation is disabled by GD_FLG_SKIP_RELOC */
  81. /* Make sure we don't lose GD overwritten by zero new GD */
  82. mov %r0, %r25
  83. mov %r1, 0
  84. bl board_init_r
  85. ENDPROC(_start)
  86. /*
  87. * void board_init_f_r_trampoline(stack-pointer address)
  88. *
  89. * This "function" does not return, instead it continues in RAM
  90. * after relocating the monitor code.
  91. *
  92. * r0 = new stack-pointer
  93. */
  94. ENTRY(board_init_f_r_trampoline)
  95. /* Set up the stack- and frame-pointers */
  96. mov %sp, %r0
  97. mov %fp, %sp
  98. /* Update position of intterupt vector table */
  99. lr %r0, [ARC_AUX_INTR_VEC_BASE]
  100. ld %r1, [%r25, GD_RELOC_OFF]
  101. add %r0, %r0, %r1
  102. sr %r0, [ARC_AUX_INTR_VEC_BASE]
  103. /* Re-enter U-Boot by calling board_init_f_r */
  104. j board_init_f_r
  105. ENDPROC(board_init_f_r_trampoline)