1 /* 2 * Copyright (C) 2017-2019 Alibaba Group Holding Limited 3 */ 4 5 /****************************************************************************** 6 * @file drv_bmu.h 7 * @brief header file for bmu driver 8 * @version V1.0 9 * @date 02. June 2017 10 * @model bmu 11 ******************************************************************************/ 12 13 #ifndef _CSI_BMU_H_ 14 #define _CSI_BMU_H_ 15 16 17 #include <drv/common.h> 18 #include <drv/pmu.h> 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 /// definition for bmu handle. 24 typedef void *bmu_handle_t; 25 26 typedef enum { 27 BUCK_LS0 = 0, /*run/dor/sby onoff*/ 28 BUCK_LS1 = 1, /*run/dor/sby onoff*/ 29 HVIOLDO = 2, /*run/dor/sby onoff*/ /*run/dor/sby prog BW3*/ 30 LVIOLDO = 3, /*run/dor/sby onoff*/ /*run/dor/sby prog BW3*/ 31 ABB_LS = 4, /*run/dor/sby onoff*/ 32 HVIO_LS = 5, /*run/dor/sby onoff*/ 33 ACORELDO = 6, /*run/dor sby onoff*/ 34 SIMLDO = 7, /*run/dor/sby onoff*/ /*run/dor/sby prog BW3*/ 35 ANALDO = 8, /*run/dor/sby onoff*/ /*prog*/ 36 LPCORELDO = 9, /* dor/sby onoff*/ 37 MCORELDO = 10, /* dor/sby onoff*/ 38 MAINBGP = 11, /* dor/sby onoff*/ /*prog*/ 39 BUCKDC = 12, /* dor/sby onoff*/ /*run/dor/sby prog BW8*/ 40 CORELDO = 13, /*run/dor/sby prog BW4*/ 41 SDNPVD = 14, /*onoff*/ /*prog*/ 42 SDNBOR = 15, /*prog*/ 43 SBYLDO = 16, /*prog*/ 44 SDNCMP = 17, /*onoff*/ /*prog*/ 45 SDNBGP_LP = 18, /*prog*/ 46 SDNBGP_HP = 19, /*prog*/ 47 } bmu_regulator_e; 48 49 typedef enum { 50 DISABLE = 0, 51 ENABLE = 1, 52 } bmu_enable_e; 53 54 typedef enum { 55 HVIOLDO_1_800 = 0, 56 HVIOLDO_2_500 = 1, 57 HVIOLDO_2_700 = 2, 58 HVIOLDO_2_850 = 3,/*default*/ 59 HVIOLDO_3_000 = 4, 60 HVIOLDO_3_300 = 5, 61 } bmu_hvioldo_vol_e; 62 63 typedef enum { 64 LVIOLDO_1_600 = 0, 65 LVIOLDO_1_640 = 1, 66 LVIOLDO_1_680 = 2, 67 LVIOLDO_1_720 = 3, 68 LVIOLDO_1_760 = 4, 69 LVIOLDO_1_800 = 5,/*default*/ 70 LVIOLDO_1_840 = 6, 71 LVIOLDO_1_880 = 7, 72 } bmu_lvioldo_vol_e; 73 74 typedef enum { 75 SIMLDO_1_800 = 0,/*default*/ 76 SIMLDO_2_500 = 1, 77 SIMLDO_2_700 = 2, 78 SIMLDO_2_850 = 3, 79 SIMLDO_3_000 = 4, 80 SIMLDO_3_300 = 5, 81 } bmu_simldo_vol_e; 82 83 typedef enum { 84 BUCKDC_1_500 = 0, 85 BUCKDC_1_620 = 4, 86 BUCKDC_1_740 = 8, 87 BUCKDC_1_800 = 10, 88 BUCKDC_1_830 = 11, 89 BUCKDC_1_860 = 12, 90 BUCKDC_1_950 = 15, 91 } bmu_buckdc_vol_e; 92 93 typedef enum { 94 CORELDO_0_900 = 0, 95 CORELDO_1_020 = 4, 96 CORELDO_1_110 = 7, 97 CORELDO_1_200 = 10,/*default*/ 98 } bmu_coreldo_vol_e; 99 100 typedef enum { 101 ANALDO_2_000 = 0, 102 ANALDO_2_500 = 1, 103 ANALDO_2_700 = 2, 104 ANALDO_2_850 = 3, 105 ANALDO_3_000 = 4, 106 ANALDO_3_300 = 5,/*default*/ 107 } bmu_analdo_vol_e; 108 109 typedef enum { 110 SBYLDO_1_640 = 0, 111 SBYLDO_1_680 = 1, 112 SBYLDO_1_720 = 2, 113 SBYLDO_1_760 = 3, 114 SBYLDO_1_800 = 4, 115 SBYLDO_1_840 = 5,/*default*/ 116 SBYLDO_1_880 = 6, 117 SBYLDO_1_920 = 7, 118 } bmu_sbyldo_vol_e; 119 120 typedef enum { 121 SDNPVD_2_200 = 0,/*default*/ 122 SDNPVD_2_400 = 1, 123 SDNPVD_2_600 = 2, 124 SDNPVD_2_800 = 3, 125 SDNPVD_3_000 = 4, 126 SDNPVD_3_200 = 5, 127 SDNPVD_3_400 = 6, 128 SDNPVD_3_600 = 7, 129 } bmu_sdnpvd_vol_e; 130 131 typedef enum { 132 SDNBOR_1_800 = 0, 133 SDNBOR_2_000 = 1,/*default*/ 134 SDNBOR_2_200 = 2, 135 SDNBOR_2_500 = 3, 136 SDNBOR_2_800 = 4, 137 SDNBOR_3_000 = 5, 138 SDNBOR_3_100 = 6, 139 SDNBOR_3_200 = 7, 140 } bmu_sdnbor_vol_e; 141 142 typedef enum { 143 SDNCMP_9uA = 0,/*default*/ 144 SDNCMP_11uA = 1, 145 SDNCMP_16uA = 2, 146 SDNCMP_30uA = 3, 147 } bmu_sdncmp_cur_e; 148 149 typedef enum { 150 MAINBGP_0_720 = 0, 151 MAINBGP_0_730 = 1, 152 MAINBGP_0_740 = 2, 153 MAINBGP_0_750 = 3, 154 MAINBGP_0_760 = 4, 155 MAINBGP_0_770 = 5, 156 MAINBGP_0_780 = 6, 157 MAINBGP_0_790 = 7, 158 MAINBGP_0_800 = 8,/*default*/ 159 MAINBGP_0_810 = 9, 160 MAINBGP_0_820 = 10, 161 MAINBGP_0_830 = 11, 162 MAINBGP_0_840 = 12, 163 MAINBGP_0_850 = 13, 164 MAINBGP_0_860 = 14, 165 MAINBGP_0_870 = 15, 166 } bmu_mainbgp_vol_e; 167 168 typedef enum { 169 SDNBGP_LPMODE_1_137 = 0, 170 SDNBGP_LPMODE_1_158 = 1, 171 SDNBGP_LPMODE_1_175 = 2, 172 SDNBGP_LPMODE_1_194 = 3, 173 SDNBGP_LPMODE_1_214 = 4,/*default*/ 174 SDNBGP_LPMODE_1_233 = 5, 175 SDNBGP_LPMODE_1_252 = 6, 176 SDNBGP_LPMODE_1_271 = 7, 177 } bmu_sdnbgp_lpmode_vol_e; 178 179 typedef enum { 180 SDNBGP_HPMODE_1_152 = 0, 181 SDNBGP_HPMODE_1_171 = 1, 182 SDNBGP_HPMODE_1_191 = 2, 183 SDNBGP_HPMODE_1_210 = 3, 184 SDNBGP_HPMODE_1_230 = 4,/*default*/ 185 SDNBGP_HPMODE_1_251 = 5, 186 SDNBGP_HPMODE_1_270 = 6, 187 SDNBGP_HPMODE_1_289 = 7, 188 } bmu_sdnbgp_hpmode_vol_e; 189 190 typedef enum { 191 VBAT = 0,/*default*/ 192 PVD_IN = 1, 193 } bmu_pvdsel_5V_e; 194 195 typedef enum { 196 LLP_SHUTDOWN = 0,/*default*/ 197 LLP_RESTART = 1, 198 } bmu_llp_todo_e; 199 200 typedef enum { 201 PSHOLD_DOWN = 0,/*default*/ 202 PSHOLD_UP = 1, 203 } bmu_pshold_status_e; 204 205 /****** BMU Event *****/ 206 typedef enum { 207 BMU_EVENT_SEND_COMPLETE = 0, ///< Send completed; however BMU may still transmit data 208 BMU_EVENT_RECEIVE_COMPLETE = 1, ///< Receive completed 209 BMU_EVENT_RECEIVED = 2, ///< Receiving data 210 BMU_EVENT_TRANSFER_COMPLETE = 3, ///< Transfer completed 211 BMU_EVENT_TX_COMPLETE = 4, ///< Transmit completed (optional) 212 BMU_EVENT_TX_UNDERFLOW = 5, ///< Transmit data not available (Synchronous Slave) 213 BMU_EVENT_RX_OVERFLOW = 6, ///< Receive data overflow 214 BMU_EVENT_RX_TIMEOUT = 7, ///< Receive character timeout (optional) 215 BMU_EVENT_RX_BREAK = 8, ///< Break detected on receive 216 BMU_EVENT_RX_FRAMING_ERROR = 9, ///< Framing error detected on receive 217 BMU_EVENT_RX_PARITY_ERROR = 10, ///< Parity error detected on receive 218 } bmu_event_e; 219 220 typedef void (*bmu_event_cb_t)(int32_t idx, bmu_event_e event); ///< Pointer to \ref bmu_event_cb_t : BMU Event call back. 221 222 /** 223 \brief BMU Driver Capabilities. 224 */ 225 typedef struct { 226 uint32_t asynchronous : 1; ///< supports BMU (Asynchronous) mode 227 uint32_t synchronous_master : 1; ///< supports Synchronous Master mode 228 uint32_t synchronous_slave : 1; ///< supports Synchronous Slave mode 229 uint32_t single_wire : 1; ///< supports BMU Single-wire mode 230 uint32_t event_tx_complete : 1; ///< Transmit completed event 231 uint32_t event_rx_timeout : 1; ///< Signal receive character timeout event 232 } bmu_capabilities_t; 233 234 /** 235 \brief Initialize BMU Interface. 1. Initializes the resources needed for the BMU interface 2.registers event callback function 236 \param[in] idx bmu id 237 \param[in] cb_event Pointer to \ref bmu_event_cb_t 238 \return return bmu handle if success 239 */ 240 bmu_handle_t csi_bmu_initialize(int32_t idx, bmu_event_cb_t cb_event); 241 242 /** 243 \brief De-initialize BMU Interface. stops operation and releases the software resources used by the interface 244 \param[in] handle bmu handle to operate. 245 \return error code 246 */ 247 int32_t csi_bmu_uninitialize(bmu_handle_t handle); 248 249 /** 250 \brief Get driver capabilities. 251 \param[in] handle bmu handle to operate. 252 \return \ref bmu_capabilities_t 253 */ 254 bmu_capabilities_t csi_bmu_get_capabilities(bmu_handle_t handle); 255 256 /** 257 * Pull pshold up or down. 258 * 259 * @param[in] enable Flag of up or down. 260 * @return none 261 */ 262 int32_t csi_bmu_set_pshold(bmu_handle_t handle, bmu_pshold_status_e enable); 263 264 /** 265 * Set key long long press to do. 266 * 267 * @param[in] enable Flag of shutdown or restart. 268 * @return none 269 */ 270 int32_t csi_bmu_set_llp_todo(bmu_handle_t handle, bmu_llp_todo_e enable); 271 272 /** 273 * Set mainbgp voltage. 274 * 275 * @param[in] mainbgp_vol Voltage of Regulator. 276 * @return none 277 */ 278 int32_t csi_bmu_mainbgp_setvol(bmu_handle_t handle, bmu_mainbgp_vol_e mainbgp_vol); 279 280 /** 281 * Set sdnbgp voltage in lpmode. 282 * 283 * @param[in] vol Voltage of sdnbgp in lpmode. 284 * @return none 285 */ 286 int32_t csi_bmu_sdnbgp_lpmode_setvol(bmu_handle_t handle, bmu_sdnbgp_lpmode_vol_e vol); 287 288 /** 289 * Set sdnbgp voltage in hpmode. 290 * 291 * @param[in] vol Voltage of sdnbgp in hpmode. 292 * @return none 293 */ 294 int32_t csi_bmu_sdnbgp_hpmode_setvol(bmu_handle_t handle, bmu_sdnbgp_hpmode_vol_e vol); 295 296 /** 297 * Set sdnpvd voltage. 298 * 299 * @param[in] sdnpvd_vol Voltage of sdnpvd. 300 * @return none 301 */ 302 int32_t csi_bmu_sdnpvd_setvol(bmu_handle_t handle, bmu_sdnpvd_vol_e sdnpvd_vol); 303 304 /** 305 * Set sdnpvd on or off. 306 * 307 * @param[in] enable Flag of enable or disable. 308 * @return none 309 */ 310 int32_t csi_bmu_sdnpvd_setonoff(bmu_handle_t handle, bmu_enable_e enable); 311 312 /** 313 * Select sdnpvd source. 314 * 315 * @param[in] enable Flag of sdnpvd source. 316 * @return none 317 */ 318 int32_t csi_bmu_sdnpvd_selsrc(bmu_handle_t handle, bmu_pvdsel_5V_e pvdsel); 319 320 /** 321 * Set sdnbor voltage. 322 * 323 * @param[in] sdnbor_vol Voltage of sdnbor. 324 * @return none 325 */ 326 int32_t csi_bmu_sdnbor_setvol(bmu_handle_t handle, bmu_sdnbor_vol_e sdnbor_vol); 327 328 /** 329 * Set sdncmp current. 330 * 331 * @param[in] sdncmp_cur Current of sdncmp. 332 * @return none 333 */ 334 int32_t csi_bmu_sdncmp_setcur(bmu_handle_t handle, bmu_sdncmp_cur_e sdncmp_cur); 335 336 /** 337 * Set sdncmp on or off. 338 * 339 * @param[in] enable Flag of enable or disable. 340 * @return none 341 */ 342 int32_t csi_bmu_sdncmp_setonoff(bmu_handle_t handle, bmu_enable_e enable); 343 344 /** 345 * Set hvioldo voltage in different bmu mod. 346 * 347 * @param[in] pmu_mode Pmu mode. 348 * @param[in] hvioldo Voltage value. 349 * @return 0 is OK, others is error 350 */ 351 int32_t csi_bmu_hvioldo_setvol(bmu_handle_t handle, pmu_mode_e pmu_mode, bmu_hvioldo_vol_e hvioldo_vol); 352 353 /** 354 * Set simldo voltage in different bmu mod. 355 * 356 * @param[in] pmu_mode Pmu mode. 357 * @param[in] simldo Voltage value. 358 * @return 0 is OK, others is error 359 */ 360 int32_t csi_bmu_simldo_setvol(bmu_handle_t handle, pmu_mode_e pmu_mode, bmu_simldo_vol_e simldo_vol); 361 362 /** 363 * Set buckdc voltage in different bmu mod. 364 * 365 * @param[in] pmu_mode Pmu mode. 366 * @param[in] buckdc Voltage value. 367 * @return 0 is OK, others is error 368 */ 369 int32_t csi_bmu_buckdc_setvol(bmu_handle_t handle, pmu_mode_e pmu_mode, bmu_buckdc_vol_e buckdc_vol); 370 371 /** 372 * Set coreldo voltage in different bmu mod. 373 * 374 * @param[in] pmu_mode Pmu mode. 375 * @param[in] coreldo Voltage value. 376 * @return 0 is OK, others is error 377 */ 378 int32_t csi_bmu_coreldo_setvol(bmu_handle_t handle, pmu_mode_e pmu_mode, bmu_coreldo_vol_e coreldo_vol); 379 380 /** 381 * Set lvioldo voltage in different bmu mod. 382 * 383 * @param[in] pmu_mode Pmu mode. 384 * @param[in] lvioldo Voltage value. 385 * @return 0 is OK, others is error 386 */ 387 int32_t csi_bmu_lvioldo_setvol(bmu_handle_t handle, pmu_mode_e pmu_mode, bmu_lvioldo_vol_e lvioldo_vol); 388 389 /** 390 * Set analdo voltage. 391 * 392 * @param[in] analdo Voltage value. 393 * @return 0 is OK, others is error 394 */ 395 int32_t csi_bmu_analdo_setvol(bmu_handle_t handle, bmu_analdo_vol_e analdo_vol); 396 397 /** 398 * Set sbyldo voltage. 399 * 400 * @param[in] sbyldo Voltage value. 401 * @return 0 is OK, others is error 402 */ 403 int32_t csi_bmu_sbyldo_setvol(bmu_handle_t handle, bmu_sbyldo_vol_e sbyldo_vol); 404 405 /** 406 * Set regulator on or off in run mode of bmu. 407 * 408 * @param[in] regulator Identify of Regulator. 409 * @param[in] enable Flag of on or off. 410 * @return 0 is OK, others is error 411 */ 412 int32_t csi_bmu_run_setonoff(bmu_handle_t handle, bmu_regulator_e regulator, bmu_enable_e enable); 413 414 /** 415 * Set regulator on or off in dormant mode of bmu. 416 * 417 * @param[in] regulator Identify of Regulator. 418 * @param[in] enable Flag of on or off. 419 * @return 0 is OK, others is error 420 */ 421 int32_t csi_bmu_dor_setonoff(bmu_handle_t handle, bmu_regulator_e regulator, bmu_enable_e enable); 422 423 /** 424 * Set regulator on or off in standby mode of bmu. 425 * 426 * @param[in] regulator Identify of Regulator. 427 * @param[in] enable Flag of on or off. 428 * @return 0 is OK, others is error 429 */ 430 int32_t csi_bmu_sby_setonoff(bmu_handle_t handle, bmu_regulator_e regulator, bmu_enable_e enable); 431 432 #ifdef __cplusplus 433 } 434 #endif 435 436 #endif /* _CSI_BMU_H_ */ 437