lowlevel_init.S 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * lowlevel_init.S
  3. *
  4. * AM33XX low level initialization.
  5. *
  6. * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
  7. *
  8. * Initial Code by:
  9. * Mansoor Ahamed <mansoor.ahamed@ti.com>
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  17. * kind, whether express or implied; without even the implied warranty
  18. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. */
  21. #include <config.h>
  22. #include <asm/arch/hardware.h>
  23. _mark1:
  24. .word mark1
  25. _lowlevel_init1:
  26. .word lowlevel_init
  27. _s_init_start:
  28. .word s_init_start
  29. _TEXT_BASE:
  30. .word CONFIG_SYS_TEXT_BASE /* sdram load addr from config.mk */
  31. /*****************************************************************************
  32. * lowlevel_init: - Platform low level init.
  33. ****************************************************************************/
  34. .globl lowlevel_init
  35. lowlevel_init:
  36. /* The link register is saved in ip by start.S */
  37. mov r6, ip
  38. /* check if we are already running from RAM */
  39. ldr r2, _lowlevel_init1
  40. ldr r3, _TEXT_BASE
  41. sub r4, r2, r3
  42. sub r0, pc, r4
  43. ldr sp, SRAM_STACK
  44. mark1:
  45. ldr r5, _mark1
  46. sub r5, r5, r2 /* bytes between mark1 and lowlevel_init */
  47. sub r0, r0, r5 /* r0 <- _start w.r.t current place of execution */
  48. mov r10, #0x0 /* r10 has in_ddr used by s_init() */
  49. ands r0, r0, #0xC0000000
  50. /* MSB 2 bits <> 0 then we are in ocmc or DDR */
  51. cmp r0, #0x80000000
  52. bne s_init_start
  53. mov r10, #0x01
  54. b s_init_start
  55. s_init_start:
  56. mov r0, r10 /* passing in_ddr in r0 */
  57. bl s_init
  58. /* back to arch calling code */
  59. mov pc, r6
  60. /* the literal pools origin */
  61. .ltorg
  62. SRAM_STACK:
  63. /* Place stack at the top */
  64. .word LOW_LEVEL_SRAM_STACK