Skip to content

Commit cbc3f7a

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 d4669df commit cbc3f7a

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
@@ -196,6 +196,7 @@ config OT_SOCDBG_CTRL
196196

197197
config OT_SPI_DEVICE
198198
bool
199+
select OT_SPI_HOST
199200

200201
config OT_SPI_HOST
201202
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"
@@ -450,12 +451,17 @@ struct OtSPIDeviceState {
450451
SpiDeviceFlash flash;
451452
SpiDeviceTpm tpm;
452453

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

457462
/* Properties */
458463
char *ot_id;
464+
OtSPIHostState *spihost; /* downstream SPI Host */
459465
CharBackend chr; /* communication device */
460466
guint watch_tag; /* tracker for comm device change */
461467
};
@@ -2297,6 +2303,8 @@ static int ot_spi_device_chr_be_change(void *opaque)
22972303
static Property ot_spi_device_properties[] = {
22982304
DEFINE_PROP_STRING(OT_COMMON_DEV_ID, OtSPIDeviceState, ot_id),
22992305
DEFINE_PROP_CHR("chardev", OtSPIDeviceState, chr),
2306+
DEFINE_PROP_LINK("spihost", OtSPIDeviceState, spihost, TYPE_OT_SPI_HOST,
2307+
OtSPIHostState *),
23002308
DEFINE_PROP_END_OF_LIST(),
23012309
};
23022310

@@ -2359,6 +2367,9 @@ static void ot_spi_device_reset_enter(Object *obj, ResetType type)
23592367

23602368
s->tpm_regs[R_TPM_CAP] = 0x660100u;
23612369

2370+
ibex_irq_lower(&s->passthrough_en);
2371+
ibex_irq_raise(&s->passthrough_cs);
2372+
23622373
ot_spi_device_update_irqs(s);
23632374
ot_spi_device_update_alerts(s);
23642375
}
@@ -2416,6 +2427,12 @@ static void ot_spi_device_init(Object *obj)
24162427
ibex_qdev_init_irq(obj, &s->alerts[ix], OT_DEVICE_ALERT);
24172428
}
24182429

2430+
/* Passthrough enable is active high, CS is active low */
2431+
ibex_qdev_init_irq_default(OBJECT(s), &s->passthrough_en,
2432+
OT_SPI_DEVICE_PASSTHROUGH_EN, 0);
2433+
ibex_qdev_init_irq_default(OBJECT(s), &s->passthrough_cs,
2434+
OT_SPI_DEVICE_PASSTHROUGH_CS, 1);
2435+
24192436
/*
24202437
* This timer is used to hand over to the vCPU whenever a READBUF_* irq is
24212438
* 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)