atheros_ar9331.cfg 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. # The Atheros AR9331 is a highly integrated and cost effective
  3. # IEEE 802.11n 1x1 2.4 GHz System- on-a-Chip (SoC) for wireless
  4. # local area network (WLAN) AP and router platforms.
  5. #
  6. # Notes:
  7. # - MIPS Processor ID (PRId): 0x00019374
  8. # - 24Kc MIPS processor with 64 KB I-Cache and 32 KB D-Cache,
  9. # operating at up to 400 MHz
  10. # - External 16-bit DDR1, DDR2, or SDRAM memory interface
  11. # - TRST is not available.
  12. # - EJTAG PrRst signal is not supported
  13. # - RESET_L pin A72 on the SoC will reset internal JTAG logic.
  14. #
  15. # Pins related for debug and bootstrap:
  16. # Name Pin Description
  17. # JTAG
  18. # JTAG_TCK GPIO0, (A27) Software configurable, default JTAG
  19. # JTAG_TDI GPIO6, (B46) Software configurable, default JTAG
  20. # JTAG_TDO GPIO7, (A54) Software configurable, default JTAG
  21. # JTAG_TMS GPIO8, (A52) Software configurable, default JTAG
  22. # Reset
  23. # RESET_L -, (A72) Input only
  24. # SYS_RST_L ???????? Output reset request or GPIO
  25. # Bootstrap
  26. # MEM_TYPE[1] GPIO28, (A74) 0 - SDRAM, 1 - DDR1 RAM, 2 - DDR2 RAM
  27. # MEM_TYPE[0] GPIO12, (A56)
  28. # FW_DOWNLOAD GPIO16, (A75) Used if BOOT_FROM_SPI = 0. 0 - boot from USB
  29. # 1 - boot from MDIO.
  30. # JTAG_MODE(JS) GPIO11, (B48) 0 - JTAG (Default); 1 - EJTAG
  31. # BOOT_FROM_SPI GPIO1, (A77) 0 - ROM boot; 1 - SPI boot
  32. # SEL_25M_40M GPIO0, (A78) 0 - 25MHz; 1 - 40MHz
  33. # UART
  34. # UART0_SOUT GPIO10, (A79)
  35. # UART0_SIN GPIO9, (B68)
  36. # Per default we need to use "none" variant to be able properly "reset init"
  37. # or "reset halt" the CPU.
  38. reset_config none srst_pulls_trst
  39. # For SRST based variant we still need proper timings.
  40. # For ETH part the reset should be asserted at least for 10ms
  41. # Since there is no other information let's take 100ms to be sure.
  42. adapter srst pulse_width 100
  43. # according to the SoC documentation it should take at least 5ms from
  44. # reset end till bootstrap end. In the practice we need 8ms to get JTAG back
  45. # to live.
  46. adapter srst delay 8
  47. if { [info exists CHIPNAME] } {
  48. set _CHIPNAME $_CHIPNAME
  49. } else {
  50. set _CHIPNAME ar9331
  51. }
  52. jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x00000001
  53. set _TARGETNAME $_CHIPNAME.cpu
  54. target create $_TARGETNAME mips_m4k -endian big -chain-position $_TARGETNAME
  55. # provide watchdog helper.
  56. proc disable_watchdog { } {
  57. mww 0xb8060008 0x0
  58. }
  59. $_TARGETNAME configure -event halted { disable_watchdog }
  60. # Since PrRst is not supported and SRST will reset complete chip
  61. # with JTAG engine, we need to reset CPU from CPU itself.
  62. $_TARGETNAME configure -event reset-assert-pre {
  63. halt
  64. }
  65. $_TARGETNAME configure -event reset-assert {
  66. catch "mww 0xb806001C 0x01000000"
  67. }
  68. # To be able to trigger complete chip reset, in case JTAG is blocked
  69. # or CPU not responding, we still can use this helper.
  70. proc full_reset { } {
  71. reset_config srst_only
  72. reset
  73. halt
  74. reset_config none
  75. }
  76. proc disable_watchdog { } {
  77. ;# disable watchdog
  78. mww 0xb8060008 0x0
  79. }
  80. $_TARGETNAME configure -event reset-end { disable_watchdog }
  81. # Section with helpers which can be used by boards
  82. proc ar9331_25mhz_pll_init {} {
  83. mww 0xb8050008 0x00018004 ;# bypass PLL; AHB_POST_DIV - ratio 4
  84. mww 0xb8050004 0x00000352 ;# 34000(ns)/40ns(25MHz) = 0x352 (850)
  85. mww 0xb8050000 0x40818000 ;# Power down control for CPU PLL
  86. ;# OUTDIV | REFDIV | DIV_INT
  87. mww 0xb8050010 0x001003e8 ;# CPU PLL Dither FRAC Register
  88. ;# (disabled?)
  89. mww 0xb8050000 0x00818000 ;# Power on | OUTDIV | REFDIV | DIV_INT
  90. mww 0xb8050008 0x00008000 ;# remove bypass;
  91. ;# AHB_POST_DIV - ratio 2
  92. }
  93. proc ar9331_ddr1_init {} {
  94. mww 0xb8000000 0x7fbc8cd0 ;# DDR_CONFIG - lots of DRAM confs
  95. mww 0xb8000004 0x9dd0e6a8 ;# DDR_CONFIG2 - more DRAM confs
  96. mww 0xb8000010 0x8 ;# Forces a PRECHARGE ALL cycle
  97. mww 0xb8000008 0x133 ;# mode reg: 0x133 - default
  98. mww 0xb8000010 0x1 ;# Forces an MRS update cycl
  99. mww 0xb800000c 0x2 ;# Extended mode register value.
  100. ;# default 0x2 - Reset to weak driver, DLL on
  101. mww 0xb8000010 0x2 ;# Forces an EMRS update cycle
  102. mww 0xb8000010 0x8 ;# Forces a PRECHARGE ALL cycle
  103. mww 0xb8000008 0x33 ;# mode reg: remove some bit?
  104. mww 0xb8000010 0x1 ;# Forces an MRS update cycl
  105. mww 0xb8000014 0x4186 ;# enable refres: bit(14) - set refresh rate
  106. mww 0xb800001c 0x8 ;# This register is used along with DQ Lane 0,
  107. ;# DQ[7:0], DQS_0
  108. mww 0xb8000020 0x9 ;# This register is used along with DQ Lane 1,
  109. ;# DQ[15:8], DQS_1.
  110. mww 0xb8000018 0xff ;# DDR read and capture bit mask.
  111. ;# Each bit represents a cycle of valid data.
  112. }
  113. proc ar9331_ddr2_init {} {
  114. mww 0xb8000000 0x7fbc8cd0 ;# DDR_CONFIG - lots of DRAM confs
  115. mww 0xb8000004 0x9dd0e6a8 ;# DDR_CONFIG2 - more DRAM confs
  116. mww 0xb800008c 0x00000a59
  117. mww 0xb8000010 0x00000008 ;# PRECHARGE ALL cycle
  118. mww 0xb8000090 0x00000000
  119. mww 0xb8000010 0x00000010 ;# EMR2S update cycle
  120. mww 0xb8000094 0x00000000
  121. mww 0xb8000010 0x00000020 ;# EMR3S update cycle
  122. mww 0xb800000c 0x00000000
  123. mww 0xb8000010 0x00000002 ;# EMRS update cycle
  124. mww 0xb8000008 0x00000100
  125. mww 0xb8000010 0x00000001 ;# MRS update cycle
  126. mww 0xb8000010 0x00000008 ;# PRECHARGE ALL cycle
  127. mww 0xb8000010 0x00000004
  128. mww 0xb8000010 0x00000004 ;# AUTO REFRESH cycle
  129. mww 0xb8000008 0x00000a33
  130. mww 0xb8000010 0x00000001 ;# MRS update cycle
  131. mww 0xb800000c 0x00000382
  132. mww 0xb8000010 0x00000002 ;# EMRS update cycle
  133. mww 0xb800000c 0x00000402
  134. mww 0xb8000010 0x00000002 ;# EMRS update cycle
  135. mww 0xb8000014 0x00004186 ;# DDR_REFRESH
  136. mww 0xb800001c 0x00000008 ;# DDR_TAP_CTRL0
  137. mww 0xb8000020 0x00000009 ;# DDR_TAP_CTRL1
  138. ;# DDR read and capture bit mask.
  139. ;# Each bit represents a cycle of valid data.
  140. ;# 0xff: use 16-bit DDR
  141. mww 0xb8000018 0x000000ff
  142. }