Added bus_width(). Moved bus_driver initialization into main().

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@237 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Marcel Telka 22 years ago
parent 23f6927ce7
commit 1b30500bb4

@ -30,6 +30,7 @@
#include "part.h"
typedef struct {
int (*bus_width)( parts *ps );
void (*bus_read_start)( parts *, uint32_t );
uint32_t (*bus_read_next)( parts *, uint32_t );
uint32_t (*bus_read_end)( parts * );
@ -38,6 +39,7 @@ typedef struct {
} bus_driver_t;
extern bus_driver_t *bus_driver;
#define bus_width bus_driver->bus_width
#define bus_read_start bus_driver->bus_read_start
#define bus_read_next bus_driver->bus_read_next
#define bus_read_end bus_driver->bus_read_end

@ -50,70 +50,21 @@ void
flashmem( parts *ps, FILE *f )
{
part *p = ps->parts[0];
uint8_t boot_sel;
int o = 0;
int d = 0;
uint32_t adr;
#define D_SA1110 1
#define D_PXA250 2
if (strcmp( p->part, "SA1110" ) == 0) {
printf( "SA1110 detected\n" );
d = D_SA1110;
bus_driver = &sa1110_bus_driver;
}
if (strcmp( p->part, "PXA250" ) == 0) {
printf( "PXA250 detected\n" );
d = D_PXA250;
bus_driver = &pxa250_bus_driver;
}
if (!d) {
printf( "Error: Only PXA250/SA1110 devices supported!\n" );
return;
}
printf( "Note: Supported configuration is 2 x 16 bit only\n" );
switch (d) {
case D_SA1110:
if (part_get_signal( p, "ROM_SEL" )) {
printf( "ROM_SEL: 32 bits\n" );
o = 2;
} else {
printf( "ROM_SEL: 16 bits\n" );
o = 1;
}
switch (bus_width( ps )) {
case 16:
o = 1;
break;
case D_PXA250:
boot_sel = (part_get_signal( p, "BOOT_SEL[2]" ) << 2) | (part_get_signal( p, "BOOT_SEL[1]" ) << 1) | part_get_signal( p, "BOOT_SEL[0]" );
/* see Table 6-36. in [2] */
switch (boot_sel) {
case 0:
printf( "BOOT_SEL: Asynchronous 32-bit ROM\n" );
o = 2;
break;
case 1:
printf( "BOOT_SEL: Asynchronous 16-bit ROM\n" );
o = 1;
break;
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
printf( "TODO - BOOT_SEL\n" );
return;
default:
printf( "BUG in code, file %s, line %d.\n", __FILE__, __LINE__ );
return;
}
case 32:
o = 2;
break;
default:
printf( "Unknown device!!!\n" );
break;
printf( "Error: Unknown bus width!\n" );
return;
}
/* EXTEST */

@ -36,6 +36,9 @@
#include "tap.h"
#include "detect.h"
#include "bus.h"
bus_driver_t *bus_driver = NULL;
static char *
get_token( char *buf )
@ -95,11 +98,17 @@ main( void )
if (ps)
parts_free( ps );
ps = detect_parts( "../data" );
if (!ps->len)
continue;
parts_set_instruction( ps, "SAMPLE/PRELOAD" );
parts_shift_instructions( ps );
parts_shift_data_registers( ps );
parts_set_instruction( ps, "BYPASS" );
parts_shift_instructions( ps );
if (strcmp( ps->parts[0]->part, "SA1110" ) == 0)
bus_driver = &sa1110_bus_driver;
if (strcmp( ps->parts[0]->part, "PXA250" ) == 0)
bus_driver = &pxa250_bus_driver;
continue;
}

@ -20,6 +20,10 @@
*
* Written by Marcel Telka <marcel@telka.sk>, 2002.
*
* Documentation:
* [1] Intel Corporation, "Intel PXA250 and PXA210 Application Processors
* Developer's Manual", February 2002, Order Number: 278522-001
*
*/
#include <stdint.h>
@ -70,7 +74,7 @@ pxa250_bus_read_start( parts *ps, uint32_t adr )
{
part *p = ps->parts[0];
/* see Figure 6-13 in PXA doc */
/* see Figure 6-13 in [1] */
part_set_signal( p, "nCS[0]", 1, 0 );
part_set_signal( p, "DQM[0]", 1, 0 );
part_set_signal( p, "DQM[1]", 1, 0 );
@ -92,7 +96,7 @@ pxa250_bus_read_next( parts *ps, uint32_t adr )
{
part *p = ps->parts[0];
/* see Figure 6-13 in PXA doc */
/* see Figure 6-13 in [1] */
setup_address( p, adr );
parts_shift_data_registers( ps );
@ -115,7 +119,7 @@ pxa250_bus_read_end( parts *ps )
{
part *p = ps->parts[0];
/* see Figure 6-13 in PXA doc */
/* 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 );
@ -146,7 +150,7 @@ pxa250_bus_read( parts *ps, uint32_t adr )
void
pxa250_bus_write( parts *ps, uint32_t adr, uint32_t data )
{
/* see Figure 6-17 in PXA doc */
/* see Figure 6-17 in [1] */
part *p = ps->parts[0];
part_set_signal( p, "nCS[0]", 1, 0 );
@ -170,7 +174,38 @@ pxa250_bus_write( parts *ps, uint32_t adr, uint32_t data )
parts_shift_data_registers( ps );
}
int
pxa250_bus_width( parts *ps )
{
part *p = ps->parts[0];
uint8_t boot_sel = (part_get_signal( p, "BOOT_SEL[2]" ) << 2)
| (part_get_signal( p, "BOOT_SEL[1]" ) << 1)
| part_get_signal( p, "BOOT_SEL[0]" );
/* see Table 6-36. in [1] */
switch (boot_sel) {
case 0:
printf( "BOOT_SEL: Asynchronous 32-bit ROM\n" );
return 32;
case 1:
printf( "BOOT_SEL: Asynchronous 16-bit ROM\n" );
return 16;
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
printf( "TODO - BOOT_SEL\n" );
return 0;
default:
printf( "BUG in code, file %s, line %d.\n", __FILE__, __LINE__ );
return 0;
}
}
bus_driver_t pxa250_bus_driver = {
pxa250_bus_width,
pxa250_bus_read_start,
pxa250_bus_read_next,
pxa250_bus_read_end,

@ -41,76 +41,32 @@
#include "part.h"
#include "bus.h"
bus_driver_t *bus_driver = NULL;
cfi_query_structure_t *detect_cfi( parts * );
void
readmem( parts *ps )
{
part *p = ps->parts[0];
uint8_t boot_sel;
int o = 0;
int d = 0;
cfi_query_structure_t *cfi;
#define D_SA1110 1
#define D_PXA250 2
if (strcmp( p->part, "SA1110" ) == 0) {
printf( "SA1110 detected\n" );
d = D_SA1110;
bus_driver = &sa1110_bus_driver;
}
if (strcmp( p->part, "PXA250" ) == 0) {
printf( "PXA250 detected\n" );
d = D_PXA250;
bus_driver = &pxa250_bus_driver;
}
if (!d) {
printf( "Error: Only PXA250/SA1110 devices supported!\n" );
if (!bus_driver) {
printf( "Error: Missing bus_driver!\n" );
return;
}
printf( "Note: Supported configuration is 2 x 16 bit only\n" );
switch (d) {
case D_SA1110:
if (part_get_signal( p, "ROM_SEL" )) {
printf( "ROM_SEL: 32 bits\n" );
o = 2;
} else {
printf( "ROM_SEL: 16 bits\n" );
o = 1;
}
break;
case D_PXA250:
boot_sel = (part_get_signal( p, "BOOT_SEL[2]" ) << 2) | (part_get_signal( p, "BOOT_SEL[1]" ) << 1) | part_get_signal( p, "BOOT_SEL[0]" );
/* see Table 6-36. in [2] */
switch (boot_sel) {
case 0:
printf( "BOOT_SEL: Asynchronous 32-bit ROM\n" );
o = 2;
break;
case 1:
printf( "BOOT_SEL: Asynchronous 16-bit ROM\n" );
o = 1;
break;
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
printf( "TODO - BOOT_SEL\n" );
return;
default:
printf( "BUG in code, file %s, line %d.\n", __FILE__, __LINE__ );
return;
}
switch (bus_width( ps )) {
case 16:
o = 1;
break;
default:
printf( "Unknown device!!!\n" );
case 32:
o = 2;
break;
default:
printf( "Error: Unknown bus width!\n" );
return;
}
/* EXTEST */

@ -168,7 +168,20 @@ sa1110_bus_write( parts *ps, uint32_t adr, uint32_t data )
parts_shift_data_registers( ps );
}
int
sa1110_bus_width( parts *ps )
{
if (part_get_signal( ps->parts[0], "ROM_SEL" )) {
printf( "ROM_SEL: 32 bits\n" );
return 32;
} else {
printf( "ROM_SEL: 16 bits\n" );
return 16;
}
}
bus_driver_t sa1110_bus_driver = {
sa1110_bus_width,
sa1110_bus_read_start,
sa1110_bus_read_next,
sa1110_bus_read_end,

Loading…
Cancel
Save