X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fjtag%2Faice%2Faice_interface.c;h=f9bd87eeb370348c6b9f0adbeae21213c34fc00a;hp=838b54faaf994ebfab045176fcddcf76ed767d2a;hb=efd1d642220a4f6d3b9a9607c186452b265400d2;hpb=94d64ccaebd3df17f5873c076fc08ca97088cb1e diff --git a/src/jtag/aice/aice_interface.c b/src/jtag/aice/aice_interface.c index 838b54faaf..f9bd87eeb3 100644 --- a/src/jtag/aice/aice_interface.c +++ b/src/jtag/aice/aice_interface.c @@ -13,9 +13,7 @@ * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * along with this program. If not, see . * ***************************************************************************/ #ifdef HAVE_CONFIG_H @@ -31,7 +29,7 @@ #include "aice_usb.h" #define AICE_KHZ_TO_SPEED_MAP_SIZE 16 -static int aice_khz_to_speed_map[AICE_KHZ_TO_SPEED_MAP_SIZE] = { +static const int aice_khz_to_speed_map[AICE_KHZ_TO_SPEED_MAP_SIZE] = { 30000, 15000, 7500, @@ -152,7 +150,7 @@ static int aice_execute_reset(struct jtag_command *cmd) static int last_trst; int retval = ERROR_OK; - DEBUG_JTAG_IO("reset trst: %d", cmd->cmd.reset->trst); + LOG_DEBUG_IO("reset trst: %d", cmd->cmd.reset->trst); if (cmd->cmd.reset->trst != last_trst) { if (cmd->cmd.reset->trst) @@ -241,16 +239,40 @@ static int aice_khz(int khz, int *jtag_speed) return ERROR_OK; } +int aice_scan_jtag_chain(void) +{ + LOG_DEBUG("=== %s ===", __func__); + uint8_t num_of_idcode = 0; + struct target *target; + + int res = aice_port->api->idcode(aice_target_id_codes, &num_of_idcode); + if (res != ERROR_OK) { + LOG_ERROR("<-- TARGET ERROR! Failed to identify AndesCore " + "JTAG Manufacture ID in the JTAG scan chain. " + "Failed to access EDM registers. -->"); + return res; + } + + for (uint32_t i = 0; i < num_of_idcode; i++) + LOG_DEBUG("id_codes[%d] = 0x%x", i, aice_target_id_codes[i]); + + /* Update tap idcode */ + for (target = all_targets; target; target = target->next) + target->tap->idcode = aice_target_id_codes[target->tap->abs_chain_position]; + + return ERROR_OK; +} + /***************************************************************************/ /* Command handlers */ COMMAND_HANDLER(aice_handle_aice_info_command) { LOG_DEBUG("aice_handle_aice_info_command"); - command_print(CMD_CTX, "Description: %s", param.device_desc); - command_print(CMD_CTX, "Serial number: %s", param.serial); + command_print(CMD, "Description: %s", param.device_desc); + command_print(CMD, "Serial number: %s", param.serial); if (strncmp(aice_port->name, "aice_pipe", 9) == 0) - command_print(CMD_CTX, "Adapter: %s", param.adapter_name); + command_print(CMD, "Adapter: %s", param.adapter_name); return ERROR_OK; } @@ -496,14 +518,20 @@ static const struct command_registration aice_command_handlers[] = { /***************************************************************************/ /* End of Command handlers */ -struct jtag_interface aice_interface = { +static struct jtag_interface aice_interface = { + .execute_queue = aice_execute_queue, +}; + +struct adapter_driver aice_adapter_driver = { .name = "aice", - .commands = aice_command_handlers, .transports = aice_transports, + .commands = aice_command_handlers, + .init = aice_init, .quit = aice_quit, - .execute_queue = aice_execute_queue, .speed = aice_speed, /* set interface speed */ - .speed_div = aice_speed_div, /* return readable value */ .khz = aice_khz, /* convert khz to interface speed value */ + .speed_div = aice_speed_div, /* return readable value */ + + .jtag_ops = &aice_interface, };