aboutsummaryrefslogtreecommitdiffstats
path: root/iceprog
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2018-09-02 17:11:52 +0200
committerClifford Wolf <clifford@clifford.at>2018-09-02 17:11:52 +0200
commit3681ade2c7bfb2e4befee1ff6909608752f91d92 (patch)
treea6e7280edeabb1c2afcb9fe3b97246e11929646b /iceprog
parent9df21fcb0268158173a8e5c4df3f25e930ae65f6 (diff)
downloadicestorm-3681ade2c7bfb2e4befee1ff6909608752f91d92.tar.gz
icestorm-3681ade2c7bfb2e4befee1ff6909608752f91d92.tar.bz2
icestorm-3681ade2c7bfb2e4befee1ff6909608752f91d92.zip
Force flash to exist QPI mode in iceprog
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'iceprog')
-rw-r--r--iceprog/iceprog.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/iceprog/iceprog.c b/iceprog/iceprog.c
index 104159e..6462b3d 100644
--- a/iceprog/iceprog.c
+++ b/iceprog/iceprog.c
@@ -175,7 +175,6 @@ enum flash_cmd {
FC_EPR = 0x7A, /* Erase / Program Resume */
FC_PD = 0xB9, /* Power-down */
FC_QPI = 0x38, /* Enter QPI mode */
- FC_EQPI = 0xFF, /* Exit QPI mode */
FC_ERESET = 0x66, /* Enable Reset */
FC_RESET = 0x99, /* Reset Device */
};
@@ -270,6 +269,19 @@ static void xfer_spi(uint8_t *data, int n)
data[i] = recv_byte();
}
+static uint8_t xfer_spi_bits(uint8_t data, int n)
+{
+ if (n < 1)
+ return 0;
+
+ /* Input and output, update data on negative edge read on positive, bits. */
+ send_byte(MC_DATA_IN | MC_DATA_OUT | MC_DATA_OCN | MC_DATA_BITS);
+ send_byte(n - 1);
+ send_byte(data);
+
+ return recv_byte();
+}
+
static void set_gpio(int slavesel_b, int creset_b)
{
uint8_t gpio = 0;
@@ -381,14 +393,12 @@ static void flash_read_id()
static void flash_reset()
{
- uint8_t data_eqpi[1] = { FC_EQPI };
-
flash_chip_select();
- xfer_spi(data_eqpi, 1);
+ xfer_spi_bits(0xFF, 8);
flash_chip_deselect();
flash_chip_select();
- xfer_spi(data_eqpi, 1);
+ xfer_spi_bits(0xFF, 2);
flash_chip_deselect();
}