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