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>
38 static unsigned long output = 0;
39 static int filepos = 0;
40 static int oldstate = 0;
41 static int newstate = 0;
42 static int readptr = 0;
45 extern const unsigned char fpgadata[];
48 /* if in debugging mode, then just set the variables */
49 void setPort(short p,short val)
71 out32(GPIO0_OR, output);
79 setPort(TCK,0); /* set the TCK port to low */
80 setPort(TCK,1); /* set the TCK port to high */
84 /* read in a byte of data from the prom */
85 void readByte(unsigned char *data)
87 /* pretend reading using a file */
88 *data = fpgadata[readptr++];
89 newstate = (100 * filepos++) / filesize;
90 if (newstate != oldstate) {
91 printf("%4d\r\r\r\r", newstate);
96 /* read the TDO bit from port */
97 unsigned char readTDOBit(void)
101 inputs = in32(GPIO0_IR);
102 if (inputs & JTAG_TDO)
109 /* Wait at least the specified number of microsec. */
110 /* Use a timer if possible; otherwise estimate the number of instructions */
111 /* necessary to be run based on the microcontroller speed. For this example */
112 /* we pulse the TCK port a number of times based on the processor speed. */
113 void waitTime(long microsec)
115 udelay(microsec); /* esd */