Skip to content

Commit 55bf323

Browse files
committed
[ot] hw/opentitan: ot_flash: clear erase suspend & documentation
This commit adds a "partway" fix for erase suspend implementation, immediately clearing the request to simulate the response of "no erase ongoing", as currently QEMU flash erases are modelled as synchronous (i.e. the entire erase happens at once, and cannot be suspended). Also updates the author information in the file prologue, and introduces some additional documentation about the limitations of the current QEMU model, and a couple of relevant TODOs. Signed-off-by: Alex Jones <[email protected]>
1 parent 6edc82a commit 55bf323

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

hw/opentitan/ot_flash.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*
77
* Author(s):
88
* Emmanuel Blot <[email protected]>
9+
* Alex Jones <[email protected]>
910
*
1011
* Permission is hereby granted, free of charge, to any person obtaining a copy
1112
* of this software and associated documentation files (the "Software"), to deal
@@ -25,8 +26,15 @@
2526
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2627
* THE SOFTWARE.
2728
*
28-
* Note: for now, only a minimalist subset of Power Manager device is
29-
* implemented in order to enable OpenTitan's ROM boot to progress
29+
* Known limitations:
30+
* - ECC/ICV/Scrambling functionality is not yet implemented in QEMU,
31+
* including ECC single error support.
32+
* - Alert functionality is not yet modelled (outside of test alerts).
33+
* - Program Repair / High Endurance enables are meaningless in the OpenTitan
34+
* Generic Flash Bank and so are not emulated.
35+
* - Erase Suspend is not emulated in QEMU (erases are done synchronously, so
36+
* you can suspend, but the bit will immediately be cleared).
37+
* - HW info cfg overrides are not modelled in QEMU.
3038
*/
3139

3240
#include "qemu/osdep.h"
@@ -769,6 +777,7 @@ static void ot_flash_update_irqs(OtFlashState *s)
769777

770778
static void ot_flash_update_alerts(OtFlashState *s)
771779
{
780+
/* @todo Implement non-test alert sources and update them here as well. */
772781
uint32_t level = s->regs[R_ALERT_TEST];
773782

774783
for (unsigned ix = 0u; ix < PARAM_NUM_ALERTS; ix++) {
@@ -834,7 +843,6 @@ static void ot_flash_update_prog_watermark(OtFlashState *s)
834843
ot_flash_update_irqs(s);
835844
}
836845

837-
838846
static void ot_flash_op_signal(void *opaque)
839847
{
840848
OtFlashState *s = opaque;
@@ -1838,8 +1846,13 @@ static void ot_flash_regs_write(void *opaque, hwaddr addr, uint64_t val64,
18381846
s->regs[reg] = val32;
18391847
break;
18401848
case R_ERASE_SUSPEND:
1841-
val32 &= R_ERASE_SUSPEND_REQ_MASK;
1842-
s->regs[reg] = val32;
1849+
/*
1850+
* @todo We do not implement the erase suspend operation in QEMU as we
1851+
* do all erases synchronously, and so just immediately clear the erase
1852+
* suspend request. To implement this feature properly we would have to
1853+
* add delay to bank erases & check for erase suspends at each step.
1854+
*/
1855+
s->regs[reg] = 0u;
18431856
break;
18441857
case R_REGION_CFG_REGWEN_0:
18451858
case R_REGION_CFG_REGWEN_1:
@@ -2498,6 +2511,8 @@ static void ot_flash_load(OtFlashState *s, Error **errp)
24982511
* - INFO1 bank 1
24992512
* - INFO2 bank 1
25002513
* - Debug info (ELF file names)
2514+
*
2515+
* @todo Add ECC section to backend for ECC/ICV support also
25012516
*/
25022517
flash->data = (uint32_t *)(base);
25032518
flash->info =

0 commit comments

Comments
 (0)