3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 /*******************************************************/
26 /* abstract: This file contains the routines to */
27 /* output values on the JTAG ports, to read */
28 /* the TDO bit, and to read a byte of data */
31 /*******************************************************/
34 #include <asm/processor.h>
39 static unsigned long output = 0;
40 static int filepos = 0;
41 static int oldstate = 0;
42 static int newstate = 0;
43 static int readptr = 0;
46 extern const unsigned char fpgadata[];
49 /* if in debugging mode, then just set the variables */
50 void setPort(short p,short val)
72 out_be32((void *)GPIO0_OR, output);
80 setPort(TCK,0); /* set the TCK port to low */
81 setPort(TCK,1); /* set the TCK port to high */
85 /* read in a byte of data from the prom */
86 void readByte(unsigned char *data)
88 /* pretend reading using a file */
89 *data = fpgadata[readptr++];
90 newstate = (100 * filepos++) / filesize;
91 if (newstate != oldstate) {
92 printf("%4d\r\r\r\r", newstate);
97 /* read the TDO bit from port */
98 unsigned char readTDOBit(void)
100 unsigned long inputs;
102 inputs = in_be32((void *)GPIO0_IR);
103 if (inputs & JTAG_TDO)
110 /* Wait at least the specified number of microsec. */
111 /* Use a timer if possible; otherwise estimate the number of instructions */
112 /* necessary to be run based on the microcontroller speed. For this example */
113 /* we pulse the TCK port a number of times based on the processor speed. */
114 void waitTime(long microsec)
116 udelay(microsec); /* esd */