1 /***************************************************************************
\r
2 * Copyright (C) 2008 by Øyvind Harboe *
\r
3 * oyvind.harboe@zylin.com *
\r
5 * This program is free software; you can redistribute it and/or modify *
\r
6 * it under the terms of the GNU General Public License as published by *
\r
7 * the Free Software Foundation; either version 2 of the License, or *
\r
8 * (at your option) any later version. *
\r
10 * This program is distributed in the hope that it will be useful, *
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
\r
13 * GNU General Public License for more details. *
\r
15 * You should have received a copy of the GNU General Public License *
\r
16 * along with this program; if not, write to the *
\r
17 * Free Software Foundation, Inc., *
\r
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
\r
19 ***************************************************************************/
\r
20 #ifdef HAVE_CONFIG_H
\r
24 #include "replacements.h"
\r
27 #include "bitbang.h"
\r
30 /* my private tap controller state, which tracks state for calling code */
\r
31 static tap_state_t dummy_state = TAP_RESET;
\r
33 static int dummy_clock; /* edge detector */
\r
35 static int clock_count; /* count clocks in any stable state, only stable states */
\r
37 static u32 dummy_data;
\r
40 static int dummy_speed(int speed);
\r
41 static int dummy_register_commands(struct command_context_s *cmd_ctx);
\r
42 static int dummy_init(void);
\r
43 static int dummy_quit(void);
\r
44 static int dummy_khz(int khz, int *jtag_speed);
\r
45 static int dummy_speed_div(int speed, int *khz);
\r
48 /* The dummy driver is used to easily check the code path
\r
49 * where the target is unresponsive.
\r
51 jtag_interface_t dummy_interface =
\r
55 .execute_queue = bitbang_execute_queue,
\r
57 .speed = dummy_speed,
\r
58 .register_commands = dummy_register_commands,
\r
60 .speed_div = dummy_speed_div,
\r
66 static int dummy_read(void);
\r
67 static void dummy_write(int tck, int tms, int tdi);
\r
68 static void dummy_reset(int trst, int srst);
\r
69 static void dummy_led(int on);
\r
71 static bitbang_interface_t dummy_bitbang =
\r
74 .write = dummy_write,
\r
75 .reset = dummy_reset,
\r
79 static int dummy_read(void)
\r
81 int data = 1 & dummy_data;
\r
82 dummy_data = (dummy_data >> 1) | (1<<31);
\r
87 static void dummy_write(int tck, int tms, int tdi)
\r
89 /* TAP standard: "state transitions occur on rising edge of clock" */
\r
90 if( tck != dummy_clock )
\r
94 tap_state_t old_state = dummy_state;
\r
95 dummy_state = tap_state_transition( old_state, tms );
\r
97 if( old_state != dummy_state )
\r
101 LOG_DEBUG("dummy_tap: %d stable clocks", clock_count);
\r
105 LOG_DEBUG("dummy_tap: %s", tap_state_name(dummy_state) );
\r
108 if(dummy_state == TAP_DRCAPTURE)
\r
109 dummy_data = 0x01255043;
\r
114 /* this is a stable state clock edge, no change of state here,
\r
115 * simply increment clock_count for subsequent logging
\r
124 static void dummy_reset(int trst, int srst)
\r
128 if (trst || (srst && (jtag_reset_config & RESET_SRST_PULLS_TRST)))
\r
129 dummy_state = TAP_RESET;
\r
131 LOG_DEBUG("reset to: %s", tap_state_name(dummy_state) );
\r
134 static int dummy_khz(int khz, int *jtag_speed)
\r
142 *jtag_speed=64000/khz;
\r
147 static int dummy_speed_div(int speed, int *khz)
\r
161 static int dummy_speed(int speed)
\r
166 static int dummy_register_commands(struct command_context_s *cmd_ctx)
\r
171 static int dummy_init(void)
\r
173 bitbang_interface = &dummy_bitbang;
\r
178 static int dummy_quit(void)
\r
183 static void dummy_led(int on)
\r