Skip to content

Commit

Permalink
[dv,spi] Set strong drive strength and fast slew rate for SPI pads
Browse files Browse the repository at this point in the history
Signed-off-by: Sharon Topaz <[email protected]>

[dv,spi] fix lint issues

Signed-off-by: Sharon Topaz <[email protected]>
  • Loading branch information
sha-ron committed Sep 16, 2024
1 parent e93d0ee commit 7c59d4b
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 6 deletions.
42 changes: 42 additions & 0 deletions sw/device/tests/power_virus_systemtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
12 changes: 6 additions & 6 deletions sw/device/tests/sim_dv/spi_host_tx_rx_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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};
Expand Down
41 changes: 41 additions & 0 deletions sw/device/tests/sim_dv/spi_passthrough_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,47 @@ bool test_main(void) {
dif_pinmux_output_select(&pinmux, setting.pad, setting.peripheral));
}

// 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));
Expand Down

0 comments on commit 7c59d4b

Please sign in to comment.