|
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; |
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 | }; |
@@ -2311,6 +2317,8 @@ static int ot_spi_device_chr_be_change(void *opaque) |
2311 | 2317 | static Property ot_spi_device_properties[] = { |
2312 | 2318 | DEFINE_PROP_STRING(OT_COMMON_DEV_ID, OtSPIDeviceState, ot_id), |
2313 | 2319 | DEFINE_PROP_CHR("chardev", OtSPIDeviceState, chr), |
| 2320 | + DEFINE_PROP_LINK("spihost", OtSPIDeviceState, spihost, TYPE_OT_SPI_HOST, |
| 2321 | + OtSPIHostState *), |
2314 | 2322 | DEFINE_PROP_END_OF_LIST(), |
2315 | 2323 | }; |
2316 | 2324 |
|
@@ -2373,6 +2381,9 @@ static void ot_spi_device_reset_enter(Object *obj, ResetType type) |
2373 | 2381 |
|
2374 | 2382 | s->tpm_regs[R_TPM_CAP] = 0x660100u; |
2375 | 2383 |
|
| 2384 | + ibex_irq_lower(&s->passthrough_en); |
| 2385 | + ibex_irq_raise(&s->passthrough_cs); |
| 2386 | + |
2376 | 2387 | ot_spi_device_update_irqs(s); |
2377 | 2388 | ot_spi_device_update_alerts(s); |
2378 | 2389 | } |
@@ -2430,6 +2441,12 @@ static void ot_spi_device_init(Object *obj) |
2430 | 2441 | ibex_qdev_init_irq(obj, &s->alerts[ix], OT_DEVICE_ALERT); |
2431 | 2442 | } |
2432 | 2443 |
|
| 2444 | + /* Passthrough enable is active high, CS is active low */ |
| 2445 | + ibex_qdev_init_irq_default(OBJECT(s), &s->passthrough_en, |
| 2446 | + OT_SPI_DEVICE_PASSTHROUGH_EN, 0); |
| 2447 | + ibex_qdev_init_irq_default(OBJECT(s), &s->passthrough_cs, |
| 2448 | + OT_SPI_DEVICE_PASSTHROUGH_CS, 1); |
| 2449 | + |
2433 | 2450 | /* |
2434 | 2451 | * This timer is used to hand over to the vCPU whenever a READBUF_* irq is |
2435 | 2452 | * raised, otherwide the vCPU would not be able to get notified that a |
|
0 commit comments