sde_hw_uidle.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
  4. *
  5. */
  6. #ifndef _SDE_HW_UIDLE_H
  7. #define _SDE_HW_UIDLE_H
  8. #include "sde_hw_catalog.h"
  9. #include "sde_hw_mdss.h"
  10. #include "sde_hw_util.h"
  11. struct sde_hw_uidle;
  12. #define FAL10_DANGER_SHFT 0
  13. #define FAL10_EXIT_DANGER_SHFT 4
  14. #define FAL10_EXIT_CNT_SHFT 16
  15. #define FAL10_DANGER_MSK GENMASK(2, FAL10_DANGER_SHFT)
  16. #define FAL10_EXIT_DANGER_MSK GENMASK(6, FAL10_EXIT_DANGER_SHFT)
  17. #define FAL10_EXIT_CNT_MSK GENMASK(23, FAL10_EXIT_CNT_SHFT)
  18. #define SDE_UIDLE_WD_GRANULARITY 1
  19. #define SDE_UIDLE_WD_HEART_BEAT 0
  20. #define SDE_UIDLE_WD_LOAD_VAL 3
  21. struct sde_uidle_ctl_cfg {
  22. u32 fal10_exit_cnt;
  23. u32 fal10_exit_danger;
  24. u32 fal10_danger;
  25. bool uidle_enable;
  26. };
  27. struct sde_uidle_wd_cfg {
  28. u32 granularity;
  29. u32 heart_beat;
  30. u32 load_value;
  31. bool clear;
  32. bool enable;
  33. };
  34. struct sde_uidle_cntr {
  35. u32 fal1_gate_cntr;
  36. u32 fal10_gate_cntr;
  37. u32 fal_wait_gate_cntr;
  38. u32 fal1_num_transitions_cntr;
  39. u32 fal10_num_transitions_cntr;
  40. u32 min_gate_cntr;
  41. u32 max_gate_cntr;
  42. };
  43. struct sde_uidle_status {
  44. u32 uidle_danger_status_0;
  45. u32 uidle_danger_status_1;
  46. u32 uidle_safe_status_0;
  47. u32 uidle_safe_status_1;
  48. u32 uidle_idle_status_0;
  49. u32 uidle_idle_status_1;
  50. u32 uidle_fal_status_0;
  51. u32 uidle_fal_status_1;
  52. };
  53. struct sde_hw_uidle_ops {
  54. /**
  55. * set_uidle_ctl - set uidle global config
  56. * @uidle: uidle context driver
  57. * @cfg: uidle global config
  58. */
  59. void (*set_uidle_ctl)(struct sde_hw_uidle *uidle,
  60. struct sde_uidle_ctl_cfg *cfg);
  61. /**
  62. * setup_wd_timer - set uidle watchdog timer
  63. * @uidle: uidle context driver
  64. * @cfg: uidle wd timer config
  65. */
  66. void (*setup_wd_timer)(struct sde_hw_uidle *uidle,
  67. struct sde_uidle_wd_cfg *cfg);
  68. /**
  69. * uidle_setup_cntr - set uidle perf counters
  70. * @uidle: uidle context driver
  71. * @enable: true to enable the counters
  72. */
  73. void (*uidle_setup_cntr)(struct sde_hw_uidle *uidle,
  74. bool enable);
  75. /**
  76. * uidle_get_cntr - get uidle perf counters
  77. * @uidle: uidle context driver
  78. * @cntr: pointer to return the counters
  79. */
  80. void (*uidle_get_cntr)(struct sde_hw_uidle *uidle,
  81. struct sde_uidle_cntr *cntr);
  82. /**
  83. * uidle_get_status - get uidle status
  84. * @uidle: uidle context driver
  85. * @status: pointer to return the status of uidle
  86. */
  87. void (*uidle_get_status)(struct sde_hw_uidle *uidle,
  88. struct sde_uidle_status *status);
  89. };
  90. struct sde_hw_uidle {
  91. /* base */
  92. struct sde_hw_blk_reg_map hw;
  93. /* uidle */
  94. const struct sde_uidle_cfg *cap;
  95. /* ops */
  96. struct sde_hw_uidle_ops ops;
  97. /*
  98. * uidle is common across all displays, lock to serialize access.
  99. * must be taken by client before using any ops
  100. */
  101. struct mutex uidle_lock;
  102. enum sde_uidle idx;
  103. };
  104. struct sde_hw_uidle *sde_hw_uidle_init(enum sde_uidle idx,
  105. void __iomem *addr, unsigned long len,
  106. struct sde_mdss_cfg *m);
  107. #endif /*_SDE_HW_UIDLE_H */