2 * @copyright Copyright (c) 2017-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 * @brief Interface and struct define for power_hal
22 #ifndef HAL_API_POWER_HAL_H_
23 #define HAL_API_POWER_HAL_H_
25 #include <native_service/frameworkunified_types.h>
27 /** @addtogroup system_manager
30 /** @addtogroup power_hal
31 * @ingroup system_manager
34 /** @}*/ // end of power_hal
35 /** @}*/ // end of system_manager
37 /** @addtogroup power_supply_manager_shadow
40 /** @addtogroup power_hal
41 * @ingroup power_supply_manager_shadow
46 * \~english Definition of program update is not occured
48 #define PWR_PROGUPDATE_STATE_NONE (0x0)
51 * \~english Bit position of program update
53 #define PWR_PROGUPDATE_STATE_UPDATED (0x01)
56 * \~english Bit position of map update
58 #define PWR_PROGUPDATE_STATE_MAP_UPDATED (0x02)
61 * \~english Bit position of map difference update
63 #define PWR_PROGUPDATE_STATE_MAPDIFF_UPDATED (0x04)
66 * \~english None reset state
68 #define PWR_DATA_RESET_STATE_NONE 0
71 * \~english Reset state for initialization of user information
73 #define PWR_DATA_RESET_STATE_USER 1
76 * \~english Reset state for factory initialization
78 #define PWR_DATA_RESET_STATE_FACTORY 2
82 * @brief Command ID power_hal -> User
84 /*! @~english power_hal command receive notification */
85 #define CID_PWR_CMD_RCV 0x0103
87 /*! @~english power_hal command send result notification */
88 #define CID_PWR_CMD_SND_STS 0x0104
91 * \~english DRAM backup status
95 * \~english normal value
97 PSM_SYSUP_DRAM_NORMAL,
100 * \~english abnormal Soft Reset(software abnormality)
102 PSM_SYSUP_DRAM_SFTERRSR,
105 * \~english need to discard backup dram
107 PSM_SYSUP_DRAM_DISCARD,
110 * \~english max value
116 * \~english Start Status
118 enum PsmStartStatusT {
120 * \~english cold start
122 PSM_START_STATUS_FACTRESET,
125 * \~english hot start
127 PSM_START_STATUS_NORMAL,
130 * \~english max value
132 PSM_START_STATUS_MAX,
136 * \~english Communication state
140 * \~english Communication normal
145 * \~english Communication abnormal
147 PSM_COM_STS_ABNORMAL,
150 * \~english max value
156 * \~english DRAM power supply abnormality check result
160 * \~english DRAM power supply abnormality check result normal
165 * \~english DRAM power supply abnormality check result abnormal
167 PSM_DRAM_STS_ABNORMAL,
170 * \~english max value
176 * \~english ACC customize setting.
178 enum PsmAccCustomizeT {
180 * \~english ACC customize setting OFF.
182 PSM_ACC_CUSTOMIZE_OFF,
184 * \~english ACC customize setting ON.
190 * \~english Reset history recording flag.
192 #define PSM_RESET_HISTORY (0x10000000)
195 * \~english Reset(Start-up) factor.
203 * \~english Restart due to AGL.
207 * \~english Restart due to Tier1.
211 * \~english Restart due to user.
215 * \~english Restart due to AGL(Need to record reset history).
217 PSM_FACTOR_AGL_WITH_HISTORY = (PSM_RESET_HISTORY | PSM_FACTOR_AGL),
219 * \~english Restart due to Tier1(Need to record reset history).
221 PSM_FACTOR_TIER1_WITH_HISTORY = (PSM_RESET_HISTORY | PSM_FACTOR_TIER1),
223 * \~english Restart due to user(Need to record reset history).
225 PSM_FACTOR_USER_WITH_HISTORY = (PSM_RESET_HISTORY | PSM_FACTOR_USER)
229 * \~english Reset information type.
231 enum PowerHalResetInfoId {
233 * \~english Count of error log.
235 AGL_ERRLOG_COUNTER = 0,
237 * \~english Abnormal reset count detected by AGL.
241 * \~english State of program update.
243 AGL_PROGUPDATE_STATE,
245 * \~english Data reset state.
249 * \~english Flag of abnormal reset.
253 * \~english Max of reset information type.
255 AGL_RESERVED_LIMIT = 32
259 * \ingroup PsmNaviResetPower
260 * \~english @par Brief
261 * API to do navi reset that is forced reset if end sequence of MainSoC is not completed.
262 * \~english @param [in] h_app Handle for Application
263 * \~english @param [in] reset_factor Reset factor
264 * \~english @retval 0 : Ok
265 * \~english @retval -1 : Failed
266 * \~english @par Prerequisite
268 * \~english @par Change of internal state
269 * - Change of internal state according to the API does not occur.
270 * \~english @par Conditions of processing failure
271 * - Internal IO error. [-1]
272 * \~english @par Detail
273 * - do navi reset process.
274 * - The API can only be used by 1 process
275 * \~english @par Classification
277 * \~english @par Type
282 int PsmNaviResetPower(HANDLE h_app, PsmFactorT reset_factor);
285 * \ingroup PsmClrRamJudgeFlgPower
286 * \~english @par Brief
287 * API to do ram judge flag clear
288 * \~english @param [in] h_app Handle for Application
289 * \~english @retval 0 : Ok
290 * \~english @retval -1 : Failed
291 * \~english @par Prerequisite
293 * \~english @par Change of internal state
294 * - Change of internal state according to the API does not occur.
295 * \~english @par Conditions of processing failure
296 * - Internal IO error. [-1]
297 * \~english @par Detail
298 * - do ram judge flag clear process.
299 * - The API can only be used by 1 process
300 * \~english @par Classification
302 * \~english @par Type
307 int PsmClrRamJudgeFlgPower(HANDLE h_app);
310 * \ingroup PsmGetDramBackupStatusPower
311 * \~english @par Brief
312 * API to do get dram backup status
313 * \~english @param [in] h_app Handle for Application
314 * \~english @param [out] p_dram1 DRAM1 BackUp Status
315 * \~english @param [out] p_dram2 DRAM2 BackUp Status
316 * \~english @param [out] p_dram3 DRAM3 BackUp Status
317 * \~english @retval 0 : Ok
318 * \~english @retval -1 : Failed
319 * \~english @par Prerequisite
321 * \~english @par Change of internal state
322 * - Change of internal state according to the API does not occur.
323 * \~english @par Conditions of processing failure
324 * - Internal IO error. [-1]
325 * \~english @par Detail
326 * - do get dram backup status process.
327 * - The API can only be used by 1 process
328 * \~english @par Classification
330 * \~english @par Type
335 int PsmGetDramBackupStatusPower(HANDLE h_app, PsmSysupDramT *p_dram1, PsmSysupDramT *p_dram2, PsmSysupDramT *p_dram3);
338 * \ingroup PsmGetStartStatusPower
339 * \~english @par Brief
340 * API to do get start status
341 * \~english @param [in] h_app Handle for Application
342 * \~english @param [out] p_start_sts start status
343 * \~english @retval 0 : Ok
344 * \~english @retval -1 : Failed
345 * \~english @par Prerequisite
347 * \~english @par Change of internal state
348 * - Change of internal state according to the API does not occur.
349 * \~english @par Conditions of processing failure
350 * - Internal IO error. [-1]
351 * \~english @par Detail
352 * - do get startup state process.
353 * - The API can only be used by 1 process
354 * \~english @par Classification
356 * \~english @par Type
361 int PsmGetStartStatusPower(HANDLE h_app, PsmStartStatusT *p_start_sts);
364 * \ingroup PsmGetSyscomStatusPower
365 * \~english @par Brief
366 * API to do get communication status between mainsoc-sys
367 * \~english @param [in] h_app Handle for Application
368 * \~english @param [out] p_com_sts communication status between mainsoc-sys
369 * \~english @retval 0 : Ok
370 * \~english @retval -1 : Failed
371 * \~english @par Prerequisite
373 * \~english @par Change of internal state
374 * - Change of internal state according to the API does not occur.
375 * \~english @par Conditions of processing failure
376 * - Internal IO error. [-1]
377 * \~english @par Detail
378 * - do get communication status between mainsoc-sys process.
379 * - The API can only be used by 1 process
380 * \~english @par Classification
382 * \~english @par Type
387 int PsmGetSyscomStatusPower(HANDLE h_app, PsmComStsT *p_com_sts);
390 * \ingroup PsmGetDramPowerSupplyAbnormalityCheckResultPower
391 * \~english @par Brief
392 * API to do get dram power supply abnormality check result
393 * \~english @param [in] h_app Handle for Application
394 * \~english @param [out] p_dram_sts DRAM power supply abnormality check result
395 * \~english @retval 0 : Ok
396 * \~english @retval -1 : Failed
397 * \~english @par Prerequisite
399 * \~english @par Change of internal state
400 * - Change of internal state according to the API does not occur.
401 * \~english @par Conditions of processing failure
402 * - Internal IO error. [-1]
403 * \~english @par Detail
404 * - do get dram power supply abnormality check result process.
405 * - The API can only be used by 1 process
406 * \~english @par Classification
408 * \~english @par Type
413 int PsmGetDramPowerSupplyAbnormalityCheckResultPower(HANDLE h_app, PsmDramStsT *p_dram_sts);
416 * \ingroup PsmGetAccCustomizeSetting
417 * \~english @par Brief
418 * API to do get ACC customize setting
419 * \~english @param [in] h_app Handle for Application
420 * \~english @param [out] p_acc_customize ACC customize Setting
421 * \~english @retval 0 : Ok
422 * \~english @retval -1 : Failed
423 * \~english @par Prerequisite
425 * \~english @par Change of internal state
426 * - Change of internal state according to the API does not occur.
427 * \~english @par Conditions of processing failure
428 * - Internal IO error. [-1]
429 * \~english @par Detail
430 * - do get ACC customize setting.
431 * - The API can only be used by 1 process
432 * \~english @par Classification
434 * \~english @par Type
439 int PsmGetAccCustomizeSetting(HANDLE h_app, PsmAccCustomizeT* p_acc_customize);
442 * \ingroup PsmChgAccCustomizeSetting
443 * \~english @par Brief
444 * API to do change ACC customize setting
445 * \~english @param [in] h_app Handle for Application
446 * \~english @param [in] acc_customize ACC customize Setting
447 * \~english @retval 0 : Ok
448 * \~english @retval -1 : Failed
449 * \~english @par Prerequisite
451 * \~english @par Change of internal state
452 * - Change of internal state according to the API does not occur.
453 * \~english @par Conditions of processing failure
454 * - Internal IO error. [-1]
455 * \~english @par Detail
456 * - do set ACC customize setting.
457 * - The API can only be used by 1 process
458 * \~english @par Classification
460 * \~english @par Type
465 int PsmChgAccCustomizeSetting(HANDLE h_app, PsmAccCustomizeT acc_customize);
468 * \ingroup PsmGetStartupFactor
469 * \~english @par Brief
470 * API to do get start-up factor.
471 * \~english @param [in] h_app Handle for Application
472 * \~english @param [out] p_startup_factor Start-up factor
473 * \~english @retval 0 : Ok
474 * \~english @retval -1 : Failed
475 * \~english @par Prerequisite
477 * \~english @par Change of internal state
478 * - Change of internal state according to the API does not occur.
479 * \~english @par Conditions of processing failure
480 * - Internal IO error. [-1]
481 * \~english @par Detail
482 * - do get Start-up factor.
483 * - After the API call, start-up factor is clear.
484 * - The API can only be used by 1 process
485 * \~english @par Classification
487 * \~english @par Type
492 int PsmGetStartupFactor(HANDLE h_app, PsmFactorT* p_startup_factor);
495 * \ingroup PowerHalSetResetInfo
496 * \~english @par Brief
497 * API to do set reset information.
498 * \~english @param [in] id Reset information type.
499 * \~english @param [in] val setting value.
500 * \~english @retval 0 : Ok
501 * \~english @retval -1 : Failed
502 * \~english @par Prerequisite
504 * \~english @par Change of internal state
505 * - Change of internal state according to the API does not occur.
506 * \~english @par Conditions of processing failure
507 * - Internal IO error. [-1]
508 * - Save error to non-volatile memory. [-1]
509 * \~english @par Detail
510 * - Do set value to Reset information type(\ref PowerHalResetInfoId). \n
511 * \ref AGL_PROGUPDATE_STATE is not applicable(Only get value used by \ref PowerHalGetResetInfo). \n
512 * Domains of each reset information type are as below. \n
513 * \ref AGL_ERRLOG_COUNTER : 0 <= val <= UINT32_MAX \n
514 * \ref AGL_RESET_COUNTER : 0 <= val <= UINT32_MAX \n
515 * \ref AGL_DATARESET_STATE : It is set as below in each state of data reset. \n
516 * None reset state == \ref PWR_DATA_RESET_STATE_NONE \n
517 * Reset state for initialization of user information == \ref PWR_DATA_RESET_STATE_USER \n
518 * Reset state for factory initialization == \ref PWR_DATA_RESET_STATE_FACTORY \n
519 * \ref AGL_ILLRESET_FLAG : val = 0 or 1 (Abnormal reset is 1)
520 * - When the API is success, setting value is saved as non-volatile data.
521 * - Non-volatile memory is allocated \ref AGL_RESERVED_LIMIT for extendability.
522 * - Values setting by the API are saved when it is cold start(is_batterydiscon is true of PsmSysMcEVSysResUpChkPrmT notified from power_hal).
523 * - The API is completed within 1msec after the API is called.
524 * - The API can only be used by 1 process.
525 * \~english @par Classification
527 * \~english @par Type
530 * PowerHalGetResetInfo
532 int PowerHalSetResetInfo(enum PowerHalResetInfoId id, uint32_t val);
535 * \ingroup PowerHalGetResetInfo
536 * \~english @par Brief
537 * API to do get setting value of reset information .
538 * \~english @param [in] id Reset information type.
539 * \~english @param [out] val Buffer of value.
540 * \~english @retval 0 : Ok
541 * \~english @retval -1 : Failed
542 * \~english @par Prerequisite
544 * \~english @par Change of internal state
545 * - Change of internal state according to the API does not occur.
546 * \~english @par Conditions of processing failure
547 * - Internal IO error. [-1]
548 * - Read fail of value. [-1]
549 * \~english @par Detail
550 * - Do get value from each reset information type(\ref PowerHalResetInfoId).
551 * - Value of \ref AGL_PROGUPDATE_STATE, low 3bits are assigned as below, \n
552 * and corresponding bit is set if state is updating. \n
553 * Low 1bit(\ref PWR_PROGUPDATE_STATE_UPDATED) : Program update \n
554 * Low 2bit(\ref PWR_PROGUPDATE_STATE_MAP_UPDATED) : Map update \n
555 * Low 3bit(\ref PWR_PROGUPDATE_STATE_MAPDIFF_UPDATED) : Map difference update \n
556 * - The API is completed within 1msec after the API is called.
557 * - Completeness of data getting by the API is assured by lower layer than power_hal, \n
558 * and return -1 as internal IO error when it is occurred abnormal error.
559 * - The API can only be used by 1 process.
560 * \~english @par Classification
562 * \~english @par Type
565 * PowerHalSetResetInfo
567 int PowerHalGetResetInfo(enum PowerHalResetInfoId id, uint32_t *val);
569 /** @}*/ // end of power_hal
570 /** @}*/ // end of power_supply_manager_shadow
572 #endif // HAL_API_POWER_HAL_H_