From 147d3d73acd39e87f9156a991acf304fd842b154 Mon Sep 17 00:00:00 2001 From: Douglas Reis Date: Mon, 18 Dec 2023 15:34:21 +0000 Subject: [PATCH] [spi_dev, dv] Adapt the tpm test for sival Signed-off-by: Douglas Reis --- .../seq_lib/chip_sw_spi_device_tpm_vseq.sv | 2 ++ .../tests/sim_dv/spi_device_tpm_tx_rx_test.c | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/hw/top_earlgrey/dv/env/seq_lib/chip_sw_spi_device_tpm_vseq.sv b/hw/top_earlgrey/dv/env/seq_lib/chip_sw_spi_device_tpm_vseq.sv index 17166c31e50cd1..3ce7477df4ad5c 100644 --- a/hw/top_earlgrey/dv/env/seq_lib/chip_sw_spi_device_tpm_vseq.sv +++ b/hw/top_earlgrey/dv/env/seq_lib/chip_sw_spi_device_tpm_vseq.sv @@ -63,6 +63,8 @@ class chip_sw_spi_device_tpm_vseq extends chip_sw_base_vseq; end tpm_txn (.wr(1), .addr(addr), .data_q(data_q), .len(data_q.size()), .rdata_q(rdata_q)); + `DV_WAIT(cfg.sw_logger_vif.printed_log == "SYNC: Waiting Read", + "Timedout waiting for read config.") // Read transaction tpm_txn (.wr(0), .addr(addr), .len(data_q.size()), .rdata_q(rdata_q)); foreach (rdata_q[i]) begin diff --git a/sw/device/tests/sim_dv/spi_device_tpm_tx_rx_test.c b/sw/device/tests/sim_dv/spi_device_tpm_tx_rx_test.c index 38b40fea8ddecb..3c951cb605f291 100644 --- a/sw/device/tests/sim_dv/spi_device_tpm_tx_rx_test.c +++ b/sw/device/tests/sim_dv/spi_device_tpm_tx_rx_test.c @@ -28,6 +28,7 @@ static dif_rv_plic_t plic; typedef enum { kTpmWriteCommand = 0x0, kTpmReadCommand = 0x80, + kTpmCommandMask = 0xbf } tpm_cmd_t; enum { @@ -163,16 +164,18 @@ bool test_main(void) { &pinmux, kTopEarlgreyPinmuxPeripheralInSpiDeviceTpmCsb, kTopEarlgreyPinmuxInselIoa7)); - dif_pinmux_pad_attr_t out_attr; - dif_pinmux_pad_attr_t in_attr = { - .slew_rate = 0, - .drive_strength = 0, - .flags = kDifPinmuxPadAttrPullResistorEnable | - kDifPinmuxPadAttrPullResistorUp}; - - CHECK_DIF_OK(dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyMuxedPadsIoa7, - kDifPinmuxPadKindMio, in_attr, - &out_attr)); + if (kDeviceType == kDeviceSimDV){ + dif_pinmux_pad_attr_t out_attr; + dif_pinmux_pad_attr_t in_attr = { + .slew_rate = 0, + .drive_strength = 0, + .flags = kDifPinmuxPadAttrPullResistorEnable | + kDifPinmuxPadAttrPullResistorUp}; + + CHECK_DIF_OK(dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyMuxedPadsIoa7, + kDifPinmuxPadKindMio, in_attr, + &out_attr)); + } CHECK_DIF_OK( dif_spi_device_tpm_configure(&spi_device, kDifToggleEnabled, kTpmConfig)); @@ -213,6 +216,8 @@ bool test_main(void) { // Finished processing the write command ack_spi_tpm_header_irq(&spi_device); + LOG_INFO("SYNC: Waiting Read"); + // Send the written data right back out for reads. // Wait for read interrupt. atomic_wait_for_interrupt(); // Send the written data right back out for reads. @@ -225,6 +230,7 @@ bool test_main(void) { ack_spi_tpm_header_irq(&spi_device); // Make sure the received command matches expectation + read_command &= kTpmCommandMask; LOG_INFO("Expected 0x%x, received 0x%x", (kTpmReadCommand | (num_bytes - 1)), read_command); CHECK((kTpmReadCommand | (num_bytes - 1)) == read_command,