1 /* 2 * Renesas SCP/MCP Software 3 * Copyright (c) 2020-2021, Renesas Electronics Corporation. All rights 4 * reserved. 5 * 6 * SPDX-License-Identifier: BSD-3-Clause 7 */ 8 9 #ifndef MOD_RCAR_PMIC_H 10 #define MOD_RCAR_PMIC_H 11 12 #include <fwk_id.h> 13 #include <fwk_module_idx.h> 14 15 #include <stdbool.h> 16 #include <stdint.h> 17 18 /*! 19 * \ingroup GroupRCARModule 20 * \defgroup GroupRCARPmic PMIC 21 * \{ 22 */ 23 24 /*! 25 * \defgroup GroupRCARPmicApis APIs 26 * \{ 27 */ 28 29 /*! 30 * \brief Device API. 31 */ 32 struct mod_rcar_pmic_device_api { 33 /*! 34 * \brief Get whether the device is enabled or not. 35 * 36 * \param[in] device_id Identifier of the device to get the state of. 37 * \param[out] enabled `true` if the device is enabled, otherwise `false`. 38 * 39 * \retval ::FWK_E_HANDLER An error occurred in the device driver. 40 * \retval ::FWK_E_PARAM One or more parameters were invalid. 41 * \retval ::FWK_E_STATE The device cannot currently accept the request. 42 * \retval ::FWK_SUCCESS The operation succeeded. 43 * 44 * \return Status code representing the result of the operation. 45 */ 46 int (*get_enabled)(fwk_id_t device_id, bool *enabled); 47 48 /*! 49 * \brief Enable or disable the device. 50 * 51 * \param[in] device_id Identifier of the device to set the state of. 52 * \param[in] enable `true` to enable the device, or `false` to disable it. 53 * 54 * \retval ::FWK_E_HANDLER An error occurred in the device driver. 55 * \retval ::FWK_E_PARAM One or more parameters were invalid. 56 * \retval ::FWK_E_STATE The device cannot currently accept the request. 57 * \retval ::FWK_SUCCESS The operation succeeded. 58 * 59 * \return Status code representing the result of the operation. 60 */ 61 int (*set_enabled)(fwk_id_t device_id, bool enable); 62 63 /*! 64 * \brief Get the voltage of a device. 65 * 66 * \param[in] device_id Identifier of the device to get the voltage of. 67 * \param[out] voltage Voltage in millivolts (mV). 68 * 69 * \retval ::FWK_E_HANDLER An error occurred in the device driver. 70 * \retval ::FWK_E_PARAM One or more parameters were invalid. 71 * \retval ::FWK_E_STATE The device cannot currently accept the request. 72 * \retval ::FWK_SUCCESS The operation succeeded. 73 * 74 * \return Status code representing the result of the operation. 75 */ 76 int (*get_voltage)(fwk_id_t device_id, uint32_t *voltage); 77 78 /*! 79 * \brief Set the voltage of a device. 80 * 81 * \param[in] device_id Identifier of the device to set the voltage of. 82 * \param[in] voltage New voltage in millivolts (mV). 83 * 84 * \retval ::FWK_E_HANDLER An error occurred in the device driver. 85 * \retval ::FWK_E_PARAM One or more parameters were invalid. 86 * \retval ::FWK_E_STATE The device cannot currently accept the request. 87 * \retval ::FWK_SUCCESS The operation succeeded. 88 * 89 * \return Status code representing the result of the operation. 90 */ 91 int (*set_voltage)(fwk_id_t device_id, uint32_t voltage); 92 93 /*! 94 * \brief Set the DDR Backup mode. 95 * 96 * \param[in] device_id Identifier of the device to set the DDR BKP mode of. 97 * 98 * \retval ::FWK_SUCCESS The operation succeeded. 99 * \return One of the other driver-defined error codes. 100 */ 101 int (*set_pmic)(fwk_id_t device_id, unsigned int state); 102 103 }; 104 105 /*! 106 * \brief Driver API. 107 */ 108 struct mod_rcar_pmic_driver_api { 109 /*! 110 * \brief Get whether the device is enabled or not. 111 * 112 * \param[in] device_id Identifier of the device to get the state of. 113 * \param[out] enabled `true` if the device is enabled, otherwise `false`. 114 * 115 * \retval ::FWK_E_HANDLER An error occurred in the device driver. 116 * \retval ::FWK_E_PARAM One or more parameters were invalid. 117 * \retval ::FWK_E_STATE The device cannot currently accept the request. 118 * \retval ::FWK_SUCCESS The operation succeeded. 119 * 120 * \return Status code representing the result of the operation. 121 */ 122 int (*get_enabled)(fwk_id_t device_id, bool *enabled); 123 124 /*! 125 * \brief Enable or disable the device. 126 * 127 * \param[in] device_id Identifier of the device to set the state of. 128 * \param[in] enable `true` to enable the device, or `false` to disable it. 129 * 130 * \retval ::FWK_E_HANDLER An error occurred in the device driver. 131 * \retval ::FWK_E_PARAM One or more parameters were invalid. 132 * \retval ::FWK_E_STATE The device cannot currently accept the request. 133 * \retval ::FWK_SUCCESS The operation succeeded. 134 * 135 * \return Status code representing the result of the operation. 136 */ 137 int (*set_enabled)(fwk_id_t device_id, bool enable); 138 139 /*! 140 * \brief Get the voltage of a device. 141 * 142 * \param[in] device_id Identifier of the device to get the voltage of. 143 * \param[out] voltage Voltage in millivolts (mV). 144 * 145 * \retval ::FWK_E_HANDLER An error occurred in the device driver. 146 * \retval ::FWK_E_PARAM One or more parameters were invalid. 147 * \retval ::FWK_E_STATE The device cannot currently accept the request. 148 * \retval ::FWK_SUCCESS The operation succeeded. 149 * 150 * \return Status code representing the result of the operation. 151 */ 152 int (*get_voltage)(fwk_id_t device_id, uint32_t *voltage); 153 154 /*! 155 * \brief Set the voltage of a device. 156 * 157 * \param[in] device_id Identifier of the device to set the voltage of. 158 * \param[in] voltage New voltage in millivolts (mV). 159 * 160 * \retval ::FWK_E_HANDLER An error occurred in the device driver. 161 * \retval ::FWK_E_PARAM One or more parameters were invalid. 162 * \retval ::FWK_E_STATE The device cannot currently accept the request. 163 * \retval ::FWK_SUCCESS The operation succeeded. 164 * 165 * \return Status code representing the result of the operation. 166 */ 167 int (*set_voltage)(fwk_id_t device_id, uint32_t voltage); 168 169 /*! 170 * \brief Set the DDR Bakup mode. 171 * 172 * \param[in] device_id Identifier of the device to set the DDR BKP mode of. 173 * 174 * \retval ::FWK_SUCCESS The operation succeeded. 175 * \return One of the other driver-defined error codes. 176 */ 177 int (*set_pmic)(fwk_id_t device_id, unsigned int state); 178 }; 179 180 /*! 181 * \brief Indices. 182 */ 183 enum rcar_pmic_id { 184 RCAR_PMIC_CPU_LITTLE, 185 RCAR_PMIC_CPU_BIG, 186 RCAR_PMIC_CPU_DDR_BKUP, 187 RCAR_PMIC_CPU_GPU, 188 RCAR_PMIC_CPU_VPU 189 }; 190 191 /*! 192 * \} 193 */ 194 195 /*! 196 * \defgroup GroupRCARPmicConfig Configuration 197 * \{ 198 */ 199 200 /*! 201 * \brief Device configuration. 202 */ 203 struct mod_rcar_pmic_device_config { 204 fwk_id_t driver_id; /*!< Driver identifier */ 205 fwk_id_t driver_api_id; /*!< Driver API identifier */ 206 }; 207 208 /*! 209 * \} 210 */ 211 212 /*! 213 * \defgroup GroupRCARPmicEvents Events 214 * \{ 215 */ 216 217 /*! 218 * \brief <tt>Set enabled</tt> event response parameters. 219 */ 220 struct mod_rcar_pmic_event_params_set_enabled_response { 221 int status; /*!< Status of the request */ 222 }; 223 224 /*! 225 * \brief <tt>Set voltage</tt> event response parameters. 226 */ 227 struct mod_rcar_pmic_event_params_set_voltage_response { 228 int status; /*!< Status of the request */ 229 }; 230 231 /*! 232 * \} 233 */ 234 235 /*! 236 * \defgroup GroupRCARPmicIds Identifiers 237 * \{ 238 */ 239 240 /*! 241 * \brief API indices. 242 */ 243 enum mod_rcar_pmic_api_idx { 244 /*! API index for mod_rcar_pmic_api_id_device */ 245 MOD_RCAR_PMIC_API_IDX_DEVICE, 246 247 /*! Number of defined APIs */ 248 MOD_RCAR_PMIC_API_IDX_COUNT 249 }; 250 251 /*! Device API identifier */ 252 static const fwk_id_t mod_rcar_pmic_api_id_device = 253 FWK_ID_API_INIT(FWK_MODULE_IDX_RCAR_PMIC, MOD_RCAR_PMIC_API_IDX_DEVICE); 254 255 /*! 256 * \brief Event indices. 257 */ 258 enum mod_rcar_pmic_event_idx { 259 /*! Event index for mod_rcar_pmic_event_id_set_enabled */ 260 MOD_RCAR_PMIC_EVENT_IDX_SET_ENABLED, 261 262 /*! Event index for mod_rcar_pmic_event_id_set_voltage */ 263 MOD_RCAR_PMIC_EVENT_IDX_SET_VOLTAGE, 264 265 /*! Number of defined events */ 266 MOD_RCAR_PMIC_EVENT_IDX_COUNT 267 }; 268 269 /*! <tt>Set enabled</tt> event identifier */ 270 static const fwk_id_t mod_rcar_pmic_event_id_set_enabled = 271 FWK_ID_EVENT_INIT( 272 FWK_MODULE_IDX_RCAR_PMIC, 273 MOD_RCAR_PMIC_EVENT_IDX_SET_ENABLED); 274 275 /*! <tt>Set voltage</tt> event identifier */ 276 static const fwk_id_t mod_rcar_pmic_event_id_set_voltage = 277 FWK_ID_EVENT_INIT( 278 FWK_MODULE_IDX_RCAR_PMIC, 279 MOD_RCAR_PMIC_EVENT_IDX_SET_VOLTAGE); 280 281 /*! 282 * \} 283 */ 284 285 /*! 286 * \} 287 */ 288 289 #endif /* MOD_RCAR_PMIC_H */ 290