From 2ceeefb0224e4f25d957327ecec656466031b0d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnim=20L=C3=A4uger?= Date: Mon, 9 Jun 2008 21:11:01 +0000 Subject: [PATCH] [ 1984813 ] Bus driver cleanup, first step of part 4) (Hartley Sweeten) git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1277 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 12 + jtag/src/bus/au1500.c | 174 +++--- jtag/src/bus/avr32.c | 402 ++++++++------ jtag/src/bus/bcm1250.c | 357 +++++++----- jtag/src/bus/bf533_ezkit.c | 320 ++++++----- jtag/src/bus/bf533_stamp.c | 316 ++++++----- jtag/src/bus/bf537_stamp.c | 324 ++++++----- jtag/src/bus/bf548_ezkit.c | 322 ++++++----- jtag/src/bus/bf561_ezkit.c | 320 ++++++----- jtag/src/bus/ejtag.c | 166 +++--- jtag/src/bus/fjmem.c | 995 ++++++++++++++++----------------- jtag/src/bus/h7202.c | 252 +++++---- jtag/src/bus/ixp425.c | 242 ++++---- jtag/src/bus/jopcyc.c | 620 +++++++++++---------- jtag/src/bus/lh7a400.c | 304 +++++----- jtag/src/bus/mpc5200.c | 260 +++++---- jtag/src/bus/mpc824x.c | 588 +++++++++++--------- jtag/src/bus/ppc405ep.c | 238 ++++---- jtag/src/bus/ppc440gx_ebc8.c | 234 ++++---- jtag/src/bus/prototype.c | 354 ++++++------ jtag/src/bus/pxa2x0.c | 755 +++++++++++++------------ jtag/src/bus/s3c4510x.c | 405 +++++++------- jtag/src/bus/sa1110.c | 250 +++++---- jtag/src/bus/sh7727.c | 318 ++++++----- jtag/src/bus/sh7750r.c | 282 ++++++---- jtag/src/bus/sh7751r.c | 263 +++++---- jtag/src/bus/sharc21065l.c | 278 ++++++---- jtag/src/bus/slsup3.c | 396 +++++++------ jtag/src/bus/tx4925.c | 283 +++++----- jtag/src/bus/zefant-xs3.c | 1017 +++++++++++++++++----------------- 30 files changed, 6010 insertions(+), 5037 deletions(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index 72833d98..fbe6eb1a 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,5 +1,17 @@ 2008-06-09 Arnim Laeuger + * src/bus/bf548_ezkit.c, src/bus/fjmem.c, src/bus/ppc405ep.c, + src/bus/sh7727.c, src/bus/prototype.c, src/bus/sa1110.c, + src/bus/ppc440gx_ebc8.c, src/bus/tx4925.c, src/bus/sh7750r.c, + src/bus/pxa2x0.c, src/bus/bf533_stamp.c, src/bus/bf533_ezkit.c, + src/bus/bf537_stamp.c, src/bus/ixp425.c, src/bus/avr32.c, + src/bus/h7202.c, src/bus/zefant-xs3.c, src/bus/mpc824x.c, + src/bus/bcm1250.c, src/bus/sharc21065l.c, src/bus/au1500.c, + src/bus/lh7a400.c, src/bus/sh7751r.c, src/bus/mpc5200.c, + src/bus/jopcyc.c, src/bus/bf561_ezkit.c, src/bus/slsup3.c, + src/bus/s3c4510x.c, src/bus/ejtag.c: + [ 1984813 ] Bus driver cleanup, first step of part 4) (Hartley Sweeten) + * src/svf/svf_flex.l, src/flash/flash.c (flashmem): avoid '\r' in i18n strings (Hartley Sweeten) * po/fr.po, po/rw.po, po/sk.po: remove '\r' diff --git a/jtag/src/bus/au1500.c b/jtag/src/bus/au1500.c index 35fd3006..59a5376d 100644 --- a/jtag/src/bus/au1500.c +++ b/jtag/src/bus/au1500.c @@ -21,7 +21,7 @@ * Written by ZHANG WEI , 2003 * * Documentation: - * [1] AMD, "AMD Alchemy Solutions AU1500 Processor Data Book - + * [1] AMD, "AMD Alchemy Solutions AU1500 Processor Data Book - * Preliminary Information", June 2003, Publication ID: 30361B * */ @@ -60,61 +60,10 @@ typedef struct{ #define nROE ((bus_params_t *) bus->params)->nroe #define RD ((bus_params_t *) bus->params)->rd -static void -setup_address( bus_t *bus, uint32_t a) -{ - int i; - part_t *p = PART; - - for( i = 0; i < 32; i++) - part_set_signal( p, RAD[i], 1, (a >>i) & 1); -} - -static int au1500_bus_area(bus_t * bus, uint32_t addr, bus_area_t * area); - -static void -set_data_in( bus_t *bus ) -{ - int i; - part_t *p = PART; - bus_area_t area; - - au1500_bus_area( bus, 0, &area); - - for( i = 0; i < area.width; i++ ) - part_set_signal( p, RD[i], 0, 0 ); - -} - -static uint32_t -get_data_out( bus_t *bus ) -{ - int i; - part_t *p = PART; - bus_area_t area; - uint32_t d = 0; - - au1500_bus_area( bus, 0, &area); - - for( i = 0; i < area.width; i++ ) - d |= (uint32_t)(part_get_signal( p, RD[i] ) << i); - - return d; -} - -static void -setup_data( bus_t *bus, uint32_t d) -{ - int i; - part_t *p = PART; - bus_area_t area; - - au1500_bus_area( bus, 0, &area); - - for( i = 0; i < area.width; i++ ) - part_set_signal( p, RD[i], 1, ( d>>i ) & 1 ); -} - +/** + * bus->driver->(*new_bus) + * + */ static bus_t *au1500_bus_new( chain_t *chain, char *cmd_params[] ) { bus_t *bus; @@ -122,14 +71,14 @@ static bus_t *au1500_bus_new( chain_t *chain, char *cmd_params[] ) int i; int failed = 0; - + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) return NULL; bus = calloc( 1, sizeof (bus_t) ); if (!bus) return NULL; - + bus->driver = &au1500_bus; bus->params = calloc( 1, sizeof(bus_params_t) ); if (!bus->params){ @@ -190,10 +139,40 @@ static bus_t *au1500_bus_new( chain_t *chain, char *cmd_params[] ) } return bus; - + +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +au1500_bus_printinfo( bus_t *bus) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("AU1500 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); } -static int +/** + * bus->driver->(*prepare) + * + */ +static void +au1500_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int au1500_bus_area(bus_t *bus, uint32_t addr, bus_area_t *area) { area->description = NULL; @@ -204,28 +183,67 @@ au1500_bus_area(bus_t *bus, uint32_t addr, bus_area_t *area) return 0; - + } static void -au1500_bus_printinfo( bus_t *bus) +setup_address( bus_t *bus, uint32_t a) { int i; + part_t *p = PART; - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("AU1500 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); + for( i = 0; i < 32; i++) + part_set_signal( p, RAD[i], 1, (a >>i) & 1); } static void -au1500_bus_prepare( bus_t *bus ) +set_data_in( bus_t *bus ) { - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); + int i; + part_t *p = PART; + bus_area_t area; + + au1500_bus_area( bus, 0, &area); + + for( i = 0; i < area.width; i++ ) + part_set_signal( p, RD[i], 0, 0 ); + } -static void +static uint32_t +get_data_out( bus_t *bus ) +{ + int i; + part_t *p = PART; + bus_area_t area; + uint32_t d = 0; + + au1500_bus_area( bus, 0, &area); + + for( i = 0; i < area.width; i++ ) + d |= (uint32_t)(part_get_signal( p, RD[i] ) << i); + + return d; +} + +static void +setup_data( bus_t *bus, uint32_t d) +{ + int i; + part_t *p = PART; + bus_area_t area; + + au1500_bus_area( bus, 0, &area); + + for( i = 0; i < area.width; i++ ) + part_set_signal( p, RD[i], 1, ( d>>i ) & 1 ); +} + +/** + * bus->driver->(*read_start) + * + */ +static void au1500_bus_read_start( bus_t *bus, uint32_t adr ) { part_t *p = PART; @@ -244,6 +262,10 @@ au1500_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t au1500_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -255,6 +277,10 @@ au1500_bus_read_next( bus_t *bus, uint32_t adr ) return get_data_out( bus ); } +/** + * bus->driver->(*read_end) + * + */ static uint32_t au1500_bus_read_end( bus_t *bus ) { @@ -273,6 +299,10 @@ au1500_bus_read_end( bus_t *bus ) return get_data_out( bus ); } +/** + * bus->driver->(*read) + * + */ static uint32_t au1500_bus_read( bus_t *bus, uint32_t adr ) { @@ -280,6 +310,10 @@ au1500_bus_read( bus_t *bus, uint32_t adr ) return au1500_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void au1500_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { diff --git a/jtag/src/bus/avr32.c b/jtag/src/bus/avr32.c index 54015bb2..04ced148 100644 --- a/jtag/src/bus/avr32.c +++ b/jtag/src/bus/avr32.c @@ -418,189 +418,6 @@ nexus_memacc_write (bus_t * bus, uint32_t addr, uint32_t data, uint32_t rwcs) /* ------------------------------------------------------------------------- */ -static void -avr32_bus_printinfo (bus_t * bus) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - - printf (_("AVR32 multi-mode bus driver (JTAG part No. %d)\n"), i); -} - -static void -avr32_bus_prepare (bus_t * bus) -{ -} - -static void -avr32_bus_read_start (bus_t * bus, uint32_t addr) -{ - addr &= ADDR_MASK; - - DBG (DBG_BASIC, _("%s:addr=%08x\n"), __FUNCTION__, addr); - - switch (MODE) - { - case BUS_MODE_OCD: - case BUS_MODE_HSBC: - case BUS_MODE_HSBU: - part_set_instruction (PART, "MEMORY_WORD_ACCESS"); - mwa_scan_in_instr (bus); - mwa_scan_in_addr (bus, SLAVE, addr, ACCESS_MODE_READ); - break; - - case BUS_MODE_x8: - case BUS_MODE_x16: - case BUS_MODE_x32: - part_set_instruction (PART, "NEXUS_ACCESS"); - nexus_access_start (bus); - nexus_memacc_set_addr (bus, addr, RWCS_RD); - break; - } -} - -static uint32_t -avr32_bus_read_end (bus_t * bus) -{ - uint32_t data; - - switch (MODE) - { - case BUS_MODE_OCD: - case BUS_MODE_HSBC: - case BUS_MODE_HSBU: - mwa_scan_out_data (bus, &data); - break; - case BUS_MODE_x8: - case BUS_MODE_x16: - case BUS_MODE_x32: - nexus_memacc_read (bus, &data); - nexus_access_end (bus); - break; - } - - return data; -} - -static uint32_t -avr32_bus_read_next (bus_t * bus, uint32_t addr) -{ - uint32_t data; - - addr &= ADDR_MASK; - - switch (MODE) - { - case BUS_MODE_OCD: - case BUS_MODE_HSBC: - case BUS_MODE_HSBU: - data = avr32_bus_read_end (bus); - avr32_bus_read_start (bus, addr); - break; - case BUS_MODE_x8: - case BUS_MODE_x16: - case BUS_MODE_x32: - nexus_memacc_read (bus, &data); - nexus_memacc_set_addr (bus, addr, RWCS_RD); - break; - } - - return data; -} - -static uint32_t -avr32_bus_read (bus_t * bus, uint32_t addr) -{ - uint32_t ret; - - avr32_bus_read_start (bus, addr); - ret = avr32_bus_read_end (bus); - - return ret; -} - -static void -avr32_bus_write (bus_t * bus, uint32_t addr, uint32_t data) -{ - addr &= ADDR_MASK; - - switch (MODE) - { - case BUS_MODE_OCD: - case BUS_MODE_HSBC: - case BUS_MODE_HSBU: - part_set_instruction (PART, "MEMORY_WORD_ACCESS"); - mwa_write_word (bus, SLAVE, addr, data); - break; - case BUS_MODE_x8: - case BUS_MODE_x16: - case BUS_MODE_x32: - part_set_instruction (PART, "NEXUS_ACCESS"); - nexus_access_start (bus); - nexus_memacc_write (bus, addr, data, RWCS_WR); - nexus_access_end (bus); - break; - } -} - -static int -avr32_bus_area (bus_t * bus, uint32_t addr, bus_area_t * area) -{ - switch (MODE) - { - case BUS_MODE_HSBC: - area->description = "HSB memory space, cached"; - area->start = UINT32_C (0x00000000); - area->length = SAB_HSB_AREA_SIZE; - area->width = 32; - break; - case BUS_MODE_HSBU: - area->description = "HSB memory space, uncached"; - area->start = UINT32_C (0x00000000); - area->length = SAB_HSB_AREA_SIZE; - area->width = 32; - break; - case BUS_MODE_x8: - area->description = "HSB memory space, uncached"; - area->start = UINT32_C (0x00000000); - area->length = SAB_HSB_AREA_SIZE; - area->width = 8; - break; - case BUS_MODE_x16: - area->description = "HSB memory space, uncached"; - area->start = UINT32_C (0x00000000); - area->length = SAB_HSB_AREA_SIZE; - area->width = 16; - break; - case BUS_MODE_x32: - area->description = "HSB memory space, uncached"; - area->start = UINT32_C (0x00000000); - area->length = SAB_HSB_AREA_SIZE; - area->width = 32; - break; - case BUS_MODE_OCD: - if (addr < SAB_OCD_AREA_SIZE) - { - area->description = "OCD registers"; - area->start = UINT32_C (0x00000000); - area->length = SAB_OCD_AREA_SIZE; - area->width = 32; - break; - } - /* fallthrough */ - default: - area->description = NULL; - area->length = UINT64_C (0x100000000); - area->width = 0; - break; - } - - return 0; -} - static void avr32_bus_setup (bus_t * bus, chain_t * chain, part_t * part, unsigned int mode) @@ -658,6 +475,10 @@ check_instruction (part_t * part, const char *instr) return ret; } +/** + * bus->driver->(*new_bus) + * + */ static bus_t * avr32_bus_new (chain_t * chain, char *cmd_params[]) { @@ -742,6 +563,221 @@ avr32_bus_new (chain_t * chain, char *cmd_params[]) return bus; } +/** + * bus->driver->(*printinfo) + * + */ +static void +avr32_bus_printinfo (bus_t * bus) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + + printf (_("AVR32 multi-mode bus driver (JTAG part No. %d)\n"), i); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +avr32_bus_prepare (bus_t * bus) +{ +} + +/** + * bus->driver->(*area) + * + */ +static int +avr32_bus_area (bus_t * bus, uint32_t addr, bus_area_t * area) +{ + switch (MODE) + { + case BUS_MODE_HSBC: + area->description = "HSB memory space, cached"; + area->start = UINT32_C (0x00000000); + area->length = SAB_HSB_AREA_SIZE; + area->width = 32; + break; + case BUS_MODE_HSBU: + area->description = "HSB memory space, uncached"; + area->start = UINT32_C (0x00000000); + area->length = SAB_HSB_AREA_SIZE; + area->width = 32; + break; + case BUS_MODE_x8: + area->description = "HSB memory space, uncached"; + area->start = UINT32_C (0x00000000); + area->length = SAB_HSB_AREA_SIZE; + area->width = 8; + break; + case BUS_MODE_x16: + area->description = "HSB memory space, uncached"; + area->start = UINT32_C (0x00000000); + area->length = SAB_HSB_AREA_SIZE; + area->width = 16; + break; + case BUS_MODE_x32: + area->description = "HSB memory space, uncached"; + area->start = UINT32_C (0x00000000); + area->length = SAB_HSB_AREA_SIZE; + area->width = 32; + break; + case BUS_MODE_OCD: + if (addr < SAB_OCD_AREA_SIZE) + { + area->description = "OCD registers"; + area->start = UINT32_C (0x00000000); + area->length = SAB_OCD_AREA_SIZE; + area->width = 32; + break; + } + /* fallthrough */ + default: + area->description = NULL; + area->length = UINT64_C (0x100000000); + area->width = 0; + break; + } + + return 0; +} + +/** + * bus->driver->(*read_start) + * + */ +static void +avr32_bus_read_start (bus_t * bus, uint32_t addr) +{ + addr &= ADDR_MASK; + + DBG (DBG_BASIC, _("%s:addr=%08x\n"), __FUNCTION__, addr); + + switch (MODE) + { + case BUS_MODE_OCD: + case BUS_MODE_HSBC: + case BUS_MODE_HSBU: + part_set_instruction (PART, "MEMORY_WORD_ACCESS"); + mwa_scan_in_instr (bus); + mwa_scan_in_addr (bus, SLAVE, addr, ACCESS_MODE_READ); + break; + + case BUS_MODE_x8: + case BUS_MODE_x16: + case BUS_MODE_x32: + part_set_instruction (PART, "NEXUS_ACCESS"); + nexus_access_start (bus); + nexus_memacc_set_addr (bus, addr, RWCS_RD); + break; + } +} + +/** + * bus->driver->(*read_end) + * + */ +static uint32_t +avr32_bus_read_end (bus_t * bus) +{ + uint32_t data; + + switch (MODE) + { + case BUS_MODE_OCD: + case BUS_MODE_HSBC: + case BUS_MODE_HSBU: + mwa_scan_out_data (bus, &data); + break; + case BUS_MODE_x8: + case BUS_MODE_x16: + case BUS_MODE_x32: + nexus_memacc_read (bus, &data); + nexus_access_end (bus); + break; + } + + return data; +} + +/** + * bus->driver->(*read_next) + * + */ +static uint32_t +avr32_bus_read_next (bus_t * bus, uint32_t addr) +{ + uint32_t data; + + addr &= ADDR_MASK; + + switch (MODE) + { + case BUS_MODE_OCD: + case BUS_MODE_HSBC: + case BUS_MODE_HSBU: + data = avr32_bus_read_end (bus); + avr32_bus_read_start (bus, addr); + break; + case BUS_MODE_x8: + case BUS_MODE_x16: + case BUS_MODE_x32: + nexus_memacc_read (bus, &data); + nexus_memacc_set_addr (bus, addr, RWCS_RD); + break; + } + + return data; +} + +/** + * bus->driver->(*read) + * + */ +static uint32_t +avr32_bus_read (bus_t * bus, uint32_t addr) +{ + uint32_t ret; + + avr32_bus_read_start (bus, addr); + ret = avr32_bus_read_end (bus); + + return ret; +} + +/** + * bus->driver->(*write) + * + */ +static void +avr32_bus_write (bus_t * bus, uint32_t addr, uint32_t data) +{ + addr &= ADDR_MASK; + + switch (MODE) + { + case BUS_MODE_OCD: + case BUS_MODE_HSBC: + case BUS_MODE_HSBU: + part_set_instruction (PART, "MEMORY_WORD_ACCESS"); + mwa_write_word (bus, SLAVE, addr, data); + break; + case BUS_MODE_x8: + case BUS_MODE_x16: + case BUS_MODE_x32: + part_set_instruction (PART, "NEXUS_ACCESS"); + nexus_access_start (bus); + nexus_memacc_write (bus, addr, data, RWCS_WR); + nexus_access_end (bus); + break; + } +} + const bus_driver_t avr32_bus_driver = { "avr32", N_("Atmel AVR32 multi-mode bus driver, requires parameter\n" diff --git a/jtag/src/bus/bcm1250.c b/jtag/src/bus/bcm1250.c index 372b8cd5..6a453557 100644 --- a/jtag/src/bus/bcm1250.c +++ b/jtag/src/bus/bcm1250.c @@ -1,4 +1,3 @@ -//#define USE_BCM_EJTAG /* * $Id$ * @@ -38,9 +37,8 @@ #include "buses.h" #include "generic_bus.h" -#ifdef USE_BCM_EJTAG -int bcm1250_ejtag_do(bus_t *, uint64_t, uint64_t, int, int, unsigned char *, int); -#endif +//#define USE_BCM_EJTAG + typedef struct { chain_t *chain; part_t *part; @@ -60,6 +58,121 @@ typedef struct { #define IO_WR_L ((bus_params_t *) bus->params)->io_wr_l #define IO_OE_L ((bus_params_t *) bus->params)->io_oe_l +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +bcm1250_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[10]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = & bcm1250_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + 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; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +bcm1250_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Broadcom BCM1250 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +bcm1250_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +bcm1250_bus_area( bus_t *bus, uint32_t addr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 8; + + return 0; +} + +#ifndef USE_BCM_EJTAG + static void setup_address( bus_t *bus, uint32_t a ) { @@ -93,19 +206,11 @@ setup_data( bus_t *bus, uint32_t d ) } } -#ifndef USE_BCM_EJTAG +/** + * bus->driver->(*read_start) + * + */ static void -bcm1250_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Broadcom BCM1250 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -void bcm1250_bus_read_start( bus_t *bus, uint32_t adr ) { part_t *p = PART; @@ -129,7 +234,11 @@ bcm1250_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } -uint32_t +/** + * bus->driver->(*read_next) + * + */ +static uint32_t bcm1250_bus_read_next( bus_t *bus , uint32_t adr ) { part_t *p = PART; @@ -150,7 +259,11 @@ bcm1250_bus_read_next( bus_t *bus , uint32_t adr ) } } -uint32_t +/** + * bus->driver->(*read_end) + * + */ +static uint32_t bcm1250_bus_read_end( bus_t *bus ) { part_t *p = PART; @@ -172,7 +285,11 @@ bcm1250_bus_read_end( bus_t *bus ) } } -uint32_t +/** + * bus->driver->(*read) + * + */ +static uint32_t bcm1250_bus_read( bus_t *bus, uint32_t adr ) { uint32_t i; @@ -181,7 +298,11 @@ bcm1250_bus_read( bus_t *bus, uint32_t adr ) return i; } -void +/** + * bus->driver->(*write) + * + */ +static void bcm1250_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { part_t *p = PART; @@ -206,156 +327,41 @@ bcm1250_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) 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 */ +#else /* #ifndef USE_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 int -bcm1250_bus_area( bus_t *bus, uint32_t addr, bus_area_t *area ) -{ - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - area->width = 8; - - return 0; -} - -static void -bcm1250_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - -static bus_t * -bcm1250_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[10]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = & bcm1250_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - 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, +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" + 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<active_instruction->data_register->out->data[276-17]==0) && to--) { chain_shift_data_registers( chain, 1 ); } @@ -467,7 +473,64 @@ int bcm1250_ejtag_do(bus_t *bus, uint64_t ad, uint64_t da, int read, int type, } return 0; } -#endif + +/** + * bus->driver->(*read_start) + * + */ +static void +bcm1250_bus_read_start(bus_t *bus, uint32_t adr ) +{ + addr=adr; +} + +/** + * bus->driver->(*read) + * + */ +static 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]; + +} + +/** + * bus->driver->(*read_next) + * + */ +static 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; +} + +/** + * bus->driver->(*read_end) + * + */ +static uint32_t bcm1250_bus_read_end(bus_t *bus) +{ + return bcm1250_bus_read(bus, addr); +} + +/** + * bus->driver->(*write) + * + */ +static 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 /* #else #ifndef USE_BCM_EJTAG */ const bus_driver_t bcm1250_bus = { "bcm1250", diff --git a/jtag/src/bus/bf533_ezkit.c b/jtag/src/bus/bf533_ezkit.c index aaa731a7..d1abd442 100644 --- a/jtag/src/bus/bf533_ezkit.c +++ b/jtag/src/bus/bf533_ezkit.c @@ -65,7 +65,163 @@ typedef struct { #define SMS ((bus_params_t *) bus->params)->sms #define SWE ((bus_params_t *) bus->params)->swe -static void +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +bf533_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[15]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &bf533_ezkit_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + for (i = 0; i < 4; i++) { + sprintf( buff, "AMS_B%d", i ); + AMS[i] = part_find_signal( PART, buff ); + if (!AMS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for (i = 0; i < 19; i++) { + sprintf( buff, "ADDR[%d]", i + 1); + ADDR[i] = part_find_signal( PART, buff ); + if (!ADDR[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 16; i++) { + sprintf( buff, "DATA[%d]", i); + DATA[i] = part_find_signal( PART, buff ); + if (!DATA[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + AWE = part_find_signal( PART, "AWE_B" ); + if (!AWE) { + printf( _("signal '%s' not found\n"), "AWE_B" ); + failed = 1; + } + + AOE = part_find_signal( PART, "AOE_B" ); + if (!AOE) { + printf( _("signal '%s' not found\n"), "AOE_B" ); + failed = 1; + } + + ABE[0] = part_find_signal( PART, "ABE_B0" ); + if (!ABE[0]) { + printf( _("signal '%s' not found\n"), "ABE_B0" ); + failed = 1; + } + + ABE[1] = part_find_signal( PART, "ABE_B1" ); + if (!ABE[1]) { + printf( _("signal '%s' not found\n"), "ABE_B1" ); + failed = 1; + } + + SRAS = part_find_signal( PART, "SRAS_B" ); + if (!SRAS) { + printf( _("signal '%s' not found\n"), "SRAS_B" ); + failed = 1; + } + + SCAS = part_find_signal( PART, "SCAS_B" ); + if (!SCAS) { + printf( _("signal '%s' not found\n"), "SCAS_B" ); + failed = 1; + } + + SWE = part_find_signal( PART, "SWE_B" ); + if (!SWE) { + printf( _("signal '%s' not found\n"), "SWE_B" ); + failed = 1; + } + + SMS = part_find_signal( PART, "SMS_B" ); + if (!SMS) { + printf( _("signal '%s' not found\n"), "SMS_B" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +bf533_ezkit_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Blackfin BF533 EZKit compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +bf533_ezkit_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +bf533_ezkit_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 16; + + return 0; +} + +static void select_flash( bus_t *bus ) { part_t *p = PART; @@ -84,7 +240,7 @@ select_flash( bus_t *bus ) part_set_signal( p, SMS, 1, 1 ); } -static void +static void unselect_flash( bus_t *bus ) { part_t *p = PART; @@ -134,24 +290,10 @@ setup_data( bus_t *bus, uint32_t d ) } -static void -bf533_ezkit_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Blackfin BF533 EZKit compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void -bf533_ezkit_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void bf533_ezkit_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -168,6 +310,10 @@ bf533_ezkit_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t bf533_ezkit_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -185,6 +331,10 @@ bf533_ezkit_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t bf533_ezkit_bus_read_end( bus_t *bus ) { @@ -205,6 +355,10 @@ bf533_ezkit_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t bf533_ezkit_bus_read( bus_t *bus, uint32_t adr ) { @@ -212,6 +366,10 @@ bf533_ezkit_bus_read( bus_t *bus, uint32_t adr ) return bf533_ezkit_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void bf533_ezkit_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -235,128 +393,6 @@ bf533_ezkit_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static int -bf533_ezkit_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - area->width = 16; - - return 0; -} - -static bus_t * -bf533_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[15]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &bf533_ezkit_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - for (i = 0; i < 4; i++) { - sprintf( buff, "AMS_B%d", i ); - AMS[i] = part_find_signal( PART, buff ); - if (!AMS[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for (i = 0; i < 19; i++) { - sprintf( buff, "ADDR[%d]", i + 1); - ADDR[i] = part_find_signal( PART, buff ); - if (!ADDR[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - for (i = 0; i < 16; i++) { - sprintf( buff, "DATA[%d]", i); - DATA[i] = part_find_signal( PART, buff ); - if (!DATA[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - AWE = part_find_signal( PART, "AWE_B" ); - if (!AWE) { - printf( _("signal '%s' not found\n"), "AWE_B" ); - failed = 1; - } - - AOE = part_find_signal( PART, "AOE_B" ); - if (!AOE) { - printf( _("signal '%s' not found\n"), "AOE_B" ); - failed = 1; - } - - ABE[0] = part_find_signal( PART, "ABE_B0" ); - if (!ABE[0]) { - printf( _("signal '%s' not found\n"), "ABE_B0" ); - failed = 1; - } - - ABE[1] = part_find_signal( PART, "ABE_B1" ); - if (!ABE[1]) { - printf( _("signal '%s' not found\n"), "ABE_B1" ); - failed = 1; - } - - SRAS = part_find_signal( PART, "SRAS_B" ); - if (!SRAS) { - printf( _("signal '%s' not found\n"), "SRAS_B" ); - failed = 1; - } - - SCAS = part_find_signal( PART, "SCAS_B" ); - if (!SCAS) { - printf( _("signal '%s' not found\n"), "SCAS_B" ); - failed = 1; - } - - SWE = part_find_signal( PART, "SWE_B" ); - if (!SWE) { - printf( _("signal '%s' not found\n"), "SWE_B" ); - failed = 1; - } - - SMS = part_find_signal( PART, "SMS_B" ); - if (!SMS) { - printf( _("signal '%s' not found\n"), "SMS_B" ); - failed = 1; - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t bf533_ezkit_bus = { "bf533_ezkit", N_("Blackfin BF533 EZKit board bus driver"), diff --git a/jtag/src/bus/bf533_stamp.c b/jtag/src/bus/bf533_stamp.c index 5df16b95..a1dd5f66 100644 --- a/jtag/src/bus/bf533_stamp.c +++ b/jtag/src/bus/bf533_stamp.c @@ -65,7 +65,161 @@ typedef struct { #define SMS ((bus_params_t *) bus->params)->sms #define SWE ((bus_params_t *) bus->params)->swe -static void +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +bf533_stamp_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[15]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &bf533_stamp_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + for (i = 0; i < 2; i++) { + sprintf( buff, "PF%d", i ); + PF[i] = part_find_signal( PART, buff ); + if (!PF[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for (i = 0; i < 4; i++) { + sprintf( buff, "AMS_B%d", i ); + AMS[i] = part_find_signal( PART, buff ); + if (!AMS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for (i = 0; i < 19; i++) { + sprintf( buff, "ADDR[%d]", i + 1); + ADDR[i] = part_find_signal( PART, buff ); + if (!ADDR[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 16; i++) { + sprintf( buff, "DATA[%d]", i); + DATA[i] = part_find_signal( PART, buff ); + if (!DATA[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + AWE = part_find_signal( PART, "AWE_B" ); + if (!AWE) { + printf( _("signal '%s' not found\n"), "AWE_B" ); + failed = 1; + } + + AOE = part_find_signal( PART, "AOE_B" ); + if (!AOE) { + printf( _("signal '%s' not found\n"), "AOE_B" ); + failed = 1; + } + + SRAS = part_find_signal( PART, "SRAS_B" ); + if (!SRAS) { + printf( _("signal '%s' not found\n"), "SRAS_B" ); + failed = 1; + } + + SCAS = part_find_signal( PART, "SCAS_B" ); + if (!SCAS) { + printf( _("signal '%s' not found\n"), "SCAS_B" ); + failed = 1; + } + + SWE = part_find_signal( PART, "SWE_B" ); + if (!SWE) { + printf( _("signal '%s' not found\n"), "SWE_B" ); + failed = 1; + } + + SMS = part_find_signal( PART, "SMS_B" ); + if (!SMS) { + printf( _("signal '%s' not found\n"), "SMS_B" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +bf533_stamp_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Blackfin BF533 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +bf533_stamp_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +bf533_stamp_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 16; + + return 0; +} + +static void select_flash( bus_t *bus ) { part_t *p = PART; @@ -84,7 +238,7 @@ select_flash( bus_t *bus ) part_set_signal( p, SMS, 1, 1 ); } -static void +static void unselect_flash( bus_t *bus ) { part_t *p = PART; @@ -134,24 +288,10 @@ setup_data( bus_t *bus, uint32_t d ) } -static void -bf533_stamp_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Blackfin BF533 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void -bf533_stamp_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void bf533_stamp_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -168,6 +308,10 @@ bf533_stamp_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t bf533_stamp_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -185,6 +329,10 @@ bf533_stamp_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t bf533_stamp_bus_read_end( bus_t *bus ) { @@ -205,6 +353,10 @@ bf533_stamp_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t bf533_stamp_bus_read( bus_t *bus, uint32_t adr ) { @@ -212,6 +364,10 @@ bf533_stamp_bus_read( bus_t *bus, uint32_t adr ) return bf533_stamp_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void bf533_stamp_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -235,126 +391,6 @@ bf533_stamp_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static int -bf533_stamp_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - area->width = 16; - - return 0; -} - -static bus_t * -bf533_stamp_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[15]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &bf533_stamp_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - for (i = 0; i < 2; i++) { - sprintf( buff, "PF%d", i ); - PF[i] = part_find_signal( PART, buff ); - if (!PF[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for (i = 0; i < 4; i++) { - sprintf( buff, "AMS_B%d", i ); - AMS[i] = part_find_signal( PART, buff ); - if (!AMS[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for (i = 0; i < 19; i++) { - sprintf( buff, "ADDR[%d]", i + 1); - ADDR[i] = part_find_signal( PART, buff ); - if (!ADDR[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - for (i = 0; i < 16; i++) { - sprintf( buff, "DATA[%d]", i); - DATA[i] = part_find_signal( PART, buff ); - if (!DATA[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - AWE = part_find_signal( PART, "AWE_B" ); - if (!AWE) { - printf( _("signal '%s' not found\n"), "AWE_B" ); - failed = 1; - } - - AOE = part_find_signal( PART, "AOE_B" ); - if (!AOE) { - printf( _("signal '%s' not found\n"), "AOE_B" ); - failed = 1; - } - - SRAS = part_find_signal( PART, "SRAS_B" ); - if (!SRAS) { - printf( _("signal '%s' not found\n"), "SRAS_B" ); - failed = 1; - } - - SCAS = part_find_signal( PART, "SCAS_B" ); - if (!SCAS) { - printf( _("signal '%s' not found\n"), "SCAS_B" ); - failed = 1; - } - - SWE = part_find_signal( PART, "SWE_B" ); - if (!SWE) { - printf( _("signal '%s' not found\n"), "SWE_B" ); - failed = 1; - } - - SMS = part_find_signal( PART, "SMS_B" ); - if (!SMS) { - printf( _("signal '%s' not found\n"), "SMS_B" ); - failed = 1; - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t bf533_stamp_bus = { "bf533_stamp", N_("Blackfin BF533 Stamp board bus driver"), diff --git a/jtag/src/bus/bf537_stamp.c b/jtag/src/bus/bf537_stamp.c index 4a644320..0ae455d1 100644 --- a/jtag/src/bus/bf537_stamp.c +++ b/jtag/src/bus/bf537_stamp.c @@ -65,6 +65,146 @@ typedef struct { #define SMS ((bus_params_t *) bus->params)->sms #define SWE ((bus_params_t *) bus->params)->swe +/* + * bus->driver->(*new_bus) + * + */ +static bus_t * +bf537_stamp_bus_new_1( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[15]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + for (i = 0; i < 4; i++) { + sprintf( buff, "AMS_B%d", i ); + AMS[i] = part_find_signal( PART, buff ); + if (!AMS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for (i = 0; i < 19; i++) { + sprintf( buff, "ADDR%d", i + 1); + ADDR[i] = part_find_signal( PART, buff ); + if (!ADDR[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 16; i++) { + sprintf( buff, "DATA%d", i); + DATA[i] = part_find_signal( PART, buff ); + if (!DATA[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + AWE = part_find_signal( PART, "AWE_B" ); + if (!AWE) { + printf( _("signal '%s' not found\n"), "AWE_B" ); + failed = 1; + } + + ARE = part_find_signal( PART, "ARE_B" ); + if (!ARE) { + printf( _("signal '%s' not found\n"), "ARE_B" ); + failed = 1; + } + + ABE[0] = part_find_signal( PART, "ABE_B0" ); + if (!ABE[0]) { + printf( _("signal '%s' not found\n"), "ABE_B0" ); + failed = 1; + } + + ABE[1] = part_find_signal( PART, "ABE_B1" ); + if (!ABE[1]) { + printf( _("signal '%s' not found\n"), "ABE_B1" ); + failed = 1; + } + + SRAS = part_find_signal( PART, "SRAS_B" ); + if (!SRAS) { + printf( _("signal '%s' not found\n"), "SRAS_B" ); + failed = 1; + } + + SCAS = part_find_signal( PART, "SCAS_B" ); + if (!SCAS) { + printf( _("signal '%s' not found\n"), "SCAS_B" ); + failed = 1; + } + + SWE = part_find_signal( PART, "SWE_B" ); + if (!SWE) { + printf( _("signal '%s' not found\n"), "SWE_B" ); + failed = 1; + } + + SMS = part_find_signal( PART, "SMS_B" ); + if (!SMS) { + printf( _("signal '%s' not found\n"), "SMS_B" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*prepare) + * + */ +static void +bf537_stamp_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +bf537_stamp_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 16; + + return 0; +} + static void select_flash( bus_t *bus ) { @@ -134,13 +274,10 @@ setup_data( bus_t *bus, uint32_t d ) } -static void -bf537_stamp_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void bf537_stamp_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -157,6 +294,10 @@ bf537_stamp_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t bf537_stamp_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -174,6 +315,10 @@ bf537_stamp_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t bf537_stamp_bus_read_end( bus_t *bus ) { @@ -194,6 +339,10 @@ bf537_stamp_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t bf537_stamp_bus_read( bus_t *bus, uint32_t adr ) { @@ -201,6 +350,10 @@ bf537_stamp_bus_read( bus_t *bus, uint32_t adr ) return bf537_stamp_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void bf537_stamp_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -224,128 +377,12 @@ bf537_stamp_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static int -bf537_stamp_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - area->width = 16; - - return 0; -} - -static bus_t * -bf537_stamp_bus_new_1( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[15]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - for (i = 0; i < 4; i++) { - sprintf( buff, "AMS_B%d", i ); - AMS[i] = part_find_signal( PART, buff ); - if (!AMS[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for (i = 0; i < 19; i++) { - sprintf( buff, "ADDR%d", i + 1); - ADDR[i] = part_find_signal( PART, buff ); - if (!ADDR[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - for (i = 0; i < 16; i++) { - sprintf( buff, "DATA%d", i); - DATA[i] = part_find_signal( PART, buff ); - if (!DATA[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - AWE = part_find_signal( PART, "AWE_B" ); - if (!AWE) { - printf( _("signal '%s' not found\n"), "AWE_B" ); - failed = 1; - } - - ARE = part_find_signal( PART, "ARE_B" ); - if (!ARE) { - printf( _("signal '%s' not found\n"), "ARE_B" ); - failed = 1; - } - - ABE[0] = part_find_signal( PART, "ABE_B0" ); - if (!ABE[0]) { - printf( _("signal '%s' not found\n"), "ABE_B0" ); - failed = 1; - } - - ABE[1] = part_find_signal( PART, "ABE_B1" ); - if (!ABE[1]) { - printf( _("signal '%s' not found\n"), "ABE_B1" ); - failed = 1; - } - - SRAS = part_find_signal( PART, "SRAS_B" ); - if (!SRAS) { - printf( _("signal '%s' not found\n"), "SRAS_B" ); - failed = 1; - } - - SCAS = part_find_signal( PART, "SCAS_B" ); - if (!SCAS) { - printf( _("signal '%s' not found\n"), "SCAS_B" ); - failed = 1; - } - - SWE = part_find_signal( PART, "SWE_B" ); - if (!SWE) { - printf( _("signal '%s' not found\n"), "SWE_B" ); - failed = 1; - } - - SMS = part_find_signal( PART, "SMS_B" ); - if (!SMS) { - printf( _("signal '%s' not found\n"), "SMS_B" ); - failed = 1; - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - #ifdef ENABLE_BUS_BF537_STAMP + +/** + * bus->driver->(*new_bus) + * + */ static bus_t * bf537_stamp_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -356,6 +393,10 @@ bf537_stamp_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } +/** + * bus->driver->(*printinfo) + * + */ static void bf537_stamp_bus_printinfo( bus_t *bus ) { @@ -382,9 +423,15 @@ const bus_driver_t bf537_stamp_bus = { bf537_stamp_bus_write, NULL }; -#endif + +#endif /* #ifdef ENABLE_BUS_BF537_STAMP */ #ifdef ENABLE_BUS_BF537_EZKIT + +/** + * bus->driver->(*new_bus) + * + */ static bus_t * bf537_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -395,6 +442,10 @@ bf537_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } +/** + * bus->driver->(*printinfo) + * + */ static void bf537_ezkit_bus_printinfo( bus_t *bus ) { @@ -421,9 +472,15 @@ const bus_driver_t bf537_ezkit_bus = { bf537_stamp_bus_write, NULL }; -#endif + +#endif /* #ifdef ENABLE_BUS_BF537_EZKIT */ #ifdef ENABLE_BUS_BF527_EZKIT + +/** + * bus->driver->(*new_bus) + * + */ static bus_t * bf527_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -434,6 +491,10 @@ bf527_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } +/** + * bus->driver->(*printinfo) + * + */ static void bf527_ezkit_bus_printinfo( bus_t *bus ) { @@ -460,6 +521,5 @@ const bus_driver_t bf527_ezkit_bus = { bf537_stamp_bus_write, NULL }; -#endif - +#endif /* #ifdef ENABLE_BUS_BF527_EZKIT */ diff --git a/jtag/src/bus/bf548_ezkit.c b/jtag/src/bus/bf548_ezkit.c index 827af199..c115ad9c 100644 --- a/jtag/src/bus/bf548_ezkit.c +++ b/jtag/src/bus/bf548_ezkit.c @@ -60,6 +60,165 @@ typedef struct { #define DCS0 ((bus_params_t *) bus->params)->dcs0 #define NCE ((bus_params_t *) bus->params)->nce +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +bf548_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[15]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &bf548_ezkit_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + for (i = 0; i < 4; i++) { + sprintf( buff, "AMS%dB", i ); + AMS[i] = part_find_signal( PART, buff ); + if (!AMS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for (i = 0; i < 3; i++) { + sprintf( buff, "ADDR%d", i + 1); + ADDR[i] = part_find_signal( PART, buff ); + if (!ADDR[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for (i = 3; i < 9; i++) { + sprintf( buff, "PORTH_%d", i + 5); + ADDR[i] = part_find_signal( PART, buff ); + if (!ADDR[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for (i = 9; i < 24; i++) { + sprintf( buff, "PORTI_%d", i - 9); + ADDR[i] = part_find_signal( PART, buff ); + if (!ADDR[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for (i = 0; i < 16; i++) { + sprintf( buff, "DATA%d", i); + DATA[i] = part_find_signal( PART, buff ); + if (!DATA[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + AWE = part_find_signal( PART, "AWEB" ); + if (!AWE) { + printf( _("signal '%s' not found\n"), "AWEB" ); + failed = 1; + } + + ARE = part_find_signal( PART, "AREB" ); + if (!ARE) { + printf( _("signal '%s' not found\n"), "AREB" ); + failed = 1; + } + + AOE = part_find_signal( PART, "AOEB" ); + if (!AOE) { + printf( _("signal '%s' not found\n"), "AOEB" ); + failed = 1; + } + + DCS0 = part_find_signal( PART, "CS0_B" ); + if (!DCS0) { + printf( _("signal '%s' not found\n"), "CS0_B" ); + failed = 1; + } + + NCE = part_find_signal( PART, "PORTJ_1" ); + if (!NCE) { + printf( _("signal '%s' not found\n"), "PORTJ_1" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +bf548_ezkit_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Blackfin BF548 EZ-KIT compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +bf548_ezkit_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +bf548_ezkit_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 16; + + return 0; +} + static void select_flash( bus_t *bus ) { @@ -117,24 +276,10 @@ setup_data( bus_t *bus, uint32_t d ) } -static void -bf548_ezkit_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Blackfin BF548 EZ-KIT compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void -bf548_ezkit_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void bf548_ezkit_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -152,6 +297,10 @@ bf548_ezkit_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t bf548_ezkit_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -169,6 +318,10 @@ bf548_ezkit_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t bf548_ezkit_bus_read_end( bus_t *bus ) { @@ -190,6 +343,10 @@ bf548_ezkit_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t bf548_ezkit_bus_read( bus_t *bus, uint32_t adr ) { @@ -197,6 +354,10 @@ bf548_ezkit_bus_read( bus_t *bus, uint32_t adr ) return bf548_ezkit_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void bf548_ezkit_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -220,131 +381,6 @@ bf548_ezkit_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static int -bf548_ezkit_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - area->width = 16; - - return 0; -} - -static bus_t * -bf548_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[15]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &bf548_ezkit_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - for (i = 0; i < 4; i++) { - sprintf( buff, "AMS%dB", i ); - AMS[i] = part_find_signal( PART, buff ); - if (!AMS[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for (i = 0; i < 3; i++) { - sprintf( buff, "ADDR%d", i + 1); - ADDR[i] = part_find_signal( PART, buff ); - if (!ADDR[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for (i = 3; i < 9; i++) { - sprintf( buff, "PORTH_%d", i + 5); - ADDR[i] = part_find_signal( PART, buff ); - if (!ADDR[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for (i = 9; i < 24; i++) { - sprintf( buff, "PORTI_%d", i - 9); - ADDR[i] = part_find_signal( PART, buff ); - if (!ADDR[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for (i = 0; i < 16; i++) { - sprintf( buff, "DATA%d", i); - DATA[i] = part_find_signal( PART, buff ); - if (!DATA[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - AWE = part_find_signal( PART, "AWEB" ); - if (!AWE) { - printf( _("signal '%s' not found\n"), "AWEB" ); - failed = 1; - } - - ARE = part_find_signal( PART, "AREB" ); - if (!ARE) { - printf( _("signal '%s' not found\n"), "AREB" ); - failed = 1; - } - - AOE = part_find_signal( PART, "AOEB" ); - if (!AOE) { - printf( _("signal '%s' not found\n"), "AOEB" ); - failed = 1; - } - - DCS0 = part_find_signal( PART, "CS0_B" ); - if (!DCS0) { - printf( _("signal '%s' not found\n"), "CS0_B" ); - failed = 1; - } - - NCE = part_find_signal( PART, "PORTJ_1" ); - if (!NCE) { - printf( _("signal '%s' not found\n"), "PORTJ_1" ); - failed = 1; - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t bf548_ezkit_bus = { "bf548_ezkit", N_("Blackfin BF548 EZ-KIT board bus driver"), diff --git a/jtag/src/bus/bf561_ezkit.c b/jtag/src/bus/bf561_ezkit.c index 5ff85e7d..f08b1901 100644 --- a/jtag/src/bus/bf561_ezkit.c +++ b/jtag/src/bus/bf561_ezkit.c @@ -65,6 +65,164 @@ typedef struct { #define SMS ((bus_params_t *) bus->params)->sms #define SWE ((bus_params_t *) bus->params)->swe +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +bf561_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[15]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &bf561_ezkit_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + for (i = 0; i < 4; i++) { + sprintf( buff, "AMS_B%d", i ); + AMS[i] = part_find_signal( PART, buff ); + if (!AMS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for (i = 0; i < 24; i++) { + sprintf( buff, "ADDR%d", i + 2); + ADDR[i] = part_find_signal( PART, buff ); + if (!ADDR[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for (i = 0; i < 4; i++) { + sprintf( buff, "ABE_B%d", i); + ABE[i] = part_find_signal( PART, buff ); + if (!ABE[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for (i = 0; i < 32; i++) { + sprintf( buff, "DATA%d", i); + DATA[i] = part_find_signal( PART, buff ); + if (!DATA[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + AWE = part_find_signal( PART, "AWE_B" ); + if (!AWE) { + printf( _("signal '%s' not found\n"), "AWE_B" ); + failed = 1; + } + + AOE = part_find_signal( PART, "AOE_B" ); + if (!AOE) { + printf( _("signal '%s' not found\n"), "AOE_B" ); + failed = 1; + } + + SRAS = part_find_signal( PART, "SRAS_B" ); + if (!SRAS) { + printf( _("signal '%s' not found\n"), "SRAS_B" ); + failed = 1; + } + + SCAS = part_find_signal( PART, "SCAS_B" ); + if (!SCAS) { + printf( _("signal '%s' not found\n"), "SCAS_B" ); + failed = 1; + } + + SWE = part_find_signal( PART, "SWE_B" ); + if (!SWE) { + printf( _("signal '%s' not found\n"), "SWE_B" ); + failed = 1; + } + + for (i = 0; i < 4; i++) { + sprintf( buff, "SMS_B%d", i ); + SMS[i] = part_find_signal( PART, buff ); + if (!SMS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +bf561_ezkit_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Blackfin BF561 EZ-KIT compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +bf561_ezkit_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +bf561_ezkit_bus_area( bus_t *bus, uint32_t addr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 16; + return 0; +} + static void select_flash( bus_t *bus ) { @@ -145,24 +303,10 @@ setup_data( bus_t *bus, uint32_t d ) } -static void -bf561_ezkit_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Blackfin BF561 EZ-KIT compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void -bf561_ezkit_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void bf561_ezkit_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -179,6 +323,10 @@ bf561_ezkit_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t bf561_ezkit_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -196,6 +344,10 @@ bf561_ezkit_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t bf561_ezkit_bus_read_end( bus_t *bus ) { @@ -216,6 +368,10 @@ bf561_ezkit_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t bf561_ezkit_bus_read( bus_t *bus, uint32_t adr ) { @@ -223,6 +379,10 @@ bf561_ezkit_bus_read( bus_t *bus, uint32_t adr ) return bf561_ezkit_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void bf561_ezkit_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -244,130 +404,6 @@ bf561_ezkit_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static int -bf561_ezkit_bus_area( bus_t *bus, uint32_t addr, bus_area_t *area ) -{ - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - area->width = 16; - return 0; -} - -static bus_t * -bf561_ezkit_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[15]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &bf561_ezkit_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - for (i = 0; i < 4; i++) { - sprintf( buff, "AMS_B%d", i ); - AMS[i] = part_find_signal( PART, buff ); - if (!AMS[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for (i = 0; i < 24; i++) { - sprintf( buff, "ADDR%d", i + 2); - ADDR[i] = part_find_signal( PART, buff ); - if (!ADDR[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for (i = 0; i < 4; i++) { - sprintf( buff, "ABE_B%d", i); - ABE[i] = part_find_signal( PART, buff ); - if (!ABE[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for (i = 0; i < 32; i++) { - sprintf( buff, "DATA%d", i); - DATA[i] = part_find_signal( PART, buff ); - if (!DATA[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - AWE = part_find_signal( PART, "AWE_B" ); - if (!AWE) { - printf( _("signal '%s' not found\n"), "AWE_B" ); - failed = 1; - } - - AOE = part_find_signal( PART, "AOE_B" ); - if (!AOE) { - printf( _("signal '%s' not found\n"), "AOE_B" ); - failed = 1; - } - - SRAS = part_find_signal( PART, "SRAS_B" ); - if (!SRAS) { - printf( _("signal '%s' not found\n"), "SRAS_B" ); - failed = 1; - } - - SCAS = part_find_signal( PART, "SCAS_B" ); - if (!SCAS) { - printf( _("signal '%s' not found\n"), "SCAS_B" ); - failed = 1; - } - - SWE = part_find_signal( PART, "SWE_B" ); - if (!SWE) { - printf( _("signal '%s' not found\n"), "SWE_B" ); - failed = 1; - } - - for (i = 0; i < 4; i++) { - sprintf( buff, "SMS_B%d", i ); - SMS[i] = part_find_signal( PART, buff ); - if (!SMS[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t bf561_ezkit_bus = { "bf561_ezkit", N_("Blackfin BF561 EZ-KIT board bus driver"), diff --git a/jtag/src/bus/ejtag.c b/jtag/src/bus/ejtag.c index 5dc07bac..7a166cf3 100644 --- a/jtag/src/bus/ejtag.c +++ b/jtag/src/bus/ejtag.c @@ -60,19 +60,6 @@ typedef struct { #define EJTAG_25 1 #define EJTAG_26 2 -static int ejtag_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ); - -static void -ejtag_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("EJTAG compatible bus driver via PrAcc (JTAG part No. %d)\n"), i ); -} - /* EJTAG control register bits */ #define PerRst 20 #define PRnW 19 @@ -86,6 +73,51 @@ ejtag_bus_printinfo( bus_t *bus ) #define Rocc 31 #define ProbTrap 14 +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +ejtag_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &ejtag_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + BP->initialized = 0; + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +ejtag_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("EJTAG compatible bus driver via PrAcc (JTAG part No. %d)\n"), i ); +} + static uint32_t reg_value( tap_register *reg ) { @@ -293,6 +325,10 @@ ejtag_bus_init( bus_t *bus ) BP->initialized = 1; } +/** + * bus->driver->(*prepare) + * + */ static void ejtag_bus_prepare( bus_t *bus ) { @@ -302,6 +338,37 @@ ejtag_bus_prepare( bus_t *bus ) ejtag_bus_init( bus ); } +/** + * bus->driver->(*area) + * + */ +static int +ejtag_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + if (adr < UINT32_C(0x20000000)) { + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x20000000); + area->width = 8; + } else if (adr < UINT32_C(0x40000000)) { + area->description = NULL; + area->start = UINT32_C(0x20000000); + area->length = UINT64_C(0x20000000); + area->width = 16; + } else if (adr < UINT32_C(0x60000000)) { + area->description = NULL; + area->start = UINT32_C(0x40000000); + area->length = UINT64_C(0x20000000); + area->width = 32; + } else { + area->description = NULL; + area->start = UINT32_C(0x60000000); + area->length = UINT64_C(0xa0000000); + area->width = 0; + } + return 0; +} + static int ejtag_gen_read( uint32_t *code, uint32_t adr ) { @@ -338,6 +405,10 @@ ejtag_gen_read( uint32_t *code, uint32_t adr ) return p - code; } +/** + * bus->driver->(*read_start) + * + */ static void ejtag_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -347,6 +418,10 @@ ejtag_bus_read_start( bus_t *bus, uint32_t adr ) // printf("bus_read_start: adr=0x%08x\n", adr); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t ejtag_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -362,6 +437,10 @@ ejtag_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t ejtag_bus_read_end( bus_t *bus ) { @@ -377,6 +456,10 @@ ejtag_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t ejtag_bus_read( bus_t *bus, uint32_t adr ) { @@ -384,6 +467,10 @@ ejtag_bus_read( bus_t *bus, uint32_t adr ) return ejtag_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void ejtag_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -420,59 +507,6 @@ ejtag_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) // printf("bus_write: adr=0x%08x data=0x%08x\n", adr, data); } -static int -ejtag_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - if (adr < UINT32_C(0x20000000)) { - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x20000000); - area->width = 8; - } else if (adr < UINT32_C(0x40000000)) { - area->description = NULL; - area->start = UINT32_C(0x20000000); - area->length = UINT64_C(0x20000000); - area->width = 16; - } else if (adr < UINT32_C(0x60000000)) { - area->description = NULL; - area->start = UINT32_C(0x40000000); - area->length = UINT64_C(0x20000000); - area->width = 32; - } else { - area->description = NULL; - area->start = UINT32_C(0x60000000); - area->length = UINT64_C(0xa0000000); - area->width = 0; - } - return 0; -} - -static bus_t * -ejtag_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &ejtag_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - BP->initialized = 0; - - return bus; -} - const bus_driver_t ejtag_bus = { "ejtag", N_("EJTAG compatible bus driver via PrAcc"), diff --git a/jtag/src/bus/fjmem.c b/jtag/src/bus/fjmem.c index 4801aeb5..840b63e1 100644 --- a/jtag/src/bus/fjmem.c +++ b/jtag/src/bus/fjmem.c @@ -82,226 +82,423 @@ typedef struct { #define FJMEM_REG ((bus_params_t *) bus->params)->fjmem_reg #define BLOCK_DESC ((bus_params_t *) bus->params)->block_desc -static void -setup_address( bus_t *bus, uint32_t a, block_param_t *block ) +static int +fjmem_detect_reg_len( chain_t *chain, part_t *part, char *opcode, int len ) { - data_register *dr = FJMEM_REG; - block_desc_t *bd = &(BLOCK_DESC); - int idx; - uint16_t num = block->num; - - LAST_ADDR = a; - - /* correct address for > 8 bit data widths */ - a >>= block->ashift; - - /* set block number */ - for (idx = 0; idx < bd->block_len; idx++) { - dr->in->data[bd->block_pos + idx] = num & 1; - num >>= 1; - } + data_register *dr; + instruction *i; + int l, fjmem_reg_len; + char *tdo_bit; - /* set address */ - for (idx = 0; idx < block->addr_width; idx++) { - dr->in->data[bd->addr_pos + idx] = a & 1; - a >>= 1; + /* build register FJMEM_REG with length of 1 bit*/ + dr = data_register_alloc( FJMEM_REG_NAME, 1 ); + if (!dr) { + printf( _("out of memory\n") ); + return 0; } -} - -static void -setup_data( bus_t *bus, uint32_t d, block_param_t *block ) -{ - data_register *dr = FJMEM_REG; - block_desc_t *bd = &(BLOCK_DESC); - int idx; + dr->next = part->data_registers; + part->data_registers = dr; - /* set data */ - for (idx = 0; idx < block->data_width; idx++) { - dr->in->data[bd->data_pos + idx] = d & 1; - d >>= 1; + /* build instruction FJMEM_INST with code given by command line parameter + that maps to FJMEM_REG */ + if (strlen( opcode ) != part->instruction_length) { + printf( _("invalid instruction length\n") ); + return 0; } -} - - -static int block_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area, block_param_t **bl_match ); - - -/* *************************************************************************** - * fjmem_bus_printinfo - * ***************************************************************************/ -static void -fjmem_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("fjmem FPGA bus driver via USER register (JTAG part No. %d)\n"), i ); -} + i = instruction_alloc( FJMEM_INST_NAME, part->instruction_length, opcode ); + if (!i) { + printf( _("out of memory\n") ); + return 0; + } + i->next = part->instructions; + part->instructions = i; + i->data_register = dr; + /* force jtag reset on all parts of the chain + -> they're in BYPASS mode now */ + chain_set_trst( chain, 0 ); + chain_set_trst( chain, 1 ); + tap_reset( chain ); -/* *************************************************************************** - * fjmem_bus_prepare - * ***************************************************************************/ -static void -fjmem_bus_prepare( bus_t *bus ) -{ - part_t *p = PART; - chain_t *chain = CHAIN; + /* flood all BYPASS registers with 0 for the following detection */ + register_fill( dr->in, 0); + tap_capture_dr( chain ); + for (l = 0; l < chain->parts->len; l++) + tap_shift_register( chain, dr->in, NULL, EXITMODE_SHIFT ); + /* shift once more and return to idle state */ + tap_shift_register( chain, dr->in, NULL, EXITMODE_IDLE ); - /* ensure FJMEM_INST is active */ - part_set_instruction( p, FJMEM_INST_NAME ); + /* set the FJMEM_INST instruction and activate it */ + part_set_instruction( part, FJMEM_INST_NAME ); chain_shift_instructions( chain ); -} + /* skip autodetect if register length was already specified */ + if (len) + return len; -/* *************************************************************************** - * fjmem_bus_read_start - * ***************************************************************************/ -static void -fjmem_bus_read_start( bus_t *bus, uint32_t adr ) -{ - chain_t *chain = CHAIN; - block_desc_t *bd = &(BLOCK_DESC); - data_register *dr = FJMEM_REG; - bus_area_t area; - block_param_t *block; + /* now detect the register length of FJMEM_REG: + shift 1s through the data register until they appear at TDO + NB: We don't shift only through the FJMEM_REG but also through the + registers of all other parts in the chain. They're set to + BYPASS hopefully. */ + fjmem_reg_len = 0; + register_fill( dr->in, 1); + register_fill( dr->out, 0); + tdo_bit = dr->out->data; - block_bus_area( bus, adr, &area, &block ); - if (!block) { - printf( _("Address out of range\n") ); - LAST_ADDR = adr; - return; + tap_capture_dr( chain ); + /* read current TDO and then shift once */ + tap_shift_register( chain, dr->in, dr->out, EXITMODE_SHIFT ); + register_get_string( dr->out ); + while ((tdo_bit[0] == 0) && (fjmem_reg_len < FJMEM_MAX_REG_LEN)) { + /* read current TDO and then shift once */ + tap_shift_register( chain, dr->in, dr->out, EXITMODE_SHIFT ); + tdo_bit = dr->out->data; + fjmem_reg_len++; } + /* consider BYPASS register of other parts in the chain */ + fjmem_reg_len -= chain->parts->len - 1; + /* shift once more and return to idle state */ + tap_shift_register( chain, dr->in, NULL, EXITMODE_IDLE ); +#ifdef DEBUG + printf("FJMEM data register length: %d\n", fjmem_reg_len); +#endif - setup_address( bus, adr, block ); - - /* select read instruction */ - dr->in->data[bd->instr_pos+0] = 1; - dr->in->data[bd->instr_pos+1] = 0; - dr->in->data[bd->instr_pos+2] = 0; - - chain_shift_data_registers( chain, 0 ); + return fjmem_reg_len < FJMEM_MAX_REG_LEN ? fjmem_reg_len : -1; } - -/* *************************************************************************** - * fjmem_bus_read_next - * ***************************************************************************/ -static uint32_t -fjmem_bus_read_next( bus_t *bus, uint32_t adr ) +static int +fjmem_detect_fields( chain_t *chain, part_t *part, bus_t *bus ) { - chain_t *chain = CHAIN; block_desc_t *bd = &(BLOCK_DESC); data_register *dr = FJMEM_REG; - uint32_t d; - bus_area_t area; - block_param_t *block; int idx; +#ifdef DEBUG + const char *reg_string; +#endif - block_bus_area( bus, adr, &area, &block ); - if (!block) { - printf( _("Address out of range\n") ); - LAST_ADDR = adr; + /* set safe defaults */ + bd->block_len = 0; + bd->addr_pos = 0; + bd->addr_len = 0; + bd->data_pos = 0; + bd->data_len = 0; + + /* extend FJMEM_REG to finally detected size */ + if (dr->in) + free( dr->in ); + if ((dr->in = register_alloc( bd->reg_len )) == NULL) { + printf( _("out of memory\n") ); + return 0; + } + if (dr->out) + free( dr->out ); + if ((dr->out = register_alloc( bd->reg_len )) == NULL) { + printf( _("out of memory\n") ); return 0; } - setup_address( bus, adr, block ); + /* Shift the detect instruction (all-1) into FJMEM_REG. */ + register_fill( dr->in, 1 ); chain_shift_data_registers( chain, 1 ); - /* extract data from TDO stream */ - d = 0; - for (idx = 0; idx < block->data_width; idx++) - if (dr->out->data[bd->data_pos + idx]) - d |= 1 << idx; + /* With the next shift we will read the field marker pattern. + Shift in the query for block 0, will be used lateron. */ + register_fill( dr->in, 0 ); + /* enter query instruction: 110 */ + dr->in->data[bd->instr_pos+1] = 1; + dr->in->data[bd->instr_pos+2] = 1; - return d; -} + /* shift register */ + chain_shift_data_registers( chain, 1 ); + /* and examine output from field detect */ +#ifdef DEBUG + reg_string = register_get_string( dr->out ); + printf("captured: %s\n", reg_string); +#endif + /* scan block field */ + idx = bd->block_pos; + while (dr->out->data[idx] && (idx < dr->out->len)) + idx++; + bd->block_len = idx - bd->block_pos; + /* scan address field */ + bd->addr_pos = idx; + while ((dr->out->data[idx] == 0) && (idx < dr->out->len)) + idx++; + bd->addr_len = idx - bd->addr_pos; + /* scan data field */ + bd->data_pos = idx; + while (dr->out->data[idx] && (idx < dr->out->len)) + idx++; + bd->data_len = idx - bd->data_pos; -/* *************************************************************************** - * fjmem_bus_read_end - * ***************************************************************************/ -static uint32_t -fjmem_bus_read_end( bus_t *bus ) +#ifdef DEBUG + printf("block pos: %d, len: %d\n", bd->block_pos, bd->block_len); + printf("addr pos: %d, len: %d\n", bd->addr_pos, bd->addr_len); + printf("data pos: %d, len: %d\n", bd->data_pos, bd->data_len); +#endif + + if ((bd->block_len > 0) && + (bd->addr_len > 0) && + (bd->data_len > 0)) + return 1; + else + return 0; +} + +static int +fjmem_query_blocks( chain_t *chain, part_t *part, bus_t *bus ) { - chain_t *chain = CHAIN; block_desc_t *bd = &(BLOCK_DESC); data_register *dr = FJMEM_REG; - uint32_t d; - bus_area_t area; - block_param_t *block; - int idx; - - block_bus_area( bus, LAST_ADDR, &area, &block ); - if (!block) { - printf( _("Address out of range\n") ); - return 0; - } + int max_block_num, block_num; + int failed = 0; +#ifdef DEBUG + const char *reg_string; +#endif - /* prepare idle instruction to disable any spurious unintentional reads */ - dr->in->data[bd->instr_pos+0] = 0; - dr->in->data[bd->instr_pos+1] = 0; - dr->in->data[bd->instr_pos+2] = 0; + /* the current block number is 0, it has been requested by the previous + shift during fjmem_detect_fields */ + max_block_num = (1 << bd->block_len) - 1; + for (block_num = 0; block_num <= max_block_num; block_num++) { + int next_block_num = block_num + 1; + int idx; + int addr_len, data_len; - chain_shift_data_registers( chain, 1 ); + /* prepare the next query before shifting the data register */ + for (idx = 0; idx < bd->block_len; idx++) { + dr->in->data[bd->block_pos + idx] = next_block_num & 1; + next_block_num >>= 1; + } + chain_shift_data_registers( chain, 1 ); - /* extract data from TDO stream */ - d = 0; - for (idx = 0; idx < block->data_width; idx++) - if (dr->out->data[bd->data_pos + idx]) - d |= 1 << idx; + /* and examine output from block query */ +#ifdef DEBUG + reg_string = register_get_string( dr->out ); + printf("captured: %s\n", reg_string); +#endif - return d; -} + /* extract address field length */ + for (addr_len = 0; addr_len < bd->addr_len; addr_len++) + if (dr->out->data[bd->addr_pos + addr_len] == 0) + break; + + /* extract data field length */ + for (data_len = 0; data_len < bd->data_len; data_len++) + if (dr->out->data[bd->data_pos + data_len] == 0) + break; + + /* it's a valid block only if address field and data field are + both larger than 0 */ + if ((addr_len > 0) && (data_len > 0)) { + block_param_t *bl; + int nbytes; + if ((bl = (block_param_t *)calloc( 1, sizeof( block_param_t ) )) == NULL) { + printf( _("out of memory\n") ); + failed |= 1; + break; + } -/* *************************************************************************** - * fjmem_bus_read - * ***************************************************************************/ -static uint32_t -fjmem_bus_read( bus_t *bus, uint32_t adr ) + bl->next = bd->blocks; + bl->num = block_num; + bl->addr_width = addr_len; + bl->data_width = data_len; + bd->blocks = bl; + + /* determine address shift, depends on data width */ + nbytes = data_len / 8; + if (data_len % 8) + nbytes++; + + bl->ashift = 0; + while (nbytes != 1) { + bl->ashift++; + nbytes >>= 1; + } + + /* determine start address of this block */ + if (bl->next == NULL) + bl->start = 0; + else { + if ((bl->addr_width << bl->ashift) <= (bl->next->addr_width << bl->next->ashift)) { + bl->start = bl->next->start + (1 << (bl->next->addr_width + bl->next->ashift)); + } else { + uint32_t mask = 1 << (bl->addr_width + bl->ashift); + bl->start = bl->next->start & ~(mask - 1); + bl->start += mask; + } + } + /* and fill in end address of this block */ + bl->end = bl->start + (1 << (bl->addr_width + bl->ashift)) - 1; + +#ifdef DEBUG + printf("block # %d\n", block_num); + printf(" start 0x%08x\n", bl->start); + printf(" end 0x%08x\n", bl->end); + printf(" addr len %d\n", bl->addr_width); + printf(" data len %d\n", bl->data_width); +#endif + } + } + + return failed ? 0 : 1; +} + +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +fjmem_bus_new( chain_t *chain, char *params[] ) { - fjmem_bus_read_start( bus, adr ); - return fjmem_bus_read_end( bus ); + bus_t *bus = NULL; + int failed = 0; + part_t *part; + char *opcode = NULL; + int fjmem_reg_len = 0; + int idx; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + if (chain->active_part >= chain->parts->len) { + printf( _("%s: no active part\n"), "fjmem" ); + return NULL; + } + part = chain->parts->parts[chain->active_part]; + + /* parse parameters */ + for (idx = 2; idx < cmd_params( params ); idx++) { + char *comma, *value; + + comma = strchr( params[idx], '=' ); + if (comma == NULL) { + printf( _("Wrong parameter specification: %s\n"), params[idx] ); + continue; + } + + /* set value and terminate parameter name string */ + value = comma + 1; + *comma = '\0'; + + if (strcasecmp( params[idx], "opcode" ) == 0) + opcode = value; + if (strcasecmp( params[idx], "len" ) == 0) { + unsigned int tmp; + cmd_get_number( value, &tmp ); + fjmem_reg_len = (int)tmp; + } + } + + if (opcode) { + block_desc_t *bd; + + fjmem_reg_len = fjmem_detect_reg_len( chain, part, opcode, fjmem_reg_len ); + if (fjmem_reg_len <= 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &fjmem_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + FJMEM_REG = part_find_data_register( PART, FJMEM_REG_NAME ); + bd = &(BLOCK_DESC); + bd->blocks = NULL; + bd->reg_len = fjmem_reg_len; + bd->instr_pos = 0; + bd->block_pos = bd->instr_pos + 4; /* 3 bits for instruction field, 1 bit ack field */ + + if (fjmem_detect_fields( chain, part, bus ) > 0) { + if (fjmem_query_blocks( chain, part, bus ) > 0) { + } else + failed |= 1; + } else + failed |= 1; + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + } else + printf( _("Parameter for instruction opcode missing.\n") ); + + return bus; } +static void +fjmem_free_blocks( block_param_t *bl ) +{ + if (bl) { + fjmem_free_blocks( bl->next ); + free( bl ); + } +} -/* *************************************************************************** - * fjmem_bus_write - * ***************************************************************************/ +/** + * bus->driver->(*free_bus) + * + */ static void -fjmem_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) +fjmem_bus_free( bus_t *bus ) { - chain_t *chain = CHAIN; - block_desc_t *bd = &(BLOCK_DESC); data_register *dr = FJMEM_REG; - bus_area_t area; - block_param_t *block; - block_bus_area( bus, adr, &area, &block ); - if (!block) { - printf( _("Address out of range\n") ); - return; - } + /* fill all fields with '0' + -> prepare idle instruction for next startup/detect */ + part_set_instruction( PART, FJMEM_INST_NAME ); + chain_shift_instructions( CHAIN ); - setup_address( bus, adr, block ); - setup_data( bus, data, block ); + register_fill( dr->in, 0 ); + chain_shift_data_registers( CHAIN, 0 ); - /* select write instruction */ - dr->in->data[bd->instr_pos+0] = 0; - dr->in->data[bd->instr_pos+1] = 1; - dr->in->data[bd->instr_pos+2] = 0; + fjmem_free_blocks( BLOCK_DESC.blocks ); + BLOCK_DESC.blocks = NULL; - chain_shift_data_registers( chain, 0 ); + generic_bus_free( bus ); +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +fjmem_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("fjmem FPGA bus driver via USER register (JTAG part No. %d)\n"), i ); } +/** + * bus->driver->(*prepare) + * + */ +static void +fjmem_bus_prepare( bus_t *bus ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; -/* *************************************************************************** - * jopcyc_bus_area - * ***************************************************************************/ + /* ensure FJMEM_INST is active */ + part_set_instruction( p, FJMEM_INST_NAME ); + chain_shift_instructions( chain ); +} static int block_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area, block_param_t **bl_match ) @@ -340,7 +537,10 @@ block_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area, block_param_t **bl_m return 0; } - +/** + * bus->driver->(*area) + * + */ static int fjmem_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) { @@ -349,385 +549,186 @@ fjmem_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) return block_bus_area( bus, adr, area, &bl ); } - static void -fjmem_free_blocks( block_param_t *bl ) -{ - if (bl) { - fjmem_free_blocks( bl->next ); - free( bl ); - } -} - -static void -fjmem_bus_free( bus_t *bus ) +setup_address( bus_t *bus, uint32_t a, block_param_t *block ) { data_register *dr = FJMEM_REG; + block_desc_t *bd = &(BLOCK_DESC); + int idx; + uint16_t num = block->num; - /* fill all fields with '0' - -> prepare idle instruction for next startup/detect */ - part_set_instruction( PART, FJMEM_INST_NAME ); - chain_shift_instructions( CHAIN ); + LAST_ADDR = a; - register_fill( dr->in, 0 ); - chain_shift_data_registers( CHAIN, 0 ); + /* correct address for > 8 bit data widths */ + a >>= block->ashift; - fjmem_free_blocks( BLOCK_DESC.blocks ); - BLOCK_DESC.blocks = NULL; + /* set block number */ + for (idx = 0; idx < bd->block_len; idx++) { + dr->in->data[bd->block_pos + idx] = num & 1; + num >>= 1; + } - generic_bus_free( bus ); + /* set address */ + for (idx = 0; idx < block->addr_width; idx++) { + dr->in->data[bd->addr_pos + idx] = a & 1; + a >>= 1; + } } -static int -fjmem_detect_reg_len( chain_t *chain, part_t *part, char *opcode, int len ) +static void +setup_data( bus_t *bus, uint32_t d, block_param_t *block ) { - data_register *dr; - instruction *i; - int l, fjmem_reg_len; - char *tdo_bit; + data_register *dr = FJMEM_REG; + block_desc_t *bd = &(BLOCK_DESC); + int idx; - /* build register FJMEM_REG with length of 1 bit*/ - dr = data_register_alloc( FJMEM_REG_NAME, 1 ); - if (!dr) { - printf( _("out of memory\n") ); - return 0; + /* set data */ + for (idx = 0; idx < block->data_width; idx++) { + dr->in->data[bd->data_pos + idx] = d & 1; + d >>= 1; } +} - dr->next = part->data_registers; - part->data_registers = dr; +/** + * bus->driver->(*read_start) + * + */ +static void +fjmem_bus_read_start( bus_t *bus, uint32_t adr ) +{ + chain_t *chain = CHAIN; + block_desc_t *bd = &(BLOCK_DESC); + data_register *dr = FJMEM_REG; + bus_area_t area; + block_param_t *block; - /* build instruction FJMEM_INST with code given by command line parameter - that maps to FJMEM_REG */ - if (strlen( opcode ) != part->instruction_length) { - printf( _("invalid instruction length\n") ); - return 0; - } - i = instruction_alloc( FJMEM_INST_NAME, part->instruction_length, opcode ); - if (!i) { - printf( _("out of memory\n") ); - return 0; + block_bus_area( bus, adr, &area, &block ); + if (!block) { + printf( _("Address out of range\n") ); + LAST_ADDR = adr; + return; } - i->next = part->instructions; - part->instructions = i; - i->data_register = dr; - - /* force jtag reset on all parts of the chain - -> they're in BYPASS mode now */ - chain_set_trst( chain, 0 ); - chain_set_trst( chain, 1 ); - tap_reset( chain ); - /* flood all BYPASS registers with 0 for the following detection */ - register_fill( dr->in, 0); - tap_capture_dr( chain ); - for (l = 0; l < chain->parts->len; l++) - tap_shift_register( chain, dr->in, NULL, EXITMODE_SHIFT ); - /* shift once more and return to idle state */ - tap_shift_register( chain, dr->in, NULL, EXITMODE_IDLE ); - - /* set the FJMEM_INST instruction and activate it */ - part_set_instruction( part, FJMEM_INST_NAME ); - chain_shift_instructions( chain ); - - /* skip autodetect if register length was already specified */ - if (len) - return len; - - /* now detect the register length of FJMEM_REG: - shift 1s through the data register until they appear at TDO - NB: We don't shift only through the FJMEM_REG but also through the - registers of all other parts in the chain. They're set to - BYPASS hopefully. */ - fjmem_reg_len = 0; - register_fill( dr->in, 1); - register_fill( dr->out, 0); - tdo_bit = dr->out->data; + setup_address( bus, adr, block ); - tap_capture_dr( chain ); - /* read current TDO and then shift once */ - tap_shift_register( chain, dr->in, dr->out, EXITMODE_SHIFT ); - register_get_string( dr->out ); - while ((tdo_bit[0] == 0) && (fjmem_reg_len < FJMEM_MAX_REG_LEN)) { - /* read current TDO and then shift once */ - tap_shift_register( chain, dr->in, dr->out, EXITMODE_SHIFT ); - tdo_bit = dr->out->data; - fjmem_reg_len++; - } - /* consider BYPASS register of other parts in the chain */ - fjmem_reg_len -= chain->parts->len - 1; - /* shift once more and return to idle state */ - tap_shift_register( chain, dr->in, NULL, EXITMODE_IDLE ); -#ifdef DEBUG - printf("FJMEM data register length: %d\n", fjmem_reg_len); -#endif + /* select read instruction */ + dr->in->data[bd->instr_pos+0] = 1; + dr->in->data[bd->instr_pos+1] = 0; + dr->in->data[bd->instr_pos+2] = 0; - return fjmem_reg_len < FJMEM_MAX_REG_LEN ? fjmem_reg_len : -1; + chain_shift_data_registers( chain, 0 ); } -static int -fjmem_detect_fields( chain_t *chain, part_t *part, bus_t *bus ) +/** + * bus->driver->(*read_next) + * + */ +static uint32_t +fjmem_bus_read_next( bus_t *bus, uint32_t adr ) { + chain_t *chain = CHAIN; block_desc_t *bd = &(BLOCK_DESC); data_register *dr = FJMEM_REG; + uint32_t d; + bus_area_t area; + block_param_t *block; int idx; -#ifdef DEBUG - const char *reg_string; -#endif - - /* set safe defaults */ - bd->block_len = 0; - bd->addr_pos = 0; - bd->addr_len = 0; - bd->data_pos = 0; - bd->data_len = 0; - /* extend FJMEM_REG to finally detected size */ - if (dr->in) - free( dr->in ); - if ((dr->in = register_alloc( bd->reg_len )) == NULL) { - printf( _("out of memory\n") ); - return 0; - } - if (dr->out) - free( dr->out ); - if ((dr->out = register_alloc( bd->reg_len )) == NULL) { - printf( _("out of memory\n") ); + block_bus_area( bus, adr, &area, &block ); + if (!block) { + printf( _("Address out of range\n") ); + LAST_ADDR = adr; return 0; } - /* Shift the detect instruction (all-1) into FJMEM_REG. */ - register_fill( dr->in, 1 ); - chain_shift_data_registers( chain, 1 ); - - /* With the next shift we will read the field marker pattern. - Shift in the query for block 0, will be used lateron. */ - register_fill( dr->in, 0 ); - /* enter query instruction: 110 */ - dr->in->data[bd->instr_pos+1] = 1; - dr->in->data[bd->instr_pos+2] = 1; - - /* shift register */ + setup_address( bus, adr, block ); chain_shift_data_registers( chain, 1 ); - /* and examine output from field detect */ -#ifdef DEBUG - reg_string = register_get_string( dr->out ); - printf("captured: %s\n", reg_string); -#endif - /* scan block field */ - idx = bd->block_pos; - while (dr->out->data[idx] && (idx < dr->out->len)) - idx++; - bd->block_len = idx - bd->block_pos; - /* scan address field */ - bd->addr_pos = idx; - while ((dr->out->data[idx] == 0) && (idx < dr->out->len)) - idx++; - bd->addr_len = idx - bd->addr_pos; - /* scan data field */ - bd->data_pos = idx; - while (dr->out->data[idx] && (idx < dr->out->len)) - idx++; - bd->data_len = idx - bd->data_pos; - -#ifdef DEBUG - printf("block pos: %d, len: %d\n", bd->block_pos, bd->block_len); - printf("addr pos: %d, len: %d\n", bd->addr_pos, bd->addr_len); - printf("data pos: %d, len: %d\n", bd->data_pos, bd->data_len); -#endif + /* extract data from TDO stream */ + d = 0; + for (idx = 0; idx < block->data_width; idx++) + if (dr->out->data[bd->data_pos + idx]) + d |= 1 << idx; - if ((bd->block_len > 0) && - (bd->addr_len > 0) && - (bd->data_len > 0)) - return 1; - else - return 0; + return d; } -static int -fjmem_query_blocks( chain_t *chain, part_t *part, bus_t *bus ) +/** + * bus->driver->(*read_end) + * + */ +static uint32_t +fjmem_bus_read_end( bus_t *bus ) { + chain_t *chain = CHAIN; block_desc_t *bd = &(BLOCK_DESC); data_register *dr = FJMEM_REG; - int max_block_num, block_num; - int failed = 0; -#ifdef DEBUG - const char *reg_string; -#endif - - /* the current block number is 0, it has been requested by the previous - shift during fjmem_detect_fields */ - max_block_num = (1 << bd->block_len) - 1; - for (block_num = 0; block_num <= max_block_num; block_num++) { - int next_block_num = block_num + 1; - int idx; - int addr_len, data_len; - - /* prepare the next query before shifting the data register */ - for (idx = 0; idx < bd->block_len; idx++) { - dr->in->data[bd->block_pos + idx] = next_block_num & 1; - next_block_num >>= 1; - } - chain_shift_data_registers( chain, 1 ); - - /* and examine output from block query */ -#ifdef DEBUG - reg_string = register_get_string( dr->out ); - printf("captured: %s\n", reg_string); -#endif - - /* extract address field length */ - for (addr_len = 0; addr_len < bd->addr_len; addr_len++) - if (dr->out->data[bd->addr_pos + addr_len] == 0) - break; - - /* extract data field length */ - for (data_len = 0; data_len < bd->data_len; data_len++) - if (dr->out->data[bd->data_pos + data_len] == 0) - break; - - /* it's a valid block only if address field and data field are - both larger than 0 */ - if ((addr_len > 0) && (data_len > 0)) { - block_param_t *bl; - int nbytes; - - if ((bl = (block_param_t *)calloc( 1, sizeof( block_param_t ) )) == NULL) { - printf( _("out of memory\n") ); - failed |= 1; - break; - } - - bl->next = bd->blocks; - bl->num = block_num; - bl->addr_width = addr_len; - bl->data_width = data_len; - bd->blocks = bl; + uint32_t d; + bus_area_t area; + block_param_t *block; + int idx; - /* determine address shift, depends on data width */ - nbytes = data_len / 8; - if (data_len % 8) - nbytes++; + block_bus_area( bus, LAST_ADDR, &area, &block ); + if (!block) { + printf( _("Address out of range\n") ); + return 0; + } - bl->ashift = 0; - while (nbytes != 1) { - bl->ashift++; - nbytes >>= 1; - } + /* prepare idle instruction to disable any spurious unintentional reads */ + dr->in->data[bd->instr_pos+0] = 0; + dr->in->data[bd->instr_pos+1] = 0; + dr->in->data[bd->instr_pos+2] = 0; - /* determine start address of this block */ - if (bl->next == NULL) - bl->start = 0; - else { - if ((bl->addr_width << bl->ashift) <= (bl->next->addr_width << bl->next->ashift)) { - bl->start = bl->next->start + (1 << (bl->next->addr_width + bl->next->ashift)); - } else { - uint32_t mask = 1 << (bl->addr_width + bl->ashift); - bl->start = bl->next->start & ~(mask - 1); - bl->start += mask; - } - } - /* and fill in end address of this block */ - bl->end = bl->start + (1 << (bl->addr_width + bl->ashift)) - 1; + chain_shift_data_registers( chain, 1 ); -#ifdef DEBUG - printf("block # %d\n", block_num); - printf(" start 0x%08x\n", bl->start); - printf(" end 0x%08x\n", bl->end); - printf(" addr len %d\n", bl->addr_width); - printf(" data len %d\n", bl->data_width); -#endif - } - } + /* extract data from TDO stream */ + d = 0; + for (idx = 0; idx < block->data_width; idx++) + if (dr->out->data[bd->data_pos + idx]) + d |= 1 << idx; - return failed ? 0 : 1; + return d; } -static bus_t * -fjmem_bus_new( chain_t *chain, char *params[] ) +/** + * bus->driver->(*read) + * + */ +static uint32_t +fjmem_bus_read( bus_t *bus, uint32_t adr ) { - bus_t *bus = NULL; - int failed = 0; - part_t *part; - char *opcode = NULL; - int fjmem_reg_len = 0; - int idx; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - if (chain->active_part >= chain->parts->len) { - printf( _("%s: no active part\n"), "fjmem" ); - return NULL; - } - part = chain->parts->parts[chain->active_part]; - - /* parse parameters */ - for (idx = 2; idx < cmd_params( params ); idx++) { - char *comma, *value; - - comma = strchr( params[idx], '=' ); - if (comma == NULL) { - printf( _("Wrong parameter specification: %s\n"), params[idx] ); - continue; - } + fjmem_bus_read_start( bus, adr ); + return fjmem_bus_read_end( bus ); +} - /* set value and terminate parameter name string */ - value = comma + 1; - *comma = '\0'; +/** + * bus->driver->(*write) + * + */ +static void +fjmem_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) +{ + chain_t *chain = CHAIN; + block_desc_t *bd = &(BLOCK_DESC); + data_register *dr = FJMEM_REG; + bus_area_t area; + block_param_t *block; - if (strcasecmp( params[idx], "opcode" ) == 0) - opcode = value; - if (strcasecmp( params[idx], "len" ) == 0) { - unsigned int tmp; - cmd_get_number( value, &tmp ); - fjmem_reg_len = (int)tmp; - } + block_bus_area( bus, adr, &area, &block ); + if (!block) { + printf( _("Address out of range\n") ); + return; } - if (opcode) { - block_desc_t *bd; - - fjmem_reg_len = fjmem_detect_reg_len( chain, part, opcode, fjmem_reg_len ); - if (fjmem_reg_len <= 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &fjmem_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - FJMEM_REG = part_find_data_register( PART, FJMEM_REG_NAME ); - bd = &(BLOCK_DESC); - bd->blocks = NULL; - bd->reg_len = fjmem_reg_len; - bd->instr_pos = 0; - bd->block_pos = bd->instr_pos + 4; /* 3 bits for instruction field, 1 bit ack field */ - - if (fjmem_detect_fields( chain, part, bus ) > 0) { - if (fjmem_query_blocks( chain, part, bus ) > 0) { - } else - failed |= 1; - } else - failed |= 1; + setup_address( bus, adr, block ); + setup_data( bus, data, block ); - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - } else - printf( _("Parameter for instruction opcode missing.\n") ); + /* select write instruction */ + dr->in->data[bd->instr_pos+0] = 0; + dr->in->data[bd->instr_pos+1] = 1; + dr->in->data[bd->instr_pos+2] = 0; - return bus; + chain_shift_data_registers( chain, 0 ); } const bus_driver_t fjmem_bus = { diff --git a/jtag/src/bus/h7202.c b/jtag/src/bus/h7202.c index be02825a..c26f6c1f 100644 --- a/jtag/src/bus/h7202.c +++ b/jtag/src/bus/h7202.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, Raphael Mack + * Copyright (C) 2005, Raphael Mack * Work heavily based on file sa1110.c * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -55,6 +55,127 @@ typedef struct { #define nRWE ((bus_params_t *) bus->params)->nRWE #define nROE ((bus_params_t *) bus->params)->nROE +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +h7202_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[10]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &h7202_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + for (i = 0; i < 25; i++) { + sprintf( buff, "RA%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, "RD%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 < 4; i++) { + sprintf( buff, "nRCS%d", i ); + nRCS[i] = part_find_signal( PART, buff ); + if (!nRCS[i]) { + printf( "signal '%s' not found\n", buff ); + failed = 1; + break; + } + } + nROE = part_find_signal( PART, "nROE" ); + if (!nROE) { + printf( "signal '%s' not found\n", "nROE" ); + failed = 1; + } + + for (i = 0; i < 4; i++){ + sprintf( buff, "nRWE%d", i); + nRWE[i] = part_find_signal( PART, buff ); + if (!nRWE[i]) { + printf( "signal '%s' not found\n", buff ); + failed = 1; + } + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +h7202_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( "H7202 compatible bus driver via BSR (JTAG part No. %d)\n", i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +h7202_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +h7202_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 16; //part_get_signal( PART, part_find_signal( PART, "ROM_SEL" ) ) ? 32 : 16; + + return 0; +} + static void setup_address( bus_t *bus, uint32_t a ) { @@ -65,8 +186,6 @@ setup_address( bus_t *bus, uint32_t a ) part_set_signal( p, A[i], 1, (a >> i) & 1 ); } -static int h7202_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ); - static void set_data_in( bus_t *bus ) { @@ -93,24 +212,10 @@ setup_data( bus_t *bus, uint32_t d ) part_set_signal( p, D[i], 1, (d >> i) & 1 ); } -static void -h7202_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( "H7202 compatible bus driver via BSR (JTAG part No. %d)\n", i ); -} - -static void -h7202_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void h7202_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -131,6 +236,10 @@ h7202_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t h7202_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -152,6 +261,10 @@ h7202_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t h7202_bus_read_end( bus_t *bus ) { @@ -177,6 +290,10 @@ h7202_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t h7202_bus_read( bus_t *bus, uint32_t adr ) { @@ -184,6 +301,10 @@ h7202_bus_read( bus_t *bus, uint32_t adr ) return h7202_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void h7202_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -199,7 +320,7 @@ h7202_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) part_set_signal( p, nRCS[1], 1, 1 ); part_set_signal( p, nRCS[2], 1, 1 ); part_set_signal( p, nRCS[3], 1, 1 ); - + part_set_signal( p, nRWE[0], 1, 0 ); part_set_signal( p, nRWE[1], 1, 1 ); part_set_signal( p, nRWE[2], 1, 1 ); @@ -219,93 +340,6 @@ h7202_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static int -h7202_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - area->width = 16; //part_get_signal( PART, part_find_signal( PART, "ROM_SEL" ) ) ? 32 : 16; - - return 0; -} - -static bus_t * -h7202_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[10]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &h7202_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - for (i = 0; i < 25; i++) { - sprintf( buff, "RA%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, "RD%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 < 4; i++) { - sprintf( buff, "nRCS%d", i ); - nRCS[i] = part_find_signal( PART, buff ); - if (!nRCS[i]) { - printf( "signal '%s' not found\n", buff ); - failed = 1; - break; - } - } - nROE = part_find_signal( PART, "nROE" ); - if (!nROE) { - printf( "signal '%s' not found\n", "nROE" ); - failed = 1; - } - - for (i = 0; i < 4; i++){ - sprintf( buff, "nRWE%d", i); - nRWE[i] = part_find_signal( PART, buff ); - if (!nRWE[i]) { - printf( "signal '%s' not found\n", buff ); - failed = 1; - } - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t h7202_bus = { "h7202", "H7202 compatible bus driver via BSR", diff --git a/jtag/src/bus/ixp425.c b/jtag/src/bus/ixp425.c index ab887a10..7979dfff 100644 --- a/jtag/src/bus/ixp425.c +++ b/jtag/src/bus/ixp425.c @@ -55,7 +55,124 @@ typedef struct { #define EX_WR ((bus_params_t *) bus->params)->ex_wr #define EX_RD ((bus_params_t *) bus->params)->ex_rd -static void +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +ixp425_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[15]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &ixp425_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + for (i = 0; i < 8; i++) { + sprintf( buff, "EX_CS[%d]", i ); + EX_CS[i] = part_find_signal( PART, buff ); + if (!EX_CS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 24; i++) { + sprintf( buff, "EX_ADDR[%d]", i ); + EX_ADDR[i] = part_find_signal( PART, buff ); + if (!EX_ADDR[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 16; i++) { + sprintf( buff, "EX_DATA[%d]", i ); + EX_DATA[i] = part_find_signal( PART, buff ); + if (!EX_DATA[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + EX_WR = part_find_signal( PART, "EX_WR" ); + if (!EX_WR) { + printf( _("signal '%s' not found\n"), "EX_WR" ); + failed = 1; + } + EX_RD = part_find_signal( PART, "EX_RD" ); + if (!EX_RD) { + printf( _("signal '%s' not found\n"), "EX_RD" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +ixp425_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Intel IXP425 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +ixp425_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +ixp425_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 16; + + return 0; +} + +static void select_flash( bus_t *bus ) { part_t *p = PART; @@ -70,7 +187,7 @@ select_flash( bus_t *bus ) part_set_signal( p, EX_CS[7], 1, 1 ); } -static void +static void unselect_flash( bus_t *bus ) { part_t *p = PART; @@ -115,24 +232,10 @@ setup_data( bus_t *bus, uint32_t d ) part_set_signal( p, EX_DATA[i], 1, (d >> i) & 1 ); } -static void -ixp425_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Intel IXP425 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void -ixp425_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void ixp425_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -149,6 +252,10 @@ ixp425_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t ixp425_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -166,6 +273,10 @@ ixp425_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t ixp425_bus_read_end( bus_t *bus ) { @@ -186,6 +297,10 @@ ixp425_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t ixp425_bus_read( bus_t *bus, uint32_t adr ) { @@ -193,6 +308,10 @@ ixp425_bus_read( bus_t *bus, uint32_t adr ) return ixp425_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void ixp425_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -214,89 +333,6 @@ ixp425_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static int -ixp425_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - area->width = 16; - - return 0; -} - -static bus_t * -ixp425_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[15]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &ixp425_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - for (i = 0; i < 8; i++) { - sprintf( buff, "EX_CS[%d]", i ); - EX_CS[i] = part_find_signal( PART, buff ); - if (!EX_CS[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - for (i = 0; i < 24; i++) { - sprintf( buff, "EX_ADDR[%d]", i ); - EX_ADDR[i] = part_find_signal( PART, buff ); - if (!EX_ADDR[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - for (i = 0; i < 16; i++) { - sprintf( buff, "EX_DATA[%d]", i ); - EX_DATA[i] = part_find_signal( PART, buff ); - if (!EX_DATA[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - EX_WR = part_find_signal( PART, "EX_WR" ); - if (!EX_WR) { - printf( _("signal '%s' not found\n"), "EX_WR" ); - failed = 1; - } - EX_RD = part_find_signal( PART, "EX_RD" ); - if (!EX_RD) { - printf( _("signal '%s' not found\n"), "EX_RD" ); - failed = 1; - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t ixp425_bus = { "ixp425", N_("Intel IXP425 compatible bus driver via BSR"), diff --git a/jtag/src/bus/jopcyc.c b/jtag/src/bus/jopcyc.c index 34a4384f..3b6e97ad 100644 --- a/jtag/src/bus/jopcyc.c +++ b/jtag/src/bus/jopcyc.c @@ -133,6 +133,240 @@ typedef struct { #define SER_TXD ((bus_params_t *) bus->params)->ser_txd #define SER_NCTS ((bus_params_t *) bus->params)->ser_ncts +static int +attach_sig( bus_t *bus, signal_t **sig, char *id ) +{ + int failed = 0; + + *sig = part_find_signal( PART, id ); + if (!*sig) { + printf( _("signal '%s' not found\n"), id ); + failed = 1; + } + + return failed; +} + +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +jopcyc_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + int failed = 0; + component_t *comp; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &jopcyc_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + /* + * Setup RAMA + */ + comp = COMP_RAMA; + comp->ctype = RAM; + comp->cname = "RAMA"; + + failed |= attach_sig( bus, &(A[ 0]), "IO64" ); + failed |= attach_sig( bus, &(A[ 1]), "IO66" ); + failed |= attach_sig( bus, &(A[ 2]), "IO68" ); + failed |= attach_sig( bus, &(A[ 3]), "IO74" ); + failed |= attach_sig( bus, &(A[ 4]), "IO76" ); + failed |= attach_sig( bus, &(A[ 5]), "IO107" ); + failed |= attach_sig( bus, &(A[ 6]), "IO113" ); + failed |= attach_sig( bus, &(A[ 7]), "IO115" ); + failed |= attach_sig( bus, &(A[ 8]), "IO117" ); + failed |= attach_sig( bus, &(A[ 9]), "IO119" ); + failed |= attach_sig( bus, &(A[10]), "IO118" ); + failed |= attach_sig( bus, &(A[11]), "IO116" ); + failed |= attach_sig( bus, &(A[12]), "IO114" ); + failed |= attach_sig( bus, &(A[13]), "IO108" ); + failed |= attach_sig( bus, &(A[14]), "IO106" ); + failed |= attach_sig( bus, &(A[15]), "IO67" ); + failed |= attach_sig( bus, &(A[16]), "IO65" ); + failed |= attach_sig( bus, &(A[17]), "IO63" ); + A[18] = NULL; + + failed |= attach_sig( bus, &(D[ 0]), "IO82" ); + failed |= attach_sig( bus, &(D[ 1]), "IO84" ); + failed |= attach_sig( bus, &(D[ 2]), "IO86" ); + failed |= attach_sig( bus, &(D[ 3]), "IO88" ); + failed |= attach_sig( bus, &(D[ 4]), "IO94" ); + failed |= attach_sig( bus, &(D[ 5]), "IO98" ); + failed |= attach_sig( bus, &(D[ 6]), "IO100" ); + failed |= attach_sig( bus, &(D[ 7]), "IO104" ); + failed |= attach_sig( bus, &(D[ 8]), "IO101" ); + failed |= attach_sig( bus, &(D[ 9]), "IO99" ); + failed |= attach_sig( bus, &(D[10]), "IO95" ); + failed |= attach_sig( bus, &(D[11]), "IO93" ); + failed |= attach_sig( bus, &(D[12]), "IO87" ); + failed |= attach_sig( bus, &(D[13]), "IO85" ); + failed |= attach_sig( bus, &(D[14]), "IO83" ); + failed |= attach_sig( bus, &(D[15]), "IO79" ); + + failed |= attach_sig( bus, &(nCS), "IO78" ); + failed |= attach_sig( bus, &(nOE), "IO73" ); + failed |= attach_sig( bus, &(nWE), "IO105" ); + failed |= attach_sig( bus, &(nLB), "IO77" ); + failed |= attach_sig( bus, &(nUB), "IO75" ); + nCS2 = NULL; + nRDY = NULL; + + /* + * Setup RAMB + */ + comp = COMP_RAMB; + comp->ctype = RAM; + comp->cname = "RAMB"; + + failed |= attach_sig( bus, &(A[ 0]), "IO237" ); + failed |= attach_sig( bus, &(A[ 1]), "IO235" ); + failed |= attach_sig( bus, &(A[ 2]), "IO233" ); + failed |= attach_sig( bus, &(A[ 3]), "IO227" ); + failed |= attach_sig( bus, &(A[ 4]), "IO225" ); + failed |= attach_sig( bus, &(A[ 5]), "IO194" ); + failed |= attach_sig( bus, &(A[ 6]), "IO188" ); + failed |= attach_sig( bus, &(A[ 7]), "IO186" ); + failed |= attach_sig( bus, &(A[ 8]), "IO184" ); + failed |= attach_sig( bus, &(A[ 9]), "IO182" ); + failed |= attach_sig( bus, &(A[10]), "IO183" ); + failed |= attach_sig( bus, &(A[11]), "IO185" ); + failed |= attach_sig( bus, &(A[12]), "IO187" ); + failed |= attach_sig( bus, &(A[13]), "IO193" ); + failed |= attach_sig( bus, &(A[14]), "IO195" ); + failed |= attach_sig( bus, &(A[15]), "IO234" ); + failed |= attach_sig( bus, &(A[16]), "IO236" ); + failed |= attach_sig( bus, &(A[17]), "IO238" ); + A[18] = NULL; + + failed |= attach_sig( bus, &(D[ 0]), "IO219" ); + failed |= attach_sig( bus, &(D[ 1]), "IO217" ); + failed |= attach_sig( bus, &(D[ 2]), "IO215" ); + failed |= attach_sig( bus, &(D[ 3]), "IO213" ); + failed |= attach_sig( bus, &(D[ 4]), "IO207" ); + failed |= attach_sig( bus, &(D[ 5]), "IO203" ); + failed |= attach_sig( bus, &(D[ 6]), "IO201" ); + failed |= attach_sig( bus, &(D[ 7]), "IO197" ); + failed |= attach_sig( bus, &(D[ 8]), "IO200" ); + failed |= attach_sig( bus, &(D[ 9]), "IO202" ); + failed |= attach_sig( bus, &(D[10]), "IO206" ); + failed |= attach_sig( bus, &(D[11]), "IO208" ); + failed |= attach_sig( bus, &(D[12]), "IO214" ); + failed |= attach_sig( bus, &(D[13]), "IO216" ); + failed |= attach_sig( bus, &(D[14]), "IO218" ); + failed |= attach_sig( bus, &(D[15]), "IO222" ); + + failed |= attach_sig( bus, &(nCS), "IO223" ); + failed |= attach_sig( bus, &(nOE), "IO228" ); + failed |= attach_sig( bus, &(nWE), "IO196" ); + failed |= attach_sig( bus, &(nLB), "IO224" ); + failed |= attach_sig( bus, &(nUB), "IO226" ); + nCS2 = NULL; + nRDY = NULL; + + /* + * Setup FLASH + */ + comp = COMP_FLASH; + comp->ctype = FLASH; + comp->cname = "FLASH"; + + failed |= attach_sig( bus, &(A[ 0]), "IO47" ); + failed |= attach_sig( bus, &(A[ 1]), "IO48" ); + failed |= attach_sig( bus, &(A[ 2]), "IO49" ); + failed |= attach_sig( bus, &(A[ 3]), "IO50" ); + failed |= attach_sig( bus, &(A[ 4]), "IO125" ); + failed |= attach_sig( bus, &(A[ 5]), "IO127" ); + failed |= attach_sig( bus, &(A[ 6]), "IO131" ); + failed |= attach_sig( bus, &(A[ 7]), "IO133" ); + failed |= attach_sig( bus, &(A[ 8]), "IO158" ); + failed |= attach_sig( bus, &(A[ 9]), "IO16" ); + failed |= attach_sig( bus, &(A[10]), "IO20" ); + failed |= attach_sig( bus, &(A[11]), "IO14" ); + failed |= attach_sig( bus, &(A[12]), "IO135" ); + failed |= attach_sig( bus, &(A[13]), "IO156" ); + failed |= attach_sig( bus, &(A[14]), "IO144" ); + failed |= attach_sig( bus, &(A[15]), "IO137" ); + failed |= attach_sig( bus, &(A[16]), "IO139" ); + failed |= attach_sig( bus, &(A[17]), "IO143" ); + failed |= attach_sig( bus, &(A[18]), "IO141" ); + + failed |= attach_sig( bus, &(D[ 0]), "IO46" ); + failed |= attach_sig( bus, &(D[ 1]), "IO45" ); + failed |= attach_sig( bus, &(D[ 2]), "IO44" ); + failed |= attach_sig( bus, &(D[ 3]), "IO165" ); + failed |= attach_sig( bus, &(D[ 4]), "IO164" ); + failed |= attach_sig( bus, &(D[ 5]), "IO17" ); + failed |= attach_sig( bus, &(D[ 6]), "IO18" ); + failed |= attach_sig( bus, &(D[ 7]), "IO19" ); + D[ 8] = NULL; + D[ 9] = NULL; + D[10] = NULL; + D[11] = NULL; + D[12] = NULL; + D[13] = NULL; + D[14] = NULL; + D[15] = NULL; + + failed |= attach_sig( bus, &(nWE), "IO15" ); + failed |= attach_sig( bus, &(nOE), "IO24" ); + failed |= attach_sig( bus, &(nCS), "IO37" ); + failed |= attach_sig( bus, &(nCS2), "IO23" ); + + /* CLK1 is not observable :-( + failed |= attach_sig( bus, &(nRDY), "CLK1" ); + */ + nRDY = NULL; + + nLB = NULL; + nUB = NULL; + + /* + * Setup Serial Port + */ + failed |= attach_sig( bus, &(SER_RXD), "CLK2" ); + failed |= attach_sig( bus, &(SER_NRTS), "IO177" ); + failed |= attach_sig( bus, &(SER_TXD), "IO178" ); + failed |= attach_sig( bus, &(SER_NCTS), "CLK0" ); + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +jopcyc_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("JOP.design Cyclone Board compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} static void setup_address( bus_t *bus, uint32_t a, component_t *comp ) @@ -208,27 +442,10 @@ setup_data( bus_t *bus, uint32_t d, component_t *comp ) part_set_signal( p, D[i], 1, (d >> i) & 1 ); } -static int comp_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area, component_t **comp ); - - -/* *************************************************************************** - * jopcyc_printinfo - * ***************************************************************************/ -static void -jopcyc_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("JOP.design Cyclone Board compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - - -/* *************************************************************************** - * jopcyc_bus_prepare - * ***************************************************************************/ +/** + * bus->driver->(*prepare) + * + */ static void jopcyc_bus_prepare( bus_t *bus ) { @@ -281,18 +498,62 @@ jopcyc_bus_prepare( bus_t *bus ) chain_shift_instructions( chain ); } - -/* *************************************************************************** - * jopcyc_bus_read_start - * ***************************************************************************/ -static void -jopcyc_bus_read_start( bus_t *bus, uint32_t adr ) +static int +comp_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area, component_t **comp ) { - part_t *p = PART; - chain_t *chain = CHAIN; - bus_area_t area; - component_t *comp; - + if (adr < RAMB_START) { + area->description = "RAMA Component"; + area->start = RAMA_START; + area->length = RAM_LENGTH; + area->width = RAM_DATA_WIDTH; + *comp = COMP_RAMA; + } else if (adr < FLASH_START) { + area->description = "RAMB Component"; + area->start = RAMB_START; + area->length = RAM_LENGTH; + area->width = RAM_DATA_WIDTH; + *comp = COMP_RAMB; + } else if (adr < FLASH_START + FLASH_LENGTH) { + area->description = "FLASH Component"; + area->start = FLASH_START; + area->length = FLASH_LENGTH; + area->width = FLASH_DATA_WIDTH; + *comp = COMP_FLASH; + } else { + area->description = "Dummy"; + area->start = 2 * RAM_LENGTH + FLASH_LENGTH; + area->length = UINT64_C(0x100000000); + area->width = 0; + *comp = NULL; + } + + return 0; +} + +/** + * bus->driver->(*area) + * + */ +static int +jopcyc_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + component_t *comp; + + return comp_bus_area( bus, adr, area, &comp ); +} + +/** + * bus->driver->(*read_start) + * + */ +static void +jopcyc_bus_read_start( bus_t *bus, uint32_t adr ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + bus_area_t area; + component_t *comp; + comp_bus_area( bus, adr, &area, &comp ); if (!comp) { printf( _("Address out of range\n") ); @@ -314,10 +575,10 @@ jopcyc_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } - -/* *************************************************************************** - * jopcyc_bus_read_next - * ***************************************************************************/ +/** + * bus->driver->(*read_next) + * + */ static uint32_t jopcyc_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -344,10 +605,10 @@ jopcyc_bus_read_next( bus_t *bus, uint32_t adr ) return d; } - -/* *************************************************************************** - * jopcyc_bus_read_end - * ***************************************************************************/ +/** + * bus->driver->(*read_end) + * + */ static uint32_t jopcyc_bus_read_end( bus_t *bus ) { @@ -379,10 +640,10 @@ jopcyc_bus_read_end( bus_t *bus ) return d; } - -/* *************************************************************************** - * jopcyc_bus_read - * ***************************************************************************/ +/** + * bus->driver->(*read) + * + */ static uint32_t jopcyc_bus_read( bus_t *bus, uint32_t adr ) { @@ -390,10 +651,10 @@ jopcyc_bus_read( bus_t *bus, uint32_t adr ) return jopcyc_bus_read_end( bus ); } - -/* *************************************************************************** - * jopcyc_bus_write - * ***************************************************************************/ +/** + * bus->driver->(*write) + * + */ static void jopcyc_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -432,269 +693,6 @@ jopcyc_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } - -/* *************************************************************************** - * jopcyc_bus_area - * ***************************************************************************/ - -static int -comp_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area, component_t **comp ) -{ - if (adr < RAMB_START) { - area->description = "RAMA Component"; - area->start = RAMA_START; - area->length = RAM_LENGTH; - area->width = RAM_DATA_WIDTH; - *comp = COMP_RAMA; - } else if (adr < FLASH_START) { - area->description = "RAMB Component"; - area->start = RAMB_START; - area->length = RAM_LENGTH; - area->width = RAM_DATA_WIDTH; - *comp = COMP_RAMB; - } else if (adr < FLASH_START + FLASH_LENGTH) { - area->description = "FLASH Component"; - area->start = FLASH_START; - area->length = FLASH_LENGTH; - area->width = FLASH_DATA_WIDTH; - *comp = COMP_FLASH; - } else { - area->description = "Dummy"; - area->start = 2 * RAM_LENGTH + FLASH_LENGTH; - area->length = UINT64_C(0x100000000); - area->width = 0; - *comp = NULL; - } - - return 0; -} - - -static int -jopcyc_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - component_t *comp; - - return comp_bus_area( bus, adr, area, &comp ); -} - - -static int -attach_sig( bus_t *bus, signal_t **sig, char *id ) -{ - int failed = 0; - - *sig = part_find_signal( PART, id ); - if (!*sig) { - printf( _("signal '%s' not found\n"), id ); - failed = 1; - } - - return failed; -} - -static bus_t * -jopcyc_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - int failed = 0; - component_t *comp; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &jopcyc_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - /* - * Setup RAMA - */ - comp = COMP_RAMA; - comp->ctype = RAM; - comp->cname = "RAMA"; - - failed |= attach_sig( bus, &(A[ 0]), "IO64" ); - failed |= attach_sig( bus, &(A[ 1]), "IO66" ); - failed |= attach_sig( bus, &(A[ 2]), "IO68" ); - failed |= attach_sig( bus, &(A[ 3]), "IO74" ); - failed |= attach_sig( bus, &(A[ 4]), "IO76" ); - failed |= attach_sig( bus, &(A[ 5]), "IO107" ); - failed |= attach_sig( bus, &(A[ 6]), "IO113" ); - failed |= attach_sig( bus, &(A[ 7]), "IO115" ); - failed |= attach_sig( bus, &(A[ 8]), "IO117" ); - failed |= attach_sig( bus, &(A[ 9]), "IO119" ); - failed |= attach_sig( bus, &(A[10]), "IO118" ); - failed |= attach_sig( bus, &(A[11]), "IO116" ); - failed |= attach_sig( bus, &(A[12]), "IO114" ); - failed |= attach_sig( bus, &(A[13]), "IO108" ); - failed |= attach_sig( bus, &(A[14]), "IO106" ); - failed |= attach_sig( bus, &(A[15]), "IO67" ); - failed |= attach_sig( bus, &(A[16]), "IO65" ); - failed |= attach_sig( bus, &(A[17]), "IO63" ); - A[18] = NULL; - - failed |= attach_sig( bus, &(D[ 0]), "IO82" ); - failed |= attach_sig( bus, &(D[ 1]), "IO84" ); - failed |= attach_sig( bus, &(D[ 2]), "IO86" ); - failed |= attach_sig( bus, &(D[ 3]), "IO88" ); - failed |= attach_sig( bus, &(D[ 4]), "IO94" ); - failed |= attach_sig( bus, &(D[ 5]), "IO98" ); - failed |= attach_sig( bus, &(D[ 6]), "IO100" ); - failed |= attach_sig( bus, &(D[ 7]), "IO104" ); - failed |= attach_sig( bus, &(D[ 8]), "IO101" ); - failed |= attach_sig( bus, &(D[ 9]), "IO99" ); - failed |= attach_sig( bus, &(D[10]), "IO95" ); - failed |= attach_sig( bus, &(D[11]), "IO93" ); - failed |= attach_sig( bus, &(D[12]), "IO87" ); - failed |= attach_sig( bus, &(D[13]), "IO85" ); - failed |= attach_sig( bus, &(D[14]), "IO83" ); - failed |= attach_sig( bus, &(D[15]), "IO79" ); - - failed |= attach_sig( bus, &(nCS), "IO78" ); - failed |= attach_sig( bus, &(nOE), "IO73" ); - failed |= attach_sig( bus, &(nWE), "IO105" ); - failed |= attach_sig( bus, &(nLB), "IO77" ); - failed |= attach_sig( bus, &(nUB), "IO75" ); - nCS2 = NULL; - nRDY = NULL; - - /* - * Setup RAMB - */ - comp = COMP_RAMB; - comp->ctype = RAM; - comp->cname = "RAMB"; - - failed |= attach_sig( bus, &(A[ 0]), "IO237" ); - failed |= attach_sig( bus, &(A[ 1]), "IO235" ); - failed |= attach_sig( bus, &(A[ 2]), "IO233" ); - failed |= attach_sig( bus, &(A[ 3]), "IO227" ); - failed |= attach_sig( bus, &(A[ 4]), "IO225" ); - failed |= attach_sig( bus, &(A[ 5]), "IO194" ); - failed |= attach_sig( bus, &(A[ 6]), "IO188" ); - failed |= attach_sig( bus, &(A[ 7]), "IO186" ); - failed |= attach_sig( bus, &(A[ 8]), "IO184" ); - failed |= attach_sig( bus, &(A[ 9]), "IO182" ); - failed |= attach_sig( bus, &(A[10]), "IO183" ); - failed |= attach_sig( bus, &(A[11]), "IO185" ); - failed |= attach_sig( bus, &(A[12]), "IO187" ); - failed |= attach_sig( bus, &(A[13]), "IO193" ); - failed |= attach_sig( bus, &(A[14]), "IO195" ); - failed |= attach_sig( bus, &(A[15]), "IO234" ); - failed |= attach_sig( bus, &(A[16]), "IO236" ); - failed |= attach_sig( bus, &(A[17]), "IO238" ); - A[18] = NULL; - - failed |= attach_sig( bus, &(D[ 0]), "IO219" ); - failed |= attach_sig( bus, &(D[ 1]), "IO217" ); - failed |= attach_sig( bus, &(D[ 2]), "IO215" ); - failed |= attach_sig( bus, &(D[ 3]), "IO213" ); - failed |= attach_sig( bus, &(D[ 4]), "IO207" ); - failed |= attach_sig( bus, &(D[ 5]), "IO203" ); - failed |= attach_sig( bus, &(D[ 6]), "IO201" ); - failed |= attach_sig( bus, &(D[ 7]), "IO197" ); - failed |= attach_sig( bus, &(D[ 8]), "IO200" ); - failed |= attach_sig( bus, &(D[ 9]), "IO202" ); - failed |= attach_sig( bus, &(D[10]), "IO206" ); - failed |= attach_sig( bus, &(D[11]), "IO208" ); - failed |= attach_sig( bus, &(D[12]), "IO214" ); - failed |= attach_sig( bus, &(D[13]), "IO216" ); - failed |= attach_sig( bus, &(D[14]), "IO218" ); - failed |= attach_sig( bus, &(D[15]), "IO222" ); - - failed |= attach_sig( bus, &(nCS), "IO223" ); - failed |= attach_sig( bus, &(nOE), "IO228" ); - failed |= attach_sig( bus, &(nWE), "IO196" ); - failed |= attach_sig( bus, &(nLB), "IO224" ); - failed |= attach_sig( bus, &(nUB), "IO226" ); - nCS2 = NULL; - nRDY = NULL; - - /* - * Setup FLASH - */ - comp = COMP_FLASH; - comp->ctype = FLASH; - comp->cname = "FLASH"; - - failed |= attach_sig( bus, &(A[ 0]), "IO47" ); - failed |= attach_sig( bus, &(A[ 1]), "IO48" ); - failed |= attach_sig( bus, &(A[ 2]), "IO49" ); - failed |= attach_sig( bus, &(A[ 3]), "IO50" ); - failed |= attach_sig( bus, &(A[ 4]), "IO125" ); - failed |= attach_sig( bus, &(A[ 5]), "IO127" ); - failed |= attach_sig( bus, &(A[ 6]), "IO131" ); - failed |= attach_sig( bus, &(A[ 7]), "IO133" ); - failed |= attach_sig( bus, &(A[ 8]), "IO158" ); - failed |= attach_sig( bus, &(A[ 9]), "IO16" ); - failed |= attach_sig( bus, &(A[10]), "IO20" ); - failed |= attach_sig( bus, &(A[11]), "IO14" ); - failed |= attach_sig( bus, &(A[12]), "IO135" ); - failed |= attach_sig( bus, &(A[13]), "IO156" ); - failed |= attach_sig( bus, &(A[14]), "IO144" ); - failed |= attach_sig( bus, &(A[15]), "IO137" ); - failed |= attach_sig( bus, &(A[16]), "IO139" ); - failed |= attach_sig( bus, &(A[17]), "IO143" ); - failed |= attach_sig( bus, &(A[18]), "IO141" ); - - failed |= attach_sig( bus, &(D[ 0]), "IO46" ); - failed |= attach_sig( bus, &(D[ 1]), "IO45" ); - failed |= attach_sig( bus, &(D[ 2]), "IO44" ); - failed |= attach_sig( bus, &(D[ 3]), "IO165" ); - failed |= attach_sig( bus, &(D[ 4]), "IO164" ); - failed |= attach_sig( bus, &(D[ 5]), "IO17" ); - failed |= attach_sig( bus, &(D[ 6]), "IO18" ); - failed |= attach_sig( bus, &(D[ 7]), "IO19" ); - D[ 8] = NULL; - D[ 9] = NULL; - D[10] = NULL; - D[11] = NULL; - D[12] = NULL; - D[13] = NULL; - D[14] = NULL; - D[15] = NULL; - - failed |= attach_sig( bus, &(nWE), "IO15" ); - failed |= attach_sig( bus, &(nOE), "IO24" ); - failed |= attach_sig( bus, &(nCS), "IO37" ); - failed |= attach_sig( bus, &(nCS2), "IO23" ); - - /* CLK1 is not observable :-( - failed |= attach_sig( bus, &(nRDY), "CLK1" ); - */ - nRDY = NULL; - - nLB = NULL; - nUB = NULL; - - /* - * Setup Serial Port - */ - failed |= attach_sig( bus, &(SER_RXD), "CLK2" ); - failed |= attach_sig( bus, &(SER_NRTS), "IO177" ); - failed |= attach_sig( bus, &(SER_TXD), "IO178" ); - failed |= attach_sig( bus, &(SER_NCTS), "CLK0" ); - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t jopcyc_bus = { "jopcyc", N_("JOP.design Cyclone Board compatible bus driver via BSR"), diff --git a/jtag/src/bus/lh7a400.c b/jtag/src/bus/lh7a400.c index 619306ab..a2d782bd 100644 --- a/jtag/src/bus/lh7a400.c +++ b/jtag/src/bus/lh7a400.c @@ -23,7 +23,7 @@ * * Documentation: * - * [1] Sharp Microelectronics, "LH7A400 Universal SOC Preliminary + * [1] Sharp Microelectronics, "LH7A400 Universal SOC Preliminary * Users's Guide", May 2003, Reference No. SMA02010 * * @@ -71,6 +71,152 @@ typedef struct { #define nOE ((bus_params_t *) bus->params)->noe #define WIDTH ((bus_params_t *) bus->params)->width +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +lh7a400_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[10]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &lh7a400_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + for (i = 0; i < ADR_NUM; 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 < D_NUM; 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 < nCS_NUM; i++) { + sprintf( buff, "nCS%d", i ); + nCS[i] = part_find_signal( PART, buff ); + if (!nCS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < WIDTH_NUM; i++) { + sprintf( buff, "WIDTH%d", i ); + WIDTH[i] = part_find_signal( PART, buff ); + if (!WIDTH[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + nWE = part_find_signal( PART, "nWE0" ); + if (!nWE) { + printf( _("signal '%s' not found\n"), "nWE" ); + failed = 1; + } + nOE = part_find_signal( PART, "nOE" ); + if (!nOE) { + printf( _("signal '%s' not found\n"), "nOE" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +lh7a400_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Sharp LH7A400 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +lh7a400_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +lh7a400_bus_area ( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + unsigned int width; + + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x10000000); + + /* we determine the size of the flash that was booted from [1] table 3.1 */ + width = part_get_signal( PART, part_find_signal( PART, "WIDTH0" ) ); + width |= part_get_signal( PART, part_find_signal( PART, "WIDTH1" ) ) << 1; + + if (width < 0) + return -1; + + switch (width) { + case 0: + area->width = 8; + break; + case 1: + area->width = 16; + break; + case 2: + case 3: + area->width = 32; + } + + return 0; +} + static void setup_address( bus_t *bus, uint32_t a ) { @@ -81,8 +227,6 @@ setup_address( bus_t *bus, uint32_t a ) part_set_signal( p, A[i], 1, (a >> i) & 1 ); } -static int lh7a400_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ); - static void set_data_in( bus_t *bus ) { @@ -94,7 +238,7 @@ set_data_in( bus_t *bus ) for (i = 0; i < area.width; i++) part_set_signal( p, D[i], 0, 0 ); - + } static void @@ -110,24 +254,10 @@ setup_data( bus_t *bus, uint32_t d ) part_set_signal( p, D[i], 1, (d >> i) & 1 ); } -static void -lh7a400_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Sharp LH7A400 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void -lh7a400_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void lh7a400_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -145,6 +275,10 @@ lh7a400_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t lh7a400_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -166,7 +300,11 @@ lh7a400_bus_read_next( bus_t *bus, uint32_t adr ) return d; } -static uint32_t +/** + * bus->driver->(*read_end) + * + */ +static uint32_t lh7a400_bus_read_end( bus_t *bus ) { /* see Figure 3-3 in [1] */ @@ -189,6 +327,10 @@ lh7a400_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t lh7a400_bus_read( bus_t *bus, uint32_t adr ) { @@ -196,6 +338,10 @@ lh7a400_bus_read( bus_t *bus, uint32_t adr ) return lh7a400_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void lh7a400_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -220,118 +366,6 @@ lh7a400_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static int -lh7a400_bus_area ( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - unsigned int width; - - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x10000000); - - /* we determine the size of the flash that was booted from [1] table 3.1 */ - width = part_get_signal( PART, part_find_signal( PART, "WIDTH0" ) ); - width |= part_get_signal( PART, part_find_signal( PART, "WIDTH1" ) ) << 1; - - if (width < 0) - return -1; - - switch (width) { - case 0: - area->width = 8; - break; - case 1: - area->width = 16; - break; - case 2: - case 3: - area->width = 32; - } - - return 0; -} - -static bus_t * -lh7a400_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[10]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &lh7a400_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - for (i = 0; i < ADR_NUM; 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 < D_NUM; 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 < nCS_NUM; i++) { - sprintf( buff, "nCS%d", i ); - nCS[i] = part_find_signal( PART, buff ); - if (!nCS[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - for (i = 0; i < WIDTH_NUM; i++) { - sprintf( buff, "WIDTH%d", i ); - WIDTH[i] = part_find_signal( PART, buff ); - if (!WIDTH[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - nWE = part_find_signal( PART, "nWE0" ); - if (!nWE) { - printf( _("signal '%s' not found\n"), "nWE" ); - failed = 1; - } - nOE = part_find_signal( PART, "nOE" ); - if (!nOE) { - printf( _("signal '%s' not found\n"), "nOE" ); - failed = 1; - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t lh7a400_bus = { "lh7a400", N_("Sharp LH7A400 compatible bus driver via BSR (flash access only!)"), diff --git a/jtag/src/bus/mpc5200.c b/jtag/src/bus/mpc5200.c index eb761989..53b643f5 100644 --- a/jtag/src/bus/mpc5200.c +++ b/jtag/src/bus/mpc5200.c @@ -60,6 +60,133 @@ typedef struct { #define nOE ((bus_params_t *) bus->params)->noe #define D ((bus_params_t *) bus->params)->d +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +mpc5200_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[10]; + int i; + int failed = 0; + part_t *part; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &mpc5200_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = part = chain->parts->parts[chain->active_part]; + + /* Get the signals */ + for (i = 0; i < 24; i++) { + sprintf( buff, "EXT_AD_%d", i ); + AD[i] = part_find_signal( part, buff ); + if (!AD[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 4; i++) { + sprintf( buff, "LP_CS%d_B", i ); + nCS[i] = part_find_signal( part, buff ); + if (!nCS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + nWE = part_find_signal( part, "LP_RW" ); + if (!nWE) { + printf( _("signal '%s' not found\n"), "LP_RW" ); + failed = 1; + } + nOE = part_find_signal( part, "LP_OE" ); + if (!nOE) { + printf( _("signal '%s' not found\n"), "LP_OE" ); + failed = 1; + } + for (i = 0; i < 8; i++) { + sprintf( buff, "EXT_AD_%d", i+24 ); + D[i] = part_find_signal( part, buff ); + if (!D[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +mpc5200_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Freescale MPC5200 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +mpc5200_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +mpc5200_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + if( adr < UINT32_C(0x01000000) ) + { + area->description = N_("LocalPlus Bus"); + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x01000000); + area->width = 8; + return 0; + } + + area->description = NULL; + area->start = 0x01000000; + area->length = 0xFF000000; + area->width = 0; + return 0; +} + static void setup_address( bus_t *bus, uint32_t a ) { @@ -70,8 +197,6 @@ setup_address( bus_t *bus, uint32_t a ) part_set_signal( p, AD[i], 1, (a >> i) & 1 ); } -static int mpc5200_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ); - static void set_data_in( bus_t *bus, uint32_t adr ) { @@ -120,24 +245,10 @@ get_data( bus_t *bus, uint32_t adr ) return d; } -static void -mpc5200_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Freescale MPC5200 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void -mpc5200_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void mpc5200_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -159,6 +270,10 @@ mpc5200_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( CHAIN, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t mpc5200_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -172,6 +287,10 @@ mpc5200_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t mpc5200_bus_read_end( bus_t *bus ) { @@ -185,6 +304,10 @@ mpc5200_bus_read_end( bus_t *bus ) return get_data( bus, LAST_ADR ); } +/** + * bus->driver->(*read) + * + */ static uint32_t mpc5200_bus_read( bus_t *bus, uint32_t adr ) { @@ -192,6 +315,10 @@ mpc5200_bus_read( bus_t *bus, uint32_t adr ) return mpc5200_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void mpc5200_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -217,99 +344,6 @@ mpc5200_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static int -mpc5200_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - if( adr < UINT32_C(0x01000000) ) - { - area->description = N_("LocalPlus Bus"); - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x01000000); - area->width = 8; - return 0; - } - - area->description = NULL; - area->start = 0x01000000; - area->length = 0xFF000000; - area->width = 0; - return 0; -} - -static bus_t * -mpc5200_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[10]; - int i; - int failed = 0; - part_t *part; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &mpc5200_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = part = chain->parts->parts[chain->active_part]; - - /* Get the signals */ - for (i = 0; i < 24; i++) { - sprintf( buff, "EXT_AD_%d", i ); - AD[i] = part_find_signal( part, buff ); - if (!AD[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - for (i = 0; i < 4; i++) { - sprintf( buff, "LP_CS%d_B", i ); - nCS[i] = part_find_signal( part, buff ); - if (!nCS[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - nWE = part_find_signal( part, "LP_RW" ); - if (!nWE) { - printf( _("signal '%s' not found\n"), "LP_RW" ); - failed = 1; - } - nOE = part_find_signal( part, "LP_OE" ); - if (!nOE) { - printf( _("signal '%s' not found\n"), "LP_OE" ); - failed = 1; - } - for (i = 0; i < 8; i++) { - sprintf( buff, "EXT_AD_%d", i+24 ); - D[i] = part_find_signal( part, buff ); - if (!D[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t mpc5200_bus = { "mpc5200", N_("Freescale MPC5200 compatible bus driver via BSR"), diff --git a/jtag/src/bus/mpc824x.c b/jtag/src/bus/mpc824x.c index bf1752ca..fb179f9d 100644 --- a/jtag/src/bus/mpc824x.c +++ b/jtag/src/bus/mpc824x.c @@ -70,13 +70,288 @@ char dbgAddr = 0; char dbgData = 0; +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +mpc824x_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[10]; + int i; + int failed = 0; + part_t *part; + signal_t *s_nfoe; + signal_t *s_sdma1; + + char param[16], value[16]; + + char dfltWidth = 1; + + dbgAddr = 0; + dbgData = 0; + REVBITS = 0; + + for (i=2; cmd_params[i]; i++) { + if (strstr( cmd_params[i], "=")) { + sscanf( cmd_params[i], "%[^=]%*c%s", param, value ); + + if (!strcmp( "width", param )) { + if (!strcmp( "8", value )) { + BUS_WIDTH = 8; + dfltWidth = 0; + } else if (!strcmp( "32", value )) { + BUS_WIDTH = 32; + dfltWidth = 0; + } + else if (!strcmp( "64", value )) { + // BUS_WIDTH = 64; // Needs to fix, look at setup_data() + BUS_WIDTH = 32; + printf(_(" Bus width 64 exists in mpc824x, but not supported by UrJTAG currently\n")); + dfltWidth = 1; + } + else { + printf(_(" Only 8,32 and 64 bus width are supported for Banks 0 and 1\n")); + return NULL; + } + } + } else { + if (!strcmp( "revbits", cmd_params[i])) + REVBITS = 1; + + if (!strcmp( "help", cmd_params[i])) { + printf(_("Usage: initbus mpc824x [width=WIDTH] [revbits] [dbgAddr] [dbgData]\n\n" + " WIDTH data bus width - 8, 32, 64 (default 8)\n" + " revbits reverse bits in data bus (default - no)\n" + " dbgAddr display address bus state (default - no)\n" + " dbgData display data bus state (default - no)\n")); + return NULL; + } + + if (!strcmp( "dbgAddr", cmd_params[i])) + dbgAddr = 1; + + + if (!strcmp( "dbgData", cmd_params[i])) + dbgData = 1; + + + } + + } + if (dfltWidth) + printf(_(" Using default bus width %d\n"), BUS_WIDTH); + + // REVBITS = 0; + + + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &mpc824x_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = part = chain->parts->parts[chain->active_part]; + + s_nfoe = part_find_signal( part, "nFOE" ); + s_sdma1 = part_find_signal( part, "SDMA1" ); + part_set_signal( part, s_nfoe, 0, 0 ); + part_set_signal( part, s_sdma1, 0, 0 ); + + part_set_instruction( part, "SAMPLE/PRELOAD" ); + chain_shift_instructions( chain ); + chain_shift_data_registers( chain, 0 ); + part_set_instruction( part, "EXTEST" ); + chain_shift_instructions( chain ); + chain_shift_data_registers( chain, 1 ); + + boot_nFOE = part_get_signal( part, s_nfoe ); + boot_SDMA1 = part_get_signal( part, s_sdma1 ); + + + for (i = 0; i <= 10; i++) { + sprintf( buff, "SDMA%d", i ); + AR[i] = part_find_signal( part, buff ); + if (!AR[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + AR[11] = part_find_signal( part, "SDBA0" ); + if (!AR[11]) { + printf( _("signal '%s' not found\n"), "SDBA0" ); + failed = 1; + } + for (i = 0; i < 8; i++) { + sprintf( buff, "PAR%d", i ); + AR[19 - i] = part_find_signal( part, buff ); + if (!AR[19 - i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + AR[20] = part_find_signal( part, "SDBA1" ); + if (!AR[20]) { + printf( _("signal '%s' not found\n"), "SDBA1" ); + failed = 1; + } + AR[21] = part_find_signal( part, "SDMA11" ); + if (!AR[21]) { + printf( _("signal '%s' not found\n"), "SDMA11" ); + failed = 1; + } + AR[22] = part_find_signal( part, "SDMA12" ); + if (!AR[22]) { + printf( _("signal '%s' not found\n"), "SDMA12" ); + failed = 1; + } + + + nRCS0 = part_find_signal( part, "nRCS0" ); + if (!nRCS0) { + printf( _("signal '%s' not found\n"), "nRCS0" ); + failed = 1; + } + nWE = part_find_signal( part, "nWE" ); + if (!nWE) { + printf( _("signal '%s' not found\n"), "nWE" ); + failed = 1; + } + nFOE = part_find_signal( part, "nFOE" ); + if (!nWE) { + printf( _("signal '%s' not found\n"), "nFOE" ); + failed = 1; + } + + /* + Freescale MPC824x uses inversed bit order ([1], p. 2-18): + msb is MDH[0] while lsb is MDH[31] + Flash chips usually use another bit orded: + msb is D[31] and lsb is D[0] + + This should be rewired in the PCB (MDH[0] - D[31], ..., MDH[31] - D[0]). + Otherwise you will have to use "revbits" UrJTAG parameter and + binary files with reversed bit order. + */ + + for (i = 0; i < 32; i++) { /* Needs to be fixed for 64-bit bus width */ + sprintf( buff, "MDH%d", 31 - i ); + D[i] = part_find_signal( part, buff ); + if (!D[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +mpc824x_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Motorola MPC824x compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +mpc824x_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +mpc824x_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + + if (adr < UINT32_C(0xFF000000)) { + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0xFF000000); + area->width = 0; + + return 0; + } + + if (adr < UINT32_C(0xFF800000)) { + area->description = N_("Base ROM Interface (Bank 1)"); + area->start = UINT32_C(0xFF000000); + area->length = UINT64_C(0x00800000); + area->width = 0; + + return 0; + } + + if (boot_SDMA1 == 0) { + area->description = N_("Base ROM Interface (Bank 0)"); + area->start = UINT32_C(0xFF800000); + area->length = UINT64_C(0x00800000); + area->width = BUS_WIDTH; + + return 0; + } + + /* extended addresing mode is disabled (SDMA1 is 1) */ + if (adr < UINT32_C(0xFFC00000)) { + area->description = NULL; + area->start = UINT32_C(0xFF800000); + area->length = UINT64_C(0x00400000); + area->width = BUS_WIDTH; + + return 0; + } + + area->description = N_("Base ROM Interface (Bank 0)"); + area->start = UINT32_C(0xFFC00000); + area->length = UINT64_C(0x00400000); + area->width = BUS_WIDTH; + + return 0; +} + static void setup_address( bus_t *bus, uint32_t a ) { int i; part_t *p = PART; - switch (BUS_WIDTH) { + switch (BUS_WIDTH) { case 8:/* 8-bit data bus */ for (i = 0; i < 23; i++) part_set_signal( p, AR[i], 1, (a >> i) & 1 ); @@ -88,7 +363,7 @@ setup_address( bus_t *bus, uint32_t a ) for (i = 0; i < 20; i++) part_set_signal( p, AR[i], 1, (a >> (i+3)) & 1 ); } - + /* Just for debugging */ if (dbgAddr) { int j, k; @@ -101,7 +376,7 @@ setup_address( bus_t *bus, uint32_t a ) printf(_("Addr [%2d:0]: %06X "), k, a); for (i=0; i<3; i++) { for (j=0; j<8; j++) - if ((i*8+j) >= (23 - k)) + if ((i*8+j) >= (23 - k)) printf("%1d", (a >> (23 - (i*8+j)) ) & 1); else printf(" "); @@ -112,8 +387,6 @@ setup_address( bus_t *bus, uint32_t a ) } -static int mpc824x_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ); - static void set_data_in( bus_t *bus, uint32_t adr ) { @@ -148,8 +421,8 @@ setup_data( bus_t *bus, uint32_t adr, uint32_t d ) printf(_("Data WR [%d:0]: %08X "), area.width-1, d); int j; int bytes =0; - if (BUS_WIDTH==8) bytes = 1; - else if (BUS_WIDTH==32) bytes = 4; + if (BUS_WIDTH==8) bytes = 1; + else if (BUS_WIDTH==32) bytes = 4; else if (BUS_WIDTH==64) bytes = 4; /* Needs to be fixed - d is 32-bit long, so no 64 bit mode is possible */ for (i=0; i> (BUS_WIDTH-1 - (i*8+j)) ) & 1); - else - printf("%1d", (d >> ( (i*8+j)) ) & 1); - printf(" "); - }; - printf("\n"); - } - - return d; -} - -static void -mpc824x_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Motorola MPC824x compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} + if (REVBITS) + printf("%1d", (d >> (BUS_WIDTH-1 - (i*8+j)) ) & 1); + else + printf("%1d", (d >> ( (i*8+j)) ) & 1); + printf(" "); + }; + printf("\n"); + } -static void -mpc824x_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); + return d; } +/** + * bus->driver->(*read_start) + * + */ static void mpc824x_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -239,6 +498,10 @@ mpc824x_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( CHAIN, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t mpc824x_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -252,6 +515,10 @@ mpc824x_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t mpc824x_bus_read_end( bus_t *bus ) { @@ -265,6 +532,10 @@ mpc824x_bus_read_end( bus_t *bus ) return get_data( bus, LAST_ADR ); } +/** + * bus->driver->(*read) + * + */ static uint32_t mpc824x_bus_read( bus_t *bus, uint32_t adr ) { @@ -272,6 +543,10 @@ mpc824x_bus_read( bus_t *bus, uint32_t adr ) return mpc824x_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void mpc824x_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -301,247 +576,6 @@ mpc824x_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) } -static int -mpc824x_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - - if (adr < UINT32_C(0xFF000000)) { - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0xFF000000); - area->width = 0; - - return 0; - } - - if (adr < UINT32_C(0xFF800000)) { - area->description = N_("Base ROM Interface (Bank 1)"); - area->start = UINT32_C(0xFF000000); - area->length = UINT64_C(0x00800000); - area->width = 0; - - return 0; - } - - if (boot_SDMA1 == 0) { - area->description = N_("Base ROM Interface (Bank 0)"); - area->start = UINT32_C(0xFF800000); - area->length = UINT64_C(0x00800000); - area->width = BUS_WIDTH; - - return 0; - } - - /* extended addresing mode is disabled (SDMA1 is 1) */ - if (adr < UINT32_C(0xFFC00000)) { - area->description = NULL; - area->start = UINT32_C(0xFF800000); - area->length = UINT64_C(0x00400000); - area->width = BUS_WIDTH; - - return 0; - } - - area->description = N_("Base ROM Interface (Bank 0)"); - area->start = UINT32_C(0xFFC00000); - area->length = UINT64_C(0x00400000); - area->width = BUS_WIDTH; - - return 0; -} - -static bus_t * -mpc824x_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[10]; - int i; - int failed = 0; - part_t *part; - signal_t *s_nfoe; - signal_t *s_sdma1; - - char param[16], value[16]; - - char dfltWidth = 1; - - dbgAddr = 0; - dbgData = 0; - REVBITS = 0; - - for (i=2; cmd_params[i]; i++) { - if (strstr( cmd_params[i], "=")) { - sscanf( cmd_params[i], "%[^=]%*c%s", param, value ); - - if (!strcmp( "width", param )) { - if (!strcmp( "8", value )) { - BUS_WIDTH = 8; - dfltWidth = 0; - } else if (!strcmp( "32", value )) { - BUS_WIDTH = 32; - dfltWidth = 0; - } - else if (!strcmp( "64", value )) { - // BUS_WIDTH = 64; // Needs to fix, look at setup_data() - BUS_WIDTH = 32; - printf(_(" Bus width 64 exists in mpc824x, but not supported by UrJTAG currently\n")); - dfltWidth = 1; - } - else { - printf(_(" Only 8,32 and 64 bus width are supported for Banks 0 and 1\n")); - return NULL; - } - } - } else { - if (!strcmp( "revbits", cmd_params[i])) - REVBITS = 1; - - if (!strcmp( "help", cmd_params[i])) { - printf(_("Usage: initbus mpc824x [width=WIDTH] [revbits] [dbgAddr] [dbgData]\n\n" - " WIDTH data bus width - 8, 32, 64 (default 8)\n" - " revbits reverse bits in data bus (default - no)\n" - " dbgAddr display address bus state (default - no)\n" - " dbgData display data bus state (default - no)\n")); - return NULL; - } - - if (!strcmp( "dbgAddr", cmd_params[i])) - dbgAddr = 1; - - - if (!strcmp( "dbgData", cmd_params[i])) - dbgData = 1; - - - } - - } - if (dfltWidth) - printf(_(" Using default bus width %d\n"), BUS_WIDTH); - - // REVBITS = 0; - - - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &mpc824x_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = part = chain->parts->parts[chain->active_part]; - - s_nfoe = part_find_signal( part, "nFOE" ); - s_sdma1 = part_find_signal( part, "SDMA1" ); - part_set_signal( part, s_nfoe, 0, 0 ); - part_set_signal( part, s_sdma1, 0, 0 ); - - part_set_instruction( part, "SAMPLE/PRELOAD" ); - chain_shift_instructions( chain ); - chain_shift_data_registers( chain, 0 ); - part_set_instruction( part, "EXTEST" ); - chain_shift_instructions( chain ); - chain_shift_data_registers( chain, 1 ); - - boot_nFOE = part_get_signal( part, s_nfoe ); - boot_SDMA1 = part_get_signal( part, s_sdma1 ); - - - for (i = 0; i <= 10; i++) { - sprintf( buff, "SDMA%d", i ); - AR[i] = part_find_signal( part, buff ); - if (!AR[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - AR[11] = part_find_signal( part, "SDBA0" ); - if (!AR[11]) { - printf( _("signal '%s' not found\n"), "SDBA0" ); - failed = 1; - } - for (i = 0; i < 8; i++) { - sprintf( buff, "PAR%d", i ); - AR[19 - i] = part_find_signal( part, buff ); - if (!AR[19 - i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - AR[20] = part_find_signal( part, "SDBA1" ); - if (!AR[20]) { - printf( _("signal '%s' not found\n"), "SDBA1" ); - failed = 1; - } - AR[21] = part_find_signal( part, "SDMA11" ); - if (!AR[21]) { - printf( _("signal '%s' not found\n"), "SDMA11" ); - failed = 1; - } - AR[22] = part_find_signal( part, "SDMA12" ); - if (!AR[22]) { - printf( _("signal '%s' not found\n"), "SDMA12" ); - failed = 1; - } - - - nRCS0 = part_find_signal( part, "nRCS0" ); - if (!nRCS0) { - printf( _("signal '%s' not found\n"), "nRCS0" ); - failed = 1; - } - nWE = part_find_signal( part, "nWE" ); - if (!nWE) { - printf( _("signal '%s' not found\n"), "nWE" ); - failed = 1; - } - nFOE = part_find_signal( part, "nFOE" ); - if (!nWE) { - printf( _("signal '%s' not found\n"), "nFOE" ); - failed = 1; - } - - /* - Freescale MPC824x uses inversed bit order ([1], p. 2-18): - msb is MDH[0] while lsb is MDH[31] - Flash chips usually use another bit orded: - msb is D[31] and lsb is D[0] - - This should be rewired in the PCB (MDH[0] - D[31], ..., MDH[31] - D[0]). - Otherwise you will have to use "revbits" UrJTAG parameter and - binary files with reversed bit order. - */ - - for (i = 0; i < 32; i++) { /* Needs to be fixed for 64-bit bus width */ - sprintf( buff, "MDH%d", 31 - i ); - D[i] = part_find_signal( part, buff ); - if (!D[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t mpc824x_bus = { "mpc824x", N_("Motorola MPC824x compatible bus driver via BSR"), diff --git a/jtag/src/bus/ppc405ep.c b/jtag/src/bus/ppc405ep.c index da38fe92..5b45b974 100644 --- a/jtag/src/bus/ppc405ep.c +++ b/jtag/src/bus/ppc405ep.c @@ -53,6 +53,120 @@ typedef struct { #define nOE ((bus_params_t *) bus->params)->noe +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +ppc405ep_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[10]; + int i; + int failed = 0; + + if (!chain || !chain->parts || (chain->parts->len <= chain->active_part) || (chain->active_part < 0)) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &ppc405ep_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + for (i = 6; i < 32; i++) { + sprintf( buff, "PerAddr%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 < 16; i++) { + sprintf( buff, "PerData%d", i ); + D[i] = part_find_signal( PART, buff ); + if (!D[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + sprintf( buff, "PerCS0"); + nCS = part_find_signal( PART, buff ); + if (!nCS) { + printf( _("signal '%s' not found\n"), "nCS0" ); + failed = 1; + } + nWE = part_find_signal( PART, "PerWBE1" ); + if (!nWE) { + printf( _("signal '%s' not found\n"), "nWE" ); + failed = 1; + } + nOE = part_find_signal( PART, "PerOE" ); + if (!nOE) { + printf( _("signal '%s' not found\n"), "nOE" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +ppc405ep_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("IBM PowerPC 405EP compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +ppc405ep_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +ppc405ep_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 16; + + return 0; +} + static void setup_address( bus_t *bus, uint32_t a ) { @@ -63,8 +177,6 @@ setup_address( bus_t *bus, uint32_t a ) part_set_signal( p, A[i], 1, (a >> (31-i)) & 1 ); } -static int ppc405ep_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ); - static void set_data_in( bus_t *bus ) { @@ -91,24 +203,10 @@ setup_data( bus_t *bus, uint32_t d ) part_set_signal( p, D[15-i], 1, (d >> i) & 1 ); } -static void -ppc405ep_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("IBM PowerPC 405EP compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void -ppc405ep_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void ppc405ep_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -125,6 +223,10 @@ ppc405ep_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t ppc405ep_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -145,6 +247,10 @@ ppc405ep_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t ppc405ep_bus_read_end( bus_t *bus ) { @@ -166,17 +272,25 @@ ppc405ep_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t ppc405ep_bus_read( bus_t *bus, uint32_t adr ) { int res; - + ppc405ep_bus_read_start( bus, adr ); res = ppc405ep_bus_read_end( bus ); - + return res; } +/** + * bus->driver->(*write) + * + */ static void ppc405ep_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -199,86 +313,6 @@ ppc405ep_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static int -ppc405ep_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - area->width = 16; - - return 0; -} - -static bus_t * -ppc405ep_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[10]; - int i; - int failed = 0; - - if (!chain || !chain->parts || (chain->parts->len <= chain->active_part) || (chain->active_part < 0)) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &ppc405ep_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - for (i = 6; i < 32; i++) { - sprintf( buff, "PerAddr%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 < 16; i++) { - sprintf( buff, "PerData%d", i ); - D[i] = part_find_signal( PART, buff ); - if (!D[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - sprintf( buff, "PerCS0"); - nCS = part_find_signal( PART, buff ); - if (!nCS) { - printf( _("signal '%s' not found\n"), "nCS0" ); - failed = 1; - } - nWE = part_find_signal( PART, "PerWBE1" ); - if (!nWE) { - printf( _("signal '%s' not found\n"), "nWE" ); - failed = 1; - } - nOE = part_find_signal( PART, "PerOE" ); - if (!nOE) { - printf( _("signal '%s' not found\n"), "nOE" ); - failed = 1; - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t ppc405ep_bus = { "ppc405ep", N_("IBM PowerPC 405EP compatible bus driver via BSR"), diff --git a/jtag/src/bus/ppc440gx_ebc8.c b/jtag/src/bus/ppc440gx_ebc8.c index d2ed8760..8b287b99 100644 --- a/jtag/src/bus/ppc440gx_ebc8.c +++ b/jtag/src/bus/ppc440gx_ebc8.c @@ -55,6 +55,120 @@ typedef struct { #define nOE ((bus_params_t *) bus->params)->noe +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +ppc440gx_ebc8_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[10]; + int i; + int failed = 0; + + if (!chain || !chain->parts || (chain->parts->len <= chain->active_part) || (chain->active_part < 0)) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &ppc440gx_ebc8_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + for (i = 0; i < PPC440GX_ADDR_LINES; i++) { + sprintf( buff, "EBCADR%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 < PPC440GX_DATA_LINES; i++) { + sprintf( buff, "EBCDATA%d", i ); + D[i] = part_find_signal( PART, buff ); + if (!D[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + sprintf( buff, "EBCCS0_N"); + nCS = part_find_signal( PART, buff ); + if (!nCS) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + } + nWE = part_find_signal( PART, "EBCWE_N" ); + if (!nWE) { + printf( _("signal '%s' not found\n"), "nWE" ); + failed = 1; + } + nOE = part_find_signal( PART, "EBCOE_N" ); + if (!nOE) { + printf( _("signal '%s' not found\n"), "nOE" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +ppc440gx_ebc8_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("IBM PowerPC 440GX 8-bit compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +ppc440gx_ebc8_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +ppc440gx_ebc8_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); /* ??????????? */ + area->width = PPC440GX_DATA_LINES; + + return 0; +} + static void setup_address( bus_t *bus, uint32_t a ) { @@ -65,8 +179,6 @@ setup_address( bus_t *bus, uint32_t a ) part_set_signal( p, A[i], 1, (a >> (PPC440GX_ADDR_LINES-1-i)) & 1 ); } -static int ppc440gx_ebc8_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ); - static void set_data_in( bus_t *bus ) { @@ -93,24 +205,10 @@ setup_data( bus_t *bus, uint32_t d ) part_set_signal( p, D[PPC440GX_DATA_LINES-1-i], 1, (d >> i) & 1 ); } -static void -ppc440gx_ebc8_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("IBM PowerPC 440GX 8-bit compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void -ppc440gx_ebc8_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void ppc440gx_ebc8_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -127,6 +225,10 @@ ppc440gx_ebc8_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t ppc440gx_ebc8_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -147,6 +249,10 @@ ppc440gx_ebc8_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t ppc440gx_ebc8_bus_read_end( bus_t *bus ) { @@ -168,6 +274,10 @@ ppc440gx_ebc8_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t ppc440gx_ebc8_bus_read( bus_t *bus, uint32_t adr ) { @@ -175,6 +285,10 @@ ppc440gx_ebc8_bus_read( bus_t *bus, uint32_t adr ) return ppc440gx_ebc8_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void ppc440gx_ebc8_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -197,86 +311,6 @@ ppc440gx_ebc8_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static int -ppc440gx_ebc8_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); /* ??????????? */ - area->width = PPC440GX_DATA_LINES; - - return 0; -} - -static bus_t * -ppc440gx_ebc8_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[10]; - int i; - int failed = 0; - - if (!chain || !chain->parts || (chain->parts->len <= chain->active_part) || (chain->active_part < 0)) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &ppc440gx_ebc8_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - for (i = 0; i < PPC440GX_ADDR_LINES; i++) { - sprintf( buff, "EBCADR%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 < PPC440GX_DATA_LINES; i++) { - sprintf( buff, "EBCDATA%d", i ); - D[i] = part_find_signal( PART, buff ); - if (!D[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - sprintf( buff, "EBCCS0_N"); - nCS = part_find_signal( PART, buff ); - if (!nCS) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - } - nWE = part_find_signal( PART, "EBCWE_N" ); - if (!nWE) { - printf( _("signal '%s' not found\n"), "nWE" ); - failed = 1; - } - nOE = part_find_signal( PART, "EBCOE_N" ); - if (!nOE) { - printf( _("signal '%s' not found\n"), "nOE" ); - failed = 1; - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t ppc440gx_ebc8_bus = { "ppc440gx_ebc8", N_("IBM PowerPC 440GX 8-bit EBC compatible bus driver via BSR"), diff --git a/jtag/src/bus/prototype.c b/jtag/src/bus/prototype.c index 41491ce6..7571d235 100644 --- a/jtag/src/bus/prototype.c +++ b/jtag/src/bus/prototype.c @@ -71,164 +71,6 @@ typedef struct { #define ASHIFT ((bus_params_t *) bus->params)->ashift - -static void -setup_address( bus_t *bus, uint32_t a ) -{ - int i, j; - part_t *p = PART; - - a >>= ASHIFT; - - for ( i = 0, j = ALSBI; i < AW; i++, j += AI ) - part_set_signal( p, A[j], 1, (a >> i) & 1 ); -} - -static int -prototype_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - area->width = DW; - - return 0; -} - -static void -set_data_in( bus_t *bus ) -{ - int i, j; - part_t *p = PART; - bus_area_t area; - - prototype_bus_area( bus, 0, &area ); - - for ( i = 0, j = DLSBI; i < DW; i++, j += DI ) - part_set_signal( p, D[j], 0, 0 ); -} - -static void -setup_data( bus_t *bus, uint32_t d ) -{ - int i, j; - part_t *p = PART; - bus_area_t area; - - prototype_bus_area( bus, 0, &area ); - - for ( i = 0, j = DLSBI; i < DW; i++, j += DI ) - part_set_signal( p, D[j], 1, (d >> i) & 1 ); -} - -static void -prototype_bus_printinfo( bus_t *bus ) -{ - int i; - - for ( i = 0; i < CHAIN->parts->len; i++ ) - if ( PART == CHAIN->parts->parts[i] ) - break; - printf( _("Configurable prototype bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void -prototype_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - -static void -prototype_bus_read_start( bus_t *bus, uint32_t adr ) -{ - part_t *p = PART; - chain_t *chain = CHAIN; - - part_set_signal( p, CS, 1, CSA ); - part_set_signal( p, WE, 1, WEA ? 0 : 1 ); - part_set_signal( p, OE, 1, OEA ); - - setup_address( bus, adr ); - set_data_in( bus ); - - chain_shift_data_registers( chain, 0 ); -} - -static uint32_t -prototype_bus_read_next( bus_t *bus, uint32_t adr ) -{ - part_t *p = PART; - chain_t *chain = CHAIN; - int i, j; - uint32_t d = 0; - bus_area_t area; - - prototype_bus_area( bus, adr, &area ); - - setup_address( bus, adr ); - chain_shift_data_registers( chain, 1 ); - - for ( i = 0, j = DLSBI; i < DW; i++, j += DI ) - d |= (uint32_t) (part_get_signal( p, D[j] ) << i); - - return d; -} - -static uint32_t -prototype_bus_read_end( bus_t *bus ) -{ - part_t *p = PART; - chain_t *chain = CHAIN; - int i, j; - uint32_t d = 0; - bus_area_t area; - - prototype_bus_area( bus, 0, &area ); - - part_set_signal( p, CS, 1, CSA ? 0 : 1 ); - part_set_signal( p, OE, 1, OEA ? 0 : 1 ); - chain_shift_data_registers( chain, 1 ); - - for ( i = 0, j = DLSBI; i < DW; i++, j += DI ) - d |= (uint32_t) (part_get_signal( p, D[j] ) << i); - - return d; -} - -static uint32_t -prototype_bus_read( bus_t *bus, uint32_t adr ) -{ - int res; - - prototype_bus_read_start( bus, adr ); - res = prototype_bus_read_end( bus ); - - return res; -} - -static void -prototype_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) -{ - part_t *p = PART; - chain_t *chain = CHAIN; - - part_set_signal( p, CS, 1, CSA ); - part_set_signal( p, WE, 1, WEA ? 0 : 1 ); - part_set_signal( p, OE, 1, OEA ? 0 : 1 ); - - setup_address( bus, adr ); - setup_data( bus, data ); - - chain_shift_data_registers( chain, 0 ); - - part_set_signal( p, WE, 1, WEA ); - chain_shift_data_registers( chain, 0 ); - part_set_signal( p, WE, 1, WEA ? 0 : 1 ); - part_set_signal( p, CS, 1, CSA ? 0 : 1 ); - chain_shift_data_registers( chain, 0 ); -} - static void prototype_bus_signal_parse( char *str, char *fmt, int *inst ) { @@ -246,6 +88,10 @@ prototype_bus_signal_parse( char *str, char *fmt, int *inst ) } } +/** + * bus->driver->(*new_bus) + * + */ static bus_t * prototype_bus_new( chain_t *chain, char *cmd_params[] ) { @@ -351,7 +197,7 @@ prototype_bus_new( chain_t *chain, char *cmd_params[] ) for (i = 0, j = ALSBI; i < AW; i++, j += AI ) { sprintf( buff, afmt, j ); A[j] = part_find_signal( PART, buff ); - } + } } else { printf( _("parameters alsb= and/or amsb= are not defined\n") ); failed = 1; @@ -379,7 +225,7 @@ prototype_bus_new( chain_t *chain, char *cmd_params[] ) for ( i = 0, j = DLSBI; i < DW; i++, j += DI ) { sprintf( buff, dfmt, j ); D[j] = part_find_signal( PART, buff ); - } + } /* bus drivers are called with a byte address this address needs to be adjusted by setup_address() to the memory data width */ @@ -429,6 +275,194 @@ prototype_bus_new( chain_t *chain, char *cmd_params[] ) return bus; } +/** + * bus->driver->(*printinfo) + * + */ +static void +prototype_bus_printinfo( bus_t *bus ) +{ + int i; + + for ( i = 0; i < CHAIN->parts->len; i++ ) + if ( PART == CHAIN->parts->parts[i] ) + break; + printf( _("Configurable prototype bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +prototype_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +prototype_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = DW; + + return 0; +} + +static void +setup_address( bus_t *bus, uint32_t a ) +{ + int i, j; + part_t *p = PART; + + a >>= ASHIFT; + + for ( i = 0, j = ALSBI; i < AW; i++, j += AI ) + part_set_signal( p, A[j], 1, (a >> i) & 1 ); +} + +static void +set_data_in( bus_t *bus ) +{ + int i, j; + part_t *p = PART; + bus_area_t area; + + prototype_bus_area( bus, 0, &area ); + + for ( i = 0, j = DLSBI; i < DW; i++, j += DI ) + part_set_signal( p, D[j], 0, 0 ); +} + +static void +setup_data( bus_t *bus, uint32_t d ) +{ + int i, j; + part_t *p = PART; + bus_area_t area; + + prototype_bus_area( bus, 0, &area ); + + for ( i = 0, j = DLSBI; i < DW; i++, j += DI ) + part_set_signal( p, D[j], 1, (d >> i) & 1 ); +} + +/** + * bus->driver->(*read_start) + * + */ +static void +prototype_bus_read_start( bus_t *bus, uint32_t adr ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + + part_set_signal( p, CS, 1, CSA ); + part_set_signal( p, WE, 1, WEA ? 0 : 1 ); + part_set_signal( p, OE, 1, OEA ); + + setup_address( bus, adr ); + set_data_in( bus ); + + chain_shift_data_registers( chain, 0 ); +} + +/** + * bus->driver->(*read_next) + * + */ +static uint32_t +prototype_bus_read_next( bus_t *bus, uint32_t adr ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + int i, j; + uint32_t d = 0; + bus_area_t area; + + prototype_bus_area( bus, adr, &area ); + + setup_address( bus, adr ); + chain_shift_data_registers( chain, 1 ); + + for ( i = 0, j = DLSBI; i < DW; i++, j += DI ) + d |= (uint32_t) (part_get_signal( p, D[j] ) << i); + + return d; +} + +/** + * bus->driver->(*read_end) + * + */ +static uint32_t +prototype_bus_read_end( bus_t *bus ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + int i, j; + uint32_t d = 0; + bus_area_t area; + + prototype_bus_area( bus, 0, &area ); + + part_set_signal( p, CS, 1, CSA ? 0 : 1 ); + part_set_signal( p, OE, 1, OEA ? 0 : 1 ); + chain_shift_data_registers( chain, 1 ); + + for ( i = 0, j = DLSBI; i < DW; i++, j += DI ) + d |= (uint32_t) (part_get_signal( p, D[j] ) << i); + + return d; +} + +/** + * bus->driver->(*read) + * + */ +static uint32_t +prototype_bus_read( bus_t *bus, uint32_t adr ) +{ + int res; + + prototype_bus_read_start( bus, adr ); + res = prototype_bus_read_end( bus ); + + return res; +} + +/** + * bus->driver->(*write) + * + */ +static void +prototype_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + + part_set_signal( p, CS, 1, CSA ); + part_set_signal( p, WE, 1, WEA ? 0 : 1 ); + part_set_signal( p, OE, 1, OEA ? 0 : 1 ); + + setup_address( bus, adr ); + setup_data( bus, data ); + + chain_shift_data_registers( chain, 0 ); + + part_set_signal( p, WE, 1, WEA ); + chain_shift_data_registers( chain, 0 ); + part_set_signal( p, WE, 1, WEA ? 0 : 1 ); + part_set_signal( p, CS, 1, CSA ? 0 : 1 ); + chain_shift_data_registers( chain, 0 ); +} const bus_driver_t prototype_bus = { "prototype", diff --git a/jtag/src/bus/pxa2x0.c b/jtag/src/bus/pxa2x0.c index 015d31da..d16a081e 100644 --- a/jtag/src/bus/pxa2x0.c +++ b/jtag/src/bus/pxa2x0.c @@ -47,13 +47,13 @@ /* - * the following defines are used in proc field of the the + * the following defines are used in proc field of the the * bus_params_t structure and are used in various functions - * below + * below */ #define PROC_PXA25x 1 // including px26x series -#define PROC_PXA27x 2 +#define PROC_PXA27x 2 #define nCS_TOTAL 6 @@ -71,10 +71,10 @@ typedef struct { * * Note: the setup of nCS[*] is board-specific, rather than chip-specific! * The memory mapping and nCS[*] functions are normally set up by the boot loader. - * In our JTAG code, we manipulate the outer pins explicitly, without the help + * In our JTAG code, we manipulate the outer pins explicitly, without the help * of the CPU's memory controller - hence the need to mimick its setup. * - * Note that bus_area() and bus_read()/bus_write() use a window of 64MB + * Note that bus_area() and bus_read()/bus_write() use a window of 64MB * per nCS pin (26bit addresses), which seems to be the most common option. * For static CS[0] and CS[1] == 128 MB, the algorithms have to be modified... */ @@ -91,7 +91,7 @@ static ncs_map_entry pxa25x_ncs_map[nCS_TOTAL] = { }; // Default mapping with all nCS[*] GPIO pins used as nCS. -// Note that the same GPIO pins might be used e.g. for PCCard +// Note that the same GPIO pins might be used e.g. for PCCard // service space access or PWM outputs, or some other purpose. static ncs_map_entry pxa27x_ncs_map[nCS_TOTAL] = { {"nCS[0]", 1, 0}, // nCS[0] @@ -137,43 +137,205 @@ typedef struct { #define INITED ((bus_params_t *) bus->params)->inited - -static void -setup_address( bus_t *bus, uint32_t a ) +/* + * bus->driver->(*new_bus) + * + */ +static int +pxa2xx_bus_new_common(bus_t * bus) { + int failed = 0; + ncs_map_entry* ncs_map = NULL; +#ifdef PREPATCHNEVER + bus_t *bus; + char buff[10]; int i; - part_t *p = PART; - for (i = 0; i < 26; i++) - part_set_signal( p, MA[i], 1, (a >> i) & 1 ); + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &pxa2x0_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; +#endif + int i; + char buff[10]; + + for (i = 0; i < 26; i++) { + sprintf( buff, "MA[%d]", i ); + MA[i] = part_find_signal( PART, buff ); + if (!MA[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 32; i++) { + sprintf( buff, "MD[%d]", i ); + MD[i] = part_find_signal( PART, buff ); + if (!MD[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + if (PROC == PROC_PXA25x) { + ncs_map = pxa25x_ncs_map; + } + else if (PROC == PROC_PXA27x) { + ncs_map = pxa27x_ncs_map; + } + else + { + printf( "BUG in the code, file %s, line %d: unknown PROC\n", __FILE__, __LINE__ ); + ncs_map = pxa25x_ncs_map; // be dumb by default + } + for (i = 0; i < nCS_TOTAL; i++) { + if (ncs_map[i].enabled > 0) + { + nCS[i] = part_find_signal( PART, ncs_map[i].sig_name ); + if (!nCS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + else // disabled - this GPIO pin is unused or used for some other function + { + nCS[i] = NULL; + } + } + + for (i = 0; i < 4; i++) { + sprintf( buff, "DQM[%d]", i ); + DQM[i] = part_find_signal( PART, buff ); + if (!DQM[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + RDnWR = part_find_signal( PART, "RDnWR" ); + if (!RDnWR) { + printf( _("signal '%s' not found\n"), "RDnWR" ); + failed = 1; + } + nWE = part_find_signal( PART, "nWE" ); + if (!nWE) { + printf( _("signal '%s' not found\n"), "nWE" ); + failed = 1; + } + nOE = part_find_signal( PART, "nOE" ); + if (!nOE) { + printf( _("signal '%s' not found\n"), "nOE" ); + failed = 1; + } + nSDCAS = part_find_signal( PART, "nSDCAS" ); + if (!nSDCAS) { + printf( _("signal '%s' not found\n"), "nSDCAS" ); + failed = 1; + } + + return failed; } -static void -set_data_in( bus_t *bus, uint32_t adr ) +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +pxa2x0_bus_new( chain_t *chain, char *cmd_params[] ) { - int i; - part_t *p = PART; - bus_area_t area; + bus_t *bus; + int failed = 0; - bus->driver->area( bus, adr, &area ); + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; - for (i = 0; i < area.width; i++) - part_set_signal( p, MD[i], 0, 0 ); + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &pxa2x0_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + PROC = PROC_PXA25x; + + failed = pxa2xx_bus_new_common(bus); + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + INITED = 0; + + return bus; } -static void -setup_data( bus_t *bus, uint32_t adr, uint32_t d ) +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +pxa27x_bus_new( chain_t *chain, char *cmd_params[] ) { - int i; - part_t *p = PART; - bus_area_t area; + bus_t *bus; + int failed = 0; - bus->driver->area( bus, adr, &area ); + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; - for (i = 0; i < area.width; i++) - part_set_signal( p, MD[i], 1, (d >> i) & 1 ); + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &pxa27x_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + PROC = PROC_PXA27x; + + failed = pxa2xx_bus_new_common(bus); + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + INITED = 0; + + return bus; } +/** + * bus->driver->(*printinfo) + * + */ static void pxa2x0_bus_printinfo( bus_t *bus ) { @@ -185,6 +347,10 @@ pxa2x0_bus_printinfo( bus_t *bus ) printf( _("Intel PXA2x0 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); } +/** + * bus->driver->(*printinfo) + * + */ static void pxa27x_bus_printinfo( bus_t *bus ) { @@ -196,6 +362,10 @@ pxa27x_bus_printinfo( bus_t *bus ) printf( _("Intel PXA27x compatible bus driver via BSR (JTAG part No. %d)\n"), i ); } +/** + * bus->driver->(*init) + * + */ static int pxa2xx_bus_init( bus_t *bus ) { @@ -211,7 +381,7 @@ pxa2xx_bus_init( bus_t *bus ) if (PROC == PROC_PXA25x) { - BOOT_DEF = BOOT_DEF_PKG_TYPE | + BOOT_DEF = BOOT_DEF_PKG_TYPE | BOOT_DEF_BOOT_SEL(part_get_signal( p, part_find_signal( p, "BOOT_SEL[2]" ) ) << 2 | part_get_signal( p, part_find_signal( p, "BOOT_SEL[1]" ) ) << 1 | part_get_signal( p, part_find_signal( p, "BOOT_SEL[0]" ) )); @@ -232,6 +402,10 @@ pxa2xx_bus_init( bus_t *bus ) return 0; } +/** + * bus->driver->(*prepare) + * + */ static void pxa2xx_bus_prepare( bus_t *bus ) { @@ -241,182 +415,22 @@ pxa2xx_bus_prepare( bus_t *bus ) chain_shift_instructions( CHAIN ); } -static void -pxa2xx_bus_read_start( bus_t *bus, uint32_t adr ) -{ - int cs_index = 0; - - chain_t *chain = CHAIN; - part_t *p = PART; - - LAST_ADR = adr; - if (adr >= 0x18000000) - return; - - cs_index = adr >> 26; - if (nCS[cs_index] == NULL) - return; - - /* see Figure 6-13 in [1] */ - part_set_signal( p, nCS[cs_index], 1, 0 ); - part_set_signal( p, DQM[0], 1, 0 ); - part_set_signal( p, DQM[1], 1, 0 ); - part_set_signal( p, DQM[2], 1, 0 ); - part_set_signal( p, DQM[3], 1, 0 ); - part_set_signal( p, RDnWR, 1, 1 ); - part_set_signal( p, nWE, 1, 1 ); - part_set_signal( p, nOE, 1, 0 ); - part_set_signal( p, nSDCAS, 1, 0 ); - - setup_address( bus, adr ); - set_data_in( bus, adr ); - - chain_shift_data_registers( chain, 0 ); -} - -static uint32_t -pxa2xx_bus_read_next( bus_t *bus, uint32_t adr ) +/** + * bus->driver->(*area) + * + */ +static int +pxa2xx_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) { - part_t *p = PART; - chain_t *chain = CHAIN; - uint32_t d; - uint32_t old_last_adr = LAST_ADR; + uint32_t tmp_addr; + int ncs_index; + (void)pxa2xx_bus_init( bus ); - LAST_ADR = adr; - - if (adr < UINT32_C(0x18000000)) { - int i; - bus_area_t area; - - if (nCS[adr >> 26] == NULL) // avoid undefined nCS windows - return 0; - - bus->driver->area( bus, adr, &area ); - - /* see Figure 6-13 in [1] */ - setup_address( bus, adr ); - chain_shift_data_registers( chain, 1 ); - - d = 0; - for (i = 0; i < area.width; i++) - d |= (uint32_t) (part_get_signal( p, MD[i] ) << i); - - return d; - } - - // anything above 0x18000000 is essentially unreachable... - if (adr < UINT32_C(0x48000000)) - return 0; - - if (adr < UINT32_C(0x4C000000)) { - if (old_last_adr == (MC_BASE + BOOT_DEF_OFFSET)) - return BOOT_DEF; - - return 0; - } - - return 0; -} - -static uint32_t -pxa2xx_bus_read_end( bus_t *bus ) -{ - part_t *p = PART; - chain_t *chain = CHAIN; - - if (LAST_ADR < UINT32_C(0x18000000)) { - int i; - uint32_t d = 0; - bus_area_t area; - - if (nCS[LAST_ADR >> 26] == NULL) // avoid undefined nCS windows - return 0; - - bus->driver->area( bus, LAST_ADR, &area ); - - /* see Figure 6-13 in [1] */ - part_set_signal( p, nCS[0], 1, 1 ); - part_set_signal( p, nOE, 1, 1 ); - part_set_signal( p, nSDCAS, 1, 1 ); - - chain_shift_data_registers( chain, 1 ); - - for (i = 0; i < area.width; i++) - d |= (uint32_t) (part_get_signal( p, MD[i] ) << i); - - return d; - } - - // anything above 0x18000000 is essentially unreachable... - if (LAST_ADR < UINT32_C(0x48000000)) - return 0; - - if (LAST_ADR < UINT32_C(0x4C000000)) { - if (LAST_ADR == (MC_BASE + BOOT_DEF_OFFSET)) - return BOOT_DEF; - - return 0; - } - - return 0; -} - -static uint32_t -pxa2xx_bus_read( bus_t *bus, uint32_t adr ) -{ - pxa2xx_bus_read_start( bus, adr ); - return pxa2xx_bus_read_end( bus ); -} - -static void -pxa2xx_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) -{ - int cs_index = 0; - - /* see Figure 6-17 in [1] */ - part_t *p = PART; - chain_t *chain = CHAIN; - - if (adr >= 0x18000000) - return; - - cs_index = adr >> 26; - if (nCS[cs_index] == NULL) - return; - - part_set_signal( p, nCS[cs_index], 1, 0 ); - part_set_signal( p, DQM[0], 1, 0 ); - part_set_signal( p, DQM[1], 1, 0 ); - part_set_signal( p, DQM[2], 1, 0 ); - part_set_signal( p, DQM[3], 1, 0 ); - part_set_signal( p, RDnWR, 1, 0 ); - part_set_signal( p, nWE, 1, 1 ); - part_set_signal( p, nOE, 1, 1 ); - part_set_signal( p, nSDCAS, 1, 0 ); - - setup_address( bus, adr ); - setup_data( bus, adr, data ); - - chain_shift_data_registers( chain, 0 ); - - part_set_signal( p, nWE, 1, 0 ); - chain_shift_data_registers( chain, 0 ); - part_set_signal( p, nWE, 1, 1 ); - chain_shift_data_registers( chain, 0 ); -} - -static int -pxa2xx_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - uint32_t tmp_addr; - int ncs_index; - (void)pxa2xx_bus_init( bus ); - - /* Static Chip Select 0 (64 MB) */ - if (adr < UINT32_C(0x04000000)) { - area->description = N_("Static Chip Select 0"); - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x04000000); + /* Static Chip Select 0 (64 MB) */ + if (adr < UINT32_C(0x04000000)) { + area->description = N_("Static Chip Select 0"); + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x04000000); if (pxa25x_ncs_map[0].bus_width > 0) { @@ -492,6 +506,10 @@ pxa2xx_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) return 0; } +/** + * bus->driver->(*area) + * + */ static int pxa27x_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) { @@ -600,189 +618,224 @@ pxa27x_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) return 0; } -//static bus_t * -//pxa2x0_bus_new( void ) -static int -pxa2xx_bus_new_common(bus_t * bus) +static void +setup_address( bus_t *bus, uint32_t a ) { - int failed = 0; - ncs_map_entry* ncs_map = NULL; -#ifdef PREPATCHNEVER - bus_t *bus; - char buff[10]; int i; + part_t *p = PART; - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; + for (i = 0; i < 26; i++) + part_set_signal( p, MA[i], 1, (a >> i) & 1 ); +} - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; +static void +set_data_in( bus_t *bus, uint32_t adr ) +{ + int i; + part_t *p = PART; + bus_area_t area; - bus->driver = &pxa2x0_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } + bus->driver->area( bus, adr, &area ); - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; -#endif + for (i = 0; i < area.width; i++) + part_set_signal( p, MD[i], 0, 0 ); +} + +static void +setup_data( bus_t *bus, uint32_t adr, uint32_t d ) +{ int i; - char buff[10]; + part_t *p = PART; + bus_area_t area; - for (i = 0; i < 26; i++) { - sprintf( buff, "MA[%d]", i ); - MA[i] = part_find_signal( PART, buff ); - if (!MA[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - for (i = 0; i < 32; i++) { - sprintf( buff, "MD[%d]", i ); - MD[i] = part_find_signal( PART, buff ); - if (!MD[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - if (PROC == PROC_PXA25x) { - ncs_map = pxa25x_ncs_map; - } - else if (PROC == PROC_PXA27x) { - ncs_map = pxa27x_ncs_map; - } - else - { - printf( "BUG in the code, file %s, line %d: unknown PROC\n", __FILE__, __LINE__ ); - ncs_map = pxa25x_ncs_map; // be dumb by default - } - for (i = 0; i < nCS_TOTAL; i++) { - if (ncs_map[i].enabled > 0) - { - nCS[i] = part_find_signal( PART, ncs_map[i].sig_name ); - if (!nCS[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - else // disabled - this GPIO pin is unused or used for some other function - { - nCS[i] = NULL; - } - } + bus->driver->area( bus, adr, &area ); - for (i = 0; i < 4; i++) { - sprintf( buff, "DQM[%d]", i ); - DQM[i] = part_find_signal( PART, buff ); - if (!DQM[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - RDnWR = part_find_signal( PART, "RDnWR" ); - if (!RDnWR) { - printf( _("signal '%s' not found\n"), "RDnWR" ); - failed = 1; - } - nWE = part_find_signal( PART, "nWE" ); - if (!nWE) { - printf( _("signal '%s' not found\n"), "nWE" ); - failed = 1; - } - nOE = part_find_signal( PART, "nOE" ); - if (!nOE) { - printf( _("signal '%s' not found\n"), "nOE" ); - failed = 1; - } - nSDCAS = part_find_signal( PART, "nSDCAS" ); - if (!nSDCAS) { - printf( _("signal '%s' not found\n"), "nSDCAS" ); - failed = 1; - } + for (i = 0; i < area.width; i++) + part_set_signal( p, MD[i], 1, (d >> i) & 1 ); +} - return failed; +/** + * bus->driver->(*read_start) + * + */ +static void +pxa2xx_bus_read_start( bus_t *bus, uint32_t adr ) +{ + int cs_index = 0; + + chain_t *chain = CHAIN; + part_t *p = PART; + + LAST_ADR = adr; + if (adr >= 0x18000000) + return; + + cs_index = adr >> 26; + if (nCS[cs_index] == NULL) + return; + + /* see Figure 6-13 in [1] */ + part_set_signal( p, nCS[cs_index], 1, 0 ); + part_set_signal( p, DQM[0], 1, 0 ); + part_set_signal( p, DQM[1], 1, 0 ); + part_set_signal( p, DQM[2], 1, 0 ); + part_set_signal( p, DQM[3], 1, 0 ); + part_set_signal( p, RDnWR, 1, 1 ); + part_set_signal( p, nWE, 1, 1 ); + part_set_signal( p, nOE, 1, 0 ); + part_set_signal( p, nSDCAS, 1, 0 ); + + setup_address( bus, adr ); + set_data_in( bus, adr ); + + chain_shift_data_registers( chain, 0 ); } -static bus_t * -pxa2x0_bus_new( chain_t *chain, char *cmd_params[] ) +/** + * bus->driver->(*read_next) + * + */ +static uint32_t +pxa2xx_bus_read_next( bus_t *bus, uint32_t adr ) { - bus_t *bus; - int failed = 0; + part_t *p = PART; + chain_t *chain = CHAIN; + uint32_t d; + uint32_t old_last_adr = LAST_ADR; - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; + LAST_ADR = adr; - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; + if (adr < UINT32_C(0x18000000)) { + int i; + bus_area_t area; - bus->driver = &pxa2x0_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } + if (nCS[adr >> 26] == NULL) // avoid undefined nCS windows + return 0; - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - PROC = PROC_PXA25x; + bus->driver->area( bus, adr, &area ); - failed = pxa2xx_bus_new_common(bus); + /* see Figure 6-13 in [1] */ + setup_address( bus, adr ); + chain_shift_data_registers( chain, 1 ); - if (failed) { - free( bus->params ); - free( bus ); - return NULL; + d = 0; + for (i = 0; i < area.width; i++) + d |= (uint32_t) (part_get_signal( p, MD[i] ) << i); + + return d; } - INITED = 0; + // anything above 0x18000000 is essentially unreachable... + if (adr < UINT32_C(0x48000000)) + return 0; - return bus; + if (adr < UINT32_C(0x4C000000)) { + if (old_last_adr == (MC_BASE + BOOT_DEF_OFFSET)) + return BOOT_DEF; + + return 0; + } + + return 0; } -static bus_t * -pxa27x_bus_new( chain_t *chain, char *cmd_params[] ) +/** + * bus->driver->(*read_end) + * + */ +static uint32_t +pxa2xx_bus_read_end( bus_t *bus ) { - bus_t *bus; - int failed = 0; + part_t *p = PART; + chain_t *chain = CHAIN; - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; + if (LAST_ADR < UINT32_C(0x18000000)) { + int i; + uint32_t d = 0; + bus_area_t area; - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; + if (nCS[LAST_ADR >> 26] == NULL) // avoid undefined nCS windows + return 0; - bus->driver = &pxa27x_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; + bus->driver->area( bus, LAST_ADR, &area ); + + /* see Figure 6-13 in [1] */ + part_set_signal( p, nCS[0], 1, 1 ); + part_set_signal( p, nOE, 1, 1 ); + part_set_signal( p, nSDCAS, 1, 1 ); + + chain_shift_data_registers( chain, 1 ); + + for (i = 0; i < area.width; i++) + d |= (uint32_t) (part_get_signal( p, MD[i] ) << i); + + return d; } - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - PROC = PROC_PXA27x; + // anything above 0x18000000 is essentially unreachable... + if (LAST_ADR < UINT32_C(0x48000000)) + return 0; - failed = pxa2xx_bus_new_common(bus); + if (LAST_ADR < UINT32_C(0x4C000000)) { + if (LAST_ADR == (MC_BASE + BOOT_DEF_OFFSET)) + return BOOT_DEF; - if (failed) { - free( bus->params ); - free( bus ); - return NULL; + return 0; } - INITED = 0; + return 0; +} - return bus; +/** + * bus->driver->(*read) + * + */ +static uint32_t +pxa2xx_bus_read( bus_t *bus, uint32_t adr ) +{ + pxa2xx_bus_read_start( bus, adr ); + return pxa2xx_bus_read_end( bus ); +} + +/** + * bus->driver->(*write) + * + */ +static void +pxa2xx_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) +{ + int cs_index = 0; + + /* see Figure 6-17 in [1] */ + part_t *p = PART; + chain_t *chain = CHAIN; + + if (adr >= 0x18000000) + return; + + cs_index = adr >> 26; + if (nCS[cs_index] == NULL) + return; + + part_set_signal( p, nCS[cs_index], 1, 0 ); + part_set_signal( p, DQM[0], 1, 0 ); + part_set_signal( p, DQM[1], 1, 0 ); + part_set_signal( p, DQM[2], 1, 0 ); + part_set_signal( p, DQM[3], 1, 0 ); + part_set_signal( p, RDnWR, 1, 0 ); + part_set_signal( p, nWE, 1, 1 ); + part_set_signal( p, nOE, 1, 1 ); + part_set_signal( p, nSDCAS, 1, 0 ); + + setup_address( bus, adr ); + setup_data( bus, adr, data ); + + chain_shift_data_registers( chain, 0 ); + + part_set_signal( p, nWE, 1, 0 ); + chain_shift_data_registers( chain, 0 ); + part_set_signal( p, nWE, 1, 1 ); + chain_shift_data_registers( chain, 0 ); } const bus_driver_t pxa2x0_bus = { diff --git a/jtag/src/bus/s3c4510x.c b/jtag/src/bus/s3c4510x.c index 4e61e6dd..794b401f 100644 --- a/jtag/src/bus/s3c4510x.c +++ b/jtag/src/bus/s3c4510x.c @@ -81,7 +81,7 @@ typedef struct { ** Only using nRCS0. */ signal_t *necs[4]; signal_t *nsdcs[4]; - + signal_t *nwbe[4]; /**< not Write Byte Enable */ signal_t *noe; /**< not Output Enable */ int dbuswidth; @@ -100,6 +100,194 @@ typedef struct { #define dbus_width ((bus_params_t *) bus->params)->dbuswidth /** @brief Width of Data Bus. Detected by B0SIZE[1:0] */ +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +s3c4510_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[10]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &s3c4510_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + + dbus_width = 16; + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + for (i = 0; i < 22; i++) { + sprintf( buff, "ADDR%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, "XDATA%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 < 6; i++) { + sprintf( buff, "nRCS%d", i ); + nRCS[i] = part_find_signal( PART, buff ); + if (!nRCS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for (i = 0; i < 4; i++) { + sprintf( buff, "nECS%d", i ); + nECS[i] = part_find_signal( PART, buff ); + if (!nECS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 4; i++) { + sprintf( buff, "nRAS%d", i ); /* those are nSDCS for SDRAMs only */ + nSDCS[i] = part_find_signal( PART, buff ); + if (!nSDCS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 4; i++) { + sprintf( buff, "nWBE%d", i ); + nWBE[i] = part_find_signal( PART, buff ); + if (!nWBE[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + nOE = part_find_signal( PART, "nOE" ); + if (!nOE) { + printf( _("signal '%s' not found\n"), "nOE" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +s3c4510_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Samsung S3C4510B compatibile bus driver via BSR (JTAG part No. %d) RCS0=%ubit\n"), i ,dbus_width ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +s3c4510_bus_prepare( bus_t *bus ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + + part_set_instruction( p, "SAMPLE/PRELOAD" ); + chain_shift_instructions( chain ); + chain_shift_data_registers( chain, 0 ); + + part_set_instruction( p, "EXTEST" ); + chain_shift_instructions( chain ); +} + +/** + * bus->driver->(*area) + * + */ +static int +s3c4510_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + int b0size0, b0size1; // , endian; + + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + + // endian = part_get_signal( PART, part_find_signal( PART, "LITTLE" )); + b0size0 = part_get_signal( PART, part_find_signal( PART, "B0SIZE0" )); + b0size1 = part_get_signal( PART, part_find_signal( PART, "B0SIZE1" )); + + switch ((b0size1 << 1) | b0size0) { + case 1: + area->width = dbus_width = 8; + return 0; + case 2: + area->width = dbus_width = 16; + return 0; + case 3: + area->width = dbus_width = 32; + return 0; + default: + printf( "B0SIZE[1:0]: Unknown\n" ); + area->width = 0; + return -1; + } +} + +static void s3c4510_bus_setup_ctrl( bus_t *bus, int mode ) +{ + int k; + part_t *p = PART; + + for (k = 0; k < 6; k++) + part_set_signal( p, nRCS[k], 1, (mode & (1 << k)) ? 1 : 0 ); + + for (k = 0; k < 4; k++) + part_set_signal( p, nECS[k], 1, 1 ); + + for (k = 0; k < 4; k++) + part_set_signal( p, nSDCS[k], 1, 1 ); + + for (k = 0; k < 4; k++) + part_set_signal( p, nWBE[k], 1, (mode & (1 << (k + 8))) ? 1 : 0 ); + + part_set_signal( p, nOE, 1, (mode & (1 << 16)) ? 1 : 0 ); +} static void setup_address( bus_t *bus, uint32_t a ) @@ -141,52 +329,10 @@ setup_data( bus_t *bus, uint32_t d ) part_set_signal( p, D[i], 1, 0 ); } -static void -s3c4510_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Samsung S3C4510B compatibile bus driver via BSR (JTAG part No. %d) RCS0=%ubit\n"), i ,dbus_width ); -} - -static void s3c4510_bus_setup_ctrl( bus_t *bus, int mode ) -{ - int k; - part_t *p = PART; - - for (k = 0; k < 6; k++) - part_set_signal( p, nRCS[k], 1, (mode & (1 << k)) ? 1 : 0 ); - - for (k = 0; k < 4; k++) - part_set_signal( p, nECS[k], 1, 1 ); - - for (k = 0; k < 4; k++) - part_set_signal( p, nSDCS[k], 1, 1 ); - - for (k = 0; k < 4; k++) - part_set_signal( p, nWBE[k], 1, (mode & (1 << (k + 8))) ? 1 : 0 ); - - part_set_signal( p, nOE, 1, (mode & (1 << 16)) ? 1 : 0 ); -} - -static void -s3c4510_bus_prepare( bus_t *bus ) -{ - part_t *p = PART; - chain_t *chain = CHAIN; - - part_set_instruction( p, "SAMPLE/PRELOAD" ); - chain_shift_instructions( chain ); - chain_shift_data_registers( chain, 0 ); - - part_set_instruction( p, "EXTEST" ); - chain_shift_instructions( chain ); -} - - +/** + * bus->driver->(*read_start) + * + */ static void s3c4510_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -199,6 +345,10 @@ s3c4510_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t s3c4510_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -219,6 +369,10 @@ s3c4510_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t s3c4510_bus_read_end( bus_t *bus ) { @@ -237,6 +391,10 @@ s3c4510_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t s3c4510_bus_read( bus_t *bus, uint32_t adr ) { @@ -244,12 +402,12 @@ s3c4510_bus_read( bus_t *bus, uint32_t adr ) return s3c4510_bus_read_end( bus ); } - /** -** @brief -** ROM/SRAM/FlashPage Write Access Timing -*/ - + * bus->driver->(*write) + * + * @brief + * ROM/SRAM/FlashPage Write Access Timing + */ static void s3c4510_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -266,155 +424,26 @@ s3c4510_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { default: case 8: - s3c4510_bus_setup_ctrl( bus, 0x01fefe); /* nOE=1, nRCS0 =0, nWBE0=0 */ + s3c4510_bus_setup_ctrl( bus, 0x01fefe); /* nOE=1, nRCS0 =0, nWBE0=0 */ break; case 16: - s3c4510_bus_setup_ctrl( bus, 0x01fcfe); /* nOE=1, nRCS0 =0, nWBE0-1=0 */ + s3c4510_bus_setup_ctrl( bus, 0x01fcfe); /* nOE=1, nRCS0 =0, nWBE0-1=0 */ break; - + case 32: - s3c4510_bus_setup_ctrl( bus, 0x01f0fe); /* nOE=1, nRCS0 =0, nWBE0-3=0 */ + s3c4510_bus_setup_ctrl( bus, 0x01f0fe); /* nOE=1, nRCS0 =0, nWBE0-3=0 */ break; } - + setup_address( bus, adr ); setup_data( bus, data ); - + chain_shift_data_registers( chain, 0 ); s3c4510_bus_setup_ctrl( bus, 0x01ffff); /* nOE=1, nRCS0 =1 */ chain_shift_data_registers( chain, 0 ); - - DEBUG_LVL2( printf("bus_write %08x @ %08x\n", data, adr); ) -} - - -static int -s3c4510_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - int b0size0, b0size1; // , endian; - - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - - // endian = part_get_signal( PART, part_find_signal( PART, "LITTLE" )); - b0size0 = part_get_signal( PART, part_find_signal( PART, "B0SIZE0" )); - b0size1 = part_get_signal( PART, part_find_signal( PART, "B0SIZE1" )); - - switch ((b0size1 << 1) | b0size0) { - case 1: - area->width = dbus_width = 8; - return 0; - case 2: - area->width = dbus_width = 16; - return 0; - case 3: - area->width = dbus_width = 32; - return 0; - default: - printf( "B0SIZE[1:0]: Unknown\n" ); - area->width = 0; - return -1; - } -} - -static bus_t * -s3c4510_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[10]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &s3c4510_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - dbus_width = 16; - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - for (i = 0; i < 22; i++) { - sprintf( buff, "ADDR%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, "XDATA%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 < 6; i++) { - sprintf( buff, "nRCS%d", i ); - nRCS[i] = part_find_signal( PART, buff ); - if (!nRCS[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for (i = 0; i < 4; i++) { - sprintf( buff, "nECS%d", i ); - nECS[i] = part_find_signal( PART, buff ); - if (!nECS[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - for (i = 0; i < 4; i++) { - sprintf( buff, "nRAS%d", i ); /* those are nSDCS for SDRAMs only */ - nSDCS[i] = part_find_signal( PART, buff ); - if (!nSDCS[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - for (i = 0; i < 4; i++) { - sprintf( buff, "nWBE%d", i ); - nWBE[i] = part_find_signal( PART, buff ); - if (!nWBE[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - nOE = part_find_signal( PART, "nOE" ); - if (!nOE) { - printf( _("signal '%s' not found\n"), "nOE" ); - failed = 1; - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; + DEBUG_LVL2( printf("bus_write %08x @ %08x\n", data, adr); ) } const bus_driver_t s3c4510_bus = { diff --git a/jtag/src/bus/sa1110.c b/jtag/src/bus/sa1110.c index fa08dc9a..ec9d99ba 100644 --- a/jtag/src/bus/sa1110.c +++ b/jtag/src/bus/sa1110.c @@ -60,6 +60,128 @@ typedef struct { #define nWE ((bus_params_t *) bus->params)->nwe #define nOE ((bus_params_t *) bus->params)->noe +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +sa1110_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[10]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &sa1110_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + 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 < 6; i++) { + sprintf( buff, "nCS%d", i ); + nCS[i] = part_find_signal( PART, buff ); + if (!nCS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + RD_nWR = part_find_signal( PART, "RD_nWR" ); + if (!RD_nWR) { + printf( _("signal '%s' not found\n"), "RD_nWR" ); + failed = 1; + } + nWE = part_find_signal( PART, "nWE" ); + if (!nWE) { + printf( _("signal '%s' not found\n"), "nWE" ); + failed = 1; + } + nOE = part_find_signal( PART, "nOE" ); + if (!nOE) { + printf( _("signal '%s' not found\n"), "nOE" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +sa1110_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Intel SA-1110 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +sa1110_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +sa1110_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = part_get_signal( PART, part_find_signal( PART, "ROM_SEL" ) ) ? 32 : 16; + + return 0; +} + static void setup_address( bus_t *bus, uint32_t a ) { @@ -70,8 +192,6 @@ setup_address( bus_t *bus, uint32_t a ) part_set_signal( p, A[i], 1, (a >> i) & 1 ); } -static int sa1110_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ); - static void set_data_in( bus_t *bus ) { @@ -98,24 +218,10 @@ setup_data( bus_t *bus, uint32_t d ) part_set_signal( p, D[i], 1, (d >> i) & 1 ); } -static void -sa1110_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Intel SA-1110 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void -sa1110_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void sa1110_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -139,6 +245,10 @@ sa1110_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t sa1110_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -160,6 +270,10 @@ sa1110_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t sa1110_bus_read_end( bus_t *bus ) { @@ -187,6 +301,10 @@ sa1110_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t sa1110_bus_read( bus_t *bus, uint32_t adr ) { @@ -194,6 +312,10 @@ sa1110_bus_read( bus_t *bus, uint32_t adr ) return sa1110_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void sa1110_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -228,94 +350,6 @@ sa1110_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static int -sa1110_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - area->width = part_get_signal( PART, part_find_signal( PART, "ROM_SEL" ) ) ? 32 : 16; - - return 0; -} - -static bus_t * -sa1110_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[10]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &sa1110_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - 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 < 6; i++) { - sprintf( buff, "nCS%d", i ); - nCS[i] = part_find_signal( PART, buff ); - if (!nCS[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - RD_nWR = part_find_signal( PART, "RD_nWR" ); - if (!RD_nWR) { - printf( _("signal '%s' not found\n"), "RD_nWR" ); - failed = 1; - } - nWE = part_find_signal( PART, "nWE" ); - if (!nWE) { - printf( _("signal '%s' not found\n"), "nWE" ); - failed = 1; - } - nOE = part_find_signal( PART, "nOE" ); - if (!nOE) { - printf( _("signal '%s' not found\n"), "nOE" ); - failed = 1; - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t sa1110_bus = { "sa1110", N_("Intel SA-1110 compatible bus driver via BSR"), diff --git a/jtag/src/bus/sh7727.c b/jtag/src/bus/sh7727.c index 12f1c8f5..4d878d0e 100644 --- a/jtag/src/bus/sh7727.c +++ b/jtag/src/bus/sh7727.c @@ -61,7 +61,158 @@ typedef struct { #define MD3 ((bus_params_t *) bus->params)->md3 #define MD4 ((bus_params_t *) bus->params)->md4 -static int sh7727_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ); +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +sh7727_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[10]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &sh7727_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + 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++) { + if (i == 1) + continue; + 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 < 4; 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; + } + MD3 = part_find_signal( PART, "MD3" ); + if (!MD3) { + printf( _("signal '%s' not found\n"), "MD3" ); + failed = 1; + } + MD4 = part_find_signal( PART, "MD4" ); + if (!MD4) { + printf( _("signal '%s' not found\n"), "MD4" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +sh7727_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Hitachi SH7727 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +sh7727_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +sh7727_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + part_t *p = PART; + + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + + switch (part_get_signal( p, MD4 ) << 1 | part_get_signal( p, MD3 )) { + case 1: + area->width = 8; + return 0; + case 2: + area->width = 16; + return 0; + case 3: + area->width = 32; + return 0; + default: + printf( _("Error: Invalid bus width (MD3 = MD4 = 0)!\n") ); + area->width = 0; + return -1; + } +} static void setup_address( bus_t *bus, uint32_t a ) @@ -99,24 +250,10 @@ setup_data( bus_t *bus, uint32_t d ) part_set_signal( p, D[i], 1, (d >> i) & 1 ); } -static void -sh7727_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Hitachi SH7727 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void -sh7727_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void sh7727_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -147,6 +284,10 @@ sh7727_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( CHAIN, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t sh7727_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -154,7 +295,7 @@ sh7727_bus_read_next( bus_t *bus, uint32_t adr ) int i; uint32_t d = 0; bus_area_t area; - + sh7727_bus_area( bus, 0, &area ); setup_address( bus, adr ); @@ -166,6 +307,10 @@ sh7727_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t sh7727_bus_read_end( bus_t *bus ) { @@ -192,6 +337,10 @@ sh7727_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t sh7727_bus_read( bus_t *bus, uint32_t adr ) { @@ -199,6 +348,10 @@ sh7727_bus_read( bus_t *bus, uint32_t adr ) return sh7727_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void sh7727_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -234,134 +387,15 @@ sh7727_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) 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 int -sh7727_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - part_t *p = PART; - - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - switch (part_get_signal( p, MD4 ) << 1 | part_get_signal( p, MD3 )) { - case 1: - area->width = 8; - return 0; - case 2: - area->width = 16; - return 0; - case 3: - area->width = 32; - return 0; - default: - printf( _("Error: Invalid bus width (MD3 = MD4 = 0)!\n") ); - area->width = 0; - return -1; - } -} - -static bus_t * -sh7727_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[10]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &sh7727_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - 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++) { - if (i == 1) - continue; - 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 < 4; 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; - } - MD3 = part_find_signal( PART, "MD3" ); - if (!MD3) { - printf( _("signal '%s' not found\n"), "MD3" ); - failed = 1; - } - MD4 = part_find_signal( PART, "MD4" ); - if (!MD4) { - printf( _("signal '%s' not found\n"), "MD4" ); - failed = 1; - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; + chain_shift_data_registers( chain, 0 ); } const bus_driver_t sh7727_bus = { diff --git a/jtag/src/bus/sh7750r.c b/jtag/src/bus/sh7750r.c index 7bd954e3..147d3422 100644 --- a/jtag/src/bus/sh7750r.c +++ b/jtag/src/bus/sh7750r.c @@ -61,6 +61,142 @@ typedef struct { #define RDWR2 ((bus_params_t *) bus->params)->rdwr2 #define RD2 ((bus_params_t *) bus->params)->rd2 +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +sh7750r_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[10]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &sh7750r_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + 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; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +sh7750r_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Hitachi SH7750R compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +sh7750r_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +sh7750r_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 32; + + return 0; +} + static void setup_address( bus_t *bus, uint32_t a ) { @@ -91,24 +227,10 @@ setup_data( bus_t *bus, uint32_t d ) part_set_signal( p, D[i], 1, (d >> i) & 1 ); } -static void -sh7750r_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Hitachi SH7750R compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void -sh7750r_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void sh7750r_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -141,6 +263,10 @@ sh7750r_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( CHAIN, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t sh7750r_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -157,6 +283,10 @@ sh7750r_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t sh7750r_bus_read_end( bus_t *bus ) { @@ -186,6 +316,10 @@ sh7750r_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t sh7750r_bus_read( bus_t *bus, uint32_t adr ) { @@ -193,6 +327,10 @@ sh7750r_bus_read( bus_t *bus, uint32_t adr ) return sh7750r_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void sh7750r_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -231,117 +369,15 @@ sh7750r_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) 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 int -sh7750r_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - area->width = 32; - - return 0; -} - -static bus_t * -sh7750r_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[10]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &sh7750r_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - 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; + chain_shift_data_registers( chain, 0 ); } const bus_driver_t sh7750r_bus = { diff --git a/jtag/src/bus/sh7751r.c b/jtag/src/bus/sh7751r.c index f6237e06..db9dd808 100644 --- a/jtag/src/bus/sh7751r.c +++ b/jtag/src/bus/sh7751r.c @@ -59,6 +59,132 @@ typedef struct { #define RD ((bus_params_t *) bus->params)->rd #define BS ((bus_params_t *) bus->params)->bs +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +sh7751r_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[10]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &sh7751r_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + 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 < 4; 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, "RD_WR" ); + if (!RDWR) { + printf( _("signal '%s' not found\n"), "RDWR" ); + failed = 1; + } + RD = part_find_signal( PART, "RD_CASS_FRAME" ); + if (!RD) { + printf( _("signal '%s' not found\n"), "RD" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +sh7751r_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Hitachi SH7751R compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +sh7751r_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +sh7751r_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 16; + + return 0; +} + static void setup_address( bus_t *bus, uint32_t a ) { @@ -89,25 +215,10 @@ setup_data( bus_t *bus, uint32_t d ) part_set_signal( p, D[i], 1, (d >> i) & 1 ); } -static void -sh7751r_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Hitachi SH7751R compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - - -static void -sh7751r_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void sh7751r_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -138,6 +249,10 @@ sh7751r_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( CHAIN, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t sh7751r_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -154,6 +269,10 @@ sh7751r_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t sh7751r_bus_read_end( bus_t *bus ) { @@ -182,6 +301,10 @@ sh7751r_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t sh7751r_bus_read( bus_t *bus, uint32_t adr ) { @@ -189,6 +312,10 @@ sh7751r_bus_read( bus_t *bus, uint32_t adr ) return sh7751r_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void sh7751r_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -224,107 +351,15 @@ sh7751r_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) 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 int -sh7751r_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - area->width = 16; - - return 0; -} - -static bus_t * -sh7751r_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[10]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &sh7751r_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - 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 < 4; 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, "RD_WR" ); - if (!RDWR) { - printf( _("signal '%s' not found\n"), "RDWR" ); - failed = 1; - } - RD = part_find_signal( PART, "RD_CASS_FRAME" ); - if (!RD) { - printf( _("signal '%s' not found\n"), "RD" ); - failed = 1; - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; + chain_shift_data_registers( chain, 0 ); } const bus_driver_t sh7751r_bus = { diff --git a/jtag/src/bus/sharc21065l.c b/jtag/src/bus/sharc21065l.c index 708b24a3..c38d53bf 100644 --- a/jtag/src/bus/sharc21065l.c +++ b/jtag/src/bus/sharc21065l.c @@ -64,10 +64,130 @@ typedef struct #define nWE ((bus_params_t *) bus->params)->nwe #define nOE ((bus_params_t *) bus->params)->noe +/** + * bus->driver->(*new_bus) + * + */ +static bus_t *sharc_21065L_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[15]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + bus->driver = &sharc_21065L_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + for (i = 0; i < 19; i++) { + sprintf( buff, "ADDR%d", i ); + MA[i] = part_find_signal( PART, buff ); + if (!MA[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + for (i = 0; i < 8; i++) { + sprintf( buff, "DATA%d", i ); + MD[i] = part_find_signal( PART, buff ); + if (!MD[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + BMS = part_find_signal( PART, "BMS_B" ); + if (!BMS) { + printf( _("signal '%s' not found\n"), "BMS_B" ); + failed = 1; + } + nWE = part_find_signal( PART, "WR_B" ); + if (!nWE) { + printf( _("signal '%s' not found\n"), "WR_B" ); + failed = 1; + } + nOE = part_find_signal( PART, "RD_B" ); + if (!nOE) { + printf( _("signal '%s' not found\n"), "RD_B" ); + failed = 1; + } -static void setup_address( bus_t *bus, uint32_t a ) + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void sharc_21065L_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Analog Device's SHARC 21065L compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +sharc_21065L_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +sharc_21065L_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + /* BMS (512 KB) */ + if (adr < UINT32_C(0x080000)) { + area->description = N_("Boot Memory Select"); + area->start = UINT32_C(0x000000); + area->length = UINT64_C(0x080000); + area->width = 8; + + return 0; + } + + area->description = NULL; + area->start = UINT32_C(0xffffffff); + area->length = UINT64_C(0x080000); + area->width = 0; + return 0; +} + +static void +setup_address( bus_t *bus, uint32_t a ) { int i; part_t *p = PART; @@ -76,10 +196,8 @@ static void setup_address( bus_t *bus, uint32_t a ) part_set_signal( p, MA[i], 1, (a >> i) & 1 ); } -static int sharc_21065L_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ); - - -static void set_data_in( bus_t *bus, uint32_t adr ) +static void +set_data_in( bus_t *bus, uint32_t adr ) { int i; part_t *p = PART; @@ -92,7 +210,8 @@ static void set_data_in( bus_t *bus, uint32_t adr ) } -static void setup_data( bus_t *bus, uint32_t adr, uint32_t d ) +static void +setup_data( bus_t *bus, uint32_t adr, uint32_t d ) { int i; part_t *p = PART; @@ -104,25 +223,12 @@ static void setup_data( bus_t *bus, uint32_t adr, uint32_t d ) part_set_signal( p, MD[i], 1, (d >> i) & 1 ); } - -static void sharc_21065L_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Analog Device's SHARC 21065L compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void sharc_21065L_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - - -static void sharc_21065L_bus_read_start( bus_t *bus, uint32_t adr ) +/** + * bus->driver->(*read_start) + * + */ +static void +sharc_21065L_bus_read_start( bus_t *bus, uint32_t adr ) { chain_t *chain = CHAIN; part_t *p = PART; @@ -142,8 +248,12 @@ static void sharc_21065L_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } - -static uint32_t sharc_21065L_bus_read_next( bus_t *bus, uint32_t adr ) +/** + * bus->driver->(*read_next) + * + */ +static uint32_t +sharc_21065L_bus_read_next( bus_t *bus, uint32_t adr ) { part_t *p = PART; chain_t *chain = CHAIN; @@ -171,8 +281,12 @@ static uint32_t sharc_21065L_bus_read_next( bus_t *bus, uint32_t adr ) return 0; } - -static uint32_t sharc_21065L_bus_read_end( bus_t *bus ) +/** + * bus->driver->(*read_end) + * + */ +static uint32_t +sharc_21065L_bus_read_end( bus_t *bus ) { part_t *p = PART; chain_t *chain = CHAIN; @@ -200,15 +314,23 @@ static uint32_t sharc_21065L_bus_read_end( bus_t *bus ) return 0; } -static uint32_t sharc_21065L_bus_read( bus_t *bus, uint32_t adr ) +/** + * bus->driver->(*read) + * + */ +static uint32_t +sharc_21065L_bus_read( bus_t *bus, uint32_t adr ) { sharc_21065L_bus_read_start( bus, adr ); return sharc_21065L_bus_read_end( bus ); } - - -static void sharc_21065L_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) +/** + * bus->driver->(*write) + * + */ +static void +sharc_21065L_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { part_t *p = PART; chain_t *chain = CHAIN; @@ -232,96 +354,6 @@ static void sharc_21065L_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } - -static int sharc_21065L_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - /* BMS (512 KB) */ - if (adr < UINT32_C(0x080000)) { - area->description = N_("Boot Memory Select"); - area->start = UINT32_C(0x000000); - area->length = UINT64_C(0x080000); - area->width = 8; - - return 0; - } - - area->description = NULL; - area->start = UINT32_C(0xffffffff); - area->length = UINT64_C(0x080000); - area->width = 0; - return 0; -} - - -static bus_t *sharc_21065L_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[15]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &sharc_21065L_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - for (i = 0; i < 19; i++) { - sprintf( buff, "ADDR%d", i ); - MA[i] = part_find_signal( PART, buff ); - if (!MA[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - for (i = 0; i < 8; i++) { - sprintf( buff, "DATA%d", i ); - MD[i] = part_find_signal( PART, buff ); - if (!MD[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - BMS = part_find_signal( PART, "BMS_B" ); - if (!BMS) { - printf( _("signal '%s' not found\n"), "BMS_B" ); - failed = 1; - } - nWE = part_find_signal( PART, "WR_B" ); - if (!nWE) { - printf( _("signal '%s' not found\n"), "WR_B" ); - failed = 1; - } - nOE = part_find_signal( PART, "RD_B" ); - if (!nOE) { - printf( _("signal '%s' not found\n"), "RD_B" ); - failed = 1; - } - - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t sharc_21065L_bus = { "SHARC_21065L", N_("SHARC_21065L compatible bus driver via BSR"), diff --git a/jtag/src/bus/slsup3.c b/jtag/src/bus/slsup3.c index a68754a4..df4e739c 100644 --- a/jtag/src/bus/slsup3.c +++ b/jtag/src/bus/slsup3.c @@ -88,7 +88,198 @@ typedef struct { #define LCDSTART 0x0300000 #define LCDSIZE 0x0100000 -static int slsup3_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ); +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +slsup3_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[10]; + int i; + int failed = 0; + part_t *part; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &slsup3_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = part = chain->parts->parts[chain->active_part]; + + for(i = 0; i < 20 ; i++) { + sprintf( buff, "IO%d", addrbusio[i] ); + AD[i] = part_find_signal( part, buff ); + if (!AD[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for(i = 0; i < 16 ; i++) { + sprintf( buff, "IO%d", databusio[i] ); + DQ[i] = part_find_signal( part, buff ); + if (!DQ[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + nOE = part_find_signal( part, "IO118" ); + if (!nOE) { + printf( _("signal '%s' not found\n"), "nOE" ); + failed = 1; + } + + nSRce = part_find_signal( part, "IO116" ); + if (!nSRce) { + printf( _("signal '%s' not found\n"), "nSRce" ); + failed = 1; + } + + nSDce = part_find_signal( part, "IO119" ); + if (!nSDce) { + printf( _("signal '%s' not found\n"), "nSDce" ); + failed = 1; + } + + nFLce = part_find_signal( part, "IO117" ); + if (!nFLce) { + printf( _("signal '%s' not found\n"), "nFLce" ); + failed = 1; + } + + nFLbyte = part_find_signal( part, "IO115" ); + if (!nFLbyte) { + printf( _("signal '%s' not found\n"), "nFLbyte" ); + failed = 1; + } + + nFLby = part_find_signal( part, "IO80" ); + if (!nFLby) { + printf( _("signal '%s' not found\n"), "nFLby" ); + failed = 1; + } + + nWE = part_find_signal( part, "IO79" ); + if (!nWE) { + printf( _("signal '%s' not found\n"), "nWE" ); + failed = 1; + } + + SDclk = part_find_signal( part, "IO11" ); + if (!SDclk) { + printf( _("signal '%s' not found\n"), "SDclk" ); + failed = 1; + } + + LCDe = part_find_signal( part, "IO50" ); + if (!LCDe) { + printf( _("signal '%s' not found\n"), "LCDe" ); + failed = 1; + } + + LCDrs = part_find_signal( part, "IO108" ); + if (!LCDrs) { + printf( _("signal '%s' not found\n"), "LCDrs" ); + failed = 1; + } + + LCDrw = part_find_signal( part, "IO73" ); + if (!LCDrw) { + printf( _("signal '%s' not found\n"), "LCDrw" ); + failed = 1; + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +slsup3_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("SLS UP3 bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +/** + * bus->driver->(*prepare) + * + */ +static void +slsup3_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +slsup3_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + if ((adr >= FLASHSTART) && (adr < (FLASHSTART + FLASHSIZE))) { + area->description = N_("Flash Memory (2 MByte) byte mode"); + area->start = FLASHSTART; + area->length = FLASHSIZE; + area->width = 8; /* 16 */ + + return 0; + } + + if ((adr >= SRAMSTART) && (adr < (SRAMSTART + SRAMSIZE))) { + area->description = N_("SRAM 128KByte (64K x 16)"); + area->start = SRAMSTART; + area->length = SRAMSIZE; + area->width = 16; + + return 0; + } + + if ((adr >= LCDSTART) && (adr < (LCDSTART + LCDSIZE))) { + area->description = N_("LCD Display (RS select by A0)"); + area->start = LCDSTART; + area->length = LCDSIZE; + area->width = 8; + + return 0; + } + + area->description = NULL; + area->start = UINT32_C(0x0400000); + area->length = UINT64_C(0xFFC00000); + area->width = 0; + + return 0; +} static void setup_address( bus_t *bus, uint32_t a ) @@ -171,24 +362,10 @@ get_data( bus_t *bus, uint32_t adr ) return d; } -static void -slsup3_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("SLS UP3 bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void -slsup3_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void slsup3_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -203,11 +380,11 @@ slsup3_bus_read_start( bus_t *bus, uint32_t adr ) part_set_signal( p, nFLbyte, 1, 0); part_set_signal( p, nWE, 1, 1); part_set_signal( p, SDclk, 1, 0); - part_set_signal( p, LCDe, 1, 0); + part_set_signal( p, LCDe, 1, 0); part_set_signal( p, LCDrw, 1, 1); setup_address( bus, adr ); - + if ((adr >= LCDSTART) && (adr < (LCDSTART + LCDSIZE))) { part_set_signal( p, LCDe, 1, 1); chain_shift_data_registers( CHAIN, 0 ); @@ -220,6 +397,10 @@ slsup3_bus_read_start( bus_t *bus, uint32_t adr ) } +/** + * bus->driver->(*read_next) + * + */ static uint32_t slsup3_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -244,6 +425,10 @@ slsup3_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t slsup3_bus_read_end( bus_t *bus ) { @@ -265,16 +450,24 @@ slsup3_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t slsup3_bus_read( bus_t *bus, uint32_t adr ) { uint32_t d; - + slsup3_bus_read_start( bus, adr ); d = slsup3_bus_read_end( bus ); return d; } +/** + * bus->driver->(*write) + * + */ static void slsup3_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -311,165 +504,6 @@ slsup3_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) } } -static int -slsup3_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - if ((adr >= FLASHSTART) && (adr < (FLASHSTART + FLASHSIZE))) { - area->description = N_("Flash Memory (2 MByte) byte mode"); - area->start = FLASHSTART; - area->length = FLASHSIZE; - area->width = 8; /* 16 */ - - return 0; - } - - if ((adr >= SRAMSTART) && (adr < (SRAMSTART + SRAMSIZE))) { - area->description = N_("SRAM 128KByte (64K x 16)"); - area->start = SRAMSTART; - area->length = SRAMSIZE; - area->width = 16; - - return 0; - } - - if ((adr >= LCDSTART) && (adr < (LCDSTART + LCDSIZE))) { - area->description = N_("LCD Display (RS select by A0)"); - area->start = LCDSTART; - area->length = LCDSIZE; - area->width = 8; - - return 0; - } - - area->description = NULL; - area->start = UINT32_C(0x0400000); - area->length = UINT64_C(0xFFC00000); - area->width = 0; - - return 0; -} - -static bus_t * -slsup3_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[10]; - int i; - int failed = 0; - part_t *part; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &slsup3_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = part = chain->parts->parts[chain->active_part]; - - for(i = 0; i < 20 ; i++) { - sprintf( buff, "IO%d", addrbusio[i] ); - AD[i] = part_find_signal( part, buff ); - if (!AD[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for(i = 0; i < 16 ; i++) { - sprintf( buff, "IO%d", databusio[i] ); - DQ[i] = part_find_signal( part, buff ); - if (!DQ[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - nOE = part_find_signal( part, "IO118" ); - if (!nOE) { - printf( _("signal '%s' not found\n"), "nOE" ); - failed = 1; - } - - nSRce = part_find_signal( part, "IO116" ); - if (!nSRce) { - printf( _("signal '%s' not found\n"), "nSRce" ); - failed = 1; - } - - nSDce = part_find_signal( part, "IO119" ); - if (!nSDce) { - printf( _("signal '%s' not found\n"), "nSDce" ); - failed = 1; - } - - nFLce = part_find_signal( part, "IO117" ); - if (!nFLce) { - printf( _("signal '%s' not found\n"), "nFLce" ); - failed = 1; - } - - nFLbyte = part_find_signal( part, "IO115" ); - if (!nFLbyte) { - printf( _("signal '%s' not found\n"), "nFLbyte" ); - failed = 1; - } - - nFLby = part_find_signal( part, "IO80" ); - if (!nFLby) { - printf( _("signal '%s' not found\n"), "nFLby" ); - failed = 1; - } - - nWE = part_find_signal( part, "IO79" ); - if (!nWE) { - printf( _("signal '%s' not found\n"), "nWE" ); - failed = 1; - } - - SDclk = part_find_signal( part, "IO11" ); - if (!SDclk) { - printf( _("signal '%s' not found\n"), "SDclk" ); - failed = 1; - } - - LCDe = part_find_signal( part, "IO50" ); - if (!LCDe) { - printf( _("signal '%s' not found\n"), "LCDe" ); - failed = 1; - } - - LCDrs = part_find_signal( part, "IO108" ); - if (!LCDrs) { - printf( _("signal '%s' not found\n"), "LCDrs" ); - failed = 1; - } - - LCDrw = part_find_signal( part, "IO73" ); - if (!LCDrw) { - printf( _("signal '%s' not found\n"), "LCDrw" ); - failed = 1; - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t slsup3_bus = { "slsup3", N_("SLS UP3 compatible bus driver via BSR"), diff --git a/jtag/src/bus/tx4925.c b/jtag/src/bus/tx4925.c index 60f70da9..16ba2fdf 100644 --- a/jtag/src/bus/tx4925.c +++ b/jtag/src/bus/tx4925.c @@ -62,9 +62,145 @@ typedef struct { #define ADDR ((bus_params_t *) bus->params)->addr #define DATA ((bus_params_t *) bus->params)->data +// the number of bytes wide that the TX4925 +// CS0 signal is set to by the external +// config resistors on A13/A12 at reset +// 1, 2, or 4 are legal values + +#define TX4925_FLASH_CS_WIDTH 2 + +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +tx4925_bus_new( chain_t *chain, char *cmd_params[] ) +{ + bus_t *bus; + char buff[15]; + int i; + int failed = 0; + + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; + + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; + + bus->driver = &tx4925_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } + + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; + + OE = part_find_signal( PART, "OE" ); + if (!OE) { + printf( _("signal '%s' not found\n"), "OE" ); + failed = 1; + } + + SWE = part_find_signal( PART, "SWE" ); + if (!SWE) { + printf( _("signal '%s' not found\n"), "SWE" ); + failed = 1; + } + + for (i = 0; i < 4; i++) { + sprintf( buff, "ROMCE_%d", i ); + ROMCE[i] = part_find_signal( PART, buff ); + if (!ROMCE[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for (i = 0; i < 4; i++) { + sprintf( buff, "SDCS_%d", i ); + SDCS[i] = part_find_signal( PART, buff ); + if (!SDCS[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for (i = 0; i < 20; i++) { + sprintf( buff, "ADDR_%d", i ); + ADDR[i] = part_find_signal( PART, buff ); + if (!ADDR[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + for (i = 0; i < 16; i++) { + sprintf( buff, "DATA_%d", i ); + DATA[i] = part_find_signal( PART, buff ); + if (!DATA[i]) { + printf( _("signal '%s' not found\n"), buff ); + failed = 1; + break; + } + } + + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +tx4925_bus_printinfo( bus_t *bus ) +{ + int i; + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Toshiba TX4925 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} -static void +/** + * bus->driver->(*prepare) + * + */ +static void +tx4925_bus_prepare( bus_t *bus ) +{ + part_set_instruction( PART, "EXTEST" ); + chain_shift_instructions( CHAIN ); +} + +/** + * bus->driver->(*area) + * + */ +static int +tx4925_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 16; + + return 0; +} + +static void select_flash( bus_t *bus ) { part_t *p = PART; @@ -79,7 +215,7 @@ select_flash( bus_t *bus ) part_set_signal( p, SDCS[3], 1, 1 ); } -static void +static void unselect_flash( bus_t *bus ) { part_t *p = PART; @@ -94,14 +230,6 @@ unselect_flash( bus_t *bus ) part_set_signal( p, SDCS[3], 1, 1 ); } - -// the number of bytes wide that the TX4925 -// CS0 signal is set to by the external -// config resistors on A13/A12 at reset -// 1, 2, or 4 are legal values - -#define TX4925_FLASH_CS_WIDTH 2 - static void setup_address( bus_t *bus, uint32_t a ) { @@ -133,24 +261,10 @@ setup_data( bus_t *bus, uint32_t d ) part_set_signal( p, DATA[i], 1, (d >> i) & 1 ); } -static void -tx4925_bus_printinfo( bus_t *bus ) -{ - int i; - - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Toshiba TX4925 compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} - -static void -tx4925_bus_prepare( bus_t *bus ) -{ - part_set_instruction( PART, "EXTEST" ); - chain_shift_instructions( CHAIN ); -} - +/** + * bus->driver->(*read_start) + * + */ static void tx4925_bus_read_start( bus_t *bus, uint32_t adr ) { @@ -167,6 +281,10 @@ tx4925_bus_read_start( bus_t *bus, uint32_t adr ) chain_shift_data_registers( chain, 0 ); } +/** + * bus->driver->(*read_next) + * + */ static uint32_t tx4925_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -184,6 +302,10 @@ tx4925_bus_read_next( bus_t *bus, uint32_t adr ) return d; } +/** + * bus->driver->(*read_end) + * + */ static uint32_t tx4925_bus_read_end( bus_t *bus ) { @@ -204,6 +326,10 @@ tx4925_bus_read_end( bus_t *bus ) return d; } +/** + * bus->driver->(*read) + * + */ static uint32_t tx4925_bus_read( bus_t *bus, uint32_t adr ) { @@ -211,6 +337,10 @@ tx4925_bus_read( bus_t *bus, uint32_t adr ) return tx4925_bus_read_end( bus ); } +/** + * bus->driver->(*write) + * + */ static void tx4925_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -232,103 +362,6 @@ tx4925_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static int -tx4925_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - area->description = NULL; - area->start = UINT32_C(0x00000000); - area->length = UINT64_C(0x100000000); - area->width = 16; - - return 0; -} - -static bus_t * -tx4925_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - char buff[15]; - int i; - int failed = 0; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &tx4925_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - OE = part_find_signal( PART, "OE" ); - if (!OE) { - printf( _("signal '%s' not found\n"), "OE" ); - failed = 1; - } - - SWE = part_find_signal( PART, "SWE" ); - if (!SWE) { - printf( _("signal '%s' not found\n"), "SWE" ); - failed = 1; - } - - for (i = 0; i < 4; i++) { - sprintf( buff, "ROMCE_%d", i ); - ROMCE[i] = part_find_signal( PART, buff ); - if (!ROMCE[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for (i = 0; i < 4; i++) { - sprintf( buff, "SDCS_%d", i ); - SDCS[i] = part_find_signal( PART, buff ); - if (!SDCS[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for (i = 0; i < 20; i++) { - sprintf( buff, "ADDR_%d", i ); - ADDR[i] = part_find_signal( PART, buff ); - if (!ADDR[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - for (i = 0; i < 16; i++) { - sprintf( buff, "DATA_%d", i ); - DATA[i] = part_find_signal( PART, buff ); - if (!DATA[i]) { - printf( _("signal '%s' not found\n"), buff ); - failed = 1; - break; - } - } - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t tx4925_bus = { "tx4925", N_("Toshiba TX4925 compatible bus driver via BSR"), diff --git a/jtag/src/bus/zefant-xs3.c b/jtag/src/bus/zefant-xs3.c index a961ee89..26ca5f61 100644 --- a/jtag/src/bus/zefant-xs3.c +++ b/jtag/src/bus/zefant-xs3.c @@ -151,172 +151,380 @@ typedef struct { #define COMP_EEPROM &(((bus_params_t *) bus->params)->eeprom) #define COMP_EEPROM_STATUS &(((bus_params_t *) bus->params)->eeprom_status) -static void -setup_address( bus_t *bus, uint32_t a, component_t *comp ) -{ - int i; - part_t *p = PART; - int addr_width; - - LAST_ADDR = a; - - switch (comp->ctype) { - case FLASH: - addr_width = FLASH_ADDR_WIDTH; - /* address a is a byte address, - A0 is ignored by the flash chip */ - break; - case RAM: - addr_width = RAM_ADDR_WIDTH; - /* address a is a byte address so it is transferred into - a word address here */ - a >>= 1; - break; - case EEPROM: - case EEPROM_STATUS: - addr_width = EEPROM_ADDR_WIDTH; - break; - default: - addr_width = 0; - break; - } - - for (i = 0; i < addr_width; i++) - part_set_signal( p, A[i], 1, (a >> i) & 1 ); -} - static int -detect_data_width( component_t *comp ) +attach_sig( bus_t *bus, signal_t **sig, char *id ) { - int width; + int failed = 0; - switch (comp->ctype) { - case RAM: - width = RAM_DATA_WIDTH; - break; - case FLASH: - width = FLASH_DATA_WIDTH; - break; - case EEPROM: - case EEPROM_STATUS: - width = EEPROM_DATA_WIDTH; - break; - default: - width = 0; - break; + *sig = part_find_signal( PART, id ); + if (!*sig) { + printf( _("signal '%s' not found\n"), id ); + failed = 1; } - return width; + return failed; } -static void -set_data_in( bus_t *bus, component_t *comp ) +/** + * bus->driver->(*new_bus) + * + */ +static bus_t * +zefant_xs3_bus_new( chain_t *chain, char *cmd_params[] ) { - int i; - part_t *p = PART; - int width; + bus_t *bus; + int failed = 0; + component_t *comp; + int idx; - width = detect_data_width( comp ); + if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) + return NULL; - for (i = 0; i < width; i++) - part_set_signal( p, D[i], 0, 0 ); -} + bus = calloc( 1, sizeof (bus_t) ); + if (!bus) + return NULL; -static void -setup_data( bus_t *bus, uint32_t d, component_t *comp ) -{ - int i; - part_t *p = PART; - int width; + bus->driver = &zefant_xs3_bus; + bus->params = calloc( 1, sizeof (bus_params_t) ); + if (!bus->params) { + free( bus ); + return NULL; + } - width = detect_data_width( comp ); + CHAIN = chain; + PART = chain->parts->parts[chain->active_part]; - for (i = 0; i < width; i++) - part_set_signal( p, D[i], 1, (d >> i) & 1 ); -} + /* + * Setup FLASH + */ + comp = COMP_FLASH; + comp->ctype = FLASH; + comp->cname = "FLASH"; -static int comp_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area, component_t **comp ); + failed |= attach_sig( bus, &(A[ 0]), "IO_V9" ); + failed |= attach_sig( bus, &(A[ 1]), "IO_U10" ); + failed |= attach_sig( bus, &(A[ 2]), "IO_V10" ); + failed |= attach_sig( bus, &(A[ 3]), "IO_W10" ); + failed |= attach_sig( bus, &(A[ 4]), "IO_Y10" ); + failed |= attach_sig( bus, &(A[ 5]), "IO_W8" ); + failed |= attach_sig( bus, &(A[ 6]), "IO_W9" ); + failed |= attach_sig( bus, &(A[ 7]), "IO_V8" ); + failed |= attach_sig( bus, &(A[ 8]), "IO_V6" ); + failed |= attach_sig( bus, &(A[ 9]), "IO_AA8" ); + failed |= attach_sig( bus, &(A[10]), "IO_AB8" ); + failed |= attach_sig( bus, &(A[11]), "IO_U7" ); + failed |= attach_sig( bus, &(A[12]), "IO_V7" ); + failed |= attach_sig( bus, &(A[13]), "IO_U6" ); + failed |= attach_sig( bus, &(A[14]), "IO_Y6" ); + failed |= attach_sig( bus, &(A[15]), "IO_AB11" ); + failed |= attach_sig( bus, &(A[16]), "IO_AB10" ); + failed |= attach_sig( bus, &(A[17]), "IO_AA10" ); + failed |= attach_sig( bus, &(A[18]), "IO_W6" ); + failed |= attach_sig( bus, &(A[19]), "IO_AA6" ); + failed |= attach_sig( bus, &(A[20]), "IO_U11" ); + failed |= attach_sig( bus, &(A[21]), "IO_Y13" ); + failed |= attach_sig( bus, &(A[22]), "IO_AB13" ); + failed |= attach_sig( bus, &(A[23]), "IO_U13" ); + failed |= attach_sig( bus, &(A[24]), "IO_AA13" ); + failed |= attach_sig( bus, &(D[ 0]), "IO_AA14" ); + failed |= attach_sig( bus, &(D[ 1]), "IO_AB14" ); + failed |= attach_sig( bus, &(D[ 2]), "IO_U12" ); + failed |= attach_sig( bus, &(D[ 3]), "IO_V12" ); + failed |= attach_sig( bus, &(D[ 4]), "IO_W11" ); + failed |= attach_sig( bus, &(D[ 5]), "IO_V11" ); + failed |= attach_sig( bus, &(D[ 6]), "IO_AB9" ); + failed |= attach_sig( bus, &(D[ 7]), "IO_AA9" ); + failed |= attach_sig( bus, &(D[ 8]), "IO_U16" ); + failed |= attach_sig( bus, &(D[ 9]), "IO_AB15" ); + failed |= attach_sig( bus, &(D[10]), "IO_AA15" ); + failed |= attach_sig( bus, &(D[11]), "IO_W14" ); + failed |= attach_sig( bus, &(D[12]), "IO_V14" ); + failed |= attach_sig( bus, &(D[13]), "IO_U14" ); + failed |= attach_sig( bus, &(D[14]), "IO_W13" ); + failed |= attach_sig( bus, &(D[15]), "IO_V13" ); -/* *************************************************************************** - * zefant_xs3_printinfo - * ***************************************************************************/ -static void -zefant_xs3_bus_printinfo( bus_t *bus ) -{ - int i; + failed |= attach_sig( bus, &(nWE), "IO_Y17" ); + failed |= attach_sig( bus, &(nOE), "IO_AA17" ); + failed |= attach_sig( bus, &(nCS), "IO_U17" ); + nLB = NULL; + nUB = NULL; - for (i = 0; i < CHAIN->parts->len; i++) - if (PART == CHAIN->parts->parts[i]) - break; - printf( _("Simple Solutions Zefant-XS3 Board compatible bus driver via BSR (JTAG part No. %d)\n"), i ); -} + failed |= attach_sig( bus, &(nRP), "IO_V16" ); + failed |= attach_sig( bus, &(nBYTE), "IO_Y16" ); + failed |= attach_sig( bus, &(STS), "IO_W16" ); + SI = NULL; + SO = NULL; + SCK = NULL; -/* *************************************************************************** - * zefant_xs3_bus_prepare - * ***************************************************************************/ -static void -zefant_xs3_bus_prepare( bus_t *bus ) -{ - part_t *p = PART; - chain_t *chain = CHAIN; - component_t *comp; + /* + * Setup SO-DIMM SRAM0 + */ + comp = COMP_RAM0; + comp->ctype = RAM; + comp->cname = "RAM0"; - /* Preload update registers - See AN039, "Guidelines for IEEE Std. 1149.1 Boundary Scan Testing */ + failed |= attach_sig( bus, &(A[ 0]), "IO_AA4" ); + failed |= attach_sig( bus, &(A[ 1]), "IO_AB4" ); + failed |= attach_sig( bus, &(A[ 2]), "IO_W5" ); + failed |= attach_sig( bus, &(A[ 3]), "IO_Y3" ); + failed |= attach_sig( bus, &(A[ 4]), "IO_Y1" ); + failed |= attach_sig( bus, &(A[ 5]), "IO_M1" ); + failed |= attach_sig( bus, &(A[ 6]), "IO_N2" ); + failed |= attach_sig( bus, &(A[ 7]), "IO_L2" ); + failed |= attach_sig( bus, &(A[ 8]), "IO_L1" ); + failed |= attach_sig( bus, &(A[ 9]), "IO_K1" ); + failed |= attach_sig( bus, &(A[10]), "IO_K3" ); + failed |= attach_sig( bus, &(A[11]), "IO_L6" ); + failed |= attach_sig( bus, &(A[12]), "IO_L4" ); + failed |= attach_sig( bus, &(A[13]), "IO_L3" ); + failed |= attach_sig( bus, &(A[14]), "IO_K4" ); + failed |= attach_sig( bus, &(A[15]), "IO_AB5" ); + failed |= attach_sig( bus, &(A[16]), "IO_AA5" ); + failed |= attach_sig( bus, &(A[17]), "IO_Y5" ); + A[18] = NULL; + A[19] = NULL; + A[20] = NULL; + A[21] = NULL; + A[22] = NULL; + A[23] = NULL; + A[24] = NULL; - part_set_instruction( p, "SAMPLE/PRELOAD" ); - chain_shift_instructions( chain ); + failed |= attach_sig( bus, &(D[ 0]), "IO_W1" ); + failed |= attach_sig( bus, &(D[ 1]), "IO_V5" ); + failed |= attach_sig( bus, &(D[ 2]), "IO_V3" ); + failed |= attach_sig( bus, &(D[ 3]), "IO_V1" ); + failed |= attach_sig( bus, &(D[ 4]), "IO_N1" ); + failed |= attach_sig( bus, &(D[ 5]), "IO_N3" ); + failed |= attach_sig( bus, &(D[ 6]), "IO_M2" ); + failed |= attach_sig( bus, &(D[ 7]), "IO_M5" ); + failed |= attach_sig( bus, &(D[ 8]), "IO_M4" ); + failed |= attach_sig( bus, &(D[ 9]), "IO_M6" ); + failed |= attach_sig( bus, &(D[10]), "IO_L5" ); + failed |= attach_sig( bus, &(D[11]), "IO_N4" ); + failed |= attach_sig( bus, &(D[12]), "IO_T6" ); + failed |= attach_sig( bus, &(D[13]), "IO_V2" ); + failed |= attach_sig( bus, &(D[14]), "IO_V4" ); + failed |= attach_sig( bus, &(D[15]), "IO_U5" ); - /* FLASH */ - comp = COMP_FLASH; - setup_data( bus, 0, comp ); - part_set_signal( p, nCS, 1, 1 ); - part_set_signal( p, nWE, 1, 1 ); - part_set_signal( p, nOE, 1, 1 ); - part_set_signal( p, nRP, 1, 1 ); - part_set_signal( p, nBYTE, 1, 1 ); - part_set_signal( p, STS, 0, 0 ); + failed |= attach_sig( bus, &(nCS), "IO_W3" ); + failed |= attach_sig( bus, &(nOE), "IO_Y2" ); + failed |= attach_sig( bus, &(nWE), "IO_M3" ); + failed |= attach_sig( bus, &(nLB), "IO_W2" ); + failed |= attach_sig( bus, &(nUB), "IO_W4" ); + nRP = NULL; + nBYTE = NULL; + STS = NULL; - /* RAM0 */ - comp = COMP_RAM0; - setup_data( bus, 0, comp ); - part_set_signal( p, nCS, 1, 1 ); - part_set_signal( p, nWE, 1, 1 ); - part_set_signal( p, nOE, 1, 1 ); - part_set_signal( p, nLB, 1, 1 ); - part_set_signal( p, nUB, 1, 1 ); + SI = NULL; + SO = NULL; + SCK = NULL; - /* RAM1 */ + /* + * Setup SO-DIMM SRAM1 + */ comp = COMP_RAM1; - setup_data( bus, 0, comp ); - part_set_signal( p, nCS, 1, 1 ); - part_set_signal( p, nWE, 1, 1 ); - part_set_signal( p, nOE, 1, 1 ); - part_set_signal( p, nLB, 1, 1 ); - part_set_signal( p, nUB, 1, 1 ); + comp->ctype = RAM; + comp->cname = "RAM1"; - /* EEPROM */ + failed |= attach_sig( bus, &(A[ 0]), "IO_H5" ); + failed |= attach_sig( bus, &(A[ 1]), "IO_F5" ); + failed |= attach_sig( bus, &(A[ 2]), "IO_F2" ); + failed |= attach_sig( bus, &(A[ 3]), "IO_D1" ); + failed |= attach_sig( bus, &(A[ 4]), "IO_E1" ); + failed |= attach_sig( bus, &(A[ 5]), "IO_F10" ); + failed |= attach_sig( bus, &(A[ 6]), "IO_C7" ); + failed |= attach_sig( bus, &(A[ 7]), "IO_C10" ); + failed |= attach_sig( bus, &(A[ 8]), "IO_A10" ); + failed |= attach_sig( bus, &(A[ 9]), "IO_B10" ); + failed |= attach_sig( bus, &(A[10]), "IO_F11" ); + failed |= attach_sig( bus, &(A[11]), "IO_A9" ); + failed |= attach_sig( bus, &(A[12]), "IO_B9" ); + failed |= attach_sig( bus, &(A[13]), "IO_B8" ); + failed |= attach_sig( bus, &(A[14]), "IO_F9" ); + failed |= attach_sig( bus, &(A[15]), "IO_F4" ); + failed |= attach_sig( bus, &(A[16]), "IO_G6" ); + failed |= attach_sig( bus, &(A[17]), "IO_G5" ); + A[18] = NULL; + A[19] = NULL; + A[20] = NULL; + A[21] = NULL; + A[22] = NULL; + A[23] = NULL; + A[24] = NULL; + + failed |= attach_sig( bus, &(D[ 0]), "IO_C1" ); + failed |= attach_sig( bus, &(D[ 1]), "IO_E2" ); + failed |= attach_sig( bus, &(D[ 2]), "IO_C2" ); + failed |= attach_sig( bus, &(D[ 3]), "IO_C3" ); + failed |= attach_sig( bus, &(D[ 4]), "IO_B5" ); + failed |= attach_sig( bus, &(D[ 5]), "IO_A5" ); + failed |= attach_sig( bus, &(D[ 6]), "IO_B6" ); + failed |= attach_sig( bus, &(D[ 7]), "IO_D7" ); + failed |= attach_sig( bus, &(D[ 8]), "IO_D9" ); + failed |= attach_sig( bus, &(D[ 9]), "IO_E9" ); + failed |= attach_sig( bus, &(D[10]), "IO_F7" ); + failed |= attach_sig( bus, &(D[11]), "IO_E7" ); + failed |= attach_sig( bus, &(D[12]), "IO_D5" ); + failed |= attach_sig( bus, &(D[13]), "IO_C4" ); + failed |= attach_sig( bus, &(D[14]), "IO_D3" ); + failed |= attach_sig( bus, &(D[15]), "IO_D4" ); + + failed |= attach_sig( bus, &(nCS), "IO_D2" ); + failed |= attach_sig( bus, &(nOE), "IO_F3" ); + failed |= attach_sig( bus, &(nWE), "IO_E10" ); + failed |= attach_sig( bus, &(nLB), "IO_E4" ); + failed |= attach_sig( bus, &(nUB), "IO_E3" ); + nRP = NULL; + nBYTE = NULL; + STS = NULL; + + SI = NULL; + SO = NULL; + SCK = NULL; + + /* + * Setup EEPROM + */ comp = COMP_EEPROM; - part_set_signal(p, SI, 1, 0 ); - part_set_signal(p, SO, 0, 0 ); - part_set_signal(p, SCK, 1, 0 ); - part_set_signal(p, nCS, 1, 1 ); + comp->ctype = EEPROM; + comp->cname = "EEPROM"; - /* EEPROM Status */ + failed |= attach_sig( bus, &(SI), "IO_H19" ); + failed |= attach_sig( bus, &(SO), "IO_J21" ); + failed |= attach_sig( bus, &(SCK), "IO_H21" ); + failed |= attach_sig( bus, &(nCS), "IO_K22" ); + + for (idx = 0; idx < FLASH_ADDR_WIDTH; idx++) + A[idx] = NULL; + for (idx = 0; idx < RAM_DATA_WIDTH; idx++) + D[idx] = NULL; + nOE = NULL; + nWE = NULL; + nLB = NULL; + nUB = NULL; + nRP = NULL; + nBYTE = NULL; + STS = NULL; + + /* + * Setup EEPROM Status + * copy settings from EEPROM + */ + ((bus_params_t *) bus->params)->eeprom_status = ((bus_params_t *) bus->params)->eeprom; comp = COMP_EEPROM_STATUS; - part_set_signal(p, SI, 1, 0 ); - part_set_signal(p, SO, 0, 0 ); - part_set_signal(p, SCK, 1, 0 ); - part_set_signal(p, nCS, 1, 1 ); + comp->ctype = EEPROM_STATUS; + comp->cname = "EEPROM Status"; - chain_shift_data_registers( chain, 0 ); - part_set_instruction( p, "EXTEST" ); - chain_shift_instructions( chain ); + if (failed) { + free( bus->params ); + free( bus ); + return NULL; + } + + return bus; +} + +/** + * bus->driver->(*printinfo) + * + */ +static void +zefant_xs3_bus_printinfo( bus_t *bus ) +{ + int i; + + for (i = 0; i < CHAIN->parts->len; i++) + if (PART == CHAIN->parts->parts[i]) + break; + printf( _("Simple Solutions Zefant-XS3 Board compatible bus driver via BSR (JTAG part No. %d)\n"), i ); +} + +static void +setup_address( bus_t *bus, uint32_t a, component_t *comp ) +{ + int i; + part_t *p = PART; + int addr_width; + + LAST_ADDR = a; + + switch (comp->ctype) { + case FLASH: + addr_width = FLASH_ADDR_WIDTH; + /* address a is a byte address, + A0 is ignored by the flash chip */ + break; + case RAM: + addr_width = RAM_ADDR_WIDTH; + /* address a is a byte address so it is transferred into + a word address here */ + a >>= 1; + break; + case EEPROM: + case EEPROM_STATUS: + addr_width = EEPROM_ADDR_WIDTH; + break; + default: + addr_width = 0; + break; + } + + for (i = 0; i < addr_width; i++) + part_set_signal( p, A[i], 1, (a >> i) & 1 ); +} + +static int +detect_data_width( component_t *comp ) +{ + int width; + + switch (comp->ctype) { + case RAM: + width = RAM_DATA_WIDTH; + break; + case FLASH: + width = FLASH_DATA_WIDTH; + break; + case EEPROM: + case EEPROM_STATUS: + width = EEPROM_DATA_WIDTH; + break; + default: + width = 0; + break; + } + + return width; +} + +static void +set_data_in( bus_t *bus, component_t *comp ) +{ + int i; + part_t *p = PART; + int width; + + width = detect_data_width( comp ); + + for (i = 0; i < width; i++) + part_set_signal( p, D[i], 0, 0 ); } +static void +setup_data( bus_t *bus, uint32_t d, component_t *comp ) +{ + int i; + part_t *p = PART; + int width; + + width = detect_data_width( comp ); + + for (i = 0; i < width; i++) + part_set_signal( p, D[i], 1, (d >> i) & 1 ); +} static uint8_t eeprom_shift_byte( chain_t *chain, part_t *p, component_t *comp, uint8_t byte ) @@ -344,7 +552,6 @@ eeprom_shift_byte( chain_t *chain, part_t *p, component_t *comp, uint8_t byte ) return so_data; } - static void eeprom_disable_device( chain_t *chain, part_t *p, component_t *comp ) { @@ -357,42 +564,163 @@ eeprom_disable_device( chain_t *chain, part_t *p, component_t *comp ) chain_shift_data_registers( chain, 0 ); } - -/* *************************************************************************** - * zefant_xs3_bus_read_start - * ***************************************************************************/ +/** + * bus->driver->(*prepare) + * + */ static void -zefant_xs3_bus_read_start( bus_t *bus, uint32_t adr ) +zefant_xs3_bus_prepare( bus_t *bus ) { part_t *p = PART; chain_t *chain = CHAIN; - bus_area_t area; component_t *comp; - uint8_t cmd = EEPROM_CMD_READ; - comp_bus_area( bus, adr, &area, &comp ); - if (!comp) { - printf( _("Address out of range\n") ); - LAST_ADDR = adr; - return; - } + /* Preload update registers + See AN039, "Guidelines for IEEE Std. 1149.1 Boundary Scan Testing */ - /* determine proper address setup strategy for component */ - switch (comp->ctype) { - case FLASH: - case RAM: - part_set_signal( p, nCS, 1, 0 ); - part_set_signal( p, nWE, 1, 1 ); - part_set_signal( p, nOE, 1, 0 ); - if (comp->ctype == RAM) { - part_set_signal( p, nLB, 1, 0 ); - part_set_signal( p, nUB, 1, 0 ); - } + part_set_instruction( p, "SAMPLE/PRELOAD" ); + chain_shift_instructions( chain ); - setup_address( bus, adr, comp ); - set_data_in( bus, comp ); + /* FLASH */ + comp = COMP_FLASH; + setup_data( bus, 0, comp ); + part_set_signal( p, nCS, 1, 1 ); + part_set_signal( p, nWE, 1, 1 ); + part_set_signal( p, nOE, 1, 1 ); + part_set_signal( p, nRP, 1, 1 ); + part_set_signal( p, nBYTE, 1, 1 ); + part_set_signal( p, STS, 0, 0 ); - chain_shift_data_registers( chain, 0 ); + /* RAM0 */ + comp = COMP_RAM0; + setup_data( bus, 0, comp ); + part_set_signal( p, nCS, 1, 1 ); + part_set_signal( p, nWE, 1, 1 ); + part_set_signal( p, nOE, 1, 1 ); + part_set_signal( p, nLB, 1, 1 ); + part_set_signal( p, nUB, 1, 1 ); + + /* RAM1 */ + comp = COMP_RAM1; + setup_data( bus, 0, comp ); + part_set_signal( p, nCS, 1, 1 ); + part_set_signal( p, nWE, 1, 1 ); + part_set_signal( p, nOE, 1, 1 ); + part_set_signal( p, nLB, 1, 1 ); + part_set_signal( p, nUB, 1, 1 ); + + /* EEPROM */ + comp = COMP_EEPROM; + part_set_signal(p, SI, 1, 0 ); + part_set_signal(p, SO, 0, 0 ); + part_set_signal(p, SCK, 1, 0 ); + part_set_signal(p, nCS, 1, 1 ); + + /* EEPROM Status */ + comp = COMP_EEPROM_STATUS; + part_set_signal(p, SI, 1, 0 ); + part_set_signal(p, SO, 0, 0 ); + part_set_signal(p, SCK, 1, 0 ); + part_set_signal(p, nCS, 1, 1 ); + + chain_shift_data_registers( chain, 0 ); + + part_set_instruction( p, "EXTEST" ); + chain_shift_instructions( chain ); +} + +static int +comp_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area, component_t **comp ) +{ + if (adr < RAM0_START) { + area->description = "FLASH Component"; + area->start = FLASH_START; + area->length = FLASH_LENGTH; + area->width = FLASH_DATA_WIDTH; + *comp = COMP_FLASH; + } else if (adr < RAM1_START) { + area->description = "SO-DIMM RAM0 Component"; + area->start = RAM0_START; + area->length = RAM_LENGTH; + area->width = RAM_DATA_WIDTH; + *comp = COMP_RAM0; + } else if (adr < EEPROM_START) { + area->description = "SO-DIMM RAM1 Component"; + area->start = RAM1_START; + area->length = RAM_LENGTH; + area->width = RAM_DATA_WIDTH; + *comp = COMP_RAM1; + } else if (adr < EEPROM_STATUS_START) { + area->description = "EEPROM Component"; + area->start = EEPROM_START; + area->length = EEPROM_LENGTH; + area->width = EEPROM_DATA_WIDTH; + *comp = COMP_EEPROM; + } else if (adr < EEPROM_STATUS_START + EEPROM_STATUS) { + area->description = "EEPROM Component Status"; + area->start = EEPROM_STATUS_START; + area->length = EEPROM_LENGTH; + area->width = EEPROM_DATA_WIDTH; + *comp = COMP_EEPROM_STATUS; + } else { + area->description = "Dummy"; + area->start = FLASH_LENGTH + 2*RAM_LENGTH +2* EEPROM_LENGTH; + area->length = UINT64_C(0x100000000); + area->width = 0; + *comp = NULL; + } + + return 0; +} + +/** + * bus->driver->(*area) + * + */ +static int +zefant_xs3_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) +{ + component_t *comp; + + return comp_bus_area( bus, adr, area, &comp ); +} + +/** + * bus->driver->(*read_start) + * + */ +static void +zefant_xs3_bus_read_start( bus_t *bus, uint32_t adr ) +{ + part_t *p = PART; + chain_t *chain = CHAIN; + bus_area_t area; + component_t *comp; + uint8_t cmd = EEPROM_CMD_READ; + + comp_bus_area( bus, adr, &area, &comp ); + if (!comp) { + printf( _("Address out of range\n") ); + LAST_ADDR = adr; + return; + } + + /* determine proper address setup strategy for component */ + switch (comp->ctype) { + case FLASH: + case RAM: + part_set_signal( p, nCS, 1, 0 ); + part_set_signal( p, nWE, 1, 1 ); + part_set_signal( p, nOE, 1, 0 ); + if (comp->ctype == RAM) { + part_set_signal( p, nLB, 1, 0 ); + part_set_signal( p, nUB, 1, 0 ); + } + + setup_address( bus, adr, comp ); + set_data_in( bus, comp ); + + chain_shift_data_registers( chain, 0 ); break; @@ -423,10 +751,10 @@ zefant_xs3_bus_read_start( bus_t *bus, uint32_t adr ) } - -/* *************************************************************************** - * zefant_xs3_bus_read_next - * ***************************************************************************/ +/** + * bus->driver->(*read_next) + * + */ static uint32_t zefant_xs3_bus_read_next( bus_t *bus, uint32_t adr ) { @@ -470,10 +798,10 @@ zefant_xs3_bus_read_next( bus_t *bus, uint32_t adr ) return d; } - -/* *************************************************************************** - * zefant_xs3_bus_read_end - * ***************************************************************************/ +/** + * bus->driver->(*read_end) + * + */ static uint32_t zefant_xs3_bus_read_end( bus_t *bus ) { @@ -524,10 +852,10 @@ zefant_xs3_bus_read_end( bus_t *bus ) return d; } - -/* *************************************************************************** - * zefant_xs3_bus_read - * ***************************************************************************/ +/** + * bus->driver->(*read) + * + */ static uint32_t zefant_xs3_bus_read( bus_t *bus, uint32_t adr ) { @@ -535,10 +863,10 @@ zefant_xs3_bus_read( bus_t *bus, uint32_t adr ) return zefant_xs3_bus_read_end( bus ); } - -/* *************************************************************************** - * zefant_xs3_bus_write - * ***************************************************************************/ +/** + * bus->driver->(*write) + * + */ static void zefant_xs3_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { @@ -600,7 +928,7 @@ zefant_xs3_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) eeprom_disable_device( chain, p, comp ); - /* + /* * Step 2: * Enable writing. */ @@ -618,7 +946,7 @@ zefant_xs3_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) */ part_set_signal( p, nCS, 1, 0 ); - /* send command + /* send command command code has been determined by component type */ eeprom_shift_byte( chain, p, comp, cmd ); @@ -642,337 +970,6 @@ zefant_xs3_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) } } - -/* *************************************************************************** - * comp_bus_area - * ***************************************************************************/ - -static int -comp_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area, component_t **comp ) -{ - if (adr < RAM0_START) { - area->description = "FLASH Component"; - area->start = FLASH_START; - area->length = FLASH_LENGTH; - area->width = FLASH_DATA_WIDTH; - *comp = COMP_FLASH; - } else if (adr < RAM1_START) { - area->description = "SO-DIMM RAM0 Component"; - area->start = RAM0_START; - area->length = RAM_LENGTH; - area->width = RAM_DATA_WIDTH; - *comp = COMP_RAM0; - } else if (adr < EEPROM_START) { - area->description = "SO-DIMM RAM1 Component"; - area->start = RAM1_START; - area->length = RAM_LENGTH; - area->width = RAM_DATA_WIDTH; - *comp = COMP_RAM1; - } else if (adr < EEPROM_STATUS_START) { - area->description = "EEPROM Component"; - area->start = EEPROM_START; - area->length = EEPROM_LENGTH; - area->width = EEPROM_DATA_WIDTH; - *comp = COMP_EEPROM; - } else if (adr < EEPROM_STATUS_START + EEPROM_STATUS) { - area->description = "EEPROM Component Status"; - area->start = EEPROM_STATUS_START; - area->length = EEPROM_LENGTH; - area->width = EEPROM_DATA_WIDTH; - *comp = COMP_EEPROM_STATUS; - } else { - area->description = "Dummy"; - area->start = FLASH_LENGTH + 2*RAM_LENGTH +2* EEPROM_LENGTH; - area->length = UINT64_C(0x100000000); - area->width = 0; - *comp = NULL; - } - - return 0; -} - - -static int -zefant_xs3_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) -{ - component_t *comp; - - return comp_bus_area( bus, adr, area, &comp ); -} - - -static int -attach_sig( bus_t *bus, signal_t **sig, char *id ) -{ - int failed = 0; - - *sig = part_find_signal( PART, id ); - if (!*sig) { - printf( _("signal '%s' not found\n"), id ); - failed = 1; - } - - return failed; -} - -static bus_t * -zefant_xs3_bus_new( chain_t *chain, char *cmd_params[] ) -{ - bus_t *bus; - int failed = 0; - component_t *comp; - int idx; - - if (!chain || !chain->parts || chain->parts->len <= chain->active_part || chain->active_part < 0) - return NULL; - - bus = calloc( 1, sizeof (bus_t) ); - if (!bus) - return NULL; - - bus->driver = &zefant_xs3_bus; - bus->params = calloc( 1, sizeof (bus_params_t) ); - if (!bus->params) { - free( bus ); - return NULL; - } - - CHAIN = chain; - PART = chain->parts->parts[chain->active_part]; - - /* - * Setup FLASH - */ - comp = COMP_FLASH; - comp->ctype = FLASH; - comp->cname = "FLASH"; - - failed |= attach_sig( bus, &(A[ 0]), "IO_V9" ); - failed |= attach_sig( bus, &(A[ 1]), "IO_U10" ); - failed |= attach_sig( bus, &(A[ 2]), "IO_V10" ); - failed |= attach_sig( bus, &(A[ 3]), "IO_W10" ); - failed |= attach_sig( bus, &(A[ 4]), "IO_Y10" ); - failed |= attach_sig( bus, &(A[ 5]), "IO_W8" ); - failed |= attach_sig( bus, &(A[ 6]), "IO_W9" ); - failed |= attach_sig( bus, &(A[ 7]), "IO_V8" ); - failed |= attach_sig( bus, &(A[ 8]), "IO_V6" ); - failed |= attach_sig( bus, &(A[ 9]), "IO_AA8" ); - failed |= attach_sig( bus, &(A[10]), "IO_AB8" ); - failed |= attach_sig( bus, &(A[11]), "IO_U7" ); - failed |= attach_sig( bus, &(A[12]), "IO_V7" ); - failed |= attach_sig( bus, &(A[13]), "IO_U6" ); - failed |= attach_sig( bus, &(A[14]), "IO_Y6" ); - failed |= attach_sig( bus, &(A[15]), "IO_AB11" ); - failed |= attach_sig( bus, &(A[16]), "IO_AB10" ); - failed |= attach_sig( bus, &(A[17]), "IO_AA10" ); - failed |= attach_sig( bus, &(A[18]), "IO_W6" ); - failed |= attach_sig( bus, &(A[19]), "IO_AA6" ); - failed |= attach_sig( bus, &(A[20]), "IO_U11" ); - failed |= attach_sig( bus, &(A[21]), "IO_Y13" ); - failed |= attach_sig( bus, &(A[22]), "IO_AB13" ); - failed |= attach_sig( bus, &(A[23]), "IO_U13" ); - failed |= attach_sig( bus, &(A[24]), "IO_AA13" ); - - failed |= attach_sig( bus, &(D[ 0]), "IO_AA14" ); - failed |= attach_sig( bus, &(D[ 1]), "IO_AB14" ); - failed |= attach_sig( bus, &(D[ 2]), "IO_U12" ); - failed |= attach_sig( bus, &(D[ 3]), "IO_V12" ); - failed |= attach_sig( bus, &(D[ 4]), "IO_W11" ); - failed |= attach_sig( bus, &(D[ 5]), "IO_V11" ); - failed |= attach_sig( bus, &(D[ 6]), "IO_AB9" ); - failed |= attach_sig( bus, &(D[ 7]), "IO_AA9" ); - failed |= attach_sig( bus, &(D[ 8]), "IO_U16" ); - failed |= attach_sig( bus, &(D[ 9]), "IO_AB15" ); - failed |= attach_sig( bus, &(D[10]), "IO_AA15" ); - failed |= attach_sig( bus, &(D[11]), "IO_W14" ); - failed |= attach_sig( bus, &(D[12]), "IO_V14" ); - failed |= attach_sig( bus, &(D[13]), "IO_U14" ); - failed |= attach_sig( bus, &(D[14]), "IO_W13" ); - failed |= attach_sig( bus, &(D[15]), "IO_V13" ); - - failed |= attach_sig( bus, &(nWE), "IO_Y17" ); - failed |= attach_sig( bus, &(nOE), "IO_AA17" ); - failed |= attach_sig( bus, &(nCS), "IO_U17" ); - nLB = NULL; - nUB = NULL; - - failed |= attach_sig( bus, &(nRP), "IO_V16" ); - failed |= attach_sig( bus, &(nBYTE), "IO_Y16" ); - failed |= attach_sig( bus, &(STS), "IO_W16" ); - - SI = NULL; - SO = NULL; - SCK = NULL; - - /* - * Setup SO-DIMM SRAM0 - */ - comp = COMP_RAM0; - comp->ctype = RAM; - comp->cname = "RAM0"; - - failed |= attach_sig( bus, &(A[ 0]), "IO_AA4" ); - failed |= attach_sig( bus, &(A[ 1]), "IO_AB4" ); - failed |= attach_sig( bus, &(A[ 2]), "IO_W5" ); - failed |= attach_sig( bus, &(A[ 3]), "IO_Y3" ); - failed |= attach_sig( bus, &(A[ 4]), "IO_Y1" ); - failed |= attach_sig( bus, &(A[ 5]), "IO_M1" ); - failed |= attach_sig( bus, &(A[ 6]), "IO_N2" ); - failed |= attach_sig( bus, &(A[ 7]), "IO_L2" ); - failed |= attach_sig( bus, &(A[ 8]), "IO_L1" ); - failed |= attach_sig( bus, &(A[ 9]), "IO_K1" ); - failed |= attach_sig( bus, &(A[10]), "IO_K3" ); - failed |= attach_sig( bus, &(A[11]), "IO_L6" ); - failed |= attach_sig( bus, &(A[12]), "IO_L4" ); - failed |= attach_sig( bus, &(A[13]), "IO_L3" ); - failed |= attach_sig( bus, &(A[14]), "IO_K4" ); - failed |= attach_sig( bus, &(A[15]), "IO_AB5" ); - failed |= attach_sig( bus, &(A[16]), "IO_AA5" ); - failed |= attach_sig( bus, &(A[17]), "IO_Y5" ); - A[18] = NULL; - A[19] = NULL; - A[20] = NULL; - A[21] = NULL; - A[22] = NULL; - A[23] = NULL; - A[24] = NULL; - - failed |= attach_sig( bus, &(D[ 0]), "IO_W1" ); - failed |= attach_sig( bus, &(D[ 1]), "IO_V5" ); - failed |= attach_sig( bus, &(D[ 2]), "IO_V3" ); - failed |= attach_sig( bus, &(D[ 3]), "IO_V1" ); - failed |= attach_sig( bus, &(D[ 4]), "IO_N1" ); - failed |= attach_sig( bus, &(D[ 5]), "IO_N3" ); - failed |= attach_sig( bus, &(D[ 6]), "IO_M2" ); - failed |= attach_sig( bus, &(D[ 7]), "IO_M5" ); - failed |= attach_sig( bus, &(D[ 8]), "IO_M4" ); - failed |= attach_sig( bus, &(D[ 9]), "IO_M6" ); - failed |= attach_sig( bus, &(D[10]), "IO_L5" ); - failed |= attach_sig( bus, &(D[11]), "IO_N4" ); - failed |= attach_sig( bus, &(D[12]), "IO_T6" ); - failed |= attach_sig( bus, &(D[13]), "IO_V2" ); - failed |= attach_sig( bus, &(D[14]), "IO_V4" ); - failed |= attach_sig( bus, &(D[15]), "IO_U5" ); - - failed |= attach_sig( bus, &(nCS), "IO_W3" ); - failed |= attach_sig( bus, &(nOE), "IO_Y2" ); - failed |= attach_sig( bus, &(nWE), "IO_M3" ); - failed |= attach_sig( bus, &(nLB), "IO_W2" ); - failed |= attach_sig( bus, &(nUB), "IO_W4" ); - nRP = NULL; - nBYTE = NULL; - STS = NULL; - - SI = NULL; - SO = NULL; - SCK = NULL; - - /* - * Setup SO-DIMM SRAM1 - */ - comp = COMP_RAM1; - comp->ctype = RAM; - comp->cname = "RAM1"; - - failed |= attach_sig( bus, &(A[ 0]), "IO_H5" ); - failed |= attach_sig( bus, &(A[ 1]), "IO_F5" ); - failed |= attach_sig( bus, &(A[ 2]), "IO_F2" ); - failed |= attach_sig( bus, &(A[ 3]), "IO_D1" ); - failed |= attach_sig( bus, &(A[ 4]), "IO_E1" ); - failed |= attach_sig( bus, &(A[ 5]), "IO_F10" ); - failed |= attach_sig( bus, &(A[ 6]), "IO_C7" ); - failed |= attach_sig( bus, &(A[ 7]), "IO_C10" ); - failed |= attach_sig( bus, &(A[ 8]), "IO_A10" ); - failed |= attach_sig( bus, &(A[ 9]), "IO_B10" ); - failed |= attach_sig( bus, &(A[10]), "IO_F11" ); - failed |= attach_sig( bus, &(A[11]), "IO_A9" ); - failed |= attach_sig( bus, &(A[12]), "IO_B9" ); - failed |= attach_sig( bus, &(A[13]), "IO_B8" ); - failed |= attach_sig( bus, &(A[14]), "IO_F9" ); - failed |= attach_sig( bus, &(A[15]), "IO_F4" ); - failed |= attach_sig( bus, &(A[16]), "IO_G6" ); - failed |= attach_sig( bus, &(A[17]), "IO_G5" ); - A[18] = NULL; - A[19] = NULL; - A[20] = NULL; - A[21] = NULL; - A[22] = NULL; - A[23] = NULL; - A[24] = NULL; - - failed |= attach_sig( bus, &(D[ 0]), "IO_C1" ); - failed |= attach_sig( bus, &(D[ 1]), "IO_E2" ); - failed |= attach_sig( bus, &(D[ 2]), "IO_C2" ); - failed |= attach_sig( bus, &(D[ 3]), "IO_C3" ); - failed |= attach_sig( bus, &(D[ 4]), "IO_B5" ); - failed |= attach_sig( bus, &(D[ 5]), "IO_A5" ); - failed |= attach_sig( bus, &(D[ 6]), "IO_B6" ); - failed |= attach_sig( bus, &(D[ 7]), "IO_D7" ); - failed |= attach_sig( bus, &(D[ 8]), "IO_D9" ); - failed |= attach_sig( bus, &(D[ 9]), "IO_E9" ); - failed |= attach_sig( bus, &(D[10]), "IO_F7" ); - failed |= attach_sig( bus, &(D[11]), "IO_E7" ); - failed |= attach_sig( bus, &(D[12]), "IO_D5" ); - failed |= attach_sig( bus, &(D[13]), "IO_C4" ); - failed |= attach_sig( bus, &(D[14]), "IO_D3" ); - failed |= attach_sig( bus, &(D[15]), "IO_D4" ); - - failed |= attach_sig( bus, &(nCS), "IO_D2" ); - failed |= attach_sig( bus, &(nOE), "IO_F3" ); - failed |= attach_sig( bus, &(nWE), "IO_E10" ); - failed |= attach_sig( bus, &(nLB), "IO_E4" ); - failed |= attach_sig( bus, &(nUB), "IO_E3" ); - nRP = NULL; - nBYTE = NULL; - STS = NULL; - - SI = NULL; - SO = NULL; - SCK = NULL; - - /* - * Setup EEPROM - */ - comp = COMP_EEPROM; - comp->ctype = EEPROM; - comp->cname = "EEPROM"; - - failed |= attach_sig( bus, &(SI), "IO_H19" ); - failed |= attach_sig( bus, &(SO), "IO_J21" ); - failed |= attach_sig( bus, &(SCK), "IO_H21" ); - failed |= attach_sig( bus, &(nCS), "IO_K22" ); - - for (idx = 0; idx < FLASH_ADDR_WIDTH; idx++) - A[idx] = NULL; - for (idx = 0; idx < RAM_DATA_WIDTH; idx++) - D[idx] = NULL; - nOE = NULL; - nWE = NULL; - nLB = NULL; - nUB = NULL; - nRP = NULL; - nBYTE = NULL; - STS = NULL; - - /* - * Setup EEPROM Status - * copy settings from EEPROM - */ - ((bus_params_t *) bus->params)->eeprom_status = ((bus_params_t *) bus->params)->eeprom; - comp = COMP_EEPROM_STATUS; - comp->ctype = EEPROM_STATUS; - comp->cname = "EEPROM Status"; - - - if (failed) { - free( bus->params ); - free( bus ); - return NULL; - } - - return bus; -} - const bus_driver_t zefant_xs3_bus = { "zefant-xs3", N_("Simple Solutions Zefant-XS3 Board compatible bus driver via BSR"),