2022-06-12 16:42:27 -05:00
# SPDX-License-Identifier: GPL-2.0-or-later
2009-09-10 03:06:22 -05:00
2020-04-25 18:25:32 -05:00
# board(-config) specific parameters file.
2009-09-10 03:06:22 -05:00
# set CFG_REFCLKFREQ [configC100 CFG_REFCLKFREQ]
proc config { label } {
2009-09-30 18:02:15 -05:00
return [ dict get [ configC100 ] $label ]
2009-09-10 03:06:22 -05:00
}
# show the value for the param. with label
proc showconfig { label } {
2010-11-08 03:23:49 -06:00
echo [ format " 0 x % x " [ dict get [ configC100 ] $label ] ]
2009-09-10 03:06:22 -05:00
}
# Telo board config
# when there are more then one board config
# use soft links to c100board-config.tcl
# so that only the right board-config gets
2009-09-30 18:02:15 -05:00
# included (just like include/configs/board-configs.h
2009-09-10 03:06:22 -05:00
# in u-boot.
proc configC100 { } {
# xtal freq. 24MHz
dict set configC100 CFG_REFCLKFREQ 24000000
# Amba Clk 165MHz
dict set configC100 CONFIG_SYS_HZ_CLOCK 165000000
dict set configC100 w_amba 1
dict set configC100 x_amba 1
# y = amba_clk * (w+1)*(x+1)*2/xtal_clk
2021-04-10 11:28:52 -05:00
dict set configC100 y_amba [ expr { [ dict get $configC100 CONFIG_SYS_HZ_CLOCK] * ( ( [ dict get $configC100 w_amba] + 1 ) * ( [ dict get $configC100 x_amba] + 1 ) * 2 ) / [ dict get $configC100 CFG_REFCLKFREQ] } ]
2009-09-10 03:06:22 -05:00
2009-09-30 18:02:15 -05:00
# Arm Clk 450MHz, must be a multiple of 25 MHz
2009-09-10 03:06:22 -05:00
dict set configC100 CFG_ARM_CLOCK 450000000
dict set configC100 w_arm 0
dict set configC100 x_arm 1
# y = arm_clk * (w+1)*(x+1)*2/xtal_clk
2021-04-10 11:28:52 -05:00
dict set configC100 y_arm [ expr { [ dict get $configC100 CFG_ARM_CLOCK] * ( ( [ dict get $configC100 w_arm] + 1 ) * ( [ dict get $configC100 x_arm] + 1 ) * 2 ) / [ dict get $configC100 CFG_REFCLKFREQ] } ]
2009-09-10 03:06:22 -05:00
}
2009-09-30 00:37:32 -05:00
# This should be called for reset init event handler
proc setupTelo { } {
# setup GPIO used as control signals for C100
setupGPIO
2021-01-28 05:27:53 -06:00
# This will allow access to lower 8MB or NOR
2009-09-30 18:02:15 -05:00
lowGPIO5
2009-09-30 00:37:32 -05:00
# setup NOR size,timing,etc.
setupNOR
# setup internals + PLL + DDR2
initC100
}
2009-09-10 03:06:22 -05:00
proc setupNOR { } {
2010-11-08 03:23:49 -06:00
echo " S e t t i n g u p N O R : 1 6 M B , 1 6 - b i t w i d e b u s , C S 0 "
2009-09-10 03:06:22 -05:00
# this is taken from u-boot/boards/mindspeed/ooma-darwin/board.c:nor_hw_init()
2009-09-30 18:02:15 -05:00
set EX_CSEN_REG [ regs EX_CSEN_REG ]
set EX_CS0_SEG_REG [ regs EX_CS0_SEG_REG ]
set EX_CS0_CFG_REG [ regs EX_CS0_CFG_REG ]
set EX_CS0_TMG1_REG [ regs EX_CS0_TMG1_REG ]
set EX_CS0_TMG2_REG [ regs EX_CS0_TMG2_REG ]
set EX_CS0_TMG3_REG [ regs EX_CS0_TMG3_REG ]
2009-09-10 03:06:22 -05:00
set EX_CLOCK_DIV_REG [ regs EX_CLOCK_DIV_REG ]
2009-09-30 18:02:15 -05:00
set EX_MFSM_REG [ regs EX_MFSM_REG ]
set EX_CSFSM_REG [ regs EX_CSFSM_REG ]
set EX_WRFSM_REG [ regs EX_WRFSM_REG ]
set EX_RDFSM_REG [ regs EX_RDFSM_REG ]
2009-09-10 03:06:22 -05:00
# enable Expansion Bus Clock + CS0 (NOR)
mww $EX_CSEN_REG 0x3
# set the address space for CS0=16MB
mww $EX_CS0_SEG_REG 0x7ff
# set the CS0 bus width to 16-bit
mww $EX_CS0_CFG_REG 0x202
# set timings to NOR
mww $EX_CS0_TMG1_REG 0x03034006
mww $EX_CS0_TMG2_REG 0x04040002
2009-09-30 18:02:15 -05:00
# mww $EX_CS0_TMG3_REG
2009-09-10 03:06:22 -05:00
# set EBUS clock 165/5=33MHz
mww $EX_CLOCK_DIV_REG 0x5
2021-01-28 05:27:53 -06:00
# everything else is OK with default
2009-09-10 03:06:22 -05:00
}
proc bootNOR { } {
set EXP_CS0_BASEADDR [ regs EXP_CS0_BASEADDR]
set BLOCK_RESET_REG [ regs BLOCK_RESET_REG]
set DDR_RST [ regs DDR_RST]
2009-09-30 18:02:15 -05:00
2009-09-10 03:06:22 -05:00
# put DDR controller in reset (so that it comes reset in u-boot)
mmw $BLOCK_RESET_REG 0x0 $DDR_RST
# setup CS0 controller for NOR
setupNOR
# make sure we are accessing the lower part of NOR
lowGPIO5
# set PC to start of NOR (at boot 0x20000000 = 0x0)
reg pc $EXP_CS0_BASEADDR
# run
resume
}
proc setupGPIO { } {
2010-11-08 03:23:49 -06:00
echo " S e t t i n g u p G P I O b l o c k f o r T e l o "
2009-09-10 03:06:22 -05:00
# This is current setup for Telo (see sch. for details):
# GPIO0 reset for FXS-FXO IC, leave as input, the IC has internal pullup
# GPIO1 irq line for FXS-FXO
# GPIO5 addr22 for NOR flash (access to upper 8MB)
# GPIO17 reset for DECT module.
# GPIO29 CS_n for NAND
2009-09-30 18:02:15 -05:00
set GPIO_OUTPUT_REG [ regs GPIO_OUTPUT_REG]
set GPIO_OE_REG [ regs GPIO_OE_REG]
2009-09-10 03:06:22 -05:00
# set GPIO29=GPIO17=1, GPIO5=0
2021-04-09 18:23:57 -05:00
mww $GPIO_OUTPUT_REG [ expr { 1 << 29 | 1 << 17 } ]
2009-09-10 03:06:22 -05:00
# enable [as output] GPIO29,GPIO17,GPIO5
2021-04-09 18:23:57 -05:00
mww $GPIO_OE_REG [ expr { 1 << 29 | 1 << 17 | 1 << 5 } ]
2009-09-10 03:06:22 -05:00
}
proc highGPIO5 { } {
2010-11-08 03:23:49 -06:00
echo " G P I O 5 h i g h "
2009-09-30 18:02:15 -05:00
set GPIO_OUTPUT_REG [ regs GPIO_OUTPUT_REG]
2009-09-10 03:06:22 -05:00
# set GPIO5=1
2021-04-09 18:23:57 -05:00
mmw $GPIO_OUTPUT_REG [ expr { 1 << 5 } ] 0x0
2009-09-10 03:06:22 -05:00
}
proc lowGPIO5 { } {
2010-11-08 03:23:49 -06:00
echo " G P I O 5 l o w "
2009-09-30 18:02:15 -05:00
set GPIO_OUTPUT_REG [ regs GPIO_OUTPUT_REG]
2009-09-10 03:06:22 -05:00
# set GPIO5=0
2021-04-09 18:23:57 -05:00
mmw $GPIO_OUTPUT_REG 0x0 [ expr { 1 << 5 } ]
2009-09-10 03:06:22 -05:00
}
proc boardID { id } {
# so far built:
# 4'b1111
2009-09-30 18:02:15 -05:00
dict set boardID 15 name " E V T 1 "
2009-09-10 03:06:22 -05:00
dict set boardID 15 ddr2size 128 M
# dict set boardID 15 nandsize 1G
# dict set boardID 15 norsize 16M
# 4'b0000
2009-09-30 18:02:15 -05:00
dict set boardID 0 name " E V T 2 "
2009-09-10 03:06:22 -05:00
dict set boardID 0 ddr2size 128 M
# 4'b0001
2009-09-30 18:02:15 -05:00
dict set boardID 1 name " E V T 3 "
2009-09-10 03:06:22 -05:00
dict set boardID 1 ddr2size 256 M
# 4'b1110
dict set boardID 14 name " E V T 3 _ o l d "
dict set boardID 14 ddr2size 128 M
# 4'b0010
2009-09-30 18:02:15 -05:00
dict set boardID 2 name " E V T 4 "
2009-09-10 03:06:22 -05:00
dict set boardID 2 ddr2size 256 M
return $boardID
}
2009-09-30 00:37:32 -05:00
2009-09-10 03:06:22 -05:00
# converted from u-boot/boards/mindspeed/ooma-darwin/board.c:ooma_board_detect()
2009-09-30 18:02:15 -05:00
# figure out what board revision this is, uses BOOTSTRAP register to read stuffed resistors
2009-09-10 03:06:22 -05:00
proc ooma_board_detect { } {
set GPIO_BOOTSTRAP_REG [ regs GPIO_BOOTSTRAP_REG]
2009-09-30 18:02:15 -05:00
2021-01-28 05:27:53 -06:00
# read the current value of the BOOTSTRAP pins
2009-09-10 03:06:22 -05:00
set tmp [ mrw $GPIO_BOOTSTRAP_REG ]
2010-11-08 03:23:49 -06:00
echo [ format " G P I O _ B O O T S T R A P _ R E G ( 0 x % x ) : 0 x % x " $GPIO_BOOTSTRAP_REG $tmp ]
2009-09-10 03:06:22 -05:00
# extract the GPBP bits
2021-04-09 18:23:57 -05:00
set gpbt [ expr { ( $tmp & 0x1C00 ) >> 10 | ( $tmp & 0x40 ) >> 3 } ]
2009-09-10 03:06:22 -05:00
# display board ID
2010-11-08 03:23:49 -06:00
echo [ format " T h i s i s % s ( 0 x % x ) " [ dict get [ boardID $gpbt ] $gpbt name] $gpbt ]
2009-09-30 00:37:32 -05:00
# show it on serial console
putsUART0 [ format " T h i s i s % s ( 0 x % x ) \n " [ dict get [ boardID $gpbt ] $gpbt name] $gpbt ]
2009-09-10 03:06:22 -05:00
# return the ddr2 size, used to configure DDR2 on a given board.
return [ dict get [ boardID $gpbt ] $gpbt ddr2size]
}
proc configureDDR2regs_256M { } {
2009-09-30 18:02:15 -05:00
2009-09-30 00:37:32 -05:00
set DENALI_CTL_00_DATA [ regs DENALI_CTL_00_DATA]
set DENALI_CTL_01_DATA [ regs DENALI_CTL_01_DATA]
set DENALI_CTL_02_DATA [ regs DENALI_CTL_02_DATA]
set DENALI_CTL_03_DATA [ regs DENALI_CTL_03_DATA]
set DENALI_CTL_04_DATA [ regs DENALI_CTL_04_DATA]
set DENALI_CTL_05_DATA [ regs DENALI_CTL_05_DATA]
set DENALI_CTL_06_DATA [ regs DENALI_CTL_06_DATA]
set DENALI_CTL_07_DATA [ regs DENALI_CTL_07_DATA]
set DENALI_CTL_08_DATA [ regs DENALI_CTL_08_DATA]
set DENALI_CTL_09_DATA [ regs DENALI_CTL_09_DATA]
set DENALI_CTL_10_DATA [ regs DENALI_CTL_10_DATA]
set DENALI_CTL_11_DATA [ regs DENALI_CTL_11_DATA]
set DENALI_CTL_12_DATA [ regs DENALI_CTL_12_DATA]
set DENALI_CTL_13_DATA [ regs DENALI_CTL_13_DATA]
set DENALI_CTL_14_DATA [ regs DENALI_CTL_14_DATA]
set DENALI_CTL_15_DATA [ regs DENALI_CTL_15_DATA]
set DENALI_CTL_16_DATA [ regs DENALI_CTL_16_DATA]
set DENALI_CTL_17_DATA [ regs DENALI_CTL_17_DATA]
set DENALI_CTL_18_DATA [ regs DENALI_CTL_18_DATA]
set DENALI_CTL_19_DATA [ regs DENALI_CTL_19_DATA]
set DENALI_CTL_20_DATA [ regs DENALI_CTL_20_DATA]
set DENALI_CTL_02_VAL 0x0100000000010100
set DENALI_CTL_11_VAL 0x433a32164a560a00
mw64bit $DENALI_CTL_00_DATA 0x0100000101010101
# 01_DATA mod [40]=1, enable BA2
mw64bit $DENALI_CTL_01_DATA 0x0100010100000001
mw64bit $DENALI_CTL_02_DATA $DENALI_CTL_02_VAL
mw64bit $DENALI_CTL_03_DATA 0x0102020202020201
mw64bit $DENALI_CTL_04_DATA 0x0000010100000001
mw64bit $DENALI_CTL_05_DATA 0x0203010300010101
mw64bit $DENALI_CTL_06_DATA 0x060a020200020202
2009-09-30 18:02:15 -05:00
mw64bit $DENALI_CTL_07_DATA 0x0000000300000206
2009-09-30 00:37:32 -05:00
mw64bit $DENALI_CTL_08_DATA 0x6400003f3f0a0209
mw64bit $DENALI_CTL_09_DATA 0x1a000000001a1a1a
mw64bit $DENALI_CTL_10_DATA 0x0120202020191a18
# 11_DATA mod [39-32]=16,more refresh
mw64bit $DENALI_CTL_11_DATA $DENALI_CTL_11_VAL
mw64bit $DENALI_CTL_12_DATA 0x0000000000000800
mw64bit $DENALI_CTL_13_DATA 0x0010002000100040
mw64bit $DENALI_CTL_14_DATA 0x0010004000100040
mw64bit $DENALI_CTL_15_DATA 0x04f8000000000000
mw64bit $DENALI_CTL_16_DATA 0x000000002cca0000
mw64bit $DENALI_CTL_17_DATA 0x0000000000000000
mw64bit $DENALI_CTL_18_DATA 0x0302000000000000
mw64bit $DENALI_CTL_19_DATA 0x00001300c8030600
2009-09-30 18:02:15 -05:00
mw64bit $DENALI_CTL_20_DATA 0x0000000081fe00c8
2009-09-30 00:37:32 -05:00
set wr_dqs_shift 0x40
# start DDRC
2021-04-09 18:23:57 -05:00
mw64bit $DENALI_CTL_02_DATA [ expr { $DENALI_CTL_02_VAL | ( 1 << 32 ) } ]
2009-09-30 00:37:32 -05:00
# wait int_status[2] (DRAM init complete)
2010-11-08 03:23:49 -06:00
echo - n " W a i t i n g f o r D D R 2 c o n t r o l l e r t o i n i t . . . "
2021-04-09 18:23:57 -05:00
set tmp [ mrw [ expr { $DENALI_CTL_08_DATA + 4 } ] ]
while { [ expr { $tmp & 0x040000 } ] == 0 } {
2009-09-30 00:37:32 -05:00
sleep 1
2021-04-09 18:23:57 -05:00
set tmp [ mrw [ expr { $DENALI_CTL_08_DATA + 4 } ] ]
2009-09-30 00:37:32 -05:00
}
2010-11-08 03:23:49 -06:00
echo " d o n e . "
2009-09-30 00:37:32 -05:00
# do ddr2 training sequence
# TBD (for now, if you need it, run trainDDR command)
2009-09-10 03:06:22 -05:00
}
# converted from u-boot/cpu/arm1136/comcerto/bsp100.c:config_board99()
# The values are computed based on Mindspeed and Nanya datasheets
proc configureDDR2regs_128M { } {
set DENALI_CTL_00_DATA [ regs DENALI_CTL_00_DATA]
set DENALI_CTL_01_DATA [ regs DENALI_CTL_01_DATA]
set DENALI_CTL_02_DATA [ regs DENALI_CTL_02_DATA]
set DENALI_CTL_03_DATA [ regs DENALI_CTL_03_DATA]
set DENALI_CTL_04_DATA [ regs DENALI_CTL_04_DATA]
set DENALI_CTL_05_DATA [ regs DENALI_CTL_05_DATA]
set DENALI_CTL_06_DATA [ regs DENALI_CTL_06_DATA]
set DENALI_CTL_07_DATA [ regs DENALI_CTL_07_DATA]
set DENALI_CTL_08_DATA [ regs DENALI_CTL_08_DATA]
set DENALI_CTL_09_DATA [ regs DENALI_CTL_09_DATA]
set DENALI_CTL_10_DATA [ regs DENALI_CTL_10_DATA]
set DENALI_CTL_11_DATA [ regs DENALI_CTL_11_DATA]
set DENALI_CTL_12_DATA [ regs DENALI_CTL_12_DATA]
set DENALI_CTL_13_DATA [ regs DENALI_CTL_13_DATA]
set DENALI_CTL_14_DATA [ regs DENALI_CTL_14_DATA]
set DENALI_CTL_15_DATA [ regs DENALI_CTL_15_DATA]
set DENALI_CTL_16_DATA [ regs DENALI_CTL_16_DATA]
set DENALI_CTL_17_DATA [ regs DENALI_CTL_17_DATA]
set DENALI_CTL_18_DATA [ regs DENALI_CTL_18_DATA]
set DENALI_CTL_19_DATA [ regs DENALI_CTL_19_DATA]
set DENALI_CTL_20_DATA [ regs DENALI_CTL_20_DATA]
2009-09-30 18:02:15 -05:00
set DENALI_CTL_02_VAL 0x0100010000010100
2009-09-10 03:06:22 -05:00
set DENALI_CTL_11_VAL 0x433A42124A650A37
2009-09-30 18:02:15 -05:00
# set some default values
2009-09-10 03:06:22 -05:00
mw64bit $DENALI_CTL_00_DATA 0x0100000101010101
mw64bit $DENALI_CTL_01_DATA 0x0100000100000101
mw64bit $DENALI_CTL_02_DATA $DENALI_CTL_02_VAL
mw64bit $DENALI_CTL_03_DATA 0x0102020202020201
mw64bit $DENALI_CTL_04_DATA 0x0201010100000201
mw64bit $DENALI_CTL_05_DATA 0x0203010300010101
mw64bit $DENALI_CTL_06_DATA 0x050A020200020202
mw64bit $DENALI_CTL_07_DATA 0x000000030E0B0205
mw64bit $DENALI_CTL_08_DATA 0x6427003F3F0A0209
mw64bit $DENALI_CTL_09_DATA 0x1A00002F00001A00
mw64bit $DENALI_CTL_10_DATA 0x01202020201A1A1A
mw64bit $DENALI_CTL_11_DATA $DENALI_CTL_11_VAL
mw64bit $DENALI_CTL_12_DATA 0x0000080000000800
mw64bit $DENALI_CTL_13_DATA 0x0010002000100040
mw64bit $DENALI_CTL_14_DATA 0x0010004000100040
mw64bit $DENALI_CTL_15_DATA 0x0508000000000000
mw64bit $DENALI_CTL_16_DATA 0x000020472D200000
mw64bit $DENALI_CTL_17_DATA 0x0000000008000000
mw64bit $DENALI_CTL_18_DATA 0x0302000000000000
mw64bit $DENALI_CTL_19_DATA 0x00001400C8030604
mw64bit $DENALI_CTL_20_DATA 0x00000000823600C8
set wr_dqs_shift 0x40
# start DDRC
2021-04-09 18:23:57 -05:00
mw64bit $DENALI_CTL_02_DATA [ expr { $DENALI_CTL_02_VAL | ( 1 << 32 ) } ]
2009-09-10 03:06:22 -05:00
# wait int_status[2] (DRAM init complete)
2010-11-08 03:23:49 -06:00
echo - n " W a i t i n g f o r D D R 2 c o n t r o l l e r t o i n i t . . . "
2021-04-09 18:23:57 -05:00
set tmp [ mrw [ expr { $DENALI_CTL_08_DATA + 4 } ] ]
while { [ expr { $tmp & 0x040000 } ] == 0 } {
2009-09-10 03:06:22 -05:00
sleep 1
2021-04-09 18:23:57 -05:00
set tmp [ mrw [ expr { $DENALI_CTL_08_DATA + 4 } ] ]
2009-09-10 03:06:22 -05:00
}
2009-09-30 00:37:32 -05:00
# This is not necessary
2021-04-09 18:23:57 -05:00
# mw64bit $DENALI_CTL_11_DATA [expr {($DENALI_CTL_11_VAL & ~0x00007F0000000000) | ($wr_dqs_shift << 40)} ]
2010-11-08 03:23:49 -06:00
echo " d o n e . "
2009-09-10 03:06:22 -05:00
# do ddr2 training sequence
# TBD (for now, if you need it, run trainDDR command)
}
proc setupUART0 { } {
# configure UART0 to 115200, 8N1
set GPIO_LOCK_REG [ regs GPIO_LOCK_REG]
set GPIO_IOCTRL_REG [ regs GPIO_IOCTRL_REG]
set GPIO_IOCTRL_VAL [ regs GPIO_IOCTRL_VAL]
set GPIO_IOCTRL_UART0 [ regs GPIO_IOCTRL_UART0]
2009-09-30 18:02:15 -05:00
set UART0_LCR [ regs UART0_LCR]
set LCR_DLAB [ regs LCR_DLAB]
set UART0_DLL [ regs UART0_DLL]
set UART0_DLH [ regs UART0_DLH]
set UART0_IIR [ regs UART0_IIR]
set UART0_IER [ regs UART0_IER]
set LCR_ONE_STOP [ regs LCR_ONE_STOP]
set LCR_CHAR_LEN_8 [ regs LCR_CHAR_LEN_8]
2009-09-10 03:06:22 -05:00
set FCR_XMITRES [ regs FCR_XMITRES]
2009-09-30 18:02:15 -05:00
set FCR_RCVRRES [ regs FCR_RCVRRES]
set FCR_FIFOEN [ regs FCR_FIFOEN]
set IER_UUE [ regs IER_UUE]
2009-09-10 03:06:22 -05:00
# unlock writing to IOCTRL register
mww $GPIO_LOCK_REG $GPIO_IOCTRL_VAL
# enable UART0
mmw $GPIO_IOCTRL_REG $GPIO_IOCTRL_UART0 0x0
# baudrate 115200
# This should really be amba_clk/(16*115200) but amba_clk=165MHz
set tmp 89
# Enable Divisor Latch access
mmw $UART0_LCR $LCR_DLAB 0x0
# set the divisor to $tmp
2021-04-09 18:23:57 -05:00
mww $UART0_DLL [ expr { $tmp & 0xff } ]
mww $UART0_DLH [ expr { $tmp >> 8 } ]
2009-09-10 03:06:22 -05:00
# Disable Divisor Latch access
mmw $UART0_LCR 0x0 $LCR_DLAB
# set the UART to 8N1
2021-04-09 18:23:57 -05:00
mmw $UART0_LCR [ expr { $LCR_ONE_STOP | $LCR_CHAR_LEN_8 } ] 0x0
2009-09-10 03:06:22 -05:00
# reset FIFO
2021-04-09 18:23:57 -05:00
mmw $UART0_IIR [ expr { $FCR_XMITRES | $FCR_RCVRRES | $FCR_FIFOEN } ] 0x0
2009-09-10 03:06:22 -05:00
# enable FFUART
mww $UART0_IER $IER_UUE
}
proc putcUART0 { char } {
2009-09-30 18:02:15 -05:00
set UART0_LSR [ regs UART0_LSR]
2009-09-10 03:06:22 -05:00
set UART0_THR [ regs UART0_THR]
set LSR_TEMT [ regs LSR_TEMT]
# convert the 'char' to digit
set tmp [ scan $char % c ]
# /* wait for room in the tx FIFO on FFUART */
2021-04-10 11:28:52 -05:00
while { [ expr { [ mrw $UART0_LSR ] & $LSR_TEMT } ] == 0 } { sleep 1 }
2009-09-10 03:06:22 -05:00
mww $UART0_THR $tmp
if { $char == " \n " } { putcUART0 \ r }
}
proc putsUART0 { str } {
set index 0
set len [ string length $str ]
while { $index < $len } {
putcUART0 [ string index $str $index ]
2021-04-09 18:23:57 -05:00
set index [ expr { $index + 1 } ]
2009-09-10 03:06:22 -05:00
}
}
proc trainDDR2 { } {
set ARAM_BASEADDR [ regs ARAM_BASEADDR]
# you must have run 'reset init' or u-boot
# load the training code to ARAM
load_image ./ images/ ddr2train.bin $ARAM_BASEADDR bin
# set PC to start of NOR (at boot 0x20000000 = 0x0)
reg pc $ARAM_BASEADDR
# run
resume
}
2009-09-30 00:37:32 -05:00
proc flashUBOOT { file } {
2009-09-10 03:06:22 -05:00
# this will update uboot on NOR partition
set EXP_CS0_BASEADDR [ regs EXP_CS0_BASEADDR]
2009-09-30 18:02:15 -05:00
2009-09-10 03:06:22 -05:00
# setup CS0 controller for NOR
setupNOR
# make sure we are accessing the lower part of NOR
lowGPIO5
flash probe 0
2010-11-08 03:23:49 -06:00
echo " E r a s i n g s e c t o r s 0 - 3 f o r u b o o t "
2009-09-30 00:37:32 -05:00
putsUART0 " E r a s i n g s e c t o r s 0 - 3 f o r u b o o t \n "
2009-09-10 03:06:22 -05:00
flash erase_sector 0 0 3
2010-11-08 03:23:49 -06:00
echo " P r o g r a m m i n g u - b o o t "
2009-09-30 00:37:32 -05:00
putsUART0 " P r o g r a m m i n g u - b o o t . . . "
2010-04-24 09:51:34 -05:00
arm11 memwrite burst enable
2009-09-30 00:37:32 -05:00
flash write_image $file $EXP_CS0_BASEADDR
2010-04-24 09:51:34 -05:00
arm11 memwrite burst disable
2009-09-30 00:37:32 -05:00
putsUART0 " d o n e . \n "
putsUART0 " R e b o o t i n g , p l e a s e w a i t ! \n "
reboot
2019-05-12 05:26:46 -05:00
}