| // Copyright 2022 Google LLC. |
| // Copyright lowRISC contributors. |
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| // SPDX-License-Identifier: Apache-2.0 |
| // |
| // ISP TPG mode with user defined resolution: 120x64, which covers the reg |
| // access, dma to dl_mem path |
| |
| #include "hw/top_matcha/sw/autogen/top_matcha.h" |
| #include "sw/device/lib/dif/dif_isp_wrapper.h" |
| #include "sw/device/lib/runtime/log.h" |
| #include "sw/device/lib/runtime/print.h" |
| #include "sw/device/lib/testing/test_framework/check.h" |
| #include "sw/device/lib/testing/test_framework/ottf_test_config.h" |
| #include "sw/device/lib/testing/test_framework/status.h" |
| #include "sw/device/lib/testing/test_framework/test_util.h" |
| |
| OTTF_DEFINE_TEST_CONFIG(); |
| |
| static dif_uart_t smc_uart; |
| static dif_isp_wrapper_t isp_wrapper; |
| uint32_t en_result; |
| uint32_t mem_val; |
| void _ottf_main(void) { |
| test_status_set(kTestStatusInTest); |
| |
| // Initialize the SMC UART to enable logging for non-DV simulation platforms. |
| if (kDeviceType != kDeviceSimDV) { |
| init_uart(TOP_MATCHA_SMC_UART_BASE_ADDR, &smc_uart); |
| } |
| |
| LOG_INFO("Hello from the SMC!"); |
| |
| CHECK_DIF_OK(dif_isp_wrapper_init( |
| mmio_region_from_addr(TOP_MATCHA_ISP_WRAPPER_BASE_ADDR), |
| &isp_wrapper), |
| "isp_wrapper_start failed"); |
| |
| CHECK_DIF_OK(dif_isp_wrapper_set_en(&isp_wrapper), "isp_wrapper_en failed"); |
| |
| while (en_result != 0x3D) { |
| CHECK_DIF_OK(dif_isp_wrapper_read_en(&isp_wrapper, &en_result)); |
| } |
| |
| // Note: passing a test in the SMC ends the simulation, even if the secure |
| // core is in the middle of a test. |
| mmio_region_t ml_dmem_base_addr = |
| mmio_region_from_addr(TOP_MATCHA_ML_TOP_DMEM_BASE_ADDR); |
| |
| mem_val = mmio_region_read32(ml_dmem_base_addr, 0x2000); |
| CHECK(mem_val == 0x80808080, |
| "ISP Write to ML_DMEM value offset 0x2000 - Expected: 0x80808080 | " |
| "Actual: %x", |
| mem_val); |
| |
| mem_val = mmio_region_read32(ml_dmem_base_addr, 0x203C); |
| CHECK(mem_val == 0xEEC7C374, |
| "ISP Write to ML_DMEM value offset 0x203C - Expected: 0xEEC7C374 | " |
| "Actual: %x", |
| mem_val); |
| |
| mem_val = mmio_region_read32(ml_dmem_base_addr, 0x0000); |
| CHECK(mem_val == 0xFFFFFFFF, |
| "ISP Write to ML_DMEM value offset 0x0000 - Expected: 0xFFFFFFFF | " |
| "Actual: %x", |
| mem_val); |
| |
| mem_val = mmio_region_read32(ml_dmem_base_addr, 0x000C); |
| CHECK(mem_val == 0xE1E9FDF8, |
| "ISP Write to ML_DMEM value offset 0x000C - Expected: 0xE1E9FDF8 | " |
| "Actual: %x", |
| mem_val); |
| |
| test_status_set(kTestStatusPassed); |
| } |