sdram.S 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * MS7724SE sdram self/auto-refresh setup code
  3. *
  4. * Copyright (C) 2009 Magnus Damm
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/sys.h>
  11. #include <linux/errno.h>
  12. #include <linux/linkage.h>
  13. #include <asm/asm-offsets.h>
  14. #include <asm/suspend.h>
  15. #include <asm/romimage-macros.h>
  16. /* code to enter and leave self-refresh. must be self-contained.
  17. * this code will be copied to on-chip memory and executed from there.
  18. */
  19. .balign 4
  20. ENTRY(ms7724se_sdram_enter_start)
  21. /* DBSC: put memory in self-refresh mode */
  22. ED 0xFD000010, 0x00000000 /* DBEN */
  23. ED 0xFD000040, 0x00000000 /* DBRFPDN0 */
  24. ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */
  25. ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */
  26. ED 0xFD000040, 0x00000001 /* DBRFPDN0 */
  27. rts
  28. nop
  29. ENTRY(ms7724se_sdram_enter_end)
  30. .balign 4
  31. ENTRY(ms7724se_sdram_leave_start)
  32. /* DBSC: put memory in auto-refresh mode */
  33. mov.l @(SH_SLEEP_MODE, r5), r0
  34. tst #SUSP_SH_RSTANDBY, r0
  35. bf resume_rstandby
  36. ED 0xFD000040, 0x00000000 /* DBRFPDN0 */
  37. WAIT 1
  38. ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */
  39. ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */
  40. ED 0xFD000010, 0x00000001 /* DBEN */
  41. ED 0xFD000040, 0x00010000 /* DBRFPDN0 */
  42. rts
  43. nop
  44. resume_rstandby:
  45. /* CPG: setup clocks before restarting external memory */
  46. ED 0xA4150024, 0x00004000 /* PLLCR */
  47. mov.l FRQCRA,r0
  48. mov.l @r0,r3
  49. mov.l KICK,r1
  50. or r1, r3
  51. mov.l r3, @r0
  52. mov.l LSTATS,r0
  53. mov #1,r1
  54. WAIT_LSTATS:
  55. mov.l @r0,r3
  56. tst r1,r3
  57. bf WAIT_LSTATS
  58. /* DBSC: re-initialize and put in auto-refresh */
  59. ED 0xFD000108, 0x00000181 /* DBPDCNT0 */
  60. ED 0xFD000020, 0x015B0002 /* DBCONF */
  61. ED 0xFD000030, 0x03071502 /* DBTR0 */
  62. ED 0xFD000034, 0x02020102 /* DBTR1 */
  63. ED 0xFD000038, 0x01090405 /* DBTR2 */
  64. ED 0xFD00003C, 0x00000002 /* DBTR3 */
  65. ED 0xFD000008, 0x00000005 /* DBKIND */
  66. ED 0xFD000040, 0x00000001 /* DBRFPDN0 */
  67. ED 0xFD000040, 0x00000000 /* DBRFPDN0 */
  68. ED 0xFD000018, 0x00000001 /* DBCKECNT */
  69. mov #100,r0
  70. WAIT_400NS:
  71. dt r0
  72. bf WAIT_400NS
  73. ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */
  74. ED 0xFD000060, 0x00020000 /* DBMRCNT (EMR2) */
  75. ED 0xFD000060, 0x00030000 /* DBMRCNT (EMR3) */
  76. ED 0xFD000060, 0x00010004 /* DBMRCNT (EMR) */
  77. ED 0xFD000060, 0x00000532 /* DBMRCNT (MRS) */
  78. ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */
  79. ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */
  80. ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */
  81. ED 0xFD000060, 0x00000432 /* DBMRCNT (MRS) */
  82. ED 0xFD000060, 0x000103c0 /* DBMRCNT (EMR) */
  83. ED 0xFD000060, 0x00010040 /* DBMRCNT (EMR) */
  84. mov #100,r0
  85. WAIT_400NS_2:
  86. dt r0
  87. bf WAIT_400NS_2
  88. ED 0xFD000010, 0x00000001 /* DBEN */
  89. ED 0xFD000044, 0x0000050f /* DBRFPDN1 */
  90. ED 0xFD000048, 0x236800e6 /* DBRFPDN2 */
  91. mov.l DUMMY,r0
  92. mov.l @r0, r1 /* force single dummy read */
  93. ED 0xFD000014, 0x00000002 /* DBCMDCNT (PALL) */
  94. ED 0xFD000014, 0x00000004 /* DBCMDCNT (REF) */
  95. ED 0xFD000108, 0x00000080 /* DBPDCNT0 */
  96. ED 0xFD000040, 0x00010000 /* DBRFPDN0 */
  97. rts
  98. nop
  99. .balign 4
  100. DUMMY: .long 0xac400000
  101. FRQCRA: .long 0xa4150000
  102. KICK: .long 0x80000000
  103. LSTATS: .long 0xa4150060
  104. ENTRY(ms7724se_sdram_leave_end)