lowlevel_init.S 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * Copyright (C) 2009, Emcraft Systems, Ilya Yanok <yanok@emcraft.com>
  3. *
  4. * Based on board/freescale/mx31ads/lowlevel_init.S
  5. * by Guennadi Liakhovetski.
  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 <asm/arch/mx31-regs.h>
  23. .macro REG reg, val
  24. ldr r2, =\reg
  25. ldr r3, =\val
  26. str r3, [r2]
  27. .endm
  28. .macro REG8 reg, val
  29. ldr r2, =\reg
  30. ldr r3, =\val
  31. strb r3, [r2]
  32. .endm
  33. .macro DELAY loops
  34. ldr r2, =\loops
  35. 1:
  36. subs r2, r2, #1
  37. nop
  38. bcs 1b
  39. .endm
  40. /* RedBoot: To support 133MHz DDR */
  41. .macro init_drive_strength
  42. /*
  43. * Disable maximum drive strength SDRAM/DDR lines by clearing DSE1 bits
  44. * in SW_PAD_CTL registers
  45. */
  46. /* SDCLK */
  47. ldr r1, =IOMUXC_SW_PAD_CTL(0x2b)
  48. ldr r0, [r1, #0x6C]
  49. bic r0, r0, #(1 << 12)
  50. str r0, [r1, #0x6C]
  51. /* CAS */
  52. ldr r0, [r1, #0x70]
  53. bic r0, r0, #(1 << 22)
  54. str r0, [r1, #0x70]
  55. /* RAS */
  56. ldr r0, [r1, #0x74]
  57. bic r0, r0, #(1 << 2)
  58. str r0, [r1, #0x74]
  59. /* CS2 (CSD0) */
  60. ldr r0, [r1, #0x7C]
  61. bic r0, r0, #(1 << 22)
  62. str r0, [r1, #0x7C]
  63. /* DQM3 */
  64. ldr r0, [r1, #0x84]
  65. bic r0, r0, #(1 << 22)
  66. str r0, [r1, #0x84]
  67. /* DQM2, DQM1, DQM0, SD31-SD0, A25-A0, MA10 (0x288..0x2DC) */
  68. ldr r2, =22 /* (0x2E0 - 0x288) / 4 = 22 */
  69. pad_loop:
  70. ldr r0, [r1, #0x88]
  71. bic r0, r0, #(1 << 22)
  72. bic r0, r0, #(1 << 12)
  73. bic r0, r0, #(1 << 2)
  74. str r0, [r1, #0x88]
  75. add r1, r1, #4
  76. subs r2, r2, #0x1
  77. bne pad_loop
  78. .endm /* init_drive_strength */
  79. .globl lowlevel_init
  80. lowlevel_init:
  81. init_drive_strength
  82. /* Image Processing Unit: */
  83. /* Too early to switch display on? */
  84. /* Switch on Display Interface */
  85. REG IPU_CONF, IPU_CONF_DI_EN
  86. /* Clock Control Module: */
  87. REG CCM_CCMR, 0x074B0BF5 /* Use CKIH, MCU PLL off */
  88. DELAY 0x40000
  89. REG CCM_CCMR, 0x074B0BF5 | CCMR_MPE /* MCU PLL on */
  90. /* Switch to MCU PLL */
  91. REG CCM_CCMR, (0x074B0BF5 | CCMR_MPE) & ~CCMR_MDS
  92. /* 399-133-66.5 */
  93. ldr r0, =CCM_BASE
  94. ldr r1, =0xFF871650
  95. /* PDR0 */
  96. str r1, [r0, #0x4]
  97. ldr r1, MPCTL_PARAM_399
  98. /* MPCTL */
  99. str r1, [r0, #0x10]
  100. /* Set UPLL=240MHz, USB=60MHz */
  101. ldr r1, =0x49FCFE7F
  102. /* PDR1 */
  103. str r1, [r0, #0x8]
  104. ldr r1, UPCTL_PARAM_240
  105. /* UPCTL */
  106. str r1, [r0, #0x14]
  107. /* default CLKO to 1/8 of the ARM core */
  108. mov r1, #0x00000208
  109. /* COSR */
  110. str r1, [r0, #0x1c]
  111. /* Default: 1, 4, 12, 1 */
  112. REG CCM_SPCTL, PLL_PD(1) | PLL_MFD(4) | PLL_MFI(12) | PLL_MFN(1)
  113. /* B8xxxxxx - NAND, 8xxxxxxx - CSD0 RAM */
  114. REG 0xB8001010, 0x00000004
  115. REG 0xB8001004, ((3 << 21) | /* tXP */ \
  116. (0 << 20) | /* tWTR */ \
  117. (2 << 18) | /* tRP */ \
  118. (1 << 16) | /* tMRD */ \
  119. (0 << 15) | /* tWR */ \
  120. (5 << 12) | /* tRAS */ \
  121. (1 << 10) | /* tRRD */ \
  122. (3 << 8) | /* tCAS */ \
  123. (2 << 4) | /* tRCD */ \
  124. (7 << 0) /* tRC */ )
  125. REG 0xB8001000, 0x92100000
  126. REG 0x80000f00, 0x12344321
  127. REG 0xB8001000, 0xa2100000
  128. REG 0x80000000, 0x12344321
  129. REG 0x80000000, 0x12344321
  130. REG 0xB8001000, 0xb2100000
  131. REG8 0x80000033, 0xda
  132. REG8 0x81000000, 0xff
  133. REG 0xB8001000, ((1 << 31) | \
  134. (0 << 28) | \
  135. (0 << 27) | \
  136. (3 << 24) | /* 14 rows */ \
  137. (2 << 20) | /* 10 cols */ \
  138. (2 << 16) | \
  139. (4 << 13) | /* 3.91us (64ms/16384) */ \
  140. (0 << 10) | \
  141. (0 << 8) | \
  142. (1 << 7) | \
  143. (0 << 0))
  144. REG 0x80000000, 0xDEADBEEF
  145. REG 0xB8001010, 0x0000000c
  146. mov pc, lr
  147. MPCTL_PARAM_399:
  148. .word (((1 - 1) << 26) + ((52 - 1) << 16) + (7 << 10) + (35 << 0))
  149. UPCTL_PARAM_240:
  150. .word (((2 - 1) << 26) + ((13 - 1) << 16) + (9 << 10) + (3 << 0))