blob: 051e5ef60889370805e8491106c6f4005c316a53 [file] [log] [blame]
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "hw/top_matcha/sw/autogen/top_matcha.h"
#include "sw/device/lib/arch/device.h"
#include "sw/device/lib/dif/dif_cam_ctrl.h"
#include "sw/device/lib/dif/dif_uart.h"
#include "sw/device/lib/runtime/hart.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 uart;
static dif_cam_ctrl_t cam_ctrl;
void _ottf_main(void) {
uint32_t en_result;
// Initialize the UART to enable logging for non-DV simulation platforms.
if (kDeviceType != kDeviceSimDV) {
init_uart(TOP_MATCHA_UART0_BASE_ADDR, &uart);
}
LOG_INFO("Hello Shodan!");
// Start testing
test_status_set(kTestStatusInTest);
CHECK_DIF_OK(dif_cam_ctrl_init(
mmio_region_from_addr(TOP_MATCHA_CAM_CTRL_BASE_ADDR), &cam_ctrl));
CHECK_DIF_OK(dif_cam_ctrl_read_en(&cam_ctrl, &en_result));
CHECK(en_result == 0, "cam_ctrl is not initilized: expected : 0 | actual: %d",
en_result);
CHECK_DIF_OK(dif_cam_ctrl_set_en(&cam_ctrl), "Set CAM_CTRL failed");
CHECK_DIF_OK(dif_cam_ctrl_read_en(&cam_ctrl, &en_result));
CHECK(en_result == 1, "cam_ctrl is not set: expected : 1 | actual: %d",
en_result);
CHECK_DIF_OK(dif_cam_ctrl_clear_en(&cam_ctrl), "Clear CAM_CTRL failed");
CHECK_DIF_OK(dif_cam_ctrl_read_en(&cam_ctrl, &en_result));
CHECK(en_result == 0, "cam_ctrl is not cleared: expected : 0 | actual: %d",
en_result);
test_status_set(kTestStatusPassed);
}