mt_lp_rm.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2020-2023, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef MT_LP_RM_H
  7. #define MT_LP_RM_H
  8. #include <stdbool.h>
  9. #define MT_RM_STATUS_OK (0)
  10. #define MT_RM_STATUS_BAD (-1)
  11. #define MT_RM_STATUS_STOP (-2)
  12. enum PLAT_MT_LPM_RC_TYPE {
  13. PLAT_RC_UPDATE_CONDITION,
  14. PLAT_RC_STATUS,
  15. PLAT_RC_UPDATE_REMAIN_IRQS,
  16. PLAT_RC_IS_FMAUDIO,
  17. PLAT_RC_IS_ADSP,
  18. PLAT_RC_ENTER_CNT,
  19. PLAT_RC_CLKBUF_STATUS,
  20. PLAT_RC_UFS_STATUS,
  21. PLAT_RC_IS_USB_PERI,
  22. PLAT_RC_IS_USB_INFRA,
  23. PLAT_RC_MAX,
  24. };
  25. enum plat_mt_lpm_hw_ctrl_type {
  26. PLAT_AP_MDSRC_REQ,
  27. PLAT_AP_MDSRC_ACK,
  28. PLAT_AP_IS_MD_SLEEP,
  29. PLAT_AP_MDSRC_SETTLE,
  30. PLAT_AP_GPUEB_PLL_CONTROL,
  31. PLAT_AP_GPUEB_GET_PWR_STATUS,
  32. PLAT_AP_HW_CTRL_MAX,
  33. };
  34. struct mt_resource_constraint {
  35. int level;
  36. int (*init)(void);
  37. bool (*is_valid)(unsigned int cpu, int stateid);
  38. int (*update)(int stateid, int type, const void *p);
  39. int (*run)(unsigned int cpu, int stateid);
  40. int (*reset)(unsigned int cpu, int stateid);
  41. int (*get_status)(unsigned int type, void *priv);
  42. unsigned int (*allow)(int stateid);
  43. };
  44. struct mt_resource_manager {
  45. int (*update)(struct mt_resource_constraint **con, unsigned int num,
  46. int stateid, void *priv);
  47. struct mt_resource_constraint **consts;
  48. };
  49. extern int mt_lp_rm_register(struct mt_resource_manager *rm);
  50. extern int mt_lp_rm_do_constraint(unsigned int constraint_id, unsigned int cpuid, int stateid);
  51. extern int mt_lp_rm_find_constraint(unsigned int idx, unsigned int cpuid,
  52. int stateid, void *priv);
  53. extern int mt_lp_rm_find_and_run_constraint(unsigned int idx, unsigned int cpuid,
  54. int stateid, void *priv);
  55. extern int mt_lp_rm_reset_constraint(unsigned int idx, unsigned int cpuid, int stateid);
  56. extern int mt_lp_rm_do_update(int stateid, int type, void const *p);
  57. extern int mt_lp_rm_get_status(unsigned int type, void *priv);
  58. #endif /* MT_LP_RM_H */