lowlevel_init.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * (C) Copyright 2009 DENX Software Engineering
  3. * Author: John Rigby <jrigby@gmail.com>
  4. *
  5. * Based on U-Boot and RedBoot sources for several different i.mx
  6. * platforms.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <asm/macro.h>
  24. .macro init_aips
  25. write32 0x43f00000, 0x77777777
  26. write32 0x43f00004, 0x77777777
  27. write32 0x43f00000, 0x77777777
  28. write32 0x53f00004, 0x77777777
  29. .endm
  30. .macro init_max
  31. write32 0x43f04000, 0x43210
  32. write32 0x43f04100, 0x43210
  33. write32 0x43f04200, 0x43210
  34. write32 0x43f04300, 0x43210
  35. write32 0x43f04400, 0x43210
  36. write32 0x43f04010, 0x10
  37. write32 0x43f04110, 0x10
  38. write32 0x43f04210, 0x10
  39. write32 0x43f04310, 0x10
  40. write32 0x43f04410, 0x10
  41. write32 0x43f04800, 0x0
  42. write32 0x43f04900, 0x0
  43. write32 0x43f04a00, 0x0
  44. write32 0x43f04b00, 0x0
  45. write32 0x43f04c00, 0x0
  46. .endm
  47. .macro init_m3if
  48. write32 0xb8003000, 0x1
  49. .endm
  50. .macro init_clocks
  51. /*
  52. * clocks
  53. *
  54. * first enable CLKO debug output
  55. * 0x40000000 enables the debug CLKO signal
  56. * 0x05000000 sets CLKO divider to 6
  57. * 0x00600000 makes CLKO parent clk the USB clk
  58. */
  59. write32 0x53f80064, 0x45600000
  60. write32 0x53f80008, 0x20034000
  61. /*
  62. * PCDR2: NFC = 33.25 MHz
  63. * This is required for the NAND Flash of this board, which is a Samsung
  64. * K9F1G08U0B with 25-ns R/W cycle times, in order to make it work with
  65. * the NFC driver in symmetric (i.e. one-cycle) mode.
  66. */
  67. write32 0x53f80020, 0x01010103
  68. /*
  69. * enable all implemented clocks in all three
  70. * clock control registers
  71. */
  72. write32 0x53f8000c, 0x1fffffff
  73. write32 0x53f80010, 0xffffffff
  74. write32 0x53f80014, 0xfdfff
  75. .endm
  76. .macro init_ddrtype
  77. /*
  78. * ddr_type is 3.3v SDRAM
  79. */
  80. write32 0x43fac454, 0x800
  81. .endm
  82. /*
  83. * sdram controller init
  84. */
  85. .macro init_sdram_bank bankaddr, ctl, cfg
  86. ldr r0, =0xb8001000
  87. ldr r2, =\bankaddr
  88. /*
  89. * reset SDRAM controller
  90. * then wait for initialization to complete
  91. */
  92. ldr r1, =(1 << 1)
  93. str r1, [r0, #0x10]
  94. 1: ldr r3, [r0, #0x10]
  95. tst r3, #(1 << 31)
  96. beq 1b
  97. ldr r1, =0x95728
  98. str r1, [r0, #\cfg] /* config */
  99. ldr r1, =0x92116480 /* control | precharge */
  100. str r1, [r0, #\ctl] /* write command to controller */
  101. str r1, [r2, #0x400] /* command encoded in address */
  102. ldr r1, =0xa2116480 /* auto refresh */
  103. str r1, [r0, #\ctl]
  104. ldrb r3, [r2] /* read dram twice to auto refresh */
  105. ldrb r3, [r2]
  106. ldr r1, =0xb2116480 /* control | load mode */
  107. str r1, [r0, #\ctl] /* write command to controller */
  108. strb r1, [r2, #0x33] /* command encoded in address */
  109. ldr r1, =0x82116480 /* control | normal (0)*/
  110. str r1, [r0, #\ctl] /* write command to controller */
  111. .endm
  112. .globl lowlevel_init
  113. lowlevel_init:
  114. init_aips
  115. init_max
  116. init_m3if
  117. init_clocks
  118. init_sdram_bank 0x80000000, 0x0, 0x4
  119. init_sdram_bank 0x90000000, 0x8, 0xc
  120. mov pc, lr