From e1179f5534daa3401f95ef0e3a767c52123d83ac Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Tue, 1 Jul 2003 11:54:57 +0000 Subject: [PATCH] 2003-07-01 Marcel Telka * include/bus.h (new_sh7750r_bus, new_bcm1250_bus): New function declarations (patch 753300, Matan Ziv-Av). * src/bus/Makefile.am (libbus_a_SOURCES): Added bcm1250.c and sh7750r.c (patch 753300, Matan Ziv-Av). * src/bus/bcm1250.c: New file (patch 753300, Matan Ziv-Av). * src/bus/sh7750r.c: Ditto. * src/cmd/detect.c (cmd_detect_run): Added bus driver for SH7750R and BCM1250 (patch 753300, Matan Ziv-Av). git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@490 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 8 + jtag/NEWS | 1 + jtag/include/bus.h | 2 + jtag/src/bus/Makefile.am | 4 +- jtag/src/bus/bcm1250.c | 467 +++++++++++++++++++++++++++++++++++++++ jtag/src/bus/sh7750r.c | 346 +++++++++++++++++++++++++++++ jtag/src/cmd/detect.c | 4 + 7 files changed, 831 insertions(+), 1 deletion(-) create mode 100644 jtag/src/bus/bcm1250.c create mode 100644 jtag/src/bus/sh7750r.c diff --git a/jtag/ChangeLog b/jtag/ChangeLog index 260e2339..5f3fda04 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,11 @@ +2003-07-01 Marcel Telka + + * include/bus.h (new_sh7750r_bus, new_bcm1250_bus): New function declarations (patch 753300, Matan Ziv-Av). + * src/bus/Makefile.am (libbus_a_SOURCES): Added bcm1250.c and sh7750r.c (patch 753300, Matan Ziv-Av). + * src/bus/bcm1250.c: New file (patch 753300, Matan Ziv-Av). + * src/bus/sh7750r.c: Ditto. + * src/cmd/detect.c (cmd_detect_run): Added bus driver for SH7750R and BCM1250 (patch 753300, Matan Ziv-Av). + 2003-06-19 Marcel Telka * include/jtag.h (discovery): Removed 'filename' parameter. diff --git a/jtag/NEWS b/jtag/NEWS index bd640623..c724d6cb 100644 --- a/jtag/NEWS +++ b/jtag/NEWS @@ -5,6 +5,7 @@ See libbrux/NEWS for more news. * Fixed bug with SELECT, AUTOFD, and STROBE signals handling (bug 745824). * Added new commands 'peek' and 'poke' (patch 747447, Matan Ziv-Av). * Fixed bugs in SH7727 bus driver (thanks to Rainer Dörken). + * Added bus drivers for Hitachi SH7750R and Broadcom BCM1250 (patch 753300, Matan Ziv-Av). * Added bus width detection using MD3 and MD4 signals in SH7727 bus driver (thanks to Rainer Dörken). * Changes in 'discovery' command: diff --git a/jtag/include/bus.h b/jtag/include/bus.h index d1c2b241..3a0deac3 100644 --- a/jtag/include/bus.h +++ b/jtag/include/bus.h @@ -35,5 +35,7 @@ bus_t *new_sa1110_bus( chain_t *chain, int pn ); bus_t *new_pxa250_bus( chain_t *chain, int pn ); bus_t *new_ixp425_bus( chain_t *chain, int pn ); bus_t *new_sh7727_bus( chain_t *chain, int pn ); +bus_t *new_sh7750r_bus( chain_t *chain, int pn ); +bus_t *new_bcm1250_bus( chain_t *chain, int pn ); #endif /* BUS_H */ diff --git a/jtag/src/bus/Makefile.am b/jtag/src/bus/Makefile.am index 414d6245..7ffbd9c0 100644 --- a/jtag/src/bus/Makefile.am +++ b/jtag/src/bus/Makefile.am @@ -26,7 +26,9 @@ include $(top_srcdir)/Makefile.rules noinst_LIBRARIES = libbus.a libbus_a_SOURCES = \ + bcm1250.c \ ixp425.c \ pxa2x0.c \ sa1110.c \ - sh7727.c + sh7727.c \ + sh7750r.c diff --git a/jtag/src/bus/bcm1250.c b/jtag/src/bus/bcm1250.c new file mode 100644 index 00000000..664d4eef --- /dev/null +++ b/jtag/src/bus/bcm1250.c @@ -0,0 +1,467 @@ +//#define USE_BCM_EJTAG +/* + * $Id$ + * + * 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 Matan Ziv-Av. + * + */ + +#include +#include +#include + +#include "config.h" +#include "part.h" +#include "bus.h" +#include "chain.h" +#include "bssignal.h" + +#ifdef USE_BCM_EJTAG +int bcm1250_ejtag_do(bus_t *, uint64_t, uint64_t, int, int, unsigned char *, int); +#endif +typedef struct { + chain_t *chain; + part_t *part; + signal_t *io_ad[32]; + signal_t *io_cs_l[7]; + signal_t *io_rw; + signal_t *io_wr_l; + signal_t *io_oe_l; +} bus_params_t; + +#define CHAIN ((bus_params_t *) bus->params)->chain +#define PART ((bus_params_t *) bus->params)->part + +#define IO_AD ((bus_params_t *) bus->params)->io_ad +#define IO_CS_L ((bus_params_t *) bus->params)->io_cs_l +#define IO_RW ((bus_params_t *) bus->params)->io_rw +#define IO_WR_L ((bus_params_t *) bus->params)->io_wr_l +#define IO_OE_L ((bus_params_t *) bus->params)->io_oe_l + +static void +setup_address( bus_t *bus, uint32_t a ) +{ + int i; + part_t *p = PART; + + for (i = 0; i < 24; i++) { + part_set_signal( p, IO_AD[i], 1, (a >> i) & 1 ); + } +} + +static void +set_data_in( bus_t *bus ) +{ + int i; + part_t *p = PART; + + for (i = 0; i < 8; i++) { + part_set_signal( p, IO_AD[i+24], 0, 0 ); + } +} + +static void +setup_data( bus_t *bus, uint32_t d ) +{ + int i; + part_t *p = PART; + + for (i = 0; i < 8; i++) { + part_set_signal( p, IO_AD[i+24], 1, (d >> i) & 1 ); + } +} + +#ifndef USE_BCM_EJTAG +void +bcm1250_bus_read_start( bus_t *bus, uint32_t adr ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + + part_set_signal( p, IO_CS_L[0], 1, 0 ); + part_set_signal( p, IO_CS_L[1], 1, 1 ); + part_set_signal( p, IO_CS_L[2], 1, 1 ); + part_set_signal( p, IO_CS_L[3], 1, 1 ); + part_set_signal( p, IO_CS_L[4], 1, 1 ); + part_set_signal( p, IO_CS_L[5], 1, 1 ); + part_set_signal( p, IO_CS_L[6], 1, 1 ); + part_set_signal( p, IO_CS_L[7], 1, 1 ); + part_set_signal( p, IO_RW, 1, 1 ); + part_set_signal( p, IO_WR_L, 1, 1 ); + part_set_signal( p, IO_OE_L, 1, 0 ); + + setup_address( bus, adr ); + set_data_in( bus ); + + chain_shift_data_registers( chain, 0 ); +} + +uint32_t +bcm1250_bus_read_next( bus_t *bus , uint32_t adr ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + + setup_address( bus, adr ); + chain_shift_data_registers( chain, 1 ); + + { + int i; + uint32_t d = 0; + + for (i = 0; i < 8; i++) { + d |= (uint32_t) (part_get_signal( p, IO_AD[i+24] ) << i); + } + + return d; + } +} + +uint32_t +bcm1250_bus_read_end( bus_t *bus ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + + part_set_signal( p, IO_CS_L[0], 1, 1 ); + part_set_signal( p, IO_OE_L, 1, 1 ); + chain_shift_data_registers( chain, 1 ); + + { + int i; + uint32_t d = 0; + + for (i = 0; i < 8; i++) { + d |= (uint32_t) (part_get_signal( p, IO_AD[i+24] ) << i); + } + + return d; + } +} + +uint32_t +bcm1250_bus_read( bus_t *bus, uint32_t adr ) +{ + uint32_t i; + bcm1250_bus_read_start( bus, adr ); + i=bcm1250_bus_read_end( bus ); + return i; +} + +void +bcm1250_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + + part_set_signal( p, IO_CS_L[0], 1, 0 ); + part_set_signal( p, IO_CS_L[1], 1, 1 ); + part_set_signal( p, IO_CS_L[2], 1, 1 ); + part_set_signal( p, IO_CS_L[3], 1, 1 ); + part_set_signal( p, IO_CS_L[4], 1, 1 ); + part_set_signal( p, IO_CS_L[5], 1, 1 ); + part_set_signal( p, IO_CS_L[6], 1, 1 ); + part_set_signal( p, IO_CS_L[7], 1, 1 ); + part_set_signal( p, IO_RW, 1, 0 ); + part_set_signal( p, IO_WR_L, 1, 1 ); + part_set_signal( p, IO_OE_L, 1, 1 ); + + setup_address( bus, adr ); + setup_data( bus, data ); + + chain_shift_data_registers( chain, 0 ); + + part_set_signal( p, IO_WR_L, 1, 0 ); + chain_shift_data_registers( chain, 0 ); + + part_set_signal( p, IO_WR_L, 1, 1 ); + chain_shift_data_registers( chain, 0 ); +} + +#else /* BCM_EJTAG */ +int addr; +uint64_t base = 0x1fc00000; +uint32_t bcm1250_bus_read(bus_t *bus, uint32_t adr ) { + unsigned char buf[32]; + bcm1250_ejtag_do(bus, adr+base, 0, 1, 0, buf, 0); + return buf[adr&0x1f]; + +} + +uint32_t bcm1250_bus_read_next(bus_t *bus, uint32_t adr ) { + uint32_t t; + t=bcm1250_bus_read(bus, addr); + addr=adr; + return t; +} + +uint32_t bcm1250_bus_read_end(bus_t *bus) { + return bcm1250_bus_read(bus, addr); +} + +void bcm1250_bus_read_start(bus_t *bus, uint32_t adr ) { +addr=adr; +} + +void +bcm1250_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { + unsigned char buf[32]; + bcm1250_ejtag_do(bus, adr+base, data, 0, 0, buf, 0); +} + +#endif + +static unsigned int +bcm1250_bus_width( bus_t *bus, uint32_t addr) +{ + return 8; +} + +static void +bcm1250_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +static void +bcm1250_bus_free( bus_t *bus ) +{ + free( bus->params ); + free( bus ); +} + +static const bus_t bcm1250_bus = { + NULL, + bcm1250_bus_prepare, + bcm1250_bus_width, + bcm1250_bus_read_start, + bcm1250_bus_read_next, + bcm1250_bus_read_end, + bcm1250_bus_read, + bcm1250_bus_write, + bcm1250_bus_free +}; + +bus_t * +new_bcm1250_bus( chain_t *chain, int pn ) +{ + bus_t *bus; + char buff[10]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= pn || pn < 0) + return NULL; + + bus = malloc( sizeof (bus_t) ); + if (!bus) + return NULL; + + memcpy( bus, &bcm1250_bus, sizeof (bus_t) ); + + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[pn]; + + for (i = 0; i < 32; i++) { + sprintf( buff, "IO_AD%d", i ); + IO_AD[i] = part_find_signal( PART, buff ); + if (!IO_AD[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 8; i++) { + sprintf( buff, "IO_CS_L%d", i ); + IO_CS_L[i] = part_find_signal( PART, buff ); + if (!IO_CS_L[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + IO_RW = part_find_signal( PART, "IO_RW" ); + if (!IO_RW) { + printf( _("signal '%s' not found\n"), "IO_RW" ); + failed = 1; + } + IO_WR_L = part_find_signal( PART, "IO_WR_L" ); + if (!IO_WR_L) { + printf( _("signal '%s' not found\n"), "IO_WR_L" ); + failed = 1; + } + IO_OE_L = part_find_signal( PART, "IO_OE_L" ); + if (!IO_OE_L) { + printf( _("signal '%s' not found\n"), "IO_OE_L" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + + +#ifdef USE_BCM_EJTAG +int bcm1250_ejtag_do(bus_t *bus, uint64_t ad, uint64_t da, int read, int type, + unsigned char *buf, int verbose) { + + part_t *p = PART; + chain_t *chain = CHAIN; + char ctrl[15]="010000000000"; + char addrr[80]="0000" "111" "000" + "11111111111111111111111111111111" + "00000000" "00011111" "11000000" "00000000" "000"; + int j, k, n, m; + uint64_t a; + + if(verbose)printf("BCM1250: ejtag_do(%08Lx, %08Lx, %i, %i)\n", ad, da, read, type); + + a=ad>>5; + for(j=0;j<35;j++) { + addrr[76-j]='0'+(a&1); + a>>=1; + } + + j=(1<0){ + j--; + p->active_instruction->data_register->in->data[j]=ctrl[k++]&1; + } + chain_shift_data_registers( chain, 1 ); + + + if(read) { + addrr[7]='0'; + addrr[8]='0'; + addrr[9]='0'; + } else { + addrr[7]='0'; + addrr[8]='1'; + addrr[9]='0'; + } + + part_set_instruction( p, "ADDR" ); + chain_shift_instructions(chain); + j=strlen(addrr); + k=0; + while(j>0){ + j--; + p->active_instruction->data_register->in->data[j]=addrr[k++]&1; + } + chain_shift_data_registers( chain, 0 ); + + if(!read) { + part_set_instruction( p, "DATA"); + chain_shift_instructions(chain); + for(j=0;j<277;j++) + p->active_instruction->data_register->in->data[j]=j&1; + p->active_instruction->data_register->in->data[259]=1; + p->active_instruction->data_register->in->data[258]=0; + p->active_instruction->data_register->in->data[257]=0; + p->active_instruction->data_register->in->data[256]=1; + j=0; + if(type<5) { + k=256-(n+(1<active_instruction->data_register->in->data[k+j]=da&1; + da>>=1; + j++; + } + } else { + int r; + for(r=0; r<32; r++) { + int s,t; + t=buf[r]; + for(s=0;s<8;s++) { + p->active_instruction->data_register->in->data[248-r*8+s]=t&1; + t>>=1; + } + } + } + chain_shift_data_registers( chain, 0 ); + } + + + ctrl[2]='1'; + if(!read)ctrl[3]='1'; + part_set_instruction( p, "CONTROLL" ); + chain_shift_instructions(chain); + j=strlen(ctrl); + k=0; + while(j>0){ + j--; + p->active_instruction->data_register->in->data[j]=ctrl[k++]&1; + } + chain_shift_data_registers( chain, 1 ); + if(verbose || read) { + volatile int q; + int to; + + to=5; + for(q=0;q<100;q++); + part_set_instruction( p, "DATA"); + chain_shift_instructions(chain); + chain_shift_data_registers( chain, 1 ); + + while((p->active_instruction->data_register->out->data[276-17]==0) && to--) { + chain_shift_data_registers( chain, 1 ); + } + for(j=n;jactive_instruction->data_register->out->data[255-(j*8)-m]&1; + } + if(verbose)printf("%02x ",buf[j]); + } + if(verbose) { + printf("\n"); + + printf(" status:\n"); + for(j=0;j<21;j++) { + printf("%c", '0'+p->active_instruction->data_register->out->data[276-j]); + if((j==5) || (j==11) || (j==12) || (j==16) || (j==17))printf(" "); + } + printf("\n"); + } + } + return 0; +} +#endif diff --git a/jtag/src/bus/sh7750r.c b/jtag/src/bus/sh7750r.c new file mode 100644 index 00000000..2bb4689d --- /dev/null +++ b/jtag/src/bus/sh7750r.c @@ -0,0 +1,346 @@ +/* + * $Id$ + * + * Copyright (C) 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 Matan Ziv-Av , 2003. + * Modified by Marcel Telka , 2003. + * + */ + +#include + +#include +#include +#include + +#include "part.h" +#include "bus.h" +#include "chain.h" +#include "bssignal.h" + +typedef struct { + chain_t *chain; + part_t *part; + signal_t *a[26]; + signal_t *d[64]; + signal_t *cs[7]; + signal_t *we[4]; + signal_t *rdwr; + signal_t *rd; + signal_t *rdwr2; + signal_t *rd2; +} bus_params_t; + +#define CHAIN ((bus_params_t *) bus->params)->chain +#define PART ((bus_params_t *) bus->params)->part +#define A ((bus_params_t *) bus->params)->a +#define D ((bus_params_t *) bus->params)->d +#define CS ((bus_params_t *) bus->params)->cs +#define WE ((bus_params_t *) bus->params)->we +#define RDWR ((bus_params_t *) bus->params)->rdwr +#define RD ((bus_params_t *) bus->params)->rd +#define RDWR2 ((bus_params_t *) bus->params)->rdwr2 +#define RD2 ((bus_params_t *) bus->params)->rd2 + +static void +setup_address( bus_t *bus, uint32_t a ) +{ + int i; + part_t *p = PART; + + for (i = 0; i < 26; i++) + part_set_signal( p, A[i], 1, (a >> i) & 1 ); +} + +static void +set_data_in( bus_t *bus ) +{ + int i; + part_t *p = PART; + + for (i = 0; i < 32; i++) + part_set_signal( p, D[i], 0, 0 ); +} + +static void +setup_data( bus_t *bus, uint32_t d ) +{ + int i; + part_t *p = PART; + + for (i = 0; i < 32; i++) + part_set_signal( p, D[i], 1, (d >> i) & 1 ); +} + +static void +sh7750r_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +static void +sh7750r_bus_read_start( bus_t *bus, uint32_t adr ) +{ + part_t *p = PART; + int cs[8]; + int i; + + for (i = 0; i < 8; i++) + cs[i] = 1; + cs[(adr & 0x1C000000) >> 26] = 0; + + part_set_signal( p, CS[0], 1, cs[0] ); + part_set_signal( p, CS[1], 1, cs[1] ); + part_set_signal( p, CS[2], 1, cs[2] ); + part_set_signal( p, CS[3], 1, cs[3] ); + part_set_signal( p, CS[4], 1, cs[4] ); + part_set_signal( p, CS[5], 1, cs[5] ); + part_set_signal( p, CS[6], 1, cs[6] ); + part_set_signal( p, RDWR, 1, 1 ); + part_set_signal( p, RDWR2, 1, 1 ); + part_set_signal( p, WE[0], 1, 1 ); + part_set_signal( p, WE[1], 1, 1 ); + part_set_signal( p, WE[2], 1, 1 ); + part_set_signal( p, WE[3], 1, 1 ); + part_set_signal( p, RD, 1, 0 ); + part_set_signal( p, RD2, 1, 0 ); + + setup_address( bus, adr ); + set_data_in( bus ); + chain_shift_data_registers( CHAIN, 0 ); +} + +static uint32_t +sh7750r_bus_read_next( bus_t *bus, uint32_t adr ) +{ + part_t *p = PART; + int i; + uint32_t d = 0; + + setup_address( bus, adr ); + chain_shift_data_registers( CHAIN, 1 ); + + for (i = 0; i < 32; i++) + d |= (uint32_t) (part_get_signal( p, D[i] ) << i); + + return d; +} + +static uint32_t +sh7750r_bus_read_end( bus_t *bus ) +{ + part_t *p = PART; + int cs[8]; + int i; + uint32_t d = 0; + + for (i = 0; i < 8; i++) + cs[i] = 1; + + part_set_signal( p, CS[0], 1, cs[0] ); + part_set_signal( p, CS[1], 1, cs[1] ); + part_set_signal( p, CS[2], 1, cs[2] ); + part_set_signal( p, CS[3], 1, cs[3] ); + part_set_signal( p, CS[4], 1, cs[4] ); + part_set_signal( p, CS[5], 1, cs[5] ); + part_set_signal( p, CS[6], 1, cs[6] ); + + part_set_signal( p, RD, 1, 1 ); + part_set_signal( p, RD2, 1, 1 ); + chain_shift_data_registers( CHAIN, 1 ); + + for (i = 0; i < 32; i++) + d |= (uint32_t) (part_get_signal( p, D[i] ) << i); + + return d; +} + +static uint32_t +sh7750r_bus_read( bus_t *bus, uint32_t adr ) +{ + sh7750r_bus_read_start( bus, adr ); + return sh7750r_bus_read_end( bus ); +} + +static void +sh7750r_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) +{ + chain_t *chain = CHAIN; + part_t *p = PART; + int cs[8]; + int i; + + for (i = 0; i < 8 ; i++) + cs[i] = 1; + cs[(adr & 0x1C000000) >> 26] = 0; + + part_set_signal( p, CS[0], 1, cs[0] ); + part_set_signal( p, CS[1], 1, cs[1] ); + part_set_signal( p, CS[2], 1, cs[2] ); + part_set_signal( p, CS[3], 1, cs[3] ); + part_set_signal( p, CS[4], 1, cs[4] ); + part_set_signal( p, CS[5], 1, cs[5] ); + part_set_signal( p, CS[6], 1, cs[6] ); + + part_set_signal( p, RDWR, 1, 0 ); + part_set_signal( p, RDWR2, 1, 0 ); + part_set_signal( p, WE[0], 1, 1 ); + part_set_signal( p, WE[1], 1, 1 ); + part_set_signal( p, WE[2], 1, 1 ); + part_set_signal( p, WE[3], 1, 1 ); + part_set_signal( p, RD, 1, 1 ); + part_set_signal( p, RD2, 1, 1 ); + + setup_address( bus, adr ); + setup_data( bus, data ); + + chain_shift_data_registers( chain, 0 ); + + part_set_signal( p, WE[0], 1, 0 ); + part_set_signal( p, WE[1], 1, 0 ); + part_set_signal( p, WE[2], 1, 0 ); + part_set_signal( p, WE[3], 1, 0 ); + + chain_shift_data_registers( chain, 0 ); + + part_set_signal( p, WE[0], 1, 1 ); + part_set_signal( p, WE[1], 1, 1 ); + part_set_signal( p, WE[2], 1, 1 ); + part_set_signal( p, WE[3], 1, 1 ); + + chain_shift_data_registers( chain, 0 ); +} + +static unsigned int +sh7750r_bus_width( bus_t *bus, uint32_t adr ) +{ + return 32; +} + +static void +sh7750r_bus_free( bus_t *bus ) +{ + free( bus->params ); + free( bus ); +} + +static const bus_t sh7750r_bus = { + NULL, + sh7750r_bus_prepare, + sh7750r_bus_width, + sh7750r_bus_read_start, + sh7750r_bus_read_next, + sh7750r_bus_read_end, + sh7750r_bus_read, + sh7750r_bus_write, + sh7750r_bus_free +}; + +bus_t * +new_sh7750r_bus( chain_t *chain, int pn ) +{ + bus_t *bus; + char buff[10]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= pn || pn < 0) + return NULL; + + bus = malloc( sizeof (bus_t) ); + if (!bus) + return NULL; + + memcpy( bus, &sh7750r_bus, sizeof (bus_t) ); + + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[pn]; + + for (i = 0; i < 26; i++) { + sprintf( buff, "A%d", i ); + A[i] = part_find_signal( PART, buff ); + if (!A[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 32; i++) { + sprintf( buff, "D%d", i ); + D[i] = part_find_signal( PART, buff ); + if (!D[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 7; i++) { + sprintf( buff, "CS%d", i ); + CS[i] = part_find_signal( PART, buff ); + if (!CS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 8; i++) { + sprintf( buff, "WE%d", i ); + WE[i] = part_find_signal( PART, buff ); + if (!WE[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + RDWR = part_find_signal( PART, "RDWR" ); + if (!RDWR) { + printf( _("signal '%s' not found\n"), "RDWR" ); + failed = 1; + } + RD = part_find_signal( PART, "RD" ); + if (!RD) { + printf( _("signal '%s' not found\n"), "RD" ); + failed = 1; + } + RDWR2 = part_find_signal( PART, "RDWR2" ); + if (!RDWR2) { + printf( _("signal '%s' not found\n"), "RDWR2" ); + failed = 1; + } + RD2 = part_find_signal( PART, "RD2" ); + if (!RD2) { + printf( _("signal '%s' not found\n"), "RD2" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} diff --git a/jtag/src/cmd/detect.c b/jtag/src/cmd/detect.c index 82176753..c7f32d55 100644 --- a/jtag/src/cmd/detect.c +++ b/jtag/src/cmd/detect.c @@ -66,6 +66,10 @@ cmd_detect_run( char *params[] ) bus = new_ixp425_bus( chain, 0 ); if (strcmp( chain->parts->parts[0]->part, "SH7727" ) == 0) bus = new_sh7727_bus( chain, 0 ); + if (strcmp( chain->parts->parts[0]->part, "SH7750R" ) == 0) + bus = new_sh7750r_bus( chain, 0 ); + if (strcmp( chain->parts->parts[0]->part, "BCM1250" ) == 0) + bus = new_bcm1250_bus( chain, 0 ); return 1; }