3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
5 * SPDX-License-Identifier: GPL-2.0+
8 /*******************************************************/
10 /* abstract: This file contains the routines to */
11 /* output values on the JTAG ports, to read */
12 /* the TDO bit, and to read a byte of data */
15 /*******************************************************/
18 #include <asm/processor.h>
23 static unsigned long output = 0;
24 static int filepos = 0;
25 static int oldstate = 0;
26 static int newstate = 0;
27 static int readptr = 0;
29 extern const unsigned char *xsvfdata;
31 /* if in debugging mode, then just set the variables */
32 void setPort(short p,short val)
54 out_be32((void *)GPIO0_OR, output);
62 setPort(TCK,0); /* set the TCK port to low */
63 setPort(TCK,1); /* set the TCK port to high */
67 /* read in a byte of data from the prom */
68 void readByte(unsigned char *data)
70 /* pretend reading using a file */
71 *data = xsvfdata[readptr++];
72 newstate = filepos++ >> 10;
73 if (newstate != oldstate) {
74 printf("%4d kB\r\r\r\r", newstate);
79 /* read the TDO bit from port */
80 unsigned char readTDOBit(void)
84 inputs = in_be32((void *)GPIO0_IR);
85 if (inputs & JTAG_TDO)
92 /* Wait at least the specified number of microsec. */
93 /* Use a timer if possible; otherwise estimate the number of instructions */
94 /* necessary to be run based on the microcontroller speed. For this example */
95 /* we pulse the TCK port a number of times based on the processor speed. */
96 void waitTime(long microsec)
98 udelay(microsec); /* esd */