|
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" |
@@ -449,12 +450,17 @@ struct OtSPIDeviceState { |
449 | 450 | SpiDeviceFlash flash; |
450 | 451 | SpiDeviceTpm tpm; |
451 | 452 |
|
| 453 | + /* CS signal for downstream flash in passthrough mode, active low */ |
| 454 | + IbexIRQ passthrough_cs; |
| 455 | + IbexIRQ passthrough_en; |
| 456 | + |
452 | 457 | uint32_t *spi_regs; /* Registers */ |
453 | 458 | uint32_t *tpm_regs; /* Registers */ |
454 | 459 | uint32_t *sram; /* SRAM (DPRAM on EG, E/I on DJ) */ |
455 | 460 |
|
456 | 461 | /* Properties */ |
457 | 462 | char *ot_id; |
| 463 | + OtSPIHostState *spihost; /* downstream SPI Host */ |
458 | 464 | CharBackend chr; /* communication device */ |
459 | 465 | guint watch_tag; /* tracker for comm device change */ |
460 | 466 | }; |
@@ -2286,6 +2292,8 @@ static int ot_spi_device_chr_be_change(void *opaque) |
2286 | 2292 | static Property ot_spi_device_properties[] = { |
2287 | 2293 | DEFINE_PROP_STRING(OT_COMMON_DEV_ID, OtSPIDeviceState, ot_id), |
2288 | 2294 | DEFINE_PROP_CHR("chardev", OtSPIDeviceState, chr), |
| 2295 | + DEFINE_PROP_LINK("spihost", OtSPIDeviceState, spihost, TYPE_OT_SPI_HOST, |
| 2296 | + OtSPIHostState *), |
2289 | 2297 | DEFINE_PROP_END_OF_LIST(), |
2290 | 2298 | }; |
2291 | 2299 |
|
@@ -2348,6 +2356,9 @@ static void ot_spi_device_reset_enter(Object *obj, ResetType type) |
2348 | 2356 |
|
2349 | 2357 | s->tpm_regs[R_TPM_CAP] = 0x660100u; |
2350 | 2358 |
|
| 2359 | + ibex_irq_lower(&s->passthrough_en); |
| 2360 | + ibex_irq_raise(&s->passthrough_cs); |
| 2361 | + |
2351 | 2362 | ot_spi_device_update_irqs(s); |
2352 | 2363 | ot_spi_device_update_alerts(s); |
2353 | 2364 | } |
@@ -2405,6 +2416,12 @@ static void ot_spi_device_init(Object *obj) |
2405 | 2416 | ibex_qdev_init_irq(obj, &s->alerts[ix], OT_DEVICE_ALERT); |
2406 | 2417 | } |
2407 | 2418 |
|
| 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 | + |
2408 | 2425 | /* |
2409 | 2426 | * This timer is used to hand over to the vCPU whenever a READBUF_* irq is |
2410 | 2427 | * raised, otherwide the vCPU would not be able to get notified that a |
|
0 commit comments