2 # http://focus.ti.com/docs/toolsw/folders/print/tmdsevm355.html
3 # http://c6000.spectrumdigital.com/evmdm355/
5 source [find target/ti_dm355.cfg]
7 reset_config trst_and_srst separate
9 # NOTE: disable or replace this call to dm355evm_init if you're
10 # debugging new UBL code from SRAM.
11 $_TARGETNAME configure -event reset-init { dm355evm_init }
14 # This post-reset init is called when the MMU isn't active, all IRQs
15 # are disabled, etc. It should do most of what a UBL does, except for
16 # loading code (like U-Boot) into DRAM and running it.
18 proc dm355evm_init {} {
21 echo "Initialize DM355 EVM board"
23 # CLKIN = 24 MHz ... can't talk quickly to ARM yet
26 ########################
27 # PLL1 = 432 MHz (/8, x144)
28 # ...SYSCLK1 = 216 MHz (/2) ... ARM, MJCP
29 # ...SYSCLK2 = 108 MHz (/4) ... Peripherals
30 # ...SYSCLK3 = 27 MHz (/16) ... VPBE, DAC
31 # ...SYSCLK4 = 108 MHz (/4) ... VPSS
32 # pll1.{prediv,div1,div2} are fixed
33 # pll1.postdiv set in MISC (for *this* speed grade)
35 set addr [dict get $dm355 pllc1]
36 set pll_divs [dict create]
37 dict set pll_divs div3 16
38 dict set pll_divs div4 4
39 pll_v02_setup $addr 144 $pll_divs
41 # ARM is now running at 216 MHz, so JTAG can go faster
44 ########################
45 # PLL2 = 342 MHz (/8, x114)
46 # ....SYSCLK1 = 342 MHz (/1) ... DDR PHY at 171 MHz, 2x clock
47 # pll2.{postdiv,div1} are fixed
49 set addr [dict get $dm355 pllc2]
50 set pll_divs [dict create]
51 dict set pll_divs div1 1
52 dict set pll_divs prediv 8
53 pll_v02_setup $addr 114 $pll_divs
55 ########################
59 davinci_pinmux $dm355 0 0x00007f55
61 davinci_pinmux $dm355 1 0x00145555
62 # EMIFA (NOTE: more could be set up for use as GPIOs)
63 davinci_pinmux $dm355 2 0x00000c08
64 # SPI0, SPI1, UART1, I2C, SD0, SD1, McBSP0, CLKOUTs
65 davinci_pinmux $dm355 3 0x1bff55ff
66 # MMC/SD0 instead of MS; SPI0
67 davinci_pinmux $dm355 4 0x00000000
69 ########################
72 # DDR EMIF/13, AEMIF/14, UART0/19
78 ########################
81 # VTPIOCR impedance calibration
82 set addr [dict get $dm355 sysbase]
83 set addr [expr $addr + 0x70]
85 # clear CLR, LOCK, PWRDN; wait a clock; set CLR
90 while { [expr [mrw $addr] & 0x8000] == 0 } { sleep 1 }
92 # set IO_READY; then LOCK and PWRSAVE; then PWRDN
97 # NOTE: this DDR2 initialization sequence borrows from
98 # both UBL 1.50 and the SPRUEH7D DDR2 EMIF spec.
100 # reset (then re-enable) DDR controller
106 # now set it up for Micron MT47H64M16HR-37E @ 171 MHz
108 set addr [dict get $dm355 ddr_emif]
111 mww [expr $addr + 0xe4] 0x50006404
113 # PBBPR -- burst priority
114 mww [expr $addr + 0x20] 0xfe
116 # SDCR -- unlock boot config; init for DDR2, relock, unlock SDTIM*
117 mmw [expr $addr + 0x08] 0x00800000 0
118 mmw [expr $addr + 0x08] 0x0013c632 0x03870fff
121 mww [expr $addr + 0x10] 0x2a923249
122 mww [expr $addr + 0x14] 0x4c17c763
124 # SDCR -- relock SDTIM*
125 mmw [expr $addr + 0x08] 0 0x00008000
127 # SDRCR -- refresh rate (171 MHz * 7.8usec)
128 mww [expr $addr + 0x0c] 1336
130 ########################
133 set addr [dict get $dm355 a_emif]
135 # slow/pessimistic timings
136 set nand_timings 0x40400204
137 # fast (25% faster page reads)
138 #set nand_timings 0x0400008c
141 mww [expr $addr + 0x04] 0xff
142 # CS0 == socketed NAND (default MT29F16G08FAA, 2GByte)
143 mww [expr $addr + 0x10] $nand_timings
144 # CS1 == dm9000 Ethernet
145 mww [expr $addr + 0x14] 0x00a00505
146 # NANDFCR -- only CS0 has NAND
147 mww [expr $addr + 0x60] 0x01
149 # default: both chipselects to the NAND socket are used
153 ########################
156 set addr [dict get $dm355 uart0]
158 # PWREMU_MGNT -- rx + tx in reset
159 mww [expr $addr + 0x30] 0
161 # DLL, DLH -- 115200 baud
162 mwb [expr $addr + 0x20] 0x0d
163 mwb [expr $addr + 0x24] 0x00
165 # FCR - clear and disable FIFOs
166 mwb [expr $addr + 0x08] 0x07
167 mwb [expr $addr + 0x08] 0x00
170 mwb [expr $addr + 0x04] 0x00
173 mwb [expr $addr + 0x0c] 0x03
175 # MCR - no flow control or loopback
176 mwb [expr $addr + 0x10] 0x00
178 # PWREMU_MGNT -- rx + tx normal, free running during JTAG halt
179 mww [expr $addr + 0x30] 0xe001
182 ########################
184 # turn on icache - set I bit in cp15 register c1
185 arm mcr 15 0 0 1 0 0x00051078
188 # NAND -- socket has two chipselects, MT29F16G08FAA puts 1GByte on each one.
190 # NOTE: "hwecc4" here presumes that if you're using the standard 2GB NAND
191 # you either (a) have 'new' DM355 chips, with boot ROMs that don't need to
192 # use "hwecc4_infix" for the UBL; or else (b) aren't updating anything that
193 # needs infix layout ... like an old UBL, old U-Boot, old MVL kernel, etc.
194 set _FLASHNAME $_CHIPNAME.boot
195 nand device $_FLASHNAME davinci $_TARGETNAME 0x02000000 hwecc4 0x01e10000
196 set _FLASHNAME $_CHIPNAME.flash
197 nand device $_FLASHNAME davinci $_TARGETNAME 0x02004000 hwecc4 0x01e10000
200 # - support writing UBL with its header (new layout only with new ROMs)
201 # - support writing ABL/U-Boot with its header (new layout)