Skip to content

Commit dc82ab9

Browse files
committed
[ot] hw/opentitan: ot_spi_device: Add Passthrough IRQs and SPI Host prop
This adds the corresponding out IRQs to OT SPI Device, as well as a property that contains the downstream OT SPI Host. Signed-off-by: Alice Ziuziakowska <[email protected]>
1 parent 63955d1 commit dc82ab9

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

hw/opentitan/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ config OT_SOCDBG_CTRL
177177

178178
config OT_SPI_DEVICE
179179
bool
180+
select OT_SPI_HOST
180181

181182
config OT_SPI_HOST
182183
bool

hw/opentitan/ot_spi_device.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "hw/opentitan/ot_common.h"
3737
#include "hw/opentitan/ot_fifo32.h"
3838
#include "hw/opentitan/ot_spi_device.h"
39+
#include "hw/opentitan/ot_spi_host.h"
3940
#include "hw/qdev-properties-system.h"
4041
#include "hw/qdev-properties.h"
4142
#include "hw/registerfields.h"
@@ -449,12 +450,17 @@ struct OtSPIDeviceState {
449450
SpiDeviceFlash flash;
450451
SpiDeviceTpm tpm;
451452

453+
/* CS signal for downstream flash in passthrough mode, active low */
454+
IbexIRQ passthrough_cs;
455+
IbexIRQ passthrough_en;
456+
452457
uint32_t *spi_regs; /* Registers */
453458
uint32_t *tpm_regs; /* Registers */
454459
uint32_t *sram; /* SRAM (DPRAM on EG, E/I on DJ) */
455460

456461
/* Properties */
457462
char *ot_id;
463+
OtSPIHostState *spihost; /* downstream SPI Host */
458464
CharBackend chr; /* communication device */
459465
guint watch_tag; /* tracker for comm device change */
460466
};
@@ -2286,6 +2292,8 @@ static int ot_spi_device_chr_be_change(void *opaque)
22862292
static Property ot_spi_device_properties[] = {
22872293
DEFINE_PROP_STRING(OT_COMMON_DEV_ID, OtSPIDeviceState, ot_id),
22882294
DEFINE_PROP_CHR("chardev", OtSPIDeviceState, chr),
2295+
DEFINE_PROP_LINK("spihost", OtSPIDeviceState, spihost, TYPE_OT_SPI_HOST,
2296+
OtSPIHostState *),
22892297
DEFINE_PROP_END_OF_LIST(),
22902298
};
22912299

@@ -2348,6 +2356,9 @@ static void ot_spi_device_reset_enter(Object *obj, ResetType type)
23482356

23492357
s->tpm_regs[R_TPM_CAP] = 0x660100u;
23502358

2359+
ibex_irq_lower(&s->passthrough_en);
2360+
ibex_irq_raise(&s->passthrough_cs);
2361+
23512362
ot_spi_device_update_irqs(s);
23522363
ot_spi_device_update_alerts(s);
23532364
}
@@ -2405,6 +2416,12 @@ static void ot_spi_device_init(Object *obj)
24052416
ibex_qdev_init_irq(obj, &s->alerts[ix], OT_DEVICE_ALERT);
24062417
}
24072418

2419+
/* Passthrough enable is active high, CS is active low */
2420+
ibex_qdev_init_irq_default(OBJECT(s), &s->passthrough_en,
2421+
OT_SPI_DEVICE_PASSTHROUGH_EN, 0);
2422+
ibex_qdev_init_irq_default(OBJECT(s), &s->passthrough_cs,
2423+
OT_SPI_DEVICE_PASSTHROUGH_CS, 1);
2424+
24082425
/*
24092426
* This timer is used to hand over to the vCPU whenever a READBUF_* irq is
24102427
* raised, otherwide the vCPU would not be able to get notified that a

include/hw/opentitan/ot_spi_device.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@
3333
#define TYPE_OT_SPI_DEVICE "ot-spi_device"
3434
OBJECT_DECLARE_TYPE(OtSPIDeviceState, OtSPIDeviceClass, OT_SPI_DEVICE)
3535

36+
/* IRQ lines to downstream OT SPI Host */
37+
#define OT_SPI_DEVICE_PASSTHROUGH_EN (TYPE_OT_SPI_DEVICE "-passthrough-en")
38+
#define OT_SPI_DEVICE_PASSTHROUGH_CS (TYPE_OT_SPI_DEVICE "-passthrough-cs")
39+
3640
#endif /* HW_OPENTITAN_OT_SPI_DEVICE_H */

0 commit comments

Comments
 (0)