fet_core: Add workaround for CC5137 replug problem.

This chip needs to be replugged if the the shutdown procedure (reset and
close) runs. We look for the chip's ID and skip the procedure if it
matches.
This commit is contained in:
Daniel Beer 2013-02-01 08:09:38 +13:00
parent ad420dbb93
commit 72e781d0eb
3 changed files with 30 additions and 14 deletions

View File

@ -144,3 +144,8 @@ int device_erase(device_erase_type_t et, address_t addr)
return device_default->type->erase(device_default, et, addr);
}
int device_needs_skip_close(device_t dev)
{
return (dev->dev_id[0] == 0x51) && (dev->dev_id[1] == 0x37);
}

View File

@ -140,6 +140,11 @@ int device_probe_id(device_t dev);
*/
int device_is_fram(device_t dev);
/* Determine, from the device ID bytes, whether this chip has problems
* with the FET close procedure.
*/
int device_needs_skip_close(device_t dev);
/* Set or clear a breakpoint. The index of the modified entry is
* returned, or -1 if no free entries were available. The modified
* entry is flagged so that it will be reloaded on the next run.

View File

@ -709,22 +709,28 @@ void fet_destroy(device_t dev_base)
{
struct fet_device *dev = (struct fet_device *)dev_base;
/* The second argument to C_RESET is a boolean which specifies
* whether the chip should run or not. The final argument is
* also a boolean. Setting it non-zero is required to get the
* RST pin working on the G2231, but it must be zero on the
* FR5739, or else the value of the reset vector gets set to
* 0xffff at the start of the next JTAG session.
*/
if (fet_proto_xfer(&dev->proto, C_RESET, NULL, 0, 3, FET_RESET_ALL, 1,
!device_is_fram(dev_base)) < 0)
printc_err("fet: final reset failed\n");
if (device_needs_skip_close(dev_base)) {
printc_dbg("Skipping close procedure");
} else {
/* The second argument to C_RESET is a boolean which
* specifies whether the chip should run or not. The
* final argument is also a boolean. Setting it non-zero
* is required to get the RST pin working on the G2231,
* but it must be zero on the FR5739, or else the value
* of the reset vector gets set to 0xffff at the start
* of the next JTAG session.
*/
if (fet_proto_xfer(&dev->proto, C_RESET, NULL, 0, 3,
FET_RESET_ALL, 1,
!device_is_fram(dev_base)) < 0)
printc_err("fet: final reset failed\n");
if (fet_proto_xfer(&dev->proto, C_CLOSE, NULL, 0, 1, 0) < 0)
printc_err("fet: close command failed\n");
if (fet_proto_xfer(&dev->proto, C_CLOSE, NULL, 0, 1, 0) < 0)
printc_err("fet: close command failed\n");
if (dev->base.power_buf)
powerbuf_free(dev->base.power_buf);
if (dev->base.power_buf)
powerbuf_free(dev->base.power_buf);
}
dev->proto.transport->ops->destroy(dev->proto.transport);
free(dev);