From 70621ce30969e7776a59399314decf1c139f6a4c Mon Sep 17 00:00:00 2001 From: Jie Zhang Date: Mon, 1 Feb 2010 08:18:12 +0000 Subject: [PATCH] Make bf537_stamp_bus_area only accept async memory addresses. git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1751 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 9 +++++++ urjtag/src/bus/bf537_stamp.c | 49 +++++++++++++++++++++++++++--------- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 237bd4e0..80de7b88 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -1,3 +1,12 @@ +2010-02-01 Mike Frysinger + + * src/bus/bf537_stamp.c (ASYNC_MEM_BASE, ASYNC_MEM_SIZE, IS_ASYNC_ADDR, + ASYNC_BANK): Define. + (bf537_stamp_bus_area): Only accept IS_ASYNC_ADDR() addresses. + (select_flash): Set AMS[] based on ASYNC_BANK(adr). + (bf537_stamp_bus_read_start): Pass adr to select_flash(). + (bf537_stamp_bus_write): Likewise. + 2010-02-01 Jie Zhang * src/bus/bf533_ezkit.c: Remove. diff --git a/urjtag/src/bus/bf537_stamp.c b/urjtag/src/bus/bf537_stamp.c index 39706f57..684f45e2 100644 --- a/urjtag/src/bus/bf537_stamp.c +++ b/urjtag/src/bus/bf537_stamp.c @@ -154,26 +154,51 @@ bf537_stamp_bus_new (urj_chain_t *chain, const urj_bus_driver_t *driver, * bus->driver->(*area) * */ + +#define ASYNC_MEM_BASE 0x20000000 +#define ASYNC_MEM_SIZE (4 * 1024 * 1024) +#define IS_ASYNC_ADDR(addr) ({ \ + unsigned long __addr = (unsigned long) addr; \ + __addr >= ASYNC_MEM_BASE && __addr < ASYNC_MEM_BASE + ASYNC_MEM_SIZE; \ + }) +#define ASYNC_BANK(addr) (((addr) & (ASYNC_MEM_SIZE - 1)) >> 20) + static int bf537_stamp_bus_area (urj_bus_t *bus, uint32_t adr, urj_bus_area_t *area) { - area->description = NULL; - area->start = UINT32_C (0x00000000); - area->length = UINT64_C (0x100000000); - area->width = 16; - + if (adr < ASYNC_MEM_BASE) + { + /* we can only wiggle SDRAM pins directly, so cannot drive it */ + urj_error_set (URJ_ERROR_OUT_OF_BOUNDS, + _("reading external memory not supported")); + return URJ_STATUS_FAIL; + } + else if (IS_ASYNC_ADDR(adr)) + { + area->description = "asynchronous memory"; + area->start = ASYNC_MEM_BASE; + area->length = ASYNC_MEM_SIZE; + area->width = 16; + } + else + { + /* L1 needs core to access it */ + urj_error_set (URJ_ERROR_OUT_OF_BOUNDS, + _("reading on-chip memory not supported")); + return URJ_STATUS_FAIL; + } return URJ_STATUS_OK; } static void -select_flash (urj_bus_t *bus) +select_flash (urj_bus_t *bus, uint32_t adr) { urj_part_t *p = bus->part; - urj_part_set_signal (p, AMS[0], 1, 0); - urj_part_set_signal (p, AMS[1], 1, 1); - urj_part_set_signal (p, AMS[2], 1, 1); - urj_part_set_signal (p, AMS[3], 1, 1); + urj_part_set_signal (p, AMS[0], 1, !(ASYNC_BANK(adr) == 0)); + urj_part_set_signal (p, AMS[1], 1, !(ASYNC_BANK(adr) == 1)); + urj_part_set_signal (p, AMS[2], 1, !(ASYNC_BANK(adr) == 2)); + urj_part_set_signal (p, AMS[3], 1, !(ASYNC_BANK(adr) == 3)); urj_part_set_signal (p, ABE[0], 1, 0); urj_part_set_signal (p, ABE[1], 1, 0); @@ -244,7 +269,7 @@ bf537_stamp_bus_read_start (urj_bus_t *bus, uint32_t adr) urj_part_t *p = bus->part; urj_chain_t *chain = bus->chain; - select_flash (bus); + select_flash (bus, adr); urj_part_set_signal (p, AOE, 1, 0); urj_part_set_signal (p, ARE, 1, 0); urj_part_set_signal (p, AWE, 1, 1); @@ -313,7 +338,7 @@ bf537_stamp_bus_write (urj_bus_t *bus, uint32_t adr, uint32_t data) urj_part_t *p = bus->part; urj_chain_t *chain = bus->chain; - select_flash (bus); + select_flash (bus, adr); urj_part_set_signal (p, AOE, 1, 1); urj_part_set_signal (p, ARE, 1, 1);