sbf_dram_init.S 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Board-specific sbf ddr/sdram init.
  4. *
  5. * (C) Copyright 2017 Angelo Dureghello <angelo@sysam.it>
  6. */
  7. #include <config.h>
  8. .global sbf_dram_init
  9. .text
  10. sbf_dram_init:
  11. /* Dram Initialization a1, a2, and d0 */
  12. /* mscr sdram */
  13. move.l #0xFC0A4074, %a1
  14. move.b #(CONFIG_SYS_SDRAM_DRV_STRENGTH), (%a1)
  15. nop
  16. /* SDRAM Chip 0 and 1 */
  17. move.l #0xFC0B8110, %a1
  18. move.l #0xFC0B8114, %a2
  19. /* calculate the size */
  20. move.l #0x13, %d1
  21. move.l #(CONFIG_SYS_SDRAM_SIZE), %d2
  22. #ifdef CONFIG_SYS_SDRAM_BASE1
  23. lsr.l #1, %d2
  24. #endif
  25. dramsz_loop:
  26. lsr.l #1, %d2
  27. add.l #1, %d1
  28. cmp.l #1, %d2
  29. bne dramsz_loop
  30. #ifdef CONFIG_SYS_NAND_BOOT
  31. beq asm_nand_chk_status
  32. #endif
  33. /* SDRAM Chip 0 and 1 */
  34. move.l #(CONFIG_SYS_SDRAM_BASE), (%a1)
  35. or.l %d1, (%a1)
  36. #ifdef CONFIG_SYS_SDRAM_BASE1
  37. move.l #(CONFIG_SYS_SDRAM_BASE1), (%a2)
  38. or.l %d1, (%a2)
  39. #endif
  40. nop
  41. /* dram cfg1 and cfg2 */
  42. move.l #0xFC0B8008, %a1
  43. move.l #(CONFIG_SYS_SDRAM_CFG1), (%a1)
  44. nop
  45. move.l #0xFC0B800C, %a2
  46. move.l #(CONFIG_SYS_SDRAM_CFG2), (%a2)
  47. nop
  48. move.l #0xFC0B8000, %a1 /* Mode */
  49. move.l #0xFC0B8004, %a2 /* Ctrl */
  50. /* Issue PALL */
  51. move.l #(CONFIG_SYS_SDRAM_CTRL + 2), (%a2)
  52. nop
  53. move.l #1000, %d1
  54. bsr asm_delay
  55. /* Issue PALL */
  56. move.l #(CONFIG_SYS_SDRAM_CTRL + 2), (%a2)
  57. nop
  58. /* Perform two refresh cycles */
  59. move.l #(CONFIG_SYS_SDRAM_CTRL + 4), %d0
  60. nop
  61. move.l %d0, (%a2)
  62. move.l %d0, (%a2)
  63. nop
  64. /* Issue LEMR */
  65. move.l #(CONFIG_SYS_SDRAM_MODE), (%a1)
  66. nop
  67. move.l #(CONFIG_SYS_SDRAM_EMOD), (%a1)
  68. move.l #500, %d1
  69. bsr asm_delay
  70. move.l #(CONFIG_SYS_SDRAM_CTRL), %d1
  71. and.l #0x7FFFFFFF, %d1
  72. or.l #0x10000C00, %d1
  73. move.l %d1, (%a2)
  74. nop
  75. move.l #2000, %d1
  76. bsr asm_delay
  77. rts