# SPDX-License-Identifier: GPL-2.0-or-later

# Intel Cyclone III FPGA
# see Cyclone III Device Handbook
# Table 12-2: Device IDCODE for Cyclone III Device Family

if { [info exists CHIPNAME] } {
	set _CHIPNAME $CHIPNAME
} else {
	set _CHIPNAME cycloneiii
}

array set _CYCLONE_3_DATA {
  0x020f10dd { 603 226 EP3C5_EP3C10}
  0x020f20dd {1080 409 EP3C16}
  0x020f30dd { 732 286 EP3C25}
  0x020f40dd {1632 604 EP3C40}
  0x020f50dd {1164 442 EP3C55}
  0x020f60dd {1314 502 EP3C80}
  0x020f70dd {1620 613 EP3C120}
  0x027010dd {1314 226 EP3CLS70}
  0x027000dd {1314 226 EP3CLS100}
  0x027030dd {1314 409 EP3CLS150}
  0x027020dd {1314 409 EP3CLS200}
}

set jtag_newtap_cmd {jtag newtap $_CHIPNAME tap -irlen 10 -ignore-version}
foreach id [array names _CYCLONE_3_DATA] {
  set cmd [concat "-expected-id" id]
}
eval $jtag_newtap_cmd

source [find fpga/altera_common_init.cfg]

pld create $_CHIPNAME.pld intel -chain-position $_CHIPNAME.tap -family cycloneiii
jtag configure $_CHIPNAME.tap -event setup "set_bscan_checkpos_on_setup $_CHIPNAME {$_CYCLONE_3_DATA}"
