+ if (mask) {
+ int old_cfg = jtag_get_reset_config();
+
+ old_cfg &= ~mask;
+ new_cfg |= old_cfg;
+ jtag_set_reset_config(new_cfg);
+ } else
+ new_cfg = jtag_get_reset_config();
+
+
+ /*
+ * Display the (now-)current reset mode
+ */
+ char *modes[5];
+
+ /* minimal JTAG has neither SRST nor TRST (so that's the default) */
+ switch (new_cfg & (RESET_HAS_TRST | RESET_HAS_SRST)) {
+ case RESET_HAS_SRST:
+ modes[0] = "srst_only";
+ break;
+ case RESET_HAS_TRST:
+ modes[0] = "trst_only";
+ break;
+ case RESET_TRST_AND_SRST:
+ modes[0] = "trst_and_srst";
+ break;
+ default:
+ modes[0] = "none";
+ break;
+ }
+
+ /* normally SRST and TRST are decoupled; but bugs happen ... */
+ switch (new_cfg & (RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST)) {
+ case RESET_SRST_PULLS_TRST:
+ modes[1] = "srst_pulls_trst";
+ break;
+ case RESET_TRST_PULLS_SRST:
+ modes[1] = "trst_pulls_srst";
+ break;
+ case RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST:
+ modes[1] = "combined";
+ break;
+ default:
+ modes[1] = "separate";
+ break;
+ }
+
+ /* TRST-less connectors include Altera, Xilinx, and minimal JTAG */
+ if (new_cfg & RESET_HAS_TRST) {
+ if (new_cfg & RESET_TRST_OPEN_DRAIN)
+ modes[3] = " trst_open_drain";
+ else
+ modes[3] = " trst_push_pull";
+ } else
+ modes[3] = "";
+
+ /* SRST-less connectors include TI-14, Xilinx, and minimal JTAG */
+ if (new_cfg & RESET_HAS_SRST) {
+ if (new_cfg & RESET_SRST_NO_GATING)
+ modes[2] = " srst_nogate";
+ else
+ modes[2] = " srst_gates_jtag";
+
+ if (new_cfg & RESET_SRST_PUSH_PULL)
+ modes[4] = " srst_push_pull";
+ else
+ modes[4] = " srst_open_drain";
+ } else {
+ modes[2] = "";
+ modes[4] = "";
+ }
+
+ command_print(cmd_ctx, "%s %s%s%s%s",
+ modes[0], modes[1],
+ modes[2], modes[3], modes[4]);