1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /***************************************************************************
4 * Copyright (C) 2008 by Øyvind Harboe *
5 * oyvind.harboe@zylin.com *
6 ***************************************************************************/
12 #include <jtag/interface.h>
16 /* my private tap controller state, which tracks state for calling code */
17 static tap_state_t dummy_state = TAP_RESET;
19 static int dummy_clock; /* edge detector */
21 static int clock_count; /* count clocks in any stable state, only stable states */
23 static uint32_t dummy_data;
25 static bb_value_t dummy_read(void)
27 int data = 1 & dummy_data;
28 dummy_data = (dummy_data >> 1) | (1 << 31);
29 return data ? BB_HIGH : BB_LOW;
32 static int dummy_write(int tck, int tms, int tdi)
34 /* TAP standard: "state transitions occur on rising edge of clock" */
35 if (tck != dummy_clock) {
37 tap_state_t old_state = dummy_state;
38 dummy_state = tap_state_transition(old_state, tms);
40 if (old_state != dummy_state) {
42 LOG_DEBUG("dummy_tap: %d stable clocks", clock_count);
46 LOG_DEBUG("dummy_tap: %s", tap_state_name(dummy_state));
49 if (dummy_state == TAP_DRCAPTURE)
50 dummy_data = 0x01255043;
53 /* this is a stable state clock edge, no change of state here,
54 * simply increment clock_count for subsequent logging
64 static int dummy_reset(int trst, int srst)
68 if (trst || (srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
69 dummy_state = TAP_RESET;
71 LOG_DEBUG("reset to: %s", tap_state_name(dummy_state));
75 static int dummy_led(int on)
80 static struct bitbang_interface dummy_bitbang = {
82 .write = &dummy_write,
86 static int dummy_khz(int khz, int *jtag_speed)
91 *jtag_speed = 64000/khz;
95 static int dummy_speed_div(int speed, int *khz)
105 static int dummy_speed(int speed)
110 static int dummy_init(void)
112 bitbang_interface = &dummy_bitbang;
117 static int dummy_quit(void)
122 static const struct command_registration dummy_command_handlers[] = {
126 .help = "dummy interface driver commands",
127 .chain = hello_command_handlers,
130 COMMAND_REGISTRATION_DONE,
133 /* The dummy driver is used to easily check the code path
134 * where the target is unresponsive.
136 static struct jtag_interface dummy_interface = {
137 .supported = DEBUG_CAP_TMS_SEQ,
138 .execute_queue = &bitbang_execute_queue,
141 struct adapter_driver dummy_adapter_driver = {
143 .transports = jtag_only,
144 .commands = dummy_command_handlers,
148 .reset = &dummy_reset,
149 .speed = &dummy_speed,
151 .speed_div = &dummy_speed_div,
153 .jtag_ops = &dummy_interface,