diff options
author | Megan Wachs <megan@sifive.com> | 2017-04-25 18:54:51 -0700 |
---|---|---|
committer | Palmer Dabbelt <palmer@dabbelt.com> | 2017-04-26 09:10:49 -0700 |
commit | 1ab5d7b4973b681a2a203593113bf2a8ad0bb9e0 (patch) | |
tree | 0c8595f3056dfa12b7c9e77f65fef507551c0470 | |
parent | 8dea2908b71dfca60e80113203c6e62806b34851 (diff) | |
download | riscv-openocd-1ab5d7b4973b681a2a203593113bf2a8ad0bb9e0.zip riscv-openocd-1ab5d7b4973b681a2a203593113bf2a8ad0bb9e0.tar.gz riscv-openocd-1ab5d7b4973b681a2a203593113bf2a8ad0bb9e0.tar.bz2 |
fespi: Allow the ctrl_base address specified as a parameter
-rw-r--r-- | src/flash/nor/fespi.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/flash/nor/fespi.c b/src/flash/nor/fespi.c index 1320043..925dd6f 100644 --- a/src/flash/nor/fespi.c +++ b/src/flash/nor/fespi.c @@ -167,7 +167,6 @@ struct fespi_target { static const struct fespi_target target_devices[] = { /* name, tap_idcode, ctrl_base */ { "Freedom E300 SPI Flash", 0x10e31913 , 0x10014000 }, - { "whatever", 0x00000001, 0x10014000 }, { NULL, 0, 0 } }; @@ -188,6 +187,11 @@ FLASH_BANK_COMMAND_HANDLER(fespi_flash_bank_command) bank->driver_priv = fespi_info; fespi_info->probed = 0; + fespi_info->ctrl_base = 0; + if (CMD_ARGC >= 6) { + COMMAND_PARSE_NUMBER(int, CMD_ARGV[6], fespi_info->ctrl_base); + LOG_DEBUG("ASSUMING FESPI device at ctrl_base = 0x%x", fespi_info->ctrl_base); + } return ERROR_OK; } @@ -376,7 +380,6 @@ static int fespi_erase(struct flash_bank *bank, int first, int last) } } - FESPI_WRITE_REG(FESPI_REG_TXCTRL, FESPI_TXWM(1)); retval = fespi_txwm_wait(bank); if (retval != ERROR_OK){ @@ -1035,20 +1038,28 @@ static int fespi_probe(struct flash_bank *bank) free(bank->sectors); fespi_info->probed = 0; - for (target_device = target_devices ; target_device->name ; ++target_device) - if (target_device->tap_idcode == target->tap->idcode) - break; - if (!target_device->name) { - LOG_ERROR("Device ID 0x%" PRIx32 " is not known as FESPI capable", - target->tap->idcode); - return ERROR_FAIL; - } + if (fespi_info->ctrl_base == 0) { + for (target_device = target_devices ; target_device->name ; ++target_device) + if (target_device->tap_idcode == target->tap->idcode) + break; - ctrl_base = target_device->ctrl_base; - fespi_info->ctrl_base = ctrl_base; + if (!target_device->name) { + LOG_ERROR("Device ID 0x%" PRIx32 " is not known as FESPI capable", + target->tap->idcode); + return ERROR_FAIL; + } - LOG_DEBUG("Valid FESPI on device %s at address 0x%" PRIx32, - target_device->name, bank->base); + ctrl_base = target_device->ctrl_base; + fespi_info->ctrl_base = ctrl_base; + + LOG_DEBUG("Valid FESPI on device %s at address 0x%" PRIx32, + target_device->name, bank->base); + + } else { + LOG_DEBUG("Assuming FESPI as specified at address 0x%x with ctrl at 0x%x", + fespi_info->ctrl_base, + bank->base); + } /* read and decode flash ID; returns in SW mode */ FESPI_WRITE_REG(FESPI_REG_TXCTRL, FESPI_TXWM(1)); |