blob: eca539fe00fa0788f0efc574a26da555ff2de1d1 [file] [log] [blame]
/*
* Copyright 2023 Google LLC
* Copyright lowRISC contributors
*
* 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" // Generated.
#include "sw/device/lib/arch/device.h"
#include "sw/device/lib/base/mmio.h"
#include "sw/device/lib/dif/dif_pinmux.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/pinmux_testutils.h"
#include "sw/device/lib/testing/test_framework/check.h"
#include "sw/device/lib/testing/test_framework/status.h"
static dif_pinmux_t pinmux;
static dif_uart_t uart0;
bool rom_test_main(void) {
// We need to set the test status as "in test" to indicate to the test code
// has been reached, even though this test is also in the "boot ROM".
test_status_set(kTestStatusInTest);
CHECK_DIF_OK(dif_pinmux_init(
mmio_region_from_addr(TOP_MATCHA_PINMUX_AON_BASE_ADDR), &pinmux));
pinmux_testutils_init(&pinmux);
// We need to initialize the UART regardless if we LOG any messages, since
// Verilator and FPGA platforms use the UART to communicate the test results.
if (kDeviceType != kDeviceSimDV) {
CHECK_DIF_OK(dif_uart_init(
mmio_region_from_addr(TOP_MATCHA_UART0_BASE_ADDR), &uart0));
CHECK_DIF_OK(
dif_uart_configure(&uart0, (dif_uart_config_t){
.baudrate = kUartBaudrate,
.clk_freq_hz = kClockFreqPeripheralHz,
.parity_enable = kDifToggleDisabled,
.parity = kDifUartParityEven,
.tx_enable = kDifToggleEnabled,
.rx_enable = kDifToggleEnabled,
}));
base_uart_stdout(&uart0);
}
/**
* Place test code here.
*/
/**
* Return true if the test succeeds. Return false if it should fail.
*/
return true;
}