sdram.S 3.0 KB

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