1 /* 2 * Arm SCP/MCP Software 3 * Copyright (c) 2019-2021, Arm Limited and Contributors. All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #ifndef MOD_JUNO_HDLCD_H 9 #define MOD_JUNO_HDLCD_H 10 11 #include "juno_clock.h" 12 13 #include <mod_clock.h> 14 15 #include <fwk_id.h> 16 #include <fwk_macros.h> 17 #include <fwk_module_idx.h> 18 19 #include <stdint.h> 20 21 /*! 22 * \addtogroup GroupModules Modules 23 * \{ 24 */ 25 26 /*! 27 * \defgroup GroupJUNOHDLCD JUNO HDLCD 28 * 29 * \{ 30 */ 31 32 /*! 33 * \brief Juno HDLCD device configuration 34 */ 35 struct mod_juno_hdlcd_dev_config { 36 /*! 37 * \brief Identifier of the driver 38 */ 39 fwk_id_t driver_id; 40 41 /*! 42 * \brief Identifier of the driver API 43 */ 44 fwk_id_t driver_api_id; 45 46 /*! 47 * \brief Identifier of the clock HAL 48 */ 49 fwk_id_t clock_hal_id; 50 51 /*! 52 * \brief Identifier of the clock driver input API 53 */ 54 fwk_id_t clock_api_id; 55 56 /*! 57 * \brief SCC control register 58 */ 59 FWK_RW uint32_t *scc_control; 60 61 /*! 62 * \brief The lowest rate the clock can be set to 63 */ 64 uint64_t min_rate; 65 66 /*! 67 * \brief The highest rate the clock can be set to 68 */ 69 uint64_t max_rate; 70 71 /*! 72 * \brief The maximum precision that can be used when setting the clock rate 73 */ 74 uint64_t min_step; 75 76 /*! 77 * \brief Rate type 78 */ 79 enum mod_clock_rate_type rate_type; 80 81 /*! 82 * \brief Lookup table for the rate and PLL values 83 */ 84 struct juno_clock_lookup *lookup_table; 85 86 /*! 87 * \brief Number of entries to the lookup table 88 */ 89 unsigned int lookup_table_count; 90 }; 91 92 /*! 93 * \brief HDLCD driver API 94 * 95 * \details This API provides a function to set the rate of a clock given the 96 * index in the lookup table. 97 * 98 * \note Driver of HDLCD module needs to implement this API. 99 */ 100 struct mod_juno_hdlcd_drv_api { 101 /*! 102 * \brief Change the rate of a clock using its lookup table. 103 * 104 * \param clock_id The identifier of the clock 105 * \param index The index of the lookup table that contains the information 106 * to set the rate of the clock. 107 * 108 * \retval ::FWK_SUCCESS The request is successful. 109 * \retval ::FWK_E_PARAM One or more parameters are incorrect. 110 * 111 * \return Status code representing the result of the operation. 112 */ 113 int (*set_rate_from_index)(fwk_id_t clock_id, int index); 114 }; 115 116 /*! API indices */ 117 enum mod_juno_hdlcd_api_idx { 118 MOD_JUNO_HDLCD_API_IDX_CLOCK_DRIVER, 119 MOD_JUNO_HDLCD_API_IDX_HDLCD_DRIVER_RESPONSE, 120 MOD_JUNO_HDLCD_API_COUNT, 121 }; 122 123 /*! Clock Driver API Identifier */ 124 static const fwk_id_t mod_juno_hdlcd_api_id_clock_driver = 125 FWK_ID_API_INIT(FWK_MODULE_IDX_JUNO_HDLCD, 126 MOD_JUNO_HDLCD_API_IDX_CLOCK_DRIVER); 127 128 /*! Clock Driver API Identifier */ 129 static const fwk_id_t mod_juno_hdlcd_api_id_hdlcd_driver_response = 130 FWK_ID_API_INIT(FWK_MODULE_IDX_JUNO_HDLCD, 131 MOD_JUNO_HDLCD_API_IDX_HDLCD_DRIVER_RESPONSE); 132 /*! 133 * \} 134 */ 135 136 /*! 137 * \} 138 */ 139 140 #endif /* MOD_JUNO_HDLCD_H */ 141