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