Yen-Kai Wang | 834ed7a | 2022-09-12 15:33:58 -0500 | [diff] [blame] | 1 | // Copyright lowRISC contributors. |
Michael Hoang | 61e11aa | 2022-09-09 01:08:01 +0000 | [diff] [blame] | 2 | // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 3 | // SPDX-License-Identifier: Apache-2.0 |
| 4 | |
| 5 | #ifndef MATCHA_SW_DEVICE_LIB_DIF_DIF_SMC_CTRL_H_ |
| 6 | #define MATCHA_SW_DEVICE_LIB_DIF_DIF_SMC_CTRL_H_ |
| 7 | |
| 8 | /** |
| 9 | * @file |
| 10 | * @brief <a href="/hw/ip/smc_ctrl/doc/">SMC Controller</a> Device Interface Functions |
| 11 | */ |
| 12 | |
| 13 | #include <stdint.h> |
| 14 | |
| 15 | #include "sw/device/lib/base/mmio.h" |
| 16 | |
| 17 | #include "sw/device/lib/dif/autogen/dif_smc_ctrl_autogen.h" |
| 18 | |
| 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif // __cplusplus |
| 22 | |
| 23 | dif_result_t dif_smc_ctrl_set_regwen(const dif_smc_ctrl_t *smc_ctrl); |
| 24 | dif_result_t dif_smc_ctrl_clear_regwen(const dif_smc_ctrl_t *smc_ctrl); |
| 25 | dif_result_t dif_smc_ctrl_read_regwen(const dif_smc_ctrl_t *smc_ctrl, uint32_t *result); |
| 26 | |
| 27 | dif_result_t dif_smc_ctrl_set_en(const dif_smc_ctrl_t *smc_ctrl); |
| 28 | dif_result_t dif_smc_ctrl_clear_en(const dif_smc_ctrl_t *smc_ctrl); |
| 29 | dif_result_t dif_smc_ctrl_read_en(const dif_smc_ctrl_t *smc_ctrl, uint32_t *result); |
| 30 | |
| 31 | /** |
| 32 | * Below functions are auto-generated. Keep them here for now for reference. |
| 33 | */ |
| 34 | |
| 35 | |
| 36 | /** |
| 37 | * Runtime configuration for SMC Controller. |
| 38 | * |
| 39 | * This struct describes (SOFTWARE) runtime information for one-time |
| 40 | * configuration of the hardware. |
| 41 | */ |
| 42 | typedef struct dif_smc_ctrl_config { |
| 43 | // Fields, if necessary. |
| 44 | } dif_smc_ctrl_config_t; |
| 45 | |
| 46 | |
| 47 | /** |
| 48 | * Parameters for a SMC Controller transaction. |
| 49 | */ |
| 50 | typedef struct dif_smc_ctrl_transaction { |
| 51 | // Your fields here. |
| 52 | } dif_smc_ctrl_transaction_t; |
| 53 | |
| 54 | /** |
| 55 | * An output location for a SMC Controller transaction. |
| 56 | */ |
| 57 | typedef struct dif_smc_ctrl_output { |
| 58 | // Your fields here. |
| 59 | } dif_smc_ctrl_output_t; |
| 60 | |
| 61 | |
| 62 | OT_WARN_UNUSED_RESULT |
| 63 | dif_result_t dif_smc_ctrl_configure( |
| 64 | const dif_smc_ctrl_t *smc_ctrl, |
| 65 | dif_smc_ctrl_config_t config); |
| 66 | |
| 67 | /** |
| 68 | * Begins a SMC Controller transaction. |
| 69 | * |
| 70 | * Each call to this function should be sequenced with a call to |
| 71 | * `dif_smc_ctrl_end()`. |
| 72 | * |
| 73 | * @param smc_ctrl A SMC Controller handle. |
| 74 | * @param transaction Transaction configuration parameters. |
| 75 | * @return The result of the operation. |
| 76 | */ |
| 77 | OT_WARN_UNUSED_RESULT |
| 78 | dif_result_t dif_smc_ctrl_start( |
| 79 | const dif_smc_ctrl_t *smc_ctrl, |
| 80 | dif_smc_ctrl_transaction_t transaction); |
| 81 | |
| 82 | /** Ends a SMC Controller transaction, writing the results to the given output. |
| 83 | * |
| 84 | * @param smc_ctrl A SMC Controller handle. |
| 85 | * @param output Transaction output parameters. |
| 86 | * @return The result of the operation. |
| 87 | */ |
| 88 | OT_WARN_UNUSED_RESULT |
| 89 | dif_result_t dif_smc_ctrl_end( |
| 90 | const dif_smc_ctrl_t *smc_ctrl, |
| 91 | dif_smc_ctrl_output_t output); |
| 92 | |
| 93 | /** |
| 94 | * Locks out SMC Controller functionality. |
| 95 | * |
| 96 | * This function is reentrant: calling it while functionality is locked will |
| 97 | * have no effect and return `kDifOk`. |
| 98 | * |
| 99 | * @param smc_ctrl A SMC Controller handle. |
| 100 | * @return The result of the operation. |
| 101 | */ |
| 102 | OT_WARN_UNUSED_RESULT |
| 103 | dif_result_t dif_smc_ctrl_lock( |
| 104 | const dif_smc_ctrl_t *smc_ctrl); |
| 105 | |
| 106 | /** |
| 107 | * Checks whether this SMC Controller is locked. |
| 108 | * |
| 109 | * @param smc_ctrl A SMC Controller handle. |
| 110 | * @param[out] is_locked Out-param for the locked state. |
| 111 | * @return The result of the operation. |
| 112 | */ |
| 113 | OT_WARN_UNUSED_RESULT |
| 114 | dif_result_t dif_smc_ctrl_is_locked( |
| 115 | const dif_smc_ctrl_t *smc_ctrl, |
| 116 | bool *is_locked); |
| 117 | |
| 118 | #ifdef __cplusplus |
| 119 | } // extern "C" |
| 120 | #endif // __cplusplus |
| 121 | |
| 122 | #endif // MATCHA_SW_DEVICE_LIB_DIF_DIF_SMC_CTRL_H_ |