6ab238c8815b4af5e55bb3e6ff8741e376912aeb
[fw/openocd] / tcl / target / atheros_ar9331.cfg
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.
4 #
5 # Notes:
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.
13 #
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
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
40
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
45
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
48 # to live.
49 adapter srst delay 8
50
51 if { [info exists CHIPNAME] } {
52         set _CHIPNAME $_CHIPNAME
53 } else {
54         set _CHIPNAME ar9331
55 }
56
57 jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x00000001
58
59 set _TARGETNAME $_CHIPNAME.cpu
60 target create $_TARGETNAME mips_m4k -endian big -chain-position $_TARGETNAME
61
62 # provide watchdog helper.
63 proc disable_watchdog { } {
64         mww 0xb8060008 0x0
65 }
66
67 $_TARGETNAME configure -event halted { disable_watchdog }
68
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 {
72         halt
73 }
74
75 $_TARGETNAME configure -event reset-assert {
76         catch "mww 0xb806001C 0x01000000"
77 }
78
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.
81 proc full_reset { } {
82         reset_config srst_only
83         reset
84         halt
85         reset_config none
86 }
87
88 proc disable_watchdog { } {
89         ;# disable watchdog
90         mww 0xb8060008 0x0
91 }
92
93 $_TARGETNAME configure -event reset-end { disable_watchdog }
94
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
102                                         ;# (disabled?)
103         mww 0xb8050000 0x00818000       ;# Power on | OUTDIV | REFDIV | DIV_INT
104         mww 0xb8050008 0x00008000       ;# remove bypass;
105                                         ;# AHB_POST_DIV - ratio 2
106 }
107
108 proc ar9331_ddr1_init {} {
109         mww 0xb8000000 0x7fbc8cd0       ;# DDR_CONFIG - lots of DRAM confs
110         mww 0xb8000004 0x9dd0e6a8       ;# DDR_CONFIG2 - more DRAM confs
111
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,
123                                 ;# DQ[7:0], DQS_0
124         mww 0xb8000020 0x9      ;# This register is used along with DQ Lane 1,
125                                 ;# DQ[15:8], DQS_1.
126         mww 0xb8000018 0xff     ;# DDR read and capture bit mask.
127                                 ;# Each bit represents a cycle of valid data.
128 }
129
130 proc ar9331_ddr2_init {} {
131         mww 0xb8000000 0x7fbc8cd0       ;# DDR_CONFIG - lots of DRAM confs
132         mww 0xb8000004 0x9dd0e6a8       ;# DDR_CONFIG2 - more DRAM confs
133
134         mww 0xb800008c 0x00000a59
135         mww 0xb8000010 0x00000008       ;# PRECHARGE ALL cycle
136
137         mww 0xb8000090 0x00000000
138         mww 0xb8000010 0x00000010       ;# EMR2S update cycle
139
140         mww 0xb8000094 0x00000000
141         mww 0xb8000010 0x00000020       ;# EMR3S update cycle
142
143         mww 0xb800000c 0x00000000
144         mww 0xb8000010 0x00000002       ;# EMRS update cycle
145
146         mww 0xb8000008 0x00000100
147         mww 0xb8000010 0x00000001       ;# MRS update cycle
148
149         mww 0xb8000010 0x00000008       ;# PRECHARGE ALL cycle
150
151         mww 0xb8000010 0x00000004
152         mww 0xb8000010 0x00000004       ;# AUTO REFRESH cycle
153
154         mww 0xb8000008 0x00000a33
155         mww 0xb8000010 0x00000001       ;# MRS update cycle
156
157         mww 0xb800000c 0x00000382
158         mww 0xb8000010 0x00000002       ;# EMRS update cycle
159
160         mww 0xb800000c 0x00000402
161         mww 0xb8000010 0x00000002       ;# EMRS update cycle
162
163         mww 0xb8000014 0x00004186       ;# DDR_REFRESH
164         mww 0xb800001c 0x00000008       ;# DDR_TAP_CTRL0
165         mww 0xb8000020 0x00000009       ;# DDR_TAP_CTRL1
166
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
171 }