lowlevel_init.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * (C) Copyright 2011
  3. * Matthias Weisser <weisserm@arcor.de>
  4. *
  5. * (C) Copyright 2009 DENX Software Engineering
  6. * Author: John Rigby <jrigby@gmail.com>
  7. *
  8. * Based on U-Boot and RedBoot sources for several different i.mx
  9. * platforms.
  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 in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <asm/macro.h>
  27. #include <asm/arch/macro.h>
  28. #include <asm/arch/imx-regs.h>
  29. #include <generated/asm-offsets.h>
  30. /*
  31. * clocks
  32. */
  33. .macro init_clocks
  34. /* disable clock output */
  35. write32 IMX_CCM_BASE + CCM_MCR, 0x00000000
  36. write32 IMX_CCM_BASE + CCM_CCTL, 0x50030000
  37. /*
  38. * enable all implemented clocks in all three
  39. * clock control registers
  40. */
  41. write32 IMX_CCM_BASE + CCM_CGCR0, 0x1fffffff
  42. write32 IMX_CCM_BASE + CCM_CGCR1, 0xffffffff
  43. write32 IMX_CCM_BASE + CCM_CGCR2, 0xfffff
  44. /* Devide NAND clock by 32 */
  45. write32 IMX_CCM_BASE + CCM_PCDR2, 0x0101011F
  46. .endm
  47. /*
  48. * sdram controller init
  49. */
  50. .macro init_lpddr
  51. ldr r0, =IMX_ESDRAMC_BASE
  52. ldr r2, =IMX_SDRAM_BANK0_BASE
  53. /*
  54. * reset SDRAM controller
  55. * then wait for initialization to complete
  56. */
  57. ldr r1, =(1 << 1) | (1 << 2)
  58. str r1, [r0, #ESDRAMC_ESDMISC]
  59. 1: ldr r3, [r0, #ESDRAMC_ESDMISC]
  60. tst r3, #(1 << 31)
  61. beq 1b
  62. ldr r1, =(1 << 2)
  63. str r1, [r0, #ESDRAMC_ESDMISC]
  64. ldr r1, =0x002a7420
  65. str r1, [r0, #ESDRAMC_ESDCFG0]
  66. /* control | precharge */
  67. ldr r1, =0x92216008
  68. str r1, [r0, #ESDRAMC_ESDCTL0]
  69. /* dram command encoded in address */
  70. str r1, [r2, #0x400]
  71. /* auto refresh */
  72. ldr r1, =0xa2216008
  73. str r1, [r0, #ESDRAMC_ESDCTL0]
  74. /* read dram twice to auto refresh */
  75. ldr r3, [r2]
  76. ldr r3, [r2]
  77. /* control | load mode */
  78. ldr r1, =0xb2216008
  79. str r1, [r0, #ESDRAMC_ESDCTL0]
  80. /* mode register of lpddram */
  81. strb r1, [r2, #0x33]
  82. /* extended mode register of lpddrram */
  83. ldr r2, =0x81000000
  84. strb r1, [r2]
  85. /* control | normal */
  86. ldr r1, =0x82216008
  87. str r1, [r0, #ESDRAMC_ESDCTL0]
  88. .endm
  89. .globl lowlevel_init
  90. lowlevel_init:
  91. init_aips
  92. init_max
  93. init_clocks
  94. init_lpddr
  95. mov pc, lr