Software APIs
sysrst_ctrl_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_SYSRST_CTRL_TESTUTILS_H_
6#define OPENTITAN_SW_DEVICE_LIB_TESTING_SYSRST_CTRL_TESTUTILS_H_
7
8#include <stdint.h>
9
12
13/**
14 * Setup the sysrst_ctrl direct IO (DIO) pins, that is flash write protect (WP)
15 * and EC reset.
16 *
17 * This function sets up the DIO pins as virtual open drain.
18 *
19 * This function will panic on error.
20 *
21 * @param pinmux Pointer to an initialized pinmux DIF.
22 */
23void sysrst_ctrl_testutils_setup_dio(dif_pinmux_t *pinmux);
24
25/**
26 * Release the flash WP and EC reset so that the output is not overidden to low
27 * by the block.
28 *
29 * This function will panic on error.
30 *
31 * @param pinmux Pointer to an initialized sysrst_ctrl DIF.
32 * @param release_ec Whether to release the EC reset pin.
33 * @param release_flash Whether to release the flast write protect pin.
34 */
35void sysrst_ctrl_testutils_release_dio(dif_sysrst_ctrl_t *sysrst_ctrl,
36 bool release_ec, bool release_flash);
37
38/**
39 * Set the EC reset pulse width.
40 *
41 * The supplied pulse width is converted into a count of AON clock ticks.
42 * If the width is not an exact multiple of the AON clock period, the conversion
43 * rounds down. The function will panic if the converted pulse width does not
44 * fit into the RST_CTL register.
45 *
46 * @param pinmux Pointer to an initialized sysrst_ctrl DIF.
47 * @param pulse_us Pulse width in microseconds.
48 */
49void sysrst_ctrl_testutils_set_ec_rst_pulse_width(
50 dif_sysrst_ctrl_t *sysrst_ctrl, uint32_t pulse_us);
51
52#endif // OPENTITAN_SW_DEVICE_LIB_TESTING_SYSRST_CTRL_TESTUTILS_H_