Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sival, spi] Passthru #21348

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hw/top_earlgrey/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ silicon(
name = "silicon_owner_sival_rom_ext",
testonly = True,
args = [
"--rcfile=",
"--rcfile=__builtin__/hyperdebug_teacup.json",
"--logging=info",
"--interface={interface}",
],
Expand Down
5 changes: 2 additions & 3 deletions hw/top_earlgrey/data/ip/chip_spi_device_testplan.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@
"SPI_DEVICE.MODE.PASSTHROUGH.CMD_FILTER",
]
tests: ["chip_sw_spi_device_pass_through"]
bazel: []
bazel: ["//sw/device/tests:spi_passthru_test"]
}

{
name: chip_sw_spi_device_pass_through_flash_model
desc: '''Verify the command filtering mechanism in passthrough mode.
Expand All @@ -109,7 +108,7 @@
"SPI_DEVICE.HW.LANES",
"SPI_DEVICE.MODE.PASSTHROUGH.CMD_FILTER",
]
tests: []
tests: ["//sw/device/tests:spi_passthru_test"]
}
{
name: chip_sw_spi_device_pass_through_collision
Expand Down
2 changes: 1 addition & 1 deletion hw/top_earlgrey/data/ip/chip_spi_host_testplan.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
stage: V3
si_stage: SV3
lc_states: ["PROD"]
tests: []
tests: ["//sw/device/tests:spi_passthru_test"]
}
{
name: chip_sw_spi_host_configuration
Expand Down
17 changes: 14 additions & 3 deletions sw/device/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4233,15 +4233,26 @@ opentitan_test(
# interface = "hyper310",
# tags = ["manual"],
test_cmd = """
--bootstrap="{firmware}"
""",
test_harness = "//sw/host/tests/chip/spi_passthru",
),
exec_env = dicts.add(
EARLGREY_SILICON_OWNER_ROM_EXT_ENVS,
{
"//hw/top_earlgrey:fpga_cw310_test_rom": None,
},
),
silicon = silicon_params(
test_cmd = """
--bootstrap="{firmware}"
""",
test_harness = "//sw/host/tests/chip/spi_passthru",
),
exec_env = {
"//hw/top_earlgrey:fpga_cw310_test_rom": None,
},
deps = [
"//sw/device/lib/arch:device",
"//sw/device/lib/dif:gpio",
"//sw/device/lib/dif:pinmux",
"//sw/device/lib/dif:spi_device",
"//sw/device/lib/testing:spi_device_testutils",
"//sw/device/lib/testing:spi_flash_testutils",
Expand Down
35 changes: 35 additions & 0 deletions sw/device/tests/spi_passthru_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "sw/device/lib/arch/device.h"
#include "sw/device/lib/base/status.h"
#include "sw/device/lib/dif/dif_pinmux.h"
#include "sw/device/lib/dif/dif_spi_device.h"
#include "sw/device/lib/dif/dif_spi_host.h"
#include "sw/device/lib/runtime/log.h"
Expand Down Expand Up @@ -224,6 +225,40 @@ status_t command_processor(ujson_t *uj) {
}

bool test_main(void) {
if (kDeviceType == kDeviceSilicon) {
// On teacup board, we need to enable pull-ups on the pins connected to `WP`
// and `HOLD`.
dif_pinmux_t pinmux;
mmio_region_t base_addr =
mmio_region_from_addr(TOP_EARLGREY_PINMUX_AON_BASE_ADDR);
CHECK_DIF_OK(dif_pinmux_init(base_addr, &pinmux));

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));
}

const uint32_t spi_host_clock_freq_hz =
(uint32_t)kClockFreqHiSpeedPeripheralHz;
CHECK_DIF_OK(dif_spi_host_init(
Expand Down
10 changes: 5 additions & 5 deletions sw/host/opentitanlib/src/app/config/hyperdebug_teacup.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,10 @@
{
"name": "SPI_TPM",
"pins": [
{
"name": "SPI_MUX_SEL",
"level": true,
},
{
"name": "SPI_MUX_SEL",
"level": true
},
{
"name": "SPI1_SCK",
"mode": "Alternate"
Expand All @@ -417,5 +417,5 @@
}
]
}
],
]
}