tcl/board: add SPDX tag
[fw/openocd] / tcl / board / kindle2.cfg
1 # SPDX-License-Identifier: GPL-2.0-or-later
2
3 # Board configuration file for Amazon Kindle Model No. D00701 and D00801
4 # AKA Kindle 2nd generation and Kindle DX
5 # using a Freescale MCIMX31LDVKN5D i.MX31 processor
6 #
7 # Pins at J9 40-Pin FFC-A:
8 #  1 - GND
9 # 16 - TRSTB
10 # 17 - TDI
11 # 18 - TMS
12 # 19 - TCK
13 # 20 - RTCK
14 # 21 - TDO
15 # 22 - DE
16 # 25 - BOOT_MODE4
17 # 27 - BOOT_MODE2
18
19 source [find target/imx31.cfg]
20 source [find target/imx.cfg]
21
22 $_TARGETNAME configure -event reset-init { kindle2_init }
23 $_TARGETNAME configure -event reset-start { adapter speed 1000 }
24
25 # 8MiB NOR Flash
26 set _FLASHNAME $_CHIPNAME.flash
27 flash bank $_FLASHNAME cfi 0xa0000000 0x800000 2 2 $_TARGETNAME
28
29 # 16kiB internal SRAM
30 $_TARGETNAME configure -work-area-phys 0x1fffc000 \
31         -work-area-size 0x4000 -work-area-backup 0
32
33 # FIXME: currently SRST is not wired to the system
34 reset_config trst_only
35 jtag_ntrst_assert_width 10
36 jtag_ntrst_delay 30
37
38 # this is broken but enabled by default
39 arm11 memwrite burst disable
40
41 adapter speed 1000
42 ftdi tdo_sample_edge falling
43
44 proc kindle2_init {} {
45         imx3x_reset
46         kindle2_clock_setup
47         disable_mmu_and_cache
48         kindle2_misc_init
49         kindle2_sdram_init
50         arm core_state arm
51 }
52
53 proc kindle2_clock_setup {} {
54         # CCMR: clock from FPM/CKIL
55         mww 0x53f80000  0x074b0b7b
56         # IPU_CONF
57         mww 0x53fc0000  0x040
58         # 398MHz
59         mww 0x53f80004 0xff871650
60         mww 0x53f80010 0x00331c23
61 }
62
63 proc kindle2_misc_init { } {
64         # AIPS1
65         mww 0x43f00040 0x0
66         mww 0x43f00044 0x0
67         mww 0x43f00048 0x0
68         mww 0x43f0004c 0x0
69         mww 0x43f00050 0x0
70         mww 0x43f00000 0x77777777
71         mww 0x43f00004 0x77777777
72
73         # AIPS2
74         mww 0x53f00040 0x0
75         mww 0x53f00044 0x0
76         mww 0x53f00048 0x0
77         mww 0x53f0004c 0x0
78         mww 0x53f00050 0x0
79         mww 0x53f00000 0x77777777
80         mww 0x53f00004 0x77777777
81
82         # Start 16 bit NorFlash Initialization on CS0
83         mww 0xb8002000 0x0000cc03
84         mww 0xb8002004 0xa0330d01
85         mww 0xb8002008 0x00220800
86 }
87
88 proc disable_mmu_and_cache {} {
89         # Mode Supervisor, disable FIQ, IRQ and imprecise data aborts
90         reg cpsr 0x1d3
91
92         # flush entire BTAC
93         arm mcr 15 0 7 5 6 0
94         # invalidate instruction and data cache
95         # MCR CP15, 0, R1, C7, C7, 0
96         arm mcr 15 0 7 7 0
97
98         # clean and invalidate cache
99         arm mcr 15 0 7 15 0
100
101         # disable MMU and caches
102         arm mcr 15 0 1 0 0 0
103
104         arm mcr 15 0 15 2 4 0
105
106         # invalidate TLBs
107         arm mcr 15 0 8 7 0 0
108
109         # Drain the write buffer
110         arm mcr 15 0 7 10 4 0
111
112         # start from AIPS 2GB region
113         arm mcr 15 0 15 2 4 0x40000015
114 }
115
116 proc kindle2_sdram_init {} {
117         #--------------------------------------------
118         # Samsung K4X1G323PC-8GC3 32Mx32 Mobile DDR SDRAM
119         #--------------------------------------------
120         # SDCLK
121         mww 0x43fac26c 0
122
123         # CAS
124         mww 0x43fac270 0
125
126         # RAS
127         mww 0x43fac274 0
128
129         # CS2 (CSD0)
130         mww 0x43fac27c 0x1000
131
132         # DQM3
133         mww 0x43fac284 0
134
135         # DQM2, DQM1, DQM0, SD31-SD0, A25-A0, MA10 (0x288..0x2dc)
136         mww 0x43fac288 0
137         mww 0x43fac28c 0
138         mww 0x43fac290 0
139         mww 0x43fac294 0
140         mww 0x43fac298 0
141         mww 0x43fac29c 0
142         mww 0x43fac2a0 0
143         mww 0x43fac2a4 0
144         mww 0x43fac2a8 0
145         mww 0x43fac2ac 0
146         mww 0x43fac2b0 0
147         mww 0x43fac2b4 0
148         mww 0x43fac2b8 0
149         mww 0x43fac2bc 0
150         mww 0x43fac2c0 0
151         mww 0x43fac2c4 0
152         mww 0x43fac2c8 0
153         mww 0x43fac2cc 0
154         mww 0x43fac2d0 0
155         mww 0x43fac2d4 0
156         mww 0x43fac2d8 0
157         mww 0x43fac2dc 0
158
159         # ?
160         mww 0xb8002000 0x00006602
161         mww 0xb8002004 0x00000501
162         mww 0xb8002008 0x00000000
163
164         # LPDDR1 Initialization script
165         mww 0xb8001010 0x00000002
166         mww 0xb8001010 0x00000004
167         # ESDCFG0: set timing parameters
168         mww 0xb8001004 0x007fff7f
169         # ESDCTL0: select Prechare-All mode
170         mww 0xb8001000 0x92100000
171         mww 0x80000f00 0x12344321
172         # ESDCTL0: Auto Refresh
173         mww 0xb8001000 0xa2100000
174         mww 0x80000000 0x12344321
175         mww 0x80000000 0x12344321
176         # ESDCTL0: Load Mode Register
177         mww 0xb8001000 0xb2100000
178         mwb 0x80000033 0xda
179         mwb 0x81000000 0xff
180         # ESDCTL0: enable Auto-Refresh
181         mww 0xb8001000 0x82226080
182         mww 0x80000000 0xdeadbeef
183 }