]> git.ipfire.org Git - people/ms/u-boot.git/blob - board/esd/common/xilinx_jtag/ports.c
drivers, block: remove sil680 driver
[people/ms/u-boot.git] / board / esd / common / xilinx_jtag / ports.c
1 /*
2 * (C) Copyright 2003
3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8 /*******************************************************/
9 /* file: ports.c */
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 */
13 /* from the prom */
14 /* */
15 /*******************************************************/
16
17 #include <common.h>
18 #include <asm/processor.h>
19 #include <asm/io.h>
20
21 #include "ports.h"
22
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;
28
29 extern const unsigned char *xsvfdata;
30
31 /* if in debugging mode, then just set the variables */
32 void setPort(short p,short val)
33 {
34 if (p==TMS) {
35 if (val) {
36 output |= JTAG_TMS;
37 } else {
38 output &= ~JTAG_TMS;
39 }
40 }
41 if (p==TDI) {
42 if (val) {
43 output |= JTAG_TDI;
44 } else {
45 output &= ~JTAG_TDI;
46 }
47 }
48 if (p==TCK) {
49 if (val) {
50 output |= JTAG_TCK;
51 } else {
52 output &= ~JTAG_TCK;
53 }
54 out_be32((void *)GPIO0_OR, output);
55 }
56 }
57
58
59 /* toggle tck LH */
60 void pulseClock(void)
61 {
62 setPort(TCK,0); /* set the TCK port to low */
63 setPort(TCK,1); /* set the TCK port to high */
64 }
65
66
67 /* read in a byte of data from the prom */
68 void readByte(unsigned char *data)
69 {
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);
75 oldstate = newstate;
76 }
77 }
78
79 /* read the TDO bit from port */
80 unsigned char readTDOBit(void)
81 {
82 unsigned long inputs;
83
84 inputs = in_be32((void *)GPIO0_IR);
85 if (inputs & JTAG_TDO)
86 return 1;
87 else
88 return 0;
89 }
90
91
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)
97 {
98 udelay(microsec); /* esd */
99 }