tcl/board: add SPDX tag
[fw/openocd] / tcl / board / dm365evm.cfg
1 # SPDX-License-Identifier: GPL-2.0-or-later
2
3 # DM365 EVM board -- Beta
4 #   http://focus.ti.com/docs/toolsw/folders/print/tmdxevm365.html
5 #   http://support.spectrumdigital.com/boards/evmdm365
6
7 source [find target/ti_dm365.cfg]
8
9 # NOTE:  in Rev C boards, the CPLD ignores SRST from the ARM-20 JTAG
10 # connector, so it doesn't affect generation of the reset signal.
11 # Accordingly, resets require something else.  ICEpick could do it;
12 # but its docs aren't generally available.
13 #
14 # At this writing, newer boards aren't available ... so assume no SRST.
15 # Also ICEpick docs aren't available ... so we must use watchdog reset,
16 # and hope the CPU isn't wedged or in a WFI loop (either of which can
17 # block access to CPU and thus watchdog registers).
18
19 reset_config trst_only
20 $_TARGETNAME configure -event reset-assert "davinci_wdog_reset"
21
22 # SW5.1 routes CS0: NAND vs OneNAND.
23 # SW4.6:4 controls AEMIF width (8 for NAND, 16 for OneNand)
24 # for boot-from-flash, those must agree with SW4.3:1 settings.
25
26 if { [info exists CS0MODE] } {
27         # NAND or OneNAND
28         set CS0 $CS0MODE
29 } else {
30         set CS0 ""
31         echo "WARNING:  CS0 configuration not known"
32         proc cs0_setup {a_emif} {}
33         proc flashprobe {} {}
34 }
35
36 set a_emif [dict get $dm365 a_emif]
37
38 # As shipped:  boot from NAND.
39 if { $CS0 == "NAND" } {
40         echo "CS0 NAND"
41
42         # NAND socket has two chipselects.  Default MT29F16G08FAA chip
43         # has 1GByte on each one.
44         # NOTE:  "hwecc4" here presumes that you're not updating anything
45         # that needs infix layout (e.g. UBL, old U-Boot, etc)
46         nand device low davinci $_TARGETNAME 0x02000000 hwecc4 $a_emif
47         nand device high davinci $_TARGETNAME 0x02004000 hwecc4 $a_emif
48
49         proc cs0_setup {a_emif} {
50                 global dm365
51
52                 # 8 bit EMIF
53                 davinci_pinmux $dm365 2 0x00000016
54
55                 # slow/pessimistic timings
56                 set nand_timings 0x40400204
57                 # fast (25% faster page reads)
58                 #set nand_timings 0x0400008c
59
60                 # CS0 == socketed NAND (default MT29F16G08FAA, 2 GBytes)
61                 mww [expr {$a_emif + 0x10}] $nand_timings
62
63                 # NANDFCR -- CS0 has NAND
64                 mww [expr {$a_emif + 0x60}] 0x01
65         }
66         proc flashprobe {} {
67                 nand probe 0
68                 nand probe 1
69         }
70
71 } elseif { $CS0 == "OneNAND" } {
72         echo "CS0 OneNAND"
73
74         # No support for this OneNAND in OpenOCD (yet) or Linux ...
75         # REVISIT OneNAND timings not verified to work!
76         echo "WARNING -- OneNAND not yet tested!"
77
78         proc cs0_setup {a_emif} {
79                 global dm365
80
81                 # 16 bit EMIF
82                 davinci_pinmux $dm365 2 0x00000055
83
84                 # CS0 == OneNAND (KFG1G16U2B-DIB6, 128 KBytes)
85                 mww [expr {$a_emif + 0x10}] 0x00000001
86
87                 # ONENANDCTRL -- CS0 has OneNAND, enable sync reads
88                 mww [expr {$a_emif + 0x5c}] 0x0441
89         }
90         proc flashprobe {} { }
91 }
92
93 # NOTE:  disable or replace this call to dm365evm_init if you're
94 # debugging new UBL/NANDboot code from SRAM.
95 $_TARGETNAME configure -event reset-init { dm365evm_init }
96
97 #
98 # This post-reset init is called when the MMU isn't active, all IRQs
99 # are disabled, etc.  It should do most of what a UBL does, except for
100 # loading code (like U-Boot) into DRAM and running it.
101 #
102 proc dm365evm_init {} {
103         global dm365
104
105         echo "Initialize DM365 EVM board"
106
107         # CLKIN = 24 MHz ... can't talk quickly to ARM yet
108         adapter speed 1500
109
110         # FIXME -- PLL init
111
112         ########################
113         # PINMUX setup
114
115         davinci_pinmux $dm365 0 0x00fd0000
116         davinci_pinmux $dm365 1 0x00145555
117         # mux2 controls AEMIF ... 8 bit for NAND, 16 for OneNand
118         davinci_pinmux $dm365 3 0x375affff
119         davinci_pinmux $dm365 4 0x55556555
120
121         ########################
122         # PSC setup (minimal)
123
124         # DDR EMIF/13, AEMIF/14, UART0/19
125         psc_enable 13
126         psc_enable 14
127         psc_enable 19
128         psc_go
129
130         # FIXME setup DDR2 (needs PLL)
131
132         ########################
133         # ASYNC EMIF
134
135         set a_emif [dict get $dm365 a_emif]
136
137         # AWCCR
138         mww [expr {$a_emif + 0x04}] 0xff
139         # CS0 == NAND or OneNAND
140         cs0_setup $a_emif
141         # CS1 == CPLD
142         mww [expr {$a_emif + 0x14}] 0x00a00505
143
144         # FIXME setup UART0
145
146         flashprobe
147 }