From 630a04a509970fede51899b35752bce142c63ce5 Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Fri, 7 Feb 2003 09:07:23 +0000 Subject: [PATCH] 2003-02-07 Marcel Telka * src/tap/cable/mpcbmd.c: Added support for Mpcbdm JTAG Cable (Christian Pellegrin). * src/tap/cable.c: Ditto. * src/tap/Makefile.am: Ditto. git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@336 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 6 ++ jtag/NEWS | 1 + jtag/THANKS | 1 + jtag/src/tap/Makefile.am | 1 + jtag/src/tap/cable.c | 2 + jtag/src/tap/cable/mpcbdm.c | 121 ++++++++++++++++++++++++++++++++++++ 6 files changed, 132 insertions(+) create mode 100644 jtag/src/tap/cable/mpcbdm.c diff --git a/jtag/ChangeLog b/jtag/ChangeLog index 480fbe9e..a5b6cbba 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,9 @@ +2003-02-07 Marcel Telka + + * src/tap/cable/mpcbmd.c: Added support for Mpcbdm JTAG Cable (Christian Pellegrin). + * src/tap/cable.c: Ditto. + * src/tap/Makefile.am: Ditto. + 2003-02-04 Marcel Telka * src/help.c (help): Added missing short help description for 'set' command. diff --git a/jtag/NEWS b/jtag/NEWS index 03724ea9..a4555229 100644 --- a/jtag/NEWS +++ b/jtag/NEWS @@ -2,6 +2,7 @@ $Id$ * Enhanced 'dr' command functionality. * Added new 'set signal' command. + * Added support for Mpcbdm JTAG Cable (Christian Pellegrin). jtag-0.2.2 (2003-02-04): diff --git a/jtag/THANKS b/jtag/THANKS index 359be88e..a5baa479 100644 --- a/jtag/THANKS +++ b/jtag/THANKS @@ -3,3 +3,4 @@ $Id$ Holger Schurig Stas Khirman Chris Ellec +Christian Pellegrin diff --git a/jtag/src/tap/Makefile.am b/jtag/src/tap/Makefile.am index 5a52d6a3..85b86712 100644 --- a/jtag/src/tap/Makefile.am +++ b/jtag/src/tap/Makefile.am @@ -32,6 +32,7 @@ libtap_a_SOURCES = \ cable/dlc5.c \ cable/ea253.c \ cable/ei012.c \ + cable/mpcbdm.c \ cable/wiggler.c INCLUDES = -I$(top_srcdir)/include $(OPENWINCE_INC) diff --git a/jtag/src/tap/cable.c b/jtag/src/tap/cable.c index 9b96cf3a..774520c8 100644 --- a/jtag/src/tap/cable.c +++ b/jtag/src/tap/cable.c @@ -32,6 +32,7 @@ extern cable_driver_t byteblaster_cable_driver; extern cable_driver_t dlc5_cable_driver; extern cable_driver_t ea253_cable_driver; extern cable_driver_t ei012_cable_driver; +extern cable_driver_t mpcbdm_cable_driver; extern cable_driver_t wiggler_cable_driver; uint32_t frequency = 0; @@ -41,6 +42,7 @@ cable_driver_t *cable_drivers[] = { &dlc5_cable_driver, &ea253_cable_driver, &ei012_cable_driver, + &mpcbdm_cable_driver, &wiggler_cable_driver, NULL /* last must be NULL */ }; diff --git a/jtag/src/tap/cable/mpcbdm.c b/jtag/src/tap/cable/mpcbdm.c new file mode 100644 index 00000000..ec095f58 --- /dev/null +++ b/jtag/src/tap/cable/mpcbdm.c @@ -0,0 +1,121 @@ +/* + * $Id$ + * + * Mpcbdm JTAG Cable Driver + * Copyright (C) 2002, 2003 ETC s.r.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. + * Modified for Mpcbdm by Christian Pellegrin , 2003. + * + * Documentation: + * [1] http://www.vas-gmbh.de/software/mpcbdm/ + * + */ + +#include + +#include "cable.h" +#include "state.h" + +/* + * data + */ +#define TDI 1 +#define TCK 0 +#define TMS 2 + +/* + * control + */ +#define TRST 1 +#define TRST1 3 + +/* + * status + */ +#define TDO 5 + +static unsigned int port; + +static int +mpcbdm_init( unsigned int aport ) +{ + tap_state_init(); + port = aport; + if (((port + 3 <= 0x400) && ioperm( port, 3, 1 )) || ((port + 3 > 0x400) && iopl( 3 ))) + return 0; + + outb( (1 << TRST) | (1 << TRST1), port + 2 ); + tap_state_set_trst( 1 ); + return 1; +} + +static void +mpcbdm_done( void ) +{ + if (port + 3 <= 0x400) + ioperm( port, 3, 0 ); + else + iopl( 0 ); + + tap_state_done(); +} + +static void +mpcbdm_clock( int tms, int tdi ) +{ + int trst = tap_state_get_trst(); + + tms &= 1; + tdi &= 1; + + outb( (0 << TCK) | (tms << TMS) | (tdi << TDI), port ); + outb( (trst << TRST) | (trst << TRST1), port + 2 ); + cable_wait(); + outb( (1 << TCK) | (tms << TMS) | (tdi << TDI), port ); + outb( (trst << TRST) | (trst << TRST1), port ); + cable_wait(); + + tap_state_clock( tms ); +} + +static int +mpcbdm_get_tdo( void ) +{ + outb( (0 << TCK), port ); + outb( (tap_state_get_trst() << TRST) | (tap_state_get_trst() << TRST1), port + 2 ); + cable_wait(); + return ((inb( port + 1 ) ^ 0x80) >> TDO) & 1; /* BUSY is inverted */ +} + +static void +mpcbdm_set_trst( int new_trst ) +{ + tap_state_set_trst( new_trst ); + outb( (new_trst & 1) << TRST | (new_trst & 1) << TRST1, port + 2 ); +} + +cable_driver_t mpcbdm_cable_driver = { + "MPCBDM", + "Mpcbdm JTAG cable", + mpcbdm_init, + mpcbdm_done, + mpcbdm_clock, + mpcbdm_get_tdo, + mpcbdm_set_trst +};