[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 8/9] Revert "aspeed/smc: snoop SPI transfers to fake dummy cycles
From: |
Bin Meng |
Subject: |
[PATCH 8/9] Revert "aspeed/smc: snoop SPI transfers to fake dummy cycles" |
Date: |
Thu, 14 Jan 2021 23:09:01 +0800 |
From: Bin Meng <bin.meng@windriver.com>
This reverts commit f95c4bffdc4c53b29f89762cab4adc5a43f95daf.
The incorrect implementation of dummy cycles in m25p80 model is now
corrected. Revert this commit.
Signed-off-by: Bin Meng <bin.meng@windriver.com>
---
include/hw/ssi/aspeed_smc.h | 3 -
hw/ssi/aspeed_smc.c | 116 +-----------------------------------
2 files changed, 2 insertions(+), 117 deletions(-)
diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h
index 16c03fe64f..46f3abf2e7 100644
--- a/include/hw/ssi/aspeed_smc.h
+++ b/include/hw/ssi/aspeed_smc.h
@@ -111,9 +111,6 @@ struct AspeedSMCState {
AddressSpace dram_as;
AspeedSMCFlash *flashes;
-
- uint8_t snoop_index;
- uint8_t snoop_dummies;
};
#endif /* ASPEED_SMC_H */
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
index 1e78b5232f..0df5d91d19 100644
--- a/hw/ssi/aspeed_smc.c
+++ b/hw/ssi/aspeed_smc.c
@@ -187,9 +187,6 @@
/* Flash opcodes. */
#define SPI_OP_READ 0x03 /* Read data bytes (low frequency) */
-#define SNOOP_OFF 0xFF
-#define SNOOP_START 0x0
-
/*
* Default segments mapping addresses and size for each peripheral per
* controller. These can be changed when board is initialized with the
@@ -771,104 +768,6 @@ static uint64_t aspeed_smc_flash_read(void *opaque,
hwaddr addr, unsigned size)
return ret;
}
-/*
- * TODO (clg@kaod.org): stolen from xilinx_spips.c. Should move to a
- * common include header.
- */
-typedef enum {
- READ = 0x3, READ_4 = 0x13,
- FAST_READ = 0xb, FAST_READ_4 = 0x0c,
- DOR = 0x3b, DOR_4 = 0x3c,
- QOR = 0x6b, QOR_4 = 0x6c,
- DIOR = 0xbb, DIOR_4 = 0xbc,
- QIOR = 0xeb, QIOR_4 = 0xec,
-
- PP = 0x2, PP_4 = 0x12,
- DPP = 0xa2,
- QPP = 0x32, QPP_4 = 0x34,
-} FlashCMD;
-
-static int aspeed_smc_num_dummies(uint8_t command)
-{
- switch (command) { /* check for dummies */
- case READ: /* no dummy bytes/cycles */
- case PP:
- case DPP:
- case QPP:
- case READ_4:
- case PP_4:
- case QPP_4:
- return 0;
- case FAST_READ:
- case DOR:
- case QOR:
- case DOR_4:
- case QOR_4:
- return 1;
- case DIOR:
- case FAST_READ_4:
- case DIOR_4:
- return 2;
- case QIOR:
- case QIOR_4:
- return 4;
- default:
- return -1;
- }
-}
-
-static bool aspeed_smc_do_snoop(AspeedSMCFlash *fl, uint64_t data,
- unsigned size)
-{
- AspeedSMCState *s = fl->controller;
- uint8_t addr_width = aspeed_smc_flash_is_4byte(fl) ? 4 : 3;
-
- trace_aspeed_smc_do_snoop(fl->id, s->snoop_index, s->snoop_dummies,
- (uint8_t) data & 0xff);
-
- if (s->snoop_index == SNOOP_OFF) {
- return false; /* Do nothing */
-
- } else if (s->snoop_index == SNOOP_START) {
- uint8_t cmd = data & 0xff;
- int ndummies = aspeed_smc_num_dummies(cmd);
-
- /*
- * No dummy cycles are expected with the current command. Turn
- * off snooping and let the transfer proceed normally.
- */
- if (ndummies <= 0) {
- s->snoop_index = SNOOP_OFF;
- return false;
- }
-
- s->snoop_dummies = ndummies * 8;
-
- } else if (s->snoop_index >= addr_width + 1) {
-
- /* The SPI transfer has reached the dummy cycles sequence */
- for (; s->snoop_dummies; s->snoop_dummies--) {
- ssi_transfer(s->spi, s->regs[R_DUMMY_DATA] & 0xff);
- }
-
- /* If no more dummy cycles are expected, turn off snooping */
- if (!s->snoop_dummies) {
- s->snoop_index = SNOOP_OFF;
- } else {
- s->snoop_index += size;
- }
-
- /*
- * Dummy cycles have been faked already. Ignore the current
- * SPI transfer
- */
- return true;
- }
-
- s->snoop_index += size;
- return false;
-}
-
static void aspeed_smc_flash_write(void *opaque, hwaddr addr, uint64_t data,
unsigned size)
{
@@ -887,10 +786,6 @@ static void aspeed_smc_flash_write(void *opaque, hwaddr
addr, uint64_t data,
switch (aspeed_smc_flash_mode(fl)) {
case CTRL_USERMODE:
- if (aspeed_smc_do_snoop(fl, data, size)) {
- break;
- }
-
for (i = 0; i < size; i++) {
ssi_transfer(s->spi, (data >> (8 * i)) & 0xff);
}
@@ -937,8 +832,6 @@ static void aspeed_smc_flash_update_ctrl(AspeedSMCFlash
*fl, uint32_t value)
s->regs[s->r_ctrl0 + fl->id] = value;
- s->snoop_index = unselect ? SNOOP_OFF : SNOOP_START;
-
aspeed_smc_flash_do_select(fl, unselect);
}
@@ -981,9 +874,6 @@ static void aspeed_smc_reset(DeviceState *d)
if (s->ctrl->segments == aspeed_segments_fmc) {
s->regs[s->r_conf] |= (CONF_FLASH_TYPE_SPI << CONF_FLASH_TYPE0);
}
-
- s->snoop_index = SNOOP_OFF;
- s->snoop_dummies = 0;
}
static uint64_t aspeed_smc_read(void *opaque, hwaddr addr, unsigned int size)
@@ -1419,12 +1309,10 @@ static void aspeed_smc_realize(DeviceState *dev, Error
**errp)
static const VMStateDescription vmstate_aspeed_smc = {
.name = "aspeed.smc",
- .version_id = 2,
- .minimum_version_id = 2,
+ .version_id = 1,
+ .minimum_version_id = 1,
.fields = (VMStateField[]) {
VMSTATE_UINT32_ARRAY(regs, AspeedSMCState, ASPEED_SMC_R_MAX),
- VMSTATE_UINT8(snoop_index, AspeedSMCState),
- VMSTATE_UINT8(snoop_dummies, AspeedSMCState),
VMSTATE_END_OF_LIST()
}
};
--
2.25.1
- [PATCH 0/9] hw/block: m25p80: Fix the mess of dummy bytes needed for fast read commands, Bin Meng, 2021/01/14
- [PATCH 1/9] hw/block: m25p80: Fix the number of dummy bytes needed for Windbond flashes, Bin Meng, 2021/01/14
- [PATCH 2/9] hw/block: m25p80: Fix the number of dummy bytes needed for Numonyx/Micron flashes, Bin Meng, 2021/01/14
- [PATCH 3/9] hw/block: m25p80: Fix the number of dummy bytes needed for Macronix flashes, Bin Meng, 2021/01/14
- [PATCH 4/9] hw/block: m25p80: Fix the number of dummy bytes needed for Spansion flashes, Bin Meng, 2021/01/14
- [PATCH 5/9] hw/block: m25p80: Support fast read for SST flashes, Bin Meng, 2021/01/14
- [PATCH 6/9] hw/ssi: xilinx_spips: Fix generic fifo dummy cycle handling, Bin Meng, 2021/01/14
- [PATCH 7/9] Revert "aspeed/smc: Fix number of dummy cycles for FAST_READ_4 command", Bin Meng, 2021/01/14
- [PATCH 8/9] Revert "aspeed/smc: snoop SPI transfers to fake dummy cycles",
Bin Meng <=
- [PATCH 9/9] hw/ssi: npcm7xx_fiu: Correct the dummy cycle emulation logic, Bin Meng, 2021/01/14
- Re: [PATCH 0/9] hw/block: m25p80: Fix the mess of dummy bytes needed for fast read commands, Cédric Le Goater, 2021/01/14
- Re: [PATCH 0/9] hw/block: m25p80: Fix the mess of dummy bytes needed for fast read commands, no-reply, 2021/01/14
- Re: [PATCH 0/9] hw/block: m25p80: Fix the mess of dummy bytes needed for fast read commands, Francisco Iglesias, 2021/01/14