glyn_tonga2.cfg 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. #
  3. # Glyn Tonga2 SO-DIMM CPU module (Toshiba TMPA900CMXBG, ARM9)
  4. #
  5. # http://toshiba-mikrocontroller.de/sites/TMPA900CPUBOARDStarter.htm
  6. #
  7. # Hardware on the S0-DIMM module:
  8. # - Toshiba TMPA900CMXBG (ARM9, ARM926EJ-S, max. 200MHz)
  9. # - DDR SDRAM: Hynix H5MS5162DFR-J3M (64Mbyte, x16, 1.8V, 166/83MHz at CL3/2)
  10. # - NAND flash: Samsung K9F2G08U0B-PIB0 (256M x 8 Bit, 3.3V)
  11. # - Ethernet: SMSC LAN9221I-ABZJ (10/100Mbit, Non-PCI, 16 bit interface)
  12. #
  13. source [find target/tmpa900.cfg]
  14. ########################
  15. # Target configuration #
  16. ########################
  17. # Initial JTAG speed should not exceed 1/6 of the initial CPU clock
  18. # frequency (24MHz). Be conservative and use 1/8 of the frequency.
  19. # (24MHz / 8 = 3MHz)
  20. adapter speed 3000
  21. $_TARGETNAME configure -event reset-start {
  22. # Upon reset, set the JTAG frequency to 3MHz again, see above.
  23. echo "Setting JTAG speed to 3MHz until clocks are initialized."
  24. adapter speed 3000
  25. # Halt the CPU.
  26. halt
  27. # Disable faster memory access for now.
  28. arm7_9 fast_memory_access disable
  29. }
  30. $_TARGETNAME configure -event reset-init {
  31. # Setup clocks, and initialize SRAM and DDR SDRAM.
  32. tonga2_init
  33. # At this point the CPU is running at 192MHz, increase JTAG speed.
  34. # Tests showed that 15MHz works OK, higher speeds can cause problems,
  35. # though. Not sure if this is a CPU issue or JTAG adapter issue.
  36. echo "Increasing JTAG speed to 15MHz."
  37. adapter speed 15000
  38. # Enable faster memory access.
  39. arm7_9 fast_memory_access enable
  40. }
  41. proc tonga2_init { } {
  42. ######################
  43. # PLL initialization #
  44. ######################
  45. # Clock overview (see datasheet chapter 3.5.2, page 57):
  46. # - fs: Low-frequency oscillator
  47. # - fOSCH: High-frequency oscillator (24MHz on this board)
  48. # - fPLL = fOSCH * multiplier (where multiplier can be 6 or 8)
  49. # - fFCLK = fPLL / gear (where gear can be 1/2/4/8)
  50. # - fHCLK is always fFCLK/2. fPCLK is also fFCLK/2.
  51. #
  52. # We select multiplier = 8 and gear = 1, so
  53. # fFCLK = fOSCH * 8 / 1 = 192MHz.
  54. # SYSCR3 (System Control Register 3): Disable and configure PLL.
  55. # - PLL operation control: off
  56. # - PLL constant value setting 1: always 0, as per datasheet
  57. # - PLL constant value setting 2: x8 (multiplier = 8)
  58. mww 0xf005000c 0x00000007
  59. # SYSCR4 (System Control Register 4): Configure PLL.
  60. # - PLL constant value setting 3: 140MHz or more
  61. # - PLL constant value setting 4: always 1, as per datasheet
  62. # - PLL constant value setting 5: 140MHz or more
  63. mww 0xf0050010 0x00000065
  64. # SYSCR3 (System Control Register 3): Enable PLL.
  65. # - PLL operation control: on
  66. # - All other bits remain set as above.
  67. mww 0xf005000c 0x00000087
  68. # Wait for PLL to stabilize.
  69. sleep 10
  70. # SYSCR2 (System Control Register 2): Switch from fOSCH to fPLL.
  71. # - Selection of the PLL output clock: fPLL
  72. mww 0xf0050008 0x00000002
  73. # SYSCR1 (System Control Register 1):
  74. # - Clock gear programming: fc/1 (i.e., gear = 1, don't divide).
  75. mww 0xf0050004 0x00000000
  76. # CLKCR5 (Clock Control Register 5): Set bits 3 and 6. The datasheet
  77. # says the bits are reserved, but also recommends "Write as one".
  78. mww 0xf0050054 0x00000048
  79. ##############################################################
  80. # Dynamic Memory Controller (DMC) / DDR SDRAM initialization #
  81. ##############################################################
  82. # PMC (Power Management Controller):
  83. # PMCDRV (External Port "Driverbility" control register):
  84. # Bits DRV_MEM0/DRV_MEM1 (memory relation port drive power):
  85. mww 0xf0020260 0x00000003 ;# Select 1.8V +/- 0.1V
  86. # Setup DDR SDRAM timing parameters for our specific chip.
  87. mww 0xf4310014 0x00000004 ;# cas_latency = 2
  88. mww 0xf4310018 0x00000001 ;# t_dqss = 1
  89. mww 0xf431001c 0x00000002 ;# t_mrd = 2
  90. mww 0xf4310020 0x0000000a ;# t_ras = 10
  91. mww 0xf4310024 0x0000000a ;# t_rc = 10
  92. mww 0xf4310028 0x00000013 ;# t_rcd = 3, schedule_rcd = 2
  93. mww 0xf431002c 0x0000010a ;# t_rfc = 10, schedule_rfc = 8
  94. mww 0xf4310030 0x00000013 ;# t_rp = 3, schedule_rp = 2
  95. mww 0xf4310034 0x00000002 ;# t_rrd = 2
  96. mww 0xf4310038 0x00000002 ;# t_wr = 2
  97. mww 0xf431003c 0x00000001 ;# t_wtr = 1
  98. mww 0xf4310040 0x0000000a ;# t_xp = 10
  99. mww 0xf4310044 0x0000000c ;# t_xsr = 12
  100. mww 0xf4310048 0x00000014 ;# t_esr = 20
  101. # dmc_memory_cfg_5 (DMC Memory Configuration register):
  102. # Set memory configuration:
  103. # column_bits = 10, row_bits = 13, ap-bit = 10, power_down_prd = 0,
  104. # auto_power_down = disable, stop_mem_clock = disable, memory_burst = 4
  105. mww 0xf431000c 0x00010012
  106. # dmc_user_config_5 (DMC user_config register):
  107. # Data bus width of DDR SDRAM: 16 bit
  108. mww 0xf4310304 0x00000058
  109. # dmc_refresh_prd_5 (DMC Refresh Period register):
  110. # Auto refresh: every 2656 (0xa60) DMCSCLK periods.
  111. mww 0xf4310010 0x00000a60
  112. # dmc_chip_0_cfg_5 (DMC chip_0_cfg registers):
  113. # - SDRAM address structure: bank, row, column
  114. # - address_match = 01000000 (start address [31:24])
  115. # - address_mask = 11111100 (start address [31:24] mask value)
  116. mww 0xf4310200 0x000140fc
  117. # Initialize the DDR SDRAM chip.
  118. # dmc_direct_cmd_5 (DMC Direct Command register).
  119. # See datasheet chapter 3.10.5.1, page 268.
  120. mww 0xf4310008 0x000c0000 ;# RAM init: NOP
  121. mww 0xf4310008 0x00000000 ;# RAM init: Precharge all
  122. mww 0xf4310008 0x00040000 ;# RAM init: Autorefresh
  123. mww 0xf4310008 0x00040000 ;# RAM init: Autorefresh
  124. mww 0xf4310008 0x00080032 ;# RAM init: addr_13_to_0 = 0x32
  125. mww 0xf4310008 0x000c0000 ;# RAM init: NOP
  126. mww 0xf4310008 0x000a0000 ;# RAM init: bank_addr = bank 2
  127. # dmc_id_<0-5>_cfg_5 (DMC id_<0-5>_cfg registers):
  128. # Set min./max. QoS values.
  129. # - 0x5: Enable QoS, max. QoS = 1
  130. # - 0xb: Enable QoS, min. QoS = 2
  131. mww 0xf4310100 0x00000005 ;# AHB0: CPU Data
  132. mww 0xf4310104 0x00000005 ;# AHB1: CPU Inst
  133. mww 0xf4310108 0x0000000b ;# AHB2: LCDC
  134. mww 0xf431010c 0x00000005 ;# AHB3: LCDDA, USB
  135. mww 0xf4310110 0x00000005 ;# AHB4: DMA1
  136. mww 0xf4310114 0x00000005 ;# AHB5: DMA2
  137. # dmc_memc_cmd_5 (DMC Memory Controller Command register):
  138. # Change DMC state to ready.
  139. mww 0xf4310004 0x00000000 ;# memc_cmd = "Go"
  140. # EBI: SMC Timeout register
  141. mww 0xf00a0050 0x00000001 ;# smc_timeout = 1
  142. ########################################################
  143. # Static Memory Controller (SMC) / SRAM initialization #
  144. ########################################################
  145. # smc_set_cycles_5 (SMC Set Cycles register):
  146. # tRC = 10, tWC = 10, tCEOE = 7, tWP = 5, tPC=2, tTR=2
  147. mww 0xf4311014 0x0004afaa
  148. # smc_set_opmode_5 (SMC Set Opmode register):
  149. # Memory data bus width = 16 bits, async read mode, read burst
  150. # length = 1 beat, async write mode, write burst length = 1 beat,
  151. # byte enable (SMCBE0-1) timing = SMCCSn timing, memory burst boundary
  152. # split setting = burst can cross any address boundary
  153. mww 0xf4311018 0x00000001
  154. # smc_direct_cmd_5 (SMC Direct Command register):
  155. # cmd_type = UpdateRegs, chip_select = CS1
  156. mww 0xf4311010 0x00c00000
  157. echo "Clocks, SRAM, and DDR SDRAM are now initialized."
  158. }
  159. #######################
  160. # Flash configuration #
  161. #######################
  162. # TODO: Implement NAND support.