Software APIs
dma_testutils.h
1// Copyright lowRISC contributors (OpenTitan project).
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5#ifndef OPENTITAN_SW_DEVICE_LIB_TESTING_DMA_TESTUTILS_H_
6#define OPENTITAN_SW_DEVICE_LIB_TESTING_DMA_TESTUTILS_H_
7
11#include "sw/device/lib/testing/test_framework/check.h"
12
13/**
14 * Initialize the provided SPI host for being used in the DMA hardware handshake
15 * mode.
16 *
17 * @param spi_host An spi_host DIF handle.
18 * @param peripheral_clock_freq_hz The peripheral clock frequency in hertz.
19 * @param rx_watermark The watermark level of the FIFO to raise the status IRQ
20 * for the DMA.
21 */
22void init_spi_host(dif_spi_host_t *spi_host, uint32_t peripheral_clock_freq_hz,
23 uint32_t rx_watermark);
24
25/**
26 * Setup pads for spi_host0
27 *
28 * This peripheral is 'direct' connected to the pads.
29 *
30 * @param pinmux An pinmux DIF handle.
31 */
32void setup_pads_spi_host0(dif_pinmux_t *pinmux);
33
34/**
35 * Configure the SPI for a receiving transaction and configure the DMA for the
36 * hardware handshake mode to read the SPI host.
37 *
38 * @param spi_host An spi_host DIF handle.
39 * @param dma An DMA DIF handle.
40 * @param rx_buffer Pointer to the receiving buffer, where the DMA writes the
41 * received data.
42 * @param chunk_size The size of one chunk read from the LSIO peripheral.
43 * @param total_size The total size of data to be read from the LSIO
44 * peripheral.
45 */
46void setup_spi_dma_transaction(dif_spi_host_t *spi_host, dif_dma_t *dma,
47 uint8_t *rx_buffer, uint32_t chunk_size,
48 uint32_t total_size);
49
50/**
51 * Return the digest length given a DMA opcode.
52 *
53 * @param opcode A DMA opcode.
54 * @return The digest length.
55 */
56uint32_t get_digest_length(dif_dma_transaction_opcode_t opcode);
57
58#endif // OPENTITAN_SW_DEVICE_LIB_TESTING_DMA_TESTUTILS_H_