|
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" |
@@ -450,12 +451,17 @@ struct OtSPIDeviceState { |
450 | 451 | SpiDeviceFlash flash; |
451 | 452 | SpiDeviceTpm tpm; |
452 | 453 |
|
| 454 | + /* CS signal for downstream flash in passthrough mode, active low */ |
| 455 | + IbexIRQ passthrough_cs; |
| 456 | + IbexIRQ passthrough_en; |
| 457 | + |
453 | 458 | uint32_t *spi_regs; /* Registers */ |
454 | 459 | uint32_t *tpm_regs; /* Registers */ |
455 | 460 | uint32_t *sram; /* SRAM (DPRAM on EG, E/I on DJ) */ |
456 | 461 |
|
457 | 462 | /* Properties */ |
458 | 463 | char *ot_id; |
| 464 | + OtSPIHostState *spihost; /* downstream SPI Host */ |
459 | 465 | CharBackend chr; /* communication device */ |
460 | 466 | guint watch_tag; /* tracker for comm device change */ |
461 | 467 | }; |
@@ -2297,6 +2303,8 @@ static int ot_spi_device_chr_be_change(void *opaque) |
2297 | 2303 | static Property ot_spi_device_properties[] = { |
2298 | 2304 | DEFINE_PROP_STRING(OT_COMMON_DEV_ID, OtSPIDeviceState, ot_id), |
2299 | 2305 | DEFINE_PROP_CHR("chardev", OtSPIDeviceState, chr), |
| 2306 | + DEFINE_PROP_LINK("spihost", OtSPIDeviceState, spihost, TYPE_OT_SPI_HOST, |
| 2307 | + OtSPIHostState *), |
2300 | 2308 | DEFINE_PROP_END_OF_LIST(), |
2301 | 2309 | }; |
2302 | 2310 |
|
@@ -2359,6 +2367,9 @@ static void ot_spi_device_reset_enter(Object *obj, ResetType type) |
2359 | 2367 |
|
2360 | 2368 | s->tpm_regs[R_TPM_CAP] = 0x660100u; |
2361 | 2369 |
|
| 2370 | + ibex_irq_lower(&s->passthrough_en); |
| 2371 | + ibex_irq_raise(&s->passthrough_cs); |
| 2372 | + |
2362 | 2373 | ot_spi_device_update_irqs(s); |
2363 | 2374 | ot_spi_device_update_alerts(s); |
2364 | 2375 | } |
@@ -2416,6 +2427,12 @@ static void ot_spi_device_init(Object *obj) |
2416 | 2427 | ibex_qdev_init_irq(obj, &s->alerts[ix], OT_DEVICE_ALERT); |
2417 | 2428 | } |
2418 | 2429 |
|
| 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 | + |
2419 | 2436 | /* |
2420 | 2437 | * This timer is used to hand over to the vCPU whenever a READBUF_* irq is |
2421 | 2438 | * raised, otherwide the vCPU would not be able to get notified that a |
|
0 commit comments