diff --git a/jtag/src/bus/ixp425.c b/jtag/src/bus/ixp425.c index ec1b0447..67f22ef0 100644 --- a/jtag/src/bus/ixp425.c +++ b/jtag/src/bus/ixp425.c @@ -245,7 +245,8 @@ const bus_driver_t ixp425_bus = { ixp425_bus_read_next, ixp425_bus_read_end, ixp425_bus_read, - ixp425_bus_write + ixp425_bus_write, + NULL }; static bus_t * diff --git a/jtag/src/bus/mpc824x.c b/jtag/src/bus/mpc824x.c index 442c6a5e..8673f6e3 100644 --- a/jtag/src/bus/mpc824x.c +++ b/jtag/src/bus/mpc824x.c @@ -396,5 +396,6 @@ const bus_driver_t mpc824x_bus = { mpc824x_bus_read_next, mpc824x_bus_read_end, mpc824x_bus_read, - mpc824x_bus_write + mpc824x_bus_write, + NULL }; diff --git a/jtag/src/bus/pxa2x0.c b/jtag/src/bus/pxa2x0.c index 8ec52ca2..be2bfbf7 100644 --- a/jtag/src/bus/pxa2x0.c +++ b/jtag/src/bus/pxa2x0.c @@ -381,7 +381,8 @@ const bus_driver_t pxa2x0_bus = { pxa250_bus_read_next, pxa250_bus_read_end, pxa250_bus_read, - pxa250_bus_write + pxa250_bus_write, + NULL }; static bus_t * diff --git a/jtag/src/bus/s3c4510x.c b/jtag/src/bus/s3c4510x.c index a9efed54..6b6d6811 100644 --- a/jtag/src/bus/s3c4510x.c +++ b/jtag/src/bus/s3c4510x.c @@ -322,7 +322,8 @@ const bus_driver_t s3c4510_bus = { s3c4510_bus_read_next, s3c4510_bus_read_end, s3c4510_bus_read, - s3c4510_bus_write + s3c4510_bus_write, + NULL }; static bus_t * diff --git a/jtag/src/bus/sa1110.c b/jtag/src/bus/sa1110.c index 253bbfdf..2cf5ca27 100644 --- a/jtag/src/bus/sa1110.c +++ b/jtag/src/bus/sa1110.c @@ -259,7 +259,8 @@ const bus_driver_t sa1110_bus = { sa1110_bus_read_next, sa1110_bus_read_end, sa1110_bus_read, - sa1110_bus_write + sa1110_bus_write, + NULL }; static bus_t * @@ -338,4 +339,3 @@ sa1110_bus_new( void ) return bus; } - diff --git a/jtag/src/bus/sh7727.c b/jtag/src/bus/sh7727.c index 90118de7..93cd7fc9 100644 --- a/jtag/src/bus/sh7727.c +++ b/jtag/src/bus/sh7727.c @@ -291,7 +291,8 @@ const bus_driver_t sh7727_bus = { sh7727_bus_read_next, sh7727_bus_read_end, sh7727_bus_read, - sh7727_bus_write + sh7727_bus_write, + NULL }; static bus_t * diff --git a/jtag/src/bus/sh7750r.c b/jtag/src/bus/sh7750r.c index f280ce0c..678bb59a 100644 --- a/jtag/src/bus/sh7750r.c +++ b/jtag/src/bus/sh7750r.c @@ -273,7 +273,8 @@ const bus_driver_t sh7750r_bus = { sh7750r_bus_read_next, sh7750r_bus_read_end, sh7750r_bus_read, - sh7750r_bus_write + sh7750r_bus_write, + NULL }; static bus_t * diff --git a/jtag/src/bus/sh7751r.c b/jtag/src/bus/sh7751r.c index cc322992..4eefcac2 100644 --- a/jtag/src/bus/sh7751r.c +++ b/jtag/src/bus/sh7751r.c @@ -266,7 +266,8 @@ const bus_driver_t sh7751r_bus = { sh7751r_bus_read_next, sh7751r_bus_read_end, sh7751r_bus_read, - sh7751r_bus_write + sh7751r_bus_write, + NULL }; static bus_t * diff --git a/jtag/src/cmd/detect.c b/jtag/src/cmd/detect.c index f949e154..af87470e 100644 --- a/jtag/src/cmd/detect.c +++ b/jtag/src/cmd/detect.c @@ -36,6 +36,9 @@ static int cmd_detect_run( char *params[] ) { + int i; + bus_t * abus; + if (cmd_params( params ) != 1) return -1; @@ -58,6 +61,17 @@ cmd_detect_run( char *params[] ) chain_shift_data_registers( chain, 1 ); parts_set_instruction( chain->parts, "BYPASS" ); chain_shift_instructions( chain ); + + // Initialize all the buses + for (i = 0; i < buses.len; i++) + { + abus = buses.buses[i]; + if(abus->driver->init) + { + if(!abus->driver->init(abus)) + return -1; + } + } return 1; } diff --git a/jtag/src/tap/Makefile.am b/jtag/src/tap/Makefile.am index 0fb0366e..03b5fa79 100644 --- a/jtag/src/tap/Makefile.am +++ b/jtag/src/tap/Makefile.am @@ -45,4 +45,5 @@ libtap_a_SOURCES = \ cable/lattice.c \ cable/mpcbdm.c \ cable/triton.c \ - cable/wiggler.c + cable/wiggler.c \ + cable/wiggler2.c diff --git a/jtag/src/tap/cable.c b/jtag/src/tap/cable.c index d84204b2..fc0344ed 100644 --- a/jtag/src/tap/cable.c +++ b/jtag/src/tap/cable.c @@ -41,6 +41,7 @@ extern cable_driver_t lattice_cable_driver; extern cable_driver_t mpcbdm_cable_driver; extern cable_driver_t triton_cable_driver; extern cable_driver_t wiggler_cable_driver; +extern cable_driver_t wiggler2_cable_driver; uint32_t frequency = 0; @@ -55,6 +56,7 @@ cable_driver_t *cable_drivers[] = { &mpcbdm_cable_driver, &triton_cable_driver, &wiggler_cable_driver, + &wiggler2_cable_driver, NULL /* last must be NULL */ }; diff --git a/jtag/src/tap/cable/wiggler2.c b/jtag/src/tap/cable/wiggler2.c new file mode 100644 index 00000000..3daf8f4f --- /dev/null +++ b/jtag/src/tap/cable/wiggler2.c @@ -0,0 +1,123 @@ +/* + * $Id: wiggler2.c,v 1.8 2003/09/11 16:45:15 telka Exp $ + * + * Modified WIGGLER JTAG Cable Driver + * Copyright (C) 2003 Ultra d.o.o. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Written by Marcel Telka , 2002, 2003. + * + * Documentation: + * [1] http://www.ocdemon.net/ + * [2] http://jtag-arm9.sourceforge.net/hardware.html + * + * Base on the code for the Macraigor WIGGLER code written by Marcel Telka. + * Modified by Matej Kupljen to support + * the Modified WIGGLER JTAG cable. This has an additional pin, that is + * used for CPU reset. The schematic is based on the source code for the + * open source JTAG debugger for the PXA250 (255) processor, called Jelie + * . + * + */ + +#include "sysdep.h" + +#include "cable.h" +#include "parport.h" +#include "chain.h" + +#include "generic.h" + +/* + * data D[7:0] (pins 9:2) + */ +#define TDI 3 +#define TCK 2 +#define TMS 1 +#define TRST 4 +#define CPU_RESET 0 + + +/* + * 7 - BUSY (pin 11) + * 6 - ACK (pin 10) + * 5 - PE (pin 12) + * 4 - SEL (pin 13) + * 3 - ERROR (pin 15) + */ +#define TDO 7 + +static int +wiggler2_init( cable_t *cable ) +{ + int data; + + if (parport_open( cable->port )) + return -1; + + if ((data = parport_get_data( cable->port )) < 0) { + if (parport_set_data( cable->port, 0 << TRST )) + return -1; + PARAM_TRST(cable) = 1; + } else + PARAM_TRST(cable) = (data >> TRST) & 1; + + return 0; +} + +static void +wiggler2_clock( cable_t *cable, int tms, int tdi ) +{ + tms = tms ? 1 : 0; + tdi = tdi ? 1 : 0; + + parport_set_data( cable->port, (PARAM_TRST(cable) << TRST) | (0 << TCK) | (tms << TMS) | (tdi << TDI) ); + cable_wait(); + parport_set_data( cable->port, (PARAM_TRST(cable) << TRST) | (1 << TCK) | (tms << TMS) | (tdi << TDI) ); + cable_wait(); +} + +static int +wiggler2_get_tdo( cable_t *cable ) +{ + parport_set_data( cable->port, (PARAM_TRST(cable) << TRST) | (0 << TCK) ); + cable_wait(); + return (parport_get_status( cable->port ) >> TDO) & 1; +} + +static int +wiggler2_set_trst( cable_t *cable, int trst ) +{ + PARAM_TRST(cable) = trst ? 1 : 0; + + parport_set_data( cable->port, PARAM_TRST(cable) << TRST ); + return PARAM_TRST(cable); +} + +cable_driver_t wiggler2_cable_driver = { + "WIGGLER2", + N_("Modified (with CPU Reset) WIGGLER JTAG Cable"), + generic_connect, + generic_disconnect, + generic_cable_free, + wiggler2_init, + generic_done, + wiggler2_clock, + wiggler2_get_tdo, + wiggler2_set_trst, + generic_get_trst +};