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

# Intel Arria II FPGA
# Arria II Device Handbook
# Table 11–2. 32-Bit IDCODE for Arria II Devices

#GX:
#EP2AGX45:  0x025120dd
#EP2AGX65:  0x025020dd
#EP2AGX95:  0x025130dd
#EP2AGX125: 0x025030dd
#EP2AGX190: 0x025140dd
#EP2AGX260: 0x025040dd
#EP2AGZ225: 0x024810dd
#EP2AGZ300: 0x0240a0dd
#EP2AGZ350: 0x024820dd

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

array set _ARRIA_2_DATA {
  0x025120dd {1227 1174 EP2AGX45}
  0x025020dd {1227   -1 EP2AGX65}
  0x025130dd {1467   -1 EP2AGX95}
  0x025030dd {1467   -1 EP2AGX125}
  0x025140dd {1971   -1 EP2AGX190}
  0x025040dd {1971   -1 EP2AGX260}
  0x024810dd {2274   -1 EP2AGZ225}
  0x0240a0dd {2682   -1 EP2AGZ300}
  0x024820dd {2682   -1 EP2AGZ350}
}

set jtag_newtap_cmd {jtag newtap $_CHIPNAME tap -irlen 10 -ignore-version}
foreach id [array names _ARRIA_2_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 arriaii
jtag configure $_CHIPNAME.tap -event setup "set_bscan_checkpos_on_setup $_CHIPNAME {$_ARRIA_2_DATA}"

