lowlevel_init.S 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * (C) Copyright 2006 Embedded Artists AB <www.embeddedartists.com>
  3. *
  4. * Slight modifications made to support the SMN42 board from Siemens.
  5. * 2007 Gary Jennejohn garyj@denx.de
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <config.h>
  23. #include <version.h>
  24. #include <asm/arch/hardware.h>
  25. /* some parameters for the board */
  26. /* setting up the CPU-internal memory */
  27. #define SRAM_START 0x40000000
  28. #define SRAM_SIZE 0x00004000
  29. #define BCFG0_VALUE 0x1000ffef
  30. #define BCFG1_VALUE 0x10005D2F
  31. #define BCFG2_VALUE 0x10005D2F
  32. /*
  33. * For P0.18 to set ZZ to the SRAMs to 1. Also set P0.2 (SCL) and P0.3 (SDA)
  34. * for the bit-banger I2C driver correctly.
  35. */
  36. #define IO0_VALUE 0x4000C
  37. _TEXT_BASE:
  38. .word TEXT_BASE
  39. MEMMAP_ADR:
  40. .word MEMMAP
  41. BCFG0_ADR:
  42. .word BCFG0
  43. _BCFG0_VALUE:
  44. .word BCFG0_VALUE
  45. BCFG1_ADR:
  46. .word BCFG1
  47. _BCFG1_VALUE:
  48. .word BCFG1_VALUE
  49. BCFG2_ADR:
  50. .word BCFG2
  51. _BCFG2_VALUE:
  52. .word BCFG2_VALUE
  53. IO0DIR_ADR:
  54. .word IO0DIR
  55. _IO0DIR_VALUE:
  56. .word IO0_VALUE
  57. IO0SET_ADR:
  58. .word IO0SET
  59. _IO0SET_VALUE:
  60. .word IO0_VALUE
  61. PINSEL2_ADR:
  62. .word PINSEL2
  63. PINSEL2_MASK:
  64. .word 0x00000000
  65. PINSEL2_VALUE:
  66. .word 0x0F804914
  67. .extern _start
  68. .globl lowlevel_init
  69. lowlevel_init:
  70. /* set up memory control register for bank 0 */
  71. ldr r0, _BCFG0_VALUE
  72. ldr r1, BCFG0_ADR
  73. str r0, [r1]
  74. /* set up memory control register for bank 1 */
  75. ldr r0, _BCFG1_VALUE
  76. ldr r1, BCFG1_ADR
  77. str r0, [r1]
  78. /* set up memory control register for bank 2 */
  79. ldr r0, _BCFG2_VALUE
  80. ldr r1, BCFG2_ADR
  81. str r0, [r1]
  82. /* set IO0DIR to make P0.2, P0.3 and P0.18 outputs */
  83. ldr r0, _IO0DIR_VALUE
  84. ldr r1, IO0DIR_ADR
  85. str r0, [r1]
  86. /* set P0.18 to 1 */
  87. ldr r0, _IO0SET_VALUE
  88. ldr r1, IO0SET_ADR
  89. str r0, [r1]
  90. /* set up PINSEL2 for bus-pins */
  91. ldr r0, PINSEL2_ADR
  92. ldr r1, [r0]
  93. ldr r2, PINSEL2_MASK
  94. ldr r3, PINSEL2_VALUE
  95. and r1, r1, r2
  96. orr r1, r1, r3
  97. str r1, [r0]
  98. /* move vectors to beginning of SRAM */
  99. mov r2, #SRAM_START
  100. mov r0, #0 /*_start*/
  101. ldmneia r0!, {r3-r10}
  102. stmneia r2!, {r3-r10}
  103. ldmneia r0, {r3-r9}
  104. stmneia r2, {r3-r9}
  105. /* Set-up MEMMAP register, so vectors are taken from SRAM */
  106. ldr r0, MEMMAP_ADR
  107. mov r1, #0x02 /* vectors re-mapped to static RAM */
  108. str r1, [r0]
  109. /* everything is fine now */
  110. mov pc, lr