1 # The Atheros AR9331 is a highly integrated and cost effective
2 # IEEE 802.11n 1x1 2.4 GHz System- on-a-Chip (SoC) for wireless
3 # local area network (WLAN) AP and router platforms.
6 # - MIPS Processor ID (PRId): 0x00019374
7 # - 24Kc MIPS processor with 64 KB I-Cache and 32 KB D-Cache,
8 # operating at up to 400 MHz
9 # - External 16-bit DDR1, DDR2, or SDRAM memory interface
10 # - TRST is not available.
11 # - EJTAG PrRst signal is not supported
12 # - RESET_L pin A72 on the SoC will reset internal JTAG logic.
15 # Pins related for debug and bootstrap:
16 # Name Pin Description
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
23 # RESET_L -, (A72) Input only
24 # SYS_RST_L ???????? Output reset request or GPIO
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
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
34 # UART0_SOUT GPIO10, (A79)
35 # UART0_SIN GPIO9, (B68)
37 # Per default we need to use "none" variant to be able properly "reset init"
38 # or "reset halt" the CPU.
39 reset_config none srst_pulls_trst
41 # For SRST based variant we still need proper timings.
42 # For ETH part the reset should be asserted at least for 10ms
43 # Since there is no other information let's take 100ms to be sure.
44 adapter srst pulse_width 100
46 # according to the SoC documentation it should take at least 5ms from
47 # reset end till bootstrap end. In the practice we need 8ms to get JTAG back
51 if { [info exists CHIPNAME] } {
52 set _CHIPNAME $_CHIPNAME
57 jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x00000001
59 set _TARGETNAME $_CHIPNAME.cpu
60 target create $_TARGETNAME mips_m4k -endian big -chain-position $_TARGETNAME
62 # provide watchdog helper.
63 proc disable_watchdog { } {
67 $_TARGETNAME configure -event halted { disable_watchdog }
69 # Since PrRst is not supported and SRST will reset complete chip
70 # with JTAG engine, we need to reset CPU from CPU itself.
71 $_TARGETNAME configure -event reset-assert-pre {
75 $_TARGETNAME configure -event reset-assert {
76 catch "mww 0xb806001C 0x01000000"
79 # To be able to trigger complete chip reset, in case JTAG is blocked
80 # or CPU not responding, we still can use this helper.
82 reset_config srst_only
88 proc disable_watchdog { } {
93 $_TARGETNAME configure -event reset-end { disable_watchdog }
95 # Section with helpers which can be used by boards
96 proc ar9331_25mhz_pll_init {} {
97 mww 0xb8050008 0x00018004 ;# bypass PLL; AHB_POST_DIV - ratio 4
98 mww 0xb8050004 0x00000352 ;# 34000(ns)/40ns(25MHz) = 0x352 (850)
99 mww 0xb8050000 0x40818000 ;# Power down control for CPU PLL
100 ;# OUTDIV | REFDIV | DIV_INT
101 mww 0xb8050010 0x001003e8 ;# CPU PLL Dither FRAC Register
103 mww 0xb8050000 0x00818000 ;# Power on | OUTDIV | REFDIV | DIV_INT
104 mww 0xb8050008 0x00008000 ;# remove bypass;
105 ;# AHB_POST_DIV - ratio 2
108 proc ar9331_ddr1_init {} {
109 mww 0xb8000000 0x7fbc8cd0 ;# DDR_CONFIG - lots of DRAM confs
110 mww 0xb8000004 0x9dd0e6a8 ;# DDR_CONFIG2 - more DRAM confs
112 mww 0xb8000010 0x8 ;# Forces a PRECHARGE ALL cycle
113 mww 0xb8000008 0x133 ;# mode reg: 0x133 - default
114 mww 0xb8000010 0x1 ;# Forces an MRS update cycl
115 mww 0xb800000c 0x2 ;# Extended mode register value.
116 ;# default 0x2 - Reset to weak driver, DLL on
117 mww 0xb8000010 0x2 ;# Forces an EMRS update cycle
118 mww 0xb8000010 0x8 ;# Forces a PRECHARGE ALL cycle
119 mww 0xb8000008 0x33 ;# mode reg: remove some bit?
120 mww 0xb8000010 0x1 ;# Forces an MRS update cycl
121 mww 0xb8000014 0x4186 ;# enable refres: bit(14) - set refresh rate
122 mww 0xb800001c 0x8 ;# This register is used along with DQ Lane 0,
124 mww 0xb8000020 0x9 ;# This register is used along with DQ Lane 1,
126 mww 0xb8000018 0xff ;# DDR read and capture bit mask.
127 ;# Each bit represents a cycle of valid data.
130 proc ar9331_ddr2_init {} {
131 mww 0xb8000000 0x7fbc8cd0 ;# DDR_CONFIG - lots of DRAM confs
132 mww 0xb8000004 0x9dd0e6a8 ;# DDR_CONFIG2 - more DRAM confs
134 mww 0xb800008c 0x00000a59
135 mww 0xb8000010 0x00000008 ;# PRECHARGE ALL cycle
137 mww 0xb8000090 0x00000000
138 mww 0xb8000010 0x00000010 ;# EMR2S update cycle
140 mww 0xb8000094 0x00000000
141 mww 0xb8000010 0x00000020 ;# EMR3S update cycle
143 mww 0xb800000c 0x00000000
144 mww 0xb8000010 0x00000002 ;# EMRS update cycle
146 mww 0xb8000008 0x00000100
147 mww 0xb8000010 0x00000001 ;# MRS update cycle
149 mww 0xb8000010 0x00000008 ;# PRECHARGE ALL cycle
151 mww 0xb8000010 0x00000004
152 mww 0xb8000010 0x00000004 ;# AUTO REFRESH cycle
154 mww 0xb8000008 0x00000a33
155 mww 0xb8000010 0x00000001 ;# MRS update cycle
157 mww 0xb800000c 0x00000382
158 mww 0xb8000010 0x00000002 ;# EMRS update cycle
160 mww 0xb800000c 0x00000402
161 mww 0xb8000010 0x00000002 ;# EMRS update cycle
163 mww 0xb8000014 0x00004186 ;# DDR_REFRESH
164 mww 0xb800001c 0x00000008 ;# DDR_TAP_CTRL0
165 mww 0xb8000020 0x00000009 ;# DDR_TAP_CTRL1
167 ;# DDR read and capture bit mask.
168 ;# Each bit represents a cycle of valid data.
169 ;# 0xff: use 16-bit DDR
170 mww 0xb8000018 0x000000ff