|
36 | 36 | #include "hw/opentitan/ot_common.h" |
37 | 37 | #include "hw/opentitan/ot_fifo32.h" |
38 | 38 | #include "hw/opentitan/ot_spi_device.h" |
| 39 | +#include "hw/opentitan/ot_spi_host.h" |
39 | 40 | #include "hw/qdev-properties-system.h" |
40 | 41 | #include "hw/qdev-properties.h" |
41 | 42 | #include "hw/registerfields.h" |
@@ -471,6 +472,11 @@ struct OtSPIDeviceState { |
471 | 472 | SpiDeviceFlash flash; |
472 | 473 | SpiDeviceTpm tpm; |
473 | 474 |
|
| 475 | + OtSPIHostState *spihost; |
| 476 | + /* CS signal for downstream flash in passthrough mode, active low */ |
| 477 | + IbexIRQ passthrough_cs; |
| 478 | + IbexIRQ passthrough_en; |
| 479 | + |
474 | 480 | uint32_t *spi_regs; /* Registers */ |
475 | 481 | uint32_t *tpm_regs; /* Registers */ |
476 | 482 | 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) |
2320 | 2326 | static Property ot_spi_device_properties[] = { |
2321 | 2327 | DEFINE_PROP_STRING(OT_COMMON_DEV_ID, OtSPIDeviceState, ot_id), |
2322 | 2328 | DEFINE_PROP_CHR("chardev", OtSPIDeviceState, chr), |
| 2329 | + DEFINE_PROP_LINK("spihost", OtSPIDeviceState, spihost, TYPE_OT_SPI_HOST, |
| 2330 | + OtSPIHostState *), |
2323 | 2331 | DEFINE_PROP_END_OF_LIST(), |
2324 | 2332 | }; |
2325 | 2333 |
|
@@ -2393,6 +2401,12 @@ static void ot_spi_device_realize(DeviceState *dev, Error **errp) |
2393 | 2401 |
|
2394 | 2402 | g_assert(s->ot_id); |
2395 | 2403 |
|
| 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 | + |
2396 | 2410 | qemu_chr_fe_set_handlers(&s->chr, &ot_spi_device_chr_can_receive, |
2397 | 2411 | &ot_spi_device_chr_receive, |
2398 | 2412 | &ot_spi_device_chr_event_hander, |
|
0 commit comments