pmic_wrap_init_common.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) 2022, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef PMIC_WRAP_INIT_COMMON_H
  7. #define PMIC_WRAP_INIT_COMMON_H
  8. #include <stdint.h>
  9. #include "platform_def.h"
  10. /* external API */
  11. int32_t pwrap_read(uint32_t adr, uint32_t *rdata);
  12. int32_t pwrap_write(uint32_t adr, uint32_t wdata);
  13. #define GET_WACS_FSM(x) ((x >> 1) & 0x7)
  14. /* macro for SWINF_FSM */
  15. #define SWINF_FSM_IDLE (0x00)
  16. #define SWINF_FSM_REQ (0x02)
  17. #define SWINF_FSM_WFDLE (0x04)
  18. #define SWINF_FSM_WFVLDCLR (0x06)
  19. #define SWINF_INIT_DONE (0x01)
  20. /* timeout setting */
  21. #define PWRAP_READ_US (1000)
  22. #define PWRAP_WAIT_IDLE_US (1000)
  23. /* error information flag */
  24. enum pwrap_errno {
  25. E_PWR_INVALID_ARG = 1,
  26. E_PWR_INVALID_RW = 2,
  27. E_PWR_INVALID_ADDR = 3,
  28. E_PWR_INVALID_WDAT = 4,
  29. E_PWR_INVALID_OP_MANUAL = 5,
  30. E_PWR_NOT_IDLE_STATE = 6,
  31. E_PWR_NOT_INIT_DONE = 7,
  32. E_PWR_NOT_INIT_DONE_READ = 8,
  33. E_PWR_WAIT_IDLE_TIMEOUT = 9,
  34. E_PWR_WAIT_IDLE_TIMEOUT_READ = 10,
  35. E_PWR_INIT_SIDLY_FAIL = 11,
  36. E_PWR_RESET_TIMEOUT = 12,
  37. E_PWR_TIMEOUT = 13,
  38. E_PWR_INIT_RESET_SPI = 20,
  39. E_PWR_INIT_SIDLY = 21,
  40. E_PWR_INIT_REG_CLOCK = 22,
  41. E_PWR_INIT_ENABLE_PMIC = 23,
  42. E_PWR_INIT_DIO = 24,
  43. E_PWR_INIT_CIPHER = 25,
  44. E_PWR_INIT_WRITE_TEST = 26,
  45. E_PWR_INIT_ENABLE_CRC = 27,
  46. E_PWR_INIT_ENABLE_DEWRAP = 28,
  47. E_PWR_INIT_ENABLE_EVENT = 29,
  48. E_PWR_READ_TEST_FAIL = 30,
  49. E_PWR_WRITE_TEST_FAIL = 31,
  50. E_PWR_SWITCH_DIO = 32,
  51. };
  52. #endif /* PMIC_WRAP_INIT_COMMON_H */