From 44b3377e95bbb62895063762843ee0537e76aae2 Mon Sep 17 00:00:00 2001 From: Sharon Topaz Date: Mon, 16 Sep 2024 15:08:51 +0300 Subject: [PATCH] [dv,spi] Set strong drive strength and fast slew rate for SPI pads Signed-off-by: Sharon Topaz [dv,spi] fix lint issues Signed-off-by: Sharon Topaz [dv,spi] Add kDeviceSimDV, kDeviceSilicon constraints Signed-off-by: Sharon Topaz --- sw/device/tests/power_virus_systemtest.c | 42 ++++++++++++++++++ sw/device/tests/sim_dv/spi_host_tx_rx_test.c | 12 +++--- sw/device/tests/sim_dv/spi_passthrough_test.c | 43 +++++++++++++++++++ 3 files changed, 91 insertions(+), 6 deletions(-) diff --git a/sw/device/tests/power_virus_systemtest.c b/sw/device/tests/power_virus_systemtest.c index 9a87b74be33b3b..1746a470c16680 100644 --- a/sw/device/tests/power_virus_systemtest.c +++ b/sw/device/tests/power_virus_systemtest.c @@ -1454,6 +1454,48 @@ bool test_main(void) { if (kDeviceType == kDeviceSimDV || kDeviceType == kDeviceSimVerilator) { configure_pinmux_sim(); } + + // Set pads attributes for SPI passthrough mode + dif_pinmux_pad_attr_t out_attr; + dif_pinmux_pad_attr_t in_attr = { + .slew_rate = 1, + .drive_strength = 3, + .flags = kDifPinmuxPadAttrPullResistorEnable | + kDifPinmuxPadAttrPullResistorUp}; + // spi host0 + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiHost0Sck, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiHost0Sd0, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiHost0Sd1, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiHost0Sd2, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiHost0Sd3, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + // spi device + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiDeviceSd0, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiDeviceSd1, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiDeviceSd2, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiDeviceSd3, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + // Clear GPIO pin 0 (max power indicator pin). CHECK_DIF_OK( dif_gpio_output_set_enabled(&gpio, /*pin=*/0, kDifToggleEnabled)); diff --git a/sw/device/tests/sim_dv/spi_host_tx_rx_test.c b/sw/device/tests/sim_dv/spi_host_tx_rx_test.c index 8de39e0c64d997..b70ecdda8ff4a9 100644 --- a/sw/device/tests/sim_dv/spi_host_tx_rx_test.c +++ b/sw/device/tests/sim_dv/spi_host_tx_rx_test.c @@ -147,11 +147,11 @@ void init_spi_host(dif_spi_host_t *spi_host, * This peripheral is 'direct' connected to the pads. */ void setup_pads_spi_host0(void) { - // set weak pull-ups for all the pads + // set weak pull-ups, fast slew rate and strong drive strengh for all the pads dif_pinmux_pad_attr_t out_attr; dif_pinmux_pad_attr_t in_attr = { - .slew_rate = 0, - .drive_strength = 0, + .slew_rate = 1, + .drive_strength = 3, .flags = kDifPinmuxPadAttrPullResistorEnable | kDifPinmuxPadAttrPullResistorUp}; for (uint32_t i = 0; i <= ARRAYSIZE(spi_host0_direct_pads); ++i) { @@ -167,11 +167,11 @@ void setup_pads_spi_host0(void) { * This peripheral is 'muxed', so configure the pinmux as well as pads. */ void setup_pinmux_pads_spi_host1(void) { - // Set weak pull-ups for the pads + // Set weak pull-ups, fast slew rate and strong drive strengh for the pads dif_pinmux_pad_attr_t out_attr; dif_pinmux_pad_attr_t in_attr = { - .slew_rate = 0, - .drive_strength = 0, + .slew_rate = 1, + .drive_strength = 3, // set weak pull-ups for all the pads .flags = kDifPinmuxPadAttrPullResistorEnable | kDifPinmuxPadAttrPullResistorUp}; diff --git a/sw/device/tests/sim_dv/spi_passthrough_test.c b/sw/device/tests/sim_dv/spi_passthrough_test.c index daaca11c39416d..6ef78782efe58f 100644 --- a/sw/device/tests/sim_dv/spi_passthrough_test.c +++ b/sw/device/tests/sim_dv/spi_passthrough_test.c @@ -377,6 +377,49 @@ bool test_main(void) { dif_pinmux_output_select(&pinmux, setting.pad, setting.peripheral)); } + if (kDeviceType == kDeviceSilicon || kDeviceType == kDeviceSimDV) { + // Set fast slew rate and strong drive strengh for SPI pads + dif_pinmux_pad_attr_t out_attr; + dif_pinmux_pad_attr_t in_attr = { + .slew_rate = 1, + .drive_strength = 3, + .flags = kDifPinmuxPadAttrPullResistorEnable | + kDifPinmuxPadAttrPullResistorUp}; + + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiHost0Sck, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiHost0Sd0, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiHost0Sd1, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiHost0Sd2, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiHost0Sd3, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + // Spi_Device + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiDeviceSd0, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiDeviceSd1, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiDeviceSd2, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + + CHECK_DIF_OK( + dif_pinmux_pad_write_attrs(&pinmux, kTopEarlgreyDirectPadsSpiDeviceSd3, + kDifPinmuxPadKindDio, in_attr, &out_attr)); + } + // Initialize the PLIC. CHECK_DIF_OK(dif_rv_plic_init( mmio_region_from_addr(TOP_EARLGREY_RV_PLIC_BASE_ADDR), &rv_plic));