//! \brief Update dialogue for changes in device selected in JTAG chain //! //! Updated value: //! JEDEC Code //! (Freescale) Part Number //! Description //! Device Type combo (and disabled if known device) //! IR length //! //! The device selected in the JTAG chain is updated. //! //! @param hDlg : handle for dialogue //! @note updateEraseParameters(hDlg) is called to propagate changes //! void ColdfireUnlockerPanel::updateDeviceDetails() { char buff[100]; int jedecCode; int partNum; int freescalePIN; int index; index = jtagDeviceChoiceControl->GetSelection(); if (index == wxNOT_FOUND) { jtagIdcodeStaticText->SetLabel(_("Invalid")); return; } JTAG_Chain::selectTargetDevice(index); jedecCode = JEDEC_ID(JTAG_Chain::devices[index].idcode); partNum = PART_NUM(JTAG_Chain::devices[index].idcode); freescalePIN = FREESCALE_PIN(JTAG_Chain::devices[index].idcode); sprintf(buff, "IDCODE : %8.8X", JTAG_Chain::getTargetDevice().idcode); jtagIdcodeStaticText->SetLabel(wxString::FromAscii(buff)); if (JTAG_Chain::getTargetDevice().idcode == 0) // No JTAG IDCODE freescalePINStaticControl->SetLabel(_("")); else { if (jedecCode != FREESCALE_JEDEC) sprintf(buff, "Part No. : %4.4X", partNum); else sprintf(buff, "Freescale PIN : %3.3X", freescalePIN); freescalePINStaticControl->SetLabel(wxString::FromAscii(buff)); } sprintf(buff, "Desc : %s", JTAG_Chain::getTargetDevice().deviceData->description); //print("%s\n",buff); descriptionStaticControl->SetLabel(wxString::FromAscii(buff)); targetDeviceChoiceControl->SetSelection(JTAG_Chain::getTargetDevice().deviceData->index); targetDeviceChoiceControl->Enable(JTAG_Chain::getTargetDevice().deviceData == &KnownDevices::unRecognizedDevice); irLengthSpinControl->SetValue(JTAG_Chain::getTargetDevice().irLength); updateEraseParameters(); }
static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen, const void *rxp, void *txp, unsigned long flags) { struct sandbox_spi_flash *sbsf = dev_get_priv(dev); const uint8_t *rx = rxp; uint8_t *tx = txp; uint cnt, pos = 0; int bytes = bitlen / 8; int ret; log_content("sandbox_sf: state:%x(%s) bytes:%u\n", sbsf->state, sandbox_sf_state_name(sbsf->state), bytes); if ((flags & SPI_XFER_BEGIN)) sandbox_sf_cs_activate(dev); if (sbsf->state == SF_CMD) { /* Figure out the initial state */ ret = sandbox_sf_process_cmd(sbsf, rx, tx); if (ret) return ret; ++pos; } /* Process the remaining data */ while (pos < bytes) { switch (sbsf->state) { case SF_ID: { u8 id; log_content(" id: off:%u tx:", sbsf->off); if (sbsf->off < IDCODE_LEN) { /* Extract correct byte from ID 0x00aabbcc */ id = ((JEDEC_MFR(sbsf->data) << 16) | JEDEC_ID(sbsf->data)) >> (8 * (IDCODE_LEN - 1 - sbsf->off)); } else { id = 0; } log_content("%d %02x\n", sbsf->off, id); tx[pos++] = id; ++sbsf->off; break; } case SF_ADDR: log_content(" addr: bytes:%u rx:%02x ", sbsf->addr_bytes, rx[pos]); if (sbsf->addr_bytes++ < SF_ADDR_LEN) sbsf->off = (sbsf->off << 8) | rx[pos]; log_content("addr:%06x\n", sbsf->off); if (tx) sandbox_spi_tristate(&tx[pos], 1); pos++; /* See if we're done processing */ if (sbsf->addr_bytes < SF_ADDR_LEN + sbsf->pad_addr_bytes) break; /* Next state! */ if (os_lseek(sbsf->fd, sbsf->off, OS_SEEK_SET) < 0) { puts("sandbox_sf: os_lseek() failed"); return -EIO; } switch (sbsf->cmd) { case SPINOR_OP_READ_FAST: case SPINOR_OP_READ: sbsf->state = SF_READ; break; case SPINOR_OP_PP: sbsf->state = SF_WRITE; break; default: /* assume erase state ... */ sbsf->state = SF_ERASE; goto case_sf_erase; } log_content(" cmd: transition to %s state\n", sandbox_sf_state_name(sbsf->state)); break; case SF_READ: /* * XXX: need to handle exotic behavior: * - reading past end of device */ cnt = bytes - pos; log_content(" tx: read(%u)\n", cnt); assert(tx); ret = os_read(sbsf->fd, tx + pos, cnt); if (ret < 0) { puts("sandbox_sf: os_read() failed\n"); return -EIO; } pos += ret; break; case SF_READ_STATUS: log_content(" read status: %#x\n", sbsf->status); cnt = bytes - pos; memset(tx + pos, sbsf->status, cnt); pos += cnt; break; case SF_READ_STATUS1: log_content(" read status: %#x\n", sbsf->status); cnt = bytes - pos; memset(tx + pos, sbsf->status >> 8, cnt); pos += cnt; break; case SF_WRITE_STATUS: log_content(" write status: %#x (ignored)\n", rx[pos]); pos = bytes; break; case SF_WRITE: /* * XXX: need to handle exotic behavior: * - unaligned addresses * - more than a page (256) worth of data * - reading past end of device */ if (!(sbsf->status & STAT_WEL)) { puts("sandbox_sf: write enable not set before write\n"); goto done; } cnt = bytes - pos; log_content(" rx: write(%u)\n", cnt); if (tx) sandbox_spi_tristate(&tx[pos], cnt); ret = os_write(sbsf->fd, rx + pos, cnt); if (ret < 0) { puts("sandbox_spi: os_write() failed\n"); return -EIO; } pos += ret; sbsf->status &= ~STAT_WEL; break; case SF_ERASE: case_sf_erase: { if (!(sbsf->status & STAT_WEL)) { puts("sandbox_sf: write enable not set before erase\n"); goto done; } /* verify address is aligned */ if (sbsf->off & (sbsf->erase_size - 1)) { log_content(" sector erase: cmd:%#x needs align:%#x, but we got %#x\n", sbsf->cmd, sbsf->erase_size, sbsf->off); sbsf->status &= ~STAT_WEL; goto done; } log_content(" sector erase addr: %u, size: %u\n", sbsf->off, sbsf->erase_size); cnt = bytes - pos; if (tx) sandbox_spi_tristate(&tx[pos], cnt); pos += cnt; /* * TODO([email protected]): latch WIP in status, and * delay before clearing it ? */ ret = sandbox_erase_part(sbsf, sbsf->erase_size); sbsf->status &= ~STAT_WEL; if (ret) { log_content("sandbox_sf: Erase failed\n"); goto done; } goto done; } default: log_content(" ??? no idea what to do ???\n"); goto done; }