start.S 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * armboot - Startup Code for ARM1176 CPU-core
  3. *
  4. * Copyright (c) 2007 Samsung Electronics
  5. *
  6. * Copyright (C) 2008
  7. * Guennadi Liakhovetki, DENX Software Engineering, <lg@denx.de>
  8. *
  9. * SPDX-License-Identifier: GPL-2.0+
  10. *
  11. * 2007-09-21 - Restructured codes by jsgood (jsgood.yang@samsung.com)
  12. * 2007-09-21 - Added MoviNAND and OneNAND boot codes by
  13. * jsgood (jsgood.yang@samsung.com)
  14. * Base codes by scsuh (sc.suh)
  15. */
  16. #include <asm-offsets.h>
  17. #include <config.h>
  18. #include <linux/linkage.h>
  19. #ifndef CONFIG_SYS_PHY_UBOOT_BASE
  20. #define CONFIG_SYS_PHY_UBOOT_BASE CONFIG_SYS_UBOOT_BASE
  21. #endif
  22. /*
  23. *************************************************************************
  24. *
  25. * Startup Code (reset vector)
  26. *
  27. * do important init only if we don't start from memory!
  28. * setup Memory and board specific bits prior to relocation.
  29. * relocate armboot to ram
  30. * setup stack
  31. *
  32. *************************************************************************
  33. */
  34. .globl reset
  35. reset:
  36. /* Allow the board to save important registers */
  37. b save_boot_params
  38. .globl save_boot_params_ret
  39. save_boot_params_ret:
  40. /*
  41. * set the cpu to SVC32 mode
  42. */
  43. mrs r0, cpsr
  44. bic r0, r0, #0x3f
  45. orr r0, r0, #0xd3
  46. msr cpsr, r0
  47. /*
  48. *************************************************************************
  49. *
  50. * CPU_init_critical registers
  51. *
  52. * setup important registers
  53. * setup memory timing
  54. *
  55. *************************************************************************
  56. */
  57. /*
  58. * we do sys-critical inits only at reboot,
  59. * not when booting from ram!
  60. */
  61. cpu_init_crit:
  62. /*
  63. * When booting from NAND - it has definitely been a reset, so, no need
  64. * to flush caches and disable the MMU
  65. */
  66. #ifndef CONFIG_SPL_BUILD
  67. /*
  68. * flush v4 I/D caches
  69. */
  70. mov r0, #0
  71. mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */
  72. mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */
  73. /*
  74. * disable MMU stuff and caches
  75. */
  76. mrc p15, 0, r0, c1, c0, 0
  77. bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS)
  78. bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM)
  79. orr r0, r0, #0x00000002 @ set bit 1 (A) Align
  80. orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache
  81. /* Prepare to disable the MMU */
  82. adr r2, mmu_disable_phys
  83. sub r2, r2, #(CONFIG_SYS_PHY_UBOOT_BASE - CONFIG_SYS_TEXT_BASE)
  84. b mmu_disable
  85. .align 5
  86. /* Run in a single cache-line */
  87. mmu_disable:
  88. mcr p15, 0, r0, c1, c0, 0
  89. nop
  90. nop
  91. mov pc, r2
  92. mmu_disable_phys:
  93. #endif
  94. /*
  95. * Go setup Memory and board specific bits prior to relocation.
  96. */
  97. bl lowlevel_init /* go setup pll,mux,memory */
  98. bl _main
  99. /*------------------------------------------------------------------------------*/
  100. .globl c_runtime_cpu_setup
  101. c_runtime_cpu_setup:
  102. mov pc, lr
  103. WEAK(save_boot_params)
  104. b save_boot_params_ret /* back to my caller */
  105. ENDPROC(save_boot_params)