# SPDX-License-Identifier: GPL-2.0-or-later
#
# The QCS6490/QCM6490 is a 6nm processor designed for enterprise and Internet of Things (IOT) applications,
# featuring global 5G and Wi-Fi 6E support
#
# Product Page:
# https://www.qualcomm.com/products/internet-of-things/industrial/building-enterprise/qcs6490
# https://www.qualcomm.com/products/internet-of-things/industrial/building-enterprise/qcm6490

source [find target/swj-dp.tcl]

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

if { [info exists ENDIAN] } {
   set _ENDIAN $ENDIAN
} else {
   set _ENDIAN little
}

adapter speed 500
reset_config trst_and_srst

# Set CUP TAP ID based on protocol selection
if { [using_jtag] } {
        set _CPUTAPID 0x5ba00477
} else {
        set _CPUTAPID 0x5ba02477
}

swj_newdap $_CHIPNAME cpu -expected-id $_CPUTAPID -irlen 4

dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu -ignore-syspwrupack

cti create $_CHIPNAME.cti -dap $_CHIPNAME.dap -baseaddr 0x87020000 -ap-num 1

target create $_CHIPNAME.cpu0 aarch64 -endian $_ENDIAN -dap $_CHIPNAME.dap -coreid 0 \
   -dbgbase 0x87010000 -cti $_CHIPNAME.cti -event reset-assert-post { dap init }

$_CHIPNAME.cpu0 configure -event examine-end {
   eval $_CHIPNAME.cpu0 arp_halt
}

# Default breakpoints to hardware breakpoints
gdb_breakpoint_override hard
