Skip to content

Commit 13f47e6

Browse files
committed
[ot] hw/opentitan: ot_spi_device: Create GPIOs and prop for Passthrough
Signed-off-by: Alice Ziuziakowska <[email protected]>
1 parent da2a35d commit 13f47e6

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-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: 14 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"
@@ -471,6 +472,11 @@ struct OtSPIDeviceState {
471472
SpiDeviceFlash flash;
472473
SpiDeviceTpm tpm;
473474

475+
OtSPIHostState *spihost;
476+
/* CS signal for downstream flash in passthrough mode, active low */
477+
IbexIRQ passthrough_cs;
478+
IbexIRQ passthrough_en;
479+
474480
uint32_t *spi_regs; /* Registers */
475481
uint32_t *tpm_regs; /* Registers */
476482
uint32_t *sram; /* SRAM (DPRAM on EG, E/I on DJ) */
@@ -2320,6 +2326,8 @@ static int ot_spi_device_chr_be_change(void *opaque)
23202326
static Property ot_spi_device_properties[] = {
23212327
DEFINE_PROP_STRING(OT_COMMON_DEV_ID, OtSPIDeviceState, ot_id),
23222328
DEFINE_PROP_CHR("chardev", OtSPIDeviceState, chr),
2329+
DEFINE_PROP_LINK("spihost", OtSPIDeviceState, spihost, TYPE_OT_SPI_HOST,
2330+
OtSPIHostState *),
23232331
DEFINE_PROP_END_OF_LIST(),
23242332
};
23252333

@@ -2393,6 +2401,12 @@ static void ot_spi_device_realize(DeviceState *dev, Error **errp)
23932401

23942402
g_assert(s->ot_id);
23952403

2404+
/* CS is active low, Passthrough enable is active high */
2405+
ibex_qdev_init_irq_default(OBJECT(s), &s->passthrough_cs, "passthrough-cs",
2406+
1);
2407+
ibex_qdev_init_irq_default(OBJECT(s), &s->passthrough_en, "passthrough-en",
2408+
0);
2409+
23962410
qemu_chr_fe_set_handlers(&s->chr, &ot_spi_device_chr_can_receive,
23972411
&ot_spi_device_chr_receive,
23982412
&ot_spi_device_chr_event_hander,

0 commit comments

Comments
 (0)